Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

output all possible subgraphs #18

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 56 additions & 1 deletion Cargo.lock

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

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,4 @@ rayon = "1.9.0"
serde = { version = "1.0.197", features = ["derive"] }
noodles = { version = "0.66.0", features = ["bgzf"] }
regex = "1.10.4"
itertools = "0.13.0"
50 changes: 48 additions & 2 deletions src/main.rs
Original file line number Diff line number Diff line change
@@ -1,14 +1,18 @@
use clap::Parser;
use std::fs::File;
// use std::hash::Hash;
use std::collections::HashMap;
use std::io::{self, BufReader, BufWriter};
use std::num::NonZeroUsize;
use noodles::bgzf;
use impg::impg::{Impg, SerializableImpg, AdjustedInterval, check_intervals};
use coitrees::IntervalTree;
use coitrees::{IntervalTree, BasicCOITree, Interval};
use impg::paf;
use rayon::ThreadPoolBuilder;
use std::io::BufRead;

use itertools::Itertools;

/// Command-line tool for querying overlaps in PAF files.
#[derive(Parser, Debug)]
#[clap(author, version, about)]
Expand All @@ -29,6 +33,10 @@ struct Args {
#[clap(short='b', long, value_parser)]
target_bed: Option<String>,

/// Window size to create PAF files from.
#[clap(short='w', long, value_parser)]
window_size: Option<i32>,

/// Enable transitive overlap requests.
#[clap(short='x', long, action)]
transitive: bool,
Expand Down Expand Up @@ -102,7 +110,45 @@ fn main() -> io::Result<()> {
output_results_bedpe(&impg, results, &target_name, name);
}
}
}
} else if let Some(window_size) = args.window_size {
// println!("{window_size}");
let mut seen: HashMap<u32, Vec<Interval<()>>> = HashMap::new();
for key in impg.trees.keys().sorted() {
println!("key: {}", key);
impg.trees.get(key);
let target_length = impg.seq_index.get_len_from_id(*key).expect("Target length not found in index");
println!("target length: {}", target_length);
let target_name = impg.seq_index.get_name(*key).unwrap();
println!("target name: {}", target_name);
let mut i: i32 = 0;
// check if key in coitree (once per coitree is sufficient)
let interval_arr = if let Some(interval_arr) = seen.get_mut(key) {
interval_arr
} else { // else we insert a new empty vec
seen.entry(*key).or_insert(Vec::new())
};
while i < target_length.try_into().unwrap() {
println!("IIIII: {}", i);
let end;
if i + window_size < target_length.try_into().unwrap() {
end = i + window_size;
} else {
end = target_length.try_into().unwrap();
}
// if already in coitree, extract overlapping intervals
// TODO NOT SURE HERE
// if not in coitree, add a new key with vec
// TODO NOT SURE HERE

// transitive stuff
let results = impg.query(key.clone(), i, end);
// add new intervals to coitree
interval_arr.push(Interval::new(i, end, ()));
output_results_paf(&impg, results, &target_name, None);
i = i + window_size;
}
}
}
Ok(())
}

Expand Down
Loading