Skip to content

Commit 7f5fb51

Browse files
authored
fix: update noodles-group to 0.97 (#678)
1 parent 255982d commit 7f5fb51

File tree

10 files changed

+684
-560
lines changed

10 files changed

+684
-560
lines changed

Cargo.lock

Lines changed: 650 additions & 538 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ tempfile = "3.19.1"
5959
lru = "0.13.0"
6060

6161
[dependencies.noodles]
62-
version = "0.77.0"
62+
version = "0.97.0"
6363
features = ["bed", "bgzf", "core", "csi", "gff", "tabix", "vcf"]
6464

6565
[build-dependencies]

src/db_utils/cli/copy.rs

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ use std::{fs::File, io::BufReader, path::PathBuf};
55
use clap::Parser;
66

77
use indicatif::ParallelProgressIterator;
8+
use noodles::core::Position;
89
use rayon::prelude::*;
910

1011
use crate::common::{self, cli::extract_chrom, keys, spdi};
@@ -59,12 +60,14 @@ fn copy_cf_bed(
5960
) -> Result<(), anyhow::Error> {
6061
let mut reader = File::open(path_bed)
6162
.map(BufReader::new)
62-
.map(noodles::bed::Reader::new)?;
63+
.map(noodles::bed::Reader::<3, _>::new)?;
6364

6465
tracing::info!(" reading BED records...");
65-
let bed_records = reader
66-
.records::<3>()
67-
.collect::<Result<Vec<noodles::bed::Record<3>>, _>>()?;
66+
let mut bed_records = Vec::new();
67+
let mut record = noodles::bed::Record::default();
68+
while reader.read_record(&mut record)? != 0 {
69+
bed_records.push(record.clone());
70+
}
6871
tracing::info!(
6972
" will process {} BED records in parallel...",
7073
bed_records.len()
@@ -75,9 +78,15 @@ fn copy_cf_bed(
7578
.progress_with(common::cli::progress_bar(bed_records.len()))
7679
.map(|record| {
7780
let chrom = record.reference_sequence_name();
78-
let start: usize = record.start_position().into();
81+
let start: usize = record
82+
.feature_start()
83+
.unwrap_or(Position::new(1).unwrap())
84+
.into();
7985
let start = start + 1;
80-
let stop: usize = record.end_position().into();
86+
let stop: usize = record
87+
.feature_end()
88+
.unwrap_or(Ok(Position::new(1).unwrap()))?
89+
.into();
8190

8291
let start = spdi::Pos {
8392
sequence: chrom.to_string(),

src/dbsnp/cli/import.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ fn tsv_import(
5959
.reference_sequence_names()
6060
.iter()
6161
.filter_map(|chrom| {
62+
let chrom = &chrom.to_string();
6263
let canon_chrom = chrom.strip_prefix("chr").unwrap_or(chrom);
6364
if common::cli::is_canonical(canon_chrom) {
6465
Some((common::cli::canonicalize(canon_chrom), chrom.clone()))

src/freqs/cli/import/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,7 @@ pub fn build_windows(
122122
.reference_sequence_names()
123123
.iter()
124124
.filter_map(|chrom| {
125+
let chrom = &chrom.to_string();
125126
let canon_chrom = chrom.strip_prefix("chr").unwrap_or(chrom);
126127
if common::cli::is_canonical(canon_chrom) {
127128
Some((common::cli::canonicalize(canon_chrom), chrom.clone()))

src/functional/cli/import.rs

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -106,11 +106,11 @@ fn gff_import(
106106
// Import of RefSeq GFF data.
107107
let contig_map = ContigMap::new(args.genome_release.into());
108108
let mut reader = gff::Reader::new(std::io::BufReader::new(reader));
109-
for result in reader.records() {
109+
for result in reader.record_bufs() {
110110
let record = result?;
111111

112112
// Resolve reference sequence name to contig name (for canonical ones).
113-
let seq_name = record.reference_sequence_name();
113+
let seq_name = &record.reference_sequence_name().to_string();
114114
let chromosome = match contig_map.chrom_name_to_seq(seq_name) {
115115
Ok(sequence) => {
116116
if is_canonical(&sequence.name) {
@@ -129,14 +129,15 @@ fn gff_import(
129129
};
130130

131131
/// Helper function to extract a key from the attributes of a record.
132-
fn extract(record: &gff::Record, key: &str) -> Result<String, anyhow::Error> {
132+
fn extract(record: &gff::feature::RecordBuf, key: &str) -> Result<String, anyhow::Error> {
133+
let key_ = key.as_bytes();
133134
let value = record
134135
.attributes()
135-
.get(key)
136+
.get(key_)
136137
.ok_or_else(|| anyhow::anyhow!("problem with {} attribute: {:?}", key, record))?;
137138
match value {
138-
gff::record::attributes::field::Value::String(s) => Ok(s.clone()),
139-
gff::record::attributes::field::Value::Array(arr) => {
139+
gff::feature::record_buf::attributes::field::Value::String(s) => Ok(s.to_string()),
140+
gff::feature::record_buf::attributes::field::Value::Array(arr) => {
140141
if arr.is_empty() {
141142
Err(anyhow::anyhow!(
142143
"problem with {} attribute: {:?}",
@@ -147,7 +148,7 @@ fn gff_import(
147148
if arr.len() > 1 {
148149
tracing::warn!("multiple values for {} attribute: {:?}", key, record);
149150
}
150-
Ok(arr[0].clone())
151+
Ok(arr[0].clone().to_string())
151152
}
152153
}
153154
}

src/gnomad_mtdna/cli/import.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,8 @@ fn tsv_import(
6565
.reference_sequence_names()
6666
.iter()
6767
.filter_map(|chrom| {
68-
let canon_chrom = chrom.strip_prefix("chr").unwrap_or(chrom);
68+
let chrom = chrom.to_string();
69+
let canon_chrom = chrom.strip_prefix("chr").unwrap_or(&chrom);
6970
if common::cli::is_canonical(canon_chrom) {
7071
Some((common::cli::canonicalize(canon_chrom), chrom.clone()))
7172
} else {

src/gnomad_nuclear/cli/import.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,8 @@ fn vcf_import(
124124
.reference_sequence_names()
125125
.iter()
126126
.filter_map(|chrom| {
127-
let canon_chrom = chrom.strip_prefix("chr").unwrap_or(chrom);
127+
let chrom = chrom.to_string();
128+
let canon_chrom = chrom.strip_prefix("chr").unwrap_or(&chrom);
128129
if common::cli::is_canonical(canon_chrom) {
129130
Some((common::cli::canonicalize(canon_chrom), chrom.clone()))
130131
} else {

src/helixmtdb/cli/import.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,8 @@ fn tsv_import(
5454
.reference_sequence_names()
5555
.iter()
5656
.filter_map(|chrom| {
57-
let canon_chrom = chrom.strip_prefix("chr").unwrap_or(chrom);
57+
let chrom = chrom.to_string();
58+
let canon_chrom = chrom.strip_prefix("chr").unwrap_or(&chrom);
5859
if common::cli::is_canonical(canon_chrom) {
5960
Some((common::cli::canonicalize(canon_chrom), chrom.clone()))
6061
} else {

src/tsv/cli/import/par_tbi.rs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,7 @@ fn resolve_region(
1717
) -> std::io::Result<usize> {
1818
header
1919
.reference_sequence_names()
20-
.get_index_of(
21-
std::str::from_utf8(region.name())
22-
.map_err(|e| std::io::Error::new(std::io::ErrorKind::InvalidData, e))?,
23-
)
20+
.get_index_of(region.name())
2421
.ok_or_else(|| {
2522
std::io::Error::new(
2623
std::io::ErrorKind::InvalidInput,
@@ -137,7 +134,7 @@ pub fn tsv_import(
137134
.filter(|(chrom, _, _)| {
138135
header
139136
.reference_sequence_names()
140-
.get_index_of(chrom)
137+
.get_index_of(chrom.as_bytes())
141138
.is_some()
142139
})
143140
.map(|(chrom, begin, end)| {

0 commit comments

Comments
 (0)