-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Feat: adding code outline for footprinting tool
- Loading branch information
Showing
6 changed files
with
87 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
use super::bam_writer; | ||
use super::cli::FootprintOptions; | ||
use super::fiber::*; | ||
use anyhow; | ||
use serde::{Deserialize, Serialize}; | ||
use serde_yaml; | ||
|
||
#[derive(Serialize, Deserialize, PartialEq, Debug)] | ||
pub struct FootprintYaml { | ||
modules: Vec<(i64, i64)>, | ||
} | ||
|
||
impl FootprintYaml { | ||
pub fn check_for_valid_input(&self) -> Result<(), anyhow::Error> { | ||
if self.modules.is_empty() || self.modules.len() > 8 { | ||
return Err(anyhow::anyhow!( | ||
"YAML SPECIFICATION ERROR: Number of modules must be between 1 and 8: {self:?}" | ||
)); | ||
} | ||
let mut last_end = 0; | ||
for (start, end) in &self.modules { | ||
if *start < last_end { | ||
return Err(anyhow::anyhow!( | ||
"YAML SPECIFICATION ERROR: modules are not sorted: {self:?}" | ||
)); | ||
} | ||
if *start != last_end { | ||
return Err(anyhow::anyhow!( | ||
"YAML SPECIFICATION ERROR: modules are not contiguous or do not start at 0: {self:?}" | ||
)); | ||
} | ||
if *start > *end { | ||
return Err(anyhow::anyhow!( | ||
"YAML SPECIFICATION ERROR: start > end: {self:?}" | ||
)); | ||
} | ||
last_end = *end; | ||
} | ||
Ok(()) | ||
} | ||
} | ||
|
||
pub fn start_finding_footprints(opts: &FootprintOptions) -> Result<(), anyhow::Error> { | ||
let yaml_buff = bio_io::buffer_from(&opts.yaml)?; | ||
let yaml: FootprintYaml = serde_yaml::from_reader(yaml_buff)?; | ||
yaml.check_for_valid_input()?; | ||
log::debug!("YAML: {:?}", yaml); | ||
|
||
let mut bam = bio_io::bam_reader(&opts.bam, 8); | ||
let mut out = bam_writer(&opts.out, &bam, 8); | ||
for mut rec in FiberseqRecords::new(&mut bam, 0) { | ||
// TODO | ||
rec.m6a.starts = vec![]; | ||
out.write(&rec.record)?; | ||
} | ||
Ok(()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
# modules of CTCF footprinting | ||
# Will report using a bit flag if the module does not contain an m6A (is footprinted, 1) or does contain an m6A (is not footprinted, 0) for each module. | ||
# modules must start at zero, be sorted, and be contiguous with one another. | ||
# intervals are 0-based, half-open (like BED) | ||
modules: | ||
- [0, 8] | ||
- [8, 16] | ||
- [16, 23] | ||
- [23, 29] | ||
- [29, 34] |