Skip to content

Commit

Permalink
Update to noodles 0.74.0
Browse files Browse the repository at this point in the history
  • Loading branch information
zaeleus committed May 24, 2024
1 parent f6c1ed0 commit bf6f444
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 24 deletions.
18 changes: 2 additions & 16 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ flate2 = "1.0.14"
git-testament = "0.2.0"
interval-tree = { git = "https://github.com/zaeleus/interval-tree.git", rev = "e303d7254d53de5c418d6079d4b66c30c10958d4" }
mimalloc = { version = "0.1.26", default-features = false }
noodles = { version = "0.73.0", features = ["bam", "bgzf", "core", "gff", "sam"] }
noodles-bgzf = { version = "0.30.0", features = ["libdeflate"] }
noodles = { path = "../noodles/noodles", version = "0.74.0", features = ["bam", "bgzf", "core", "gff", "sam"] }
noodles-bgzf = { path = "../noodles/noodles-bgzf", version = "0.30.0", features = ["libdeflate"] }
thiserror = "1.0.40"
tracing = "0.1.25"
tracing-subscriber = "0.3.3"
18 changes: 12 additions & 6 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,14 +70,16 @@ pub fn read_features<R>(
where
R: BufRead,
{
use noodles::gff::lazy::{record::attributes::field::Value, Line};

let mut features: HashMap<String, Vec<Feature>> = HashMap::new();

info!("reading features");

let mut line = noodles::gff::lazy::Line::default();
let mut line = Line::default();

while reader.read_lazy_line(&mut line)? != 0 {
let noodles::gff::lazy::Line::Record(ref record) = line else {
let Line::Record(ref record) = line else {
continue;
};

Expand All @@ -86,17 +88,21 @@ where
}

let reference_sequence_name = record.reference_sequence_name();
let start = record.start().try_into()?;
let end = record.end().try_into()?;
let strand = record.strand().try_into()?;
let start = record.start()?;
let end = record.end()?;
let strand = record.strand()?;

let feature = Feature::new(reference_sequence_name.into(), start, end, strand);

let attributes = record.attributes();
let id = attributes
.get(feature_id)
.ok_or_else(|| ReadFeaturesError::MissingAttribute(feature_id.into()))?
.map_err(|_| ReadFeaturesError::InvalidAttribute(feature_id.into()))?;
.map_err(|_| ReadFeaturesError::InvalidAttribute(feature_id.into()))
.and_then(|value| match value {
Value::String(s) => Ok(s),
Value::Array(_) => Err(ReadFeaturesError::InvalidAttribute(feature_id.into())),
})?;

let list = features.entry(id.into()).or_default();

Expand Down

0 comments on commit bf6f444

Please sign in to comment.