You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* feat(report parser): Detect a header line in the report file and skip.
If the first line of a kraken report is all strings and 6 fields - assume its a header line and skip with a warning.
* feat(report parser): More informative error messages
Adds line number and line context to errors
bumps version to 3.1.0
* docs: update readme and changelog with 3.1.0 features
* build: update kractor version to 3.1.0
Copy file name to clipboardExpand all lines: CHANGELOG.md
+46-4Lines changed: 46 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -5,118 +5,160 @@ All notable changes to this project will be documented in this file.
5
5
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
6
6
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
7
8
+
## [3.1.0] - 2025-12-12
9
+
10
+
### Added
11
+
12
+
- Attempt to detect headers in kraken report files and skip if it looks like a header. It does this by checking if there
13
+
are 6 fields that are all strings (or more precisely if each field returns an error when parsing into an int/float).
14
+
If so,
15
+
it is assumed that this line is a header and is skipped. A warning message is printed in this case.
16
+
-`--no-header-detect` flag to force parsing Kraken reports from the first line without auto-skipping headers, disabling
17
+
the new header detection behaviour described above
18
+
19
+
### Changed
20
+
21
+
- Kraken report/output parsing errors now include the line number and o line for easier debugging.
22
+
8
23
## [3.0.1] - 2025-10-16
9
24
10
25
### Fixed
26
+
11
27
- Prevent a panic when writing to output paths without an extension.
12
28
13
29
## [3.0.0] - 2025-09-26
14
30
15
31
### Added
16
-
- Able to specifiy taxon ids that are not present, without kractor stopping. These are instead logged to stderr with a warning. This may be useful when running kractor in a wrapper script for several fastq files and just want to extract a set of taxonids from them all - without caring if they are present or not.
32
+
33
+
- Able to specifiy taxon ids that are not present, without kractor stopping. These are instead logged to stderr with a
34
+
warning. This may be useful when running kractor in a wrapper script for several fastq files and just want to extract
35
+
a set of taxonids from them all - without caring if they are present or not.
17
36
- Include a new field `missing_taxon_ids` in the summary output.
18
37
19
38
### Changed
20
-
- Under the hood refactoring, introducing structs for the processed kraken outputs and processed kraken trees to simplify the returned data.
39
+
40
+
- Under the hood refactoring, introducing structs for the processed kraken outputs and processed kraken trees to
41
+
simplify the returned data.
21
42
22
43
### Fixed
23
-
- Unclassified reads being skipped in the tree building stage, meaning they were unable to be extracted
44
+
45
+
- Unclassified reads being skipped in the tree building stage, meaning they were unable to be extracted
24
46
25
47
## [2.0.0] - 2025-08-12
26
48
27
49
### Added
50
+
28
51
- Added a `reads_extracted_per_taxon` field to to summary report (#28)
29
52
- Added a `proportion_extracted` field to summary report (#28)
30
53
- Added the version to summary report (#28)
31
54
- Added an output format (`fasta` or `fastq`) field to the summary report (#28)
32
55
- Added a `--verbose` flag (in addition to the existing `-v`)
33
56
34
57
### Changed
58
+
35
59
- Removed `-O` for compression type, now uses `--compression-format` for clarity.
36
60
- Removed `-l` for compression level, now uses `--compression-level` for clarity.
37
61
- Renamed `--json-report` to `--summary`
38
-
- Improved the JSON report format to make it easier to read by removing `Paired` and `Single` fields and instead having a simple `total_reads_in` and `total_reads_out` field.
62
+
- Improved the JSON report format to make it easier to read by removing `Paired` and `Single` fields and instead having
63
+
a simple `total_reads_in` and `total_reads_out` field.
39
64
40
65
### Fixed
66
+
41
67
- Removed duplicate log message for taxon IDs identified
42
68
- Clippy warnings
43
69
44
70
## [1.0.1] - 2025-06-28
45
71
46
72
### Fixed
73
+
47
74
- Create subdirectories specified in output path if they don't exist (#24)
48
75
- Add output validation to prevent overwriting existing files (#25)
49
76
50
77
## [1.0.0] - 2025-04-16
51
78
52
79
### Added
80
+
53
81
- Better error handling with color-eyre (#16)
54
82
- Proper panic handling (#16)
55
83
- Tests for most functions
56
84
- JSON report with accurate read count information (#15)
57
85
58
86
### Changed
87
+
59
88
- Keep fastq parsing in bytes instead of converting to String (#17)
60
89
- Optimized functions to take `&str` instead of `String` (#21)
61
90
- Migrated to crossbeam scoped channels and refactored threading code
62
91
- Refactored JSON output and removed lazy_static dependency
63
92
64
93
### Fixed
94
+
65
95
- Root node no longer added to tree twice (#22)
66
96
67
97
## [0.4.0] - 2023-10-06
68
98
69
99
### Added
100
+
70
101
- JSON report included in stdout upon successful completion (can be disabled with `--no-json`)
71
102
72
103
### Changed
104
+
73
105
- Project renamed
74
106
75
107
## [0.3.0] - 2023-09-22
76
108
77
109
### Added
110
+
78
111
- Support for paired-end files
79
112
- Output FASTA file with `--output-fasta` option
80
113
81
114
### Changed
115
+
82
116
- Major refactor to use Noodles for fastq parsing
83
117
- Switched to Niffler for compression handling
84
118
- Streamlined arguments related to compression types/level
85
119
86
120
### Improved
121
+
87
122
- Logging functionality
88
123
89
124
## [0.2.3] - 2023-09-02
90
125
91
126
### Changed
127
+
92
128
- Code optimizations
93
129
94
130
## [0.2.2]
95
131
96
132
### Added
133
+
97
134
-`--no-compress` flag to output standard plaintext fastq files
98
135
-`--exclude` option to exclude specified reads (works with `--children` and `--parents`)
99
136
- Internal documentation (docstrings)
100
137
101
138
### Improved
139
+
102
140
- Increased verbosity of user outputs
103
141
104
142
## [0.2.1]
105
143
106
144
### Fixed
145
+
107
146
- Reduced memory usage
108
147
109
148
## [0.2.0]
110
149
111
150
### Added
151
+
112
152
- Automatic detection and handling of gz and plain files
113
153
-`--compression` argument to select compression type
114
154
-`--children` and `--parents` options to save children and parents based on kraken report
Copy file name to clipboardExpand all lines: README.md
+42-21Lines changed: 42 additions & 21 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -10,25 +10,29 @@
10
10
11
11
**kra**ken extr**actor**
12
12
13
-
Kractor extracts reads from fastq `[.gz/.bz2]` files using taxonomic classifications obtained via Kraken2.
14
-
It supports single or paired-end reads, can optionally include taxonomic parents or children, and uses minimal memory (~4.5 MB for a 17 GB FASTQ file).
13
+
Kractor extracts reads from fastq `[.gz/.bz2]` files using taxonomic classifications obtained via Kraken2.
14
+
It supports single or paired-end reads, can optionally include taxonomic parents or children, and uses minimal memory (~
15
+
4.5 MB for a 17 GB FASTQ file).
15
16
16
17
The end result is a `fast[q/a]` file containing all reads classified as the specified taxon(s).
17
18
18
19
Kractor significantly enhances processing speed compared to KrakenTools for both paired and unpaired reads.
19
20
20
21
Performance vs KrakenTools:
21
-
- Paired compressed FASTQ: ~21× faster
22
-
- Paired uncompressed FASTQ: ~10× faster
22
+
23
+
- Paired compressed FASTQ: ~21× faster
24
+
- Paired uncompressed FASTQ: ~10× faster
23
25
- Unpaired: ~4× faster (compressed or uncompressed)
24
26
25
27
For additional details, refer to the [benchmarks](benchmarks/benchmarks.md)
26
28
27
29
## Motivation
28
30
29
-
Provides similar functionality to the [KrakenTools](https://github.com/jenniferlu717/KrakenTools)`extract_kraken_reads` python script.
31
+
Provides similar functionality to the [KrakenTools](https://github.com/jenniferlu717/KrakenTools)`extract_kraken_reads`
32
+
python script.
30
33
31
-
However the main motivation was to enhance speed when processing multiple, large FASTQ files - and as a way to learn Rust.
34
+
However the main motivation was to enhance speed when processing multiple, large FASTQ files - and as a way to learn
35
+
Rust.
32
36
33
37
## Installation
34
38
@@ -115,6 +119,8 @@ Options:
115
119
Output results in FASTA format
116
120
--summary
117
121
Enable a JSON summary output written to stdout
122
+
--no-header-detect
123
+
Disable detection and skipping of header lines in the Kraken2 report
Use `--summary` to get summary statistics (output to stdout on completion)
157
+
150
158
```json
151
159
{
152
160
"total_taxon_count": 2,
@@ -162,7 +170,7 @@ Use `--summary` to get summary statistics (output to stdout on completion)
162
170
"proportion_extracted": 0.2140419091180432,
163
171
"input_format": "single",
164
172
"output_format": "fastq",
165
-
"kractor_version": "2.0.0"
173
+
"kractor_version": "3.1.0"
166
174
}
167
175
```
168
176
@@ -174,7 +182,7 @@ Use `--summary` to get summary statistics (output to stdout on completion)
174
182
175
183
`-i, --input`
176
184
177
-
Specifies one or two input FASTQ files to extract reads from. Files may be uncompressed or compressed (`gz`, `bz2`).
185
+
Specifies one or two input FASTQ files to extract reads from. Files may be uncompressed or compressed (`gz`, `bz2`).
178
186
Paired end reads can be specified by:
179
187
180
188
Using `--input` twice: `-i <R1_fastq_file> -i <R2_fastq_file>`
@@ -185,47 +193,53 @@ Using `--input` once but passing both files: `-i <R1_fastq_file> <R2_fastq_file>
185
193
186
194
`-o, --output`
187
195
188
-
Specifies the output file(s) for extracted reads, matching the order of the input files.
196
+
Specifies the output file(s) for extracted reads, matching the order of the input files.
189
197
Compression type is inferred from the file extension (.gz, .bz2). If not recognised, output will be uncompressed.
190
198
191
199
#### Kraken Output
192
200
193
201
`-k, --kraken`
194
202
195
-
Path to the [Standard Kraken Output Format file](https://github.com/DerrickWood/kraken2/wiki/Manual#standard-kraken-output-format), containing taxonomic classification of read IDs.
203
+
Path to
204
+
the [Standard Kraken Output Format file](https://github.com/DerrickWood/kraken2/wiki/Manual#standard-kraken-output-format),
205
+
containing taxonomic classification of read IDs.
196
206
197
207
#### Taxid
198
208
199
209
`-t, --taxid`
200
210
201
-
One or more taxonomic IDs to extract.
211
+
One or more taxonomic IDs to extract.
202
212
203
213
For example: `-t 1 2 10`
204
214
205
215
Each taxonomic id is affected by `--exclude`, `--parents`, and `--children` if those options are used.
206
216
207
-
Taxonomic ids do not need to be present in a given report. This may be useful when running kractor in a wrapper script for several fastq files and just want to extract a set of taxon ids from them all - without caring if they are present or not.
217
+
Taxonomic ids do not need to be present in a given report. This may be useful when running kractor in a wrapper script
218
+
for several fastq files and just want to extract a set of taxon ids from them all - without caring if they are present
219
+
or not.
208
220
209
221
### Optional:
210
222
211
223
#### Output type
212
224
213
225
`--compression-format`
214
226
215
-
Manually set output compression format, overriding what is inferred from file names.
227
+
Manually set output compression format, overriding what is inferred from file names.
216
228
217
229
Valid values:
218
-
-`gz` – gzip compression
219
-
-`bz2` – bzip2 compression
230
+
231
+
-`gz` – gzip compression
232
+
-`bz2` – bzip2 compression
220
233
-`none` – no compression
221
234
222
235
#### Compression level
223
236
224
237
`--compression-level`
225
238
226
-
Set compression level (1–9).
227
-
- 1 = fastest, largest file
228
-
- 9 = slowest, smallest file
239
+
Set compression level (1–9).
240
+
241
+
- 1 = fastest, largest file
242
+
- 9 = slowest, smallest file
229
243
230
244
Default: 2 (balance of speed and size)
231
245
@@ -239,7 +253,12 @@ Output sequences in FASTA format instead of FASTQ.
239
253
240
254
`-r, --report`
241
255
242
-
Path to the [Kraken2 report file](https://github.com/DerrickWood/kraken2/wiki/Manual#sample-report-output-format). Required if using `--parents` or `--children`.
256
+
Path to the [Kraken2 report file](https://github.com/DerrickWood/kraken2/wiki/Manual#sample-report-output-format).
257
+
Required if using `--parents` or `--children`.
258
+
259
+
The first line is automatically treated as a header if it looks non-numeric; use `--no-header-detect` to force parsing
260
+
from the very first line. Parsing errors will include the report line number and offending line to help spot format
261
+
issues.
243
262
244
263
#### Parents
245
264
@@ -265,8 +284,10 @@ Extract all reads except those matching the given taxids. Can be combined with `
0 commit comments