-
Notifications
You must be signed in to change notification settings - Fork 30
I am looking for a function that gives me an iterator over the read SequenceRecord's. #70
Copy link
Copy link
Open
Description
Thank you for this package!
This is really helpful for me and also especial thanks for giving me the initial help to start with Rust.
I now try to use the par_bridge() functionality in Rust to process two fastq entries in a muti-processor way and not load all data into memory first.
ChatGPT sent me down this rabbit hole:
fn main() {
let file1 = File::open("file1.fastq").expect("Failed to open file1");
let file2 = File::open("file2.fastq").expect("Failed to open file2");
let reader1 = BufReader::new(file1);
let reader2 = BufReader::new(file2);
// Process the FASTQ pairs in parallel
reader1
.lines()
.zip(reader2.lines())
.filter_map(|(line1, line2)| {
if let (Ok(read1), Ok(read2)) = (line1, line2) {
additional_processing(&read1, &read2)
} else {
None
}
})
.par_bridge()
.for_each(|(line1, line2)| {
process_fastq_pair(&line1, &line2);
});
}
Of cause not using the needletail logics to parse through a fastq file. After creating a somewhat promising version of this kind of logics I get this error:
305 | / reader1.next()
306 | | .zip(reader2.next())
307 | | .filter_map(|(line1, line2)| {
| | -^^^^^^^^^^ `Option<(Result<SequenceRecord<'_>, ParseError>, Result<SequenceRecord<'_>, ParseError>)>` is not an iterator
I have created the readers like that:
let mut reader1 = parse_fastx_file(&f1).expect("valid path/file");
let mut reader2 = parse_fastx_file(&f2).expect("valid path/file");
Is there something in your library that could give me the result I need for that. I assume it wants an iterator.
THANK YOU FOR YOUR HELP SO FAR!
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels