Skip to content

Commit

Permalink
refactor: Remove unnecessary code
Browse files Browse the repository at this point in the history
  • Loading branch information
cauliyang committed Feb 9, 2024
1 parent f638e45 commit 321497b
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 5 deletions.
26 changes: 22 additions & 4 deletions src/anno.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
use noodles_bam::{self as bam};

use anyhow::Result;
use clap::{arg, Args, ValueHint};
use log::{error, info, warn};
use noodles_sam::alignment::Record;
use std::path::{Path, PathBuf};
use std::str::FromStr;

use polars::df;
use polars::prelude::*;
use std::io::{self, BufRead}; // Add this line

use bio::alignment::pairwise::Scoring;
Expand Down Expand Up @@ -131,8 +132,25 @@ pub fn read_vcf<P: AsRef<Path>>(vcf_path: P) -> Result<Vec<VcfRecord>> {
.collect::<Vec<VcfRecord>>())
}

pub fn read_bam<P: AsRef<Path>>(bam_path: P) {
todo!()
pub fn read_bam<P: AsRef<Path>>(bam_path: P, read_names: &[&str]) -> Result<Vec<Record>> {
let mut reader = bam::reader::Builder.build_from_path(bam_path.as_ref())?;
let header = reader.read_header()?;

let records: Vec<_> = reader
.records(&header)
.filter_map(|result| result.ok())
.filter(|record| {
read_names.contains(
&record
.read_name()
.map(|name| name.to_string())
.unwrap_or_default()
.as_str(),
)
})
.collect();

Ok(records)
}

pub fn read_fasta<P: AsRef<Path>>(fasta_path: P) {
Expand Down
1 change: 0 additions & 1 deletion src/graph/load.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ pub fn load_cygraph_from_json(data: Value) -> Result<NLGraph> {
let edge_number = edges.as_array().unwrap().len();

let mut graph = NLGraph::with_capacity(node_number, edge_number);

let mut id2index = HashMap::new();

for node in nodes.as_array().unwrap() {
Expand Down

0 comments on commit 321497b

Please sign in to comment.