Reads I/O¶
Low-level FASTQ reading and barcode library loading. Used internally by
heuristic_discover(), tnseq_discover(), and count_barcodes().
read_barcode_fasta
¶
Read barcode library from FASTA. Supports .gz, .zst.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
str
|
Path to FASTA file. |
required |
Returns:
| Type | Description |
|---|---|
set[str]
|
Set of uppercase barcode sequences. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If file format unsupported. |
Examples:
Source code in src/seqchain/io/reads.py
validate_barcodes
¶
Validate barcode set: at least 10, at most 1000bp each, uniform length.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
barcodes
|
set[str]
|
Set of barcode sequences. |
required |
Returns:
| Type | Description |
|---|---|
int
|
Barcode length (all must be equal). |
Raises:
| Type | Description |
|---|---|
ValueError
|
If validation fails. |
Examples:
Source code in src/seqchain/io/reads.py
read_fastq_chunks
¶
read_fastq_chunks(path: str, chunk_size: int = 65536, path2: str | None = None) -> Iterator[tuple[list[str], list[str] | None]]
Stream reads from FASTQ or .reads file in chunks. Supports .gz, .zst.
Yields (reads1, reads2) tuples where reads2 is None for
single-end data. Each element is a list of read sequences (strings).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
str
|
Path to reads file. |
required |
chunk_size
|
int
|
Number of reads per chunk. |
65536
|
path2
|
str | None
|
Optional path to paired-end reads file. |
None
|
Yields:
| Type | Description |
|---|---|
tuple[list[str], list[str] | None]
|
Tuples of |
Examples:
Source code in src/seqchain/io/reads.py
76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 | |
open_reads_file
¶
Open a reads file with appropriate decompression.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
str
|
Path to file (.fastq, .fq, .reads, .fasta, .fa, with optional .gz/.zst suffix). |
required |
mode
|
str
|
File mode. |
'rt'
|
Returns:
| Type | Description |
|---|---|
IO[Any]
|
File handle. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If the extension is not recognized. |
Examples: