Skip to content

Commit

Permalink
vcf/indexer: Use format records
Browse files Browse the repository at this point in the history
  • Loading branch information
zaeleus committed Apr 10, 2024
1 parent 5c649fe commit 559dbde
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions noodles-vcf/src/indexer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,7 @@ use noodles_bgzf as bgzf;
use noodles_csi::{self as csi, binning_index::index::reference_sequence::bin::Chunk};
use noodles_tabix as tabix;

use super::{
io::Reader,
variant::{Record, RecordBuf},
};
use super::{io::Reader, variant::Record as _, Record};

/// Indexes a bgzipped-compressed VCF file.
///
Expand All @@ -26,17 +23,20 @@ where
let mut indexer = tabix::index::Indexer::default();
indexer.set_header(csi::binning_index::index::header::Builder::vcf().build());

let mut record = RecordBuf::default();
let mut record = Record::default();
let mut start_position = reader.get_ref().virtual_position();

while reader.read_record_buf(&header, &mut record)? != 0 {
while reader.read_record(&mut record)? != 0 {
let end_position = reader.get_ref().virtual_position();
let chunk = Chunk::new(start_position, end_position);

let reference_sequence_name = record.reference_sequence_name().to_string();

let start = record
.variant_start()
.transpose()?
.ok_or_else(|| io::Error::new(io::ErrorKind::InvalidData, "missing position"))?;

let end = record.variant_end(&header)?;

indexer.add_record(&reference_sequence_name, start, end, chunk)?;
Expand Down

0 comments on commit 559dbde

Please sign in to comment.