Skip to content

deserializing records from htsget stream #317

@cmdoret

Description

@cmdoret

Dear developers,

When streaming chunks using noodles-htsget, is there a way to lazily parse CRAM records in memory?

In the noodles-htsget example, I've tried to replace:

while let Some(chunk) = chunks.try_next().await? {
stdout.write_all(&chunk).await?;
}

with things like:

let first_chunk = &chunks
    .try_next()
    .await
    .expect("can't load chunk")
    .unwrap()[..];

let mut reader = Reader::new(first_chunk);
let header = reader
    .read_header()
    .unwrap();

while let Some(chunk) = chunks.try_next().await.expect("can't load chunk") {
  let mut reader = Reader::new(&chunk[..]);
  for result in reader.records(&header) {
    let record = result.expect(&format!("{:?}", chunk));
      println!("{:?}", record);
    }
}

But when trying to instantiate records, I keep getting:

Custom { kind: InvalidData, error: TryFromInt
Error(()) }

Would you have any advice to parsing these records without saving the actual file?

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions