Skip to content

How to index a VCF statically or on the fly #214

@nh13

Description

@nh13

I'd like to programmatically generate VCF records as part of my unit tests for various tools. In some cases I'll create new records then write them to disk to test the tool end to end (versus just passing methods the variant records themselves). The VCF needs to be indexed, and I was wondering how to do that after I've written the VCF as well as ideally on the fly.

I think to create the index, you can get the virtual position from the writer and perhaps something like this:

for (reference_sequence_name, start, end) in records {
writeln!(writer, "{}\t{}\t{}", reference_sequence_name, start, end)?;
let end_position = writer.virtual_position();
let chunk = Chunk::new(start_position, end_position);
indexer.add_record(reference_sequence_name, start, end, chunk)?;
start_position = end_position;
}
?

Any guidance would be greatly appreciated!

Metadata

Metadata

Assignees

Labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions