|
@@ -429,8 +429,8 @@ impl BNDDesc {
|
|
|
added_nt.push_str(seq_after);
|
|
added_nt.push_str(seq_after);
|
|
|
added_nt.remove(0);
|
|
added_nt.remove(0);
|
|
|
// determine form and orientation
|
|
// determine form and orientation
|
|
|
- // form 1 & 2: bracket after t (open>0): local before remote
|
|
|
|
|
- // form 3 & 4: bracket before t (open==0): remote before local
|
|
|
|
|
|
|
+ // form 1 & 2: bracket after t (open>0): t before p
|
|
|
|
|
+ // form 3 & 4: bracket before t (open==0): p before t
|
|
|
let after_local = open > 0;
|
|
let after_local = open > 0;
|
|
|
let (t_sens, p_sens) = match (bracket, after_local) {
|
|
let (t_sens, p_sens) = match (bracket, after_local) {
|
|
|
('[', true) => (true, true), // form 1 t[p[
|
|
('[', true) => (true, true), // form 1 t[p[
|
|
@@ -441,7 +441,8 @@ impl BNDDesc {
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
// assign A/B depending on form
|
|
// assign A/B depending on form
|
|
|
- let (a_contig, a_position, a_sens, b_contig, b_position, b_sens, added_nt) = if after_local {
|
|
|
|
|
|
|
+ let (a_contig, a_position, a_sens, b_contig, b_position, b_sens, added_nt) = if after_local
|
|
|
|
|
+ {
|
|
|
(
|
|
(
|
|
|
t_chrom.into(),
|
|
t_chrom.into(),
|
|
|
t_pos,
|
|
t_pos,
|
|
@@ -449,10 +450,9 @@ impl BNDDesc {
|
|
|
p_contig.into(),
|
|
p_contig.into(),
|
|
|
p_position,
|
|
p_position,
|
|
|
p_sens,
|
|
p_sens,
|
|
|
- added_nt
|
|
|
|
|
|
|
+ added_nt,
|
|
|
)
|
|
)
|
|
|
} else {
|
|
} else {
|
|
|
- // forms 3 & 4: A is remote, B is local
|
|
|
|
|
(
|
|
(
|
|
|
p_contig.into(),
|
|
p_contig.into(),
|
|
|
p_position,
|
|
p_position,
|
|
@@ -460,7 +460,7 @@ impl BNDDesc {
|
|
|
t_chrom.into(),
|
|
t_chrom.into(),
|
|
|
t_pos,
|
|
t_pos,
|
|
|
t_sens,
|
|
t_sens,
|
|
|
- reverse_complement(&added_nt)
|
|
|
|
|
|
|
+ reverse_complement(&added_nt),
|
|
|
)
|
|
)
|
|
|
};
|
|
};
|
|
|
Some(Self {
|
|
Some(Self {
|
|
@@ -491,17 +491,21 @@ impl BNDDesc {
|
|
|
pub fn reverse_complement(dna: &str) -> String {
|
|
pub fn reverse_complement(dna: &str) -> String {
|
|
|
fn complement(base: char) -> char {
|
|
fn complement(base: char) -> char {
|
|
|
match base {
|
|
match base {
|
|
|
- 'A' => 'T', 'T' => 'A', 'C' => 'G', 'G' => 'C',
|
|
|
|
|
- 'a' => 't', 't' => 'a', 'c' => 'g', 'g' => 'c',
|
|
|
|
|
- 'N' => 'N', 'n' => 'n',
|
|
|
|
|
|
|
+ 'A' => 'T',
|
|
|
|
|
+ 'T' => 'A',
|
|
|
|
|
+ 'C' => 'G',
|
|
|
|
|
+ 'G' => 'C',
|
|
|
|
|
+ 'a' => 't',
|
|
|
|
|
+ 't' => 'a',
|
|
|
|
|
+ 'c' => 'g',
|
|
|
|
|
+ 'g' => 'c',
|
|
|
|
|
+ 'N' => 'N',
|
|
|
|
|
+ 'n' => 'n',
|
|
|
_ => 'N',
|
|
_ => 'N',
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- dna.chars()
|
|
|
|
|
- .rev()
|
|
|
|
|
- .map(complement)
|
|
|
|
|
- .collect()
|
|
|
|
|
|
|
+ dna.chars().rev().map(complement).collect()
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
impl core::fmt::Display for BNDDesc {
|
|
impl core::fmt::Display for BNDDesc {
|
|
@@ -516,14 +520,14 @@ impl core::fmt::Display for BNDDesc {
|
|
|
}
|
|
}
|
|
|
write!(
|
|
write!(
|
|
|
f,
|
|
f,
|
|
|
- "({}:{}{};{}:{}{};ins={})",
|
|
|
|
|
|
|
+ "({}{}:{}::{}::{}:{}{})",
|
|
|
|
|
+ arrow(self.a_sens),
|
|
|
self.a_contig,
|
|
self.a_contig,
|
|
|
self.a_position,
|
|
self.a_position,
|
|
|
- arrow(self.a_sens),
|
|
|
|
|
|
|
+ self.added_nt,
|
|
|
self.b_contig,
|
|
self.b_contig,
|
|
|
self.b_position,
|
|
self.b_position,
|
|
|
arrow(self.b_sens),
|
|
arrow(self.b_sens),
|
|
|
- self.added_nt
|
|
|
|
|
)
|
|
)
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
@@ -566,7 +570,7 @@ impl<E> BNDGraph<E> {
|
|
|
&self.graph
|
|
&self.graph
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- /// Stringify all nodes for quick debugging.
|
|
|
|
|
|
|
+ /// Stringify all nodes
|
|
|
pub fn nodes_as_strings(&self) -> Vec<String> {
|
|
pub fn nodes_as_strings(&self) -> Vec<String> {
|
|
|
self.graph.node_weights().map(|n| n.to_string()).collect()
|
|
self.graph.node_weights().map(|n| n.to_string()).collect()
|
|
|
}
|
|
}
|
|
@@ -812,6 +816,12 @@ pub struct DeletionDesc {
|
|
|
pub end: u32,
|
|
pub end: u32,
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+impl fmt::Display for DeletionDesc {
|
|
|
|
|
+ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
|
|
|
|
+ write!(f, "{}:{}_{}_del", self.contig, self.start, self.end)
|
|
|
|
|
+ }
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
impl DeletionDesc {
|
|
impl DeletionDesc {
|
|
|
pub fn len(&self) -> u32 {
|
|
pub fn len(&self) -> u32 {
|
|
|
self.end.saturating_sub(self.start)
|
|
self.end.saturating_sub(self.start)
|
|
@@ -1635,6 +1645,7 @@ impl Formats {
|
|
|
/// ```
|
|
/// ```
|
|
|
pub fn n_alt_depth(&self) -> Option<(u32, u32)> {
|
|
pub fn n_alt_depth(&self) -> Option<(u32, u32)> {
|
|
|
let mut tumor_alt_depth: Option<u32> = None;
|
|
let mut tumor_alt_depth: Option<u32> = None;
|
|
|
|
|
+ let mut tumor_ref_depth: Option<u32> = None;
|
|
|
let mut tumor_total_depth: Option<u32> = None;
|
|
let mut tumor_total_depth: Option<u32> = None;
|
|
|
|
|
|
|
|
for format in &self.0 {
|
|
for format in &self.0 {
|
|
@@ -1647,12 +1658,25 @@ impl Formats {
|
|
|
Format::DP(value) => {
|
|
Format::DP(value) => {
|
|
|
tumor_total_depth = Some(*value);
|
|
tumor_total_depth = Some(*value);
|
|
|
}
|
|
}
|
|
|
|
|
+ Format::VR(values) => {
|
|
|
|
|
+ tumor_alt_depth = Some(*values);
|
|
|
|
|
+ }
|
|
|
|
|
+ Format::TR(value) => {
|
|
|
|
|
+ tumor_ref_depth = Some(*value);
|
|
|
|
|
+ }
|
|
|
|
|
+ Format::DV(values) => {
|
|
|
|
|
+ tumor_alt_depth = Some(*values);
|
|
|
|
|
+ }
|
|
|
|
|
+ Format::DR(value) => {
|
|
|
|
|
+ tumor_ref_depth = Some(*value);
|
|
|
|
|
+ }
|
|
|
_ => {}
|
|
_ => {}
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- match (tumor_alt_depth, tumor_total_depth) {
|
|
|
|
|
- (Some(alt), Some(total)) => Some((alt, total)),
|
|
|
|
|
|
|
+ match (tumor_alt_depth, tumor_total_depth, tumor_ref_depth) {
|
|
|
|
|
+ (Some(alt), Some(total), _) => Some((alt, total)),
|
|
|
|
|
+ (Some(alt), _, Some(refe)) => Some((alt, alt + refe)),
|
|
|
_ => None,
|
|
_ => None,
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|