Skip to content

Commit

Permalink
Refactor is_valid fn (#388)
Browse files Browse the repository at this point in the history
---------

Co-authored-by: Shamoni Maheshwari <shamoni.maheshwari@bespin1.fuzzplex.com>
  • Loading branch information
shamoni and Shamoni Maheshwari authored Mar 7, 2024
1 parent 51f755f commit b67e5a7
Show file tree
Hide file tree
Showing 3 changed files with 238 additions and 196 deletions.
22 changes: 3 additions & 19 deletions enclone_args/src/read_json.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

use self::annotate::{annotate_seq, get_cdr3_using_ann, print_some_annotations};
use self::refx::RefData;
use self::transcript::is_valid;
use self::transcript::is_productive_contig;
use debruijn::dna_string::DnaString;
use enclone_core::barcode_fate::BarcodeFate;
use enclone_core::defs::{EncloneControl, OriginInfo, TigData};
Expand Down Expand Up @@ -183,28 +183,12 @@ fn process_json_annotation(
print_some_annotations(refdata, &ann1, &mut log, false);
print!("\n{}", strme(&log));
}
let mut log = Vec::<u8>::new();
if ctl.gen_opt.trace_barcode == ann.barcode {
if !is_valid(
&x,
refdata,
&ann1,
true,
&mut log,
Some(ctl.gen_opt.gamma_delta),
) {
print!("{}", strme(&log));
if !is_productive_contig(&x, refdata, &ann1).0 {
println!("invalid");
return Ok(res);
}
} else if !is_valid(
&x,
refdata,
&ann1,
false,
&mut log,
Some(ctl.gen_opt.gamma_delta),
) {
} else if !is_productive_contig(&x, refdata, &ann1).0 {
return Ok(res);
}
let mut cdr3 = Vec::<(usize, Vec<u8>, usize, usize)>::new();
Expand Down
16 changes: 9 additions & 7 deletions vdj_ann/src/annotate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
// This file contains code to annotate a contig, in the sense of finding alignments
// to VDJ reference contigs. Also to find CDR3 sequences. And some related things.

use crate::refx::RefData;
use crate::transcript::is_valid;
use crate::transcript::is_productive_contig;
use crate::{refx::RefData, transcript::ContigStatus};
use align_tools::affine_align;
use amino::{aa_seq, have_start};
use bio_edit::alignment::AlignmentOperation::{Del, Ins, Match, Subst, Xclip, Yclip};
Expand Down Expand Up @@ -3022,6 +3022,8 @@ pub struct ContigAnnotation {
pub productive: Option<bool>, // productive? (null means not full length)
#[serde(default = "set_true")]
pub filtered: bool, // true and never changed (unused field)
/// criteria used to asess productive status
pub productive_criteria: Option<ContigStatus>,

pub is_gex_cell: Option<bool>, // Was the barcode declared a cell by Gene expression data, if available
pub is_asm_cell: Option<bool>, // Was the barcode declared a cell by the VDJ assembler
Expand Down Expand Up @@ -3057,6 +3059,7 @@ impl ContigAnnotation {
invalidated_umis: Option<Vec<String>>, // invalidated UMIs
is_cellx: bool, // was the barcode declared a cell?
productivex: bool, // productive?
productive_criteria: ContigStatus, // criteria used to asess productive status
jsupp: Option<JunctionSupport>, // num reads, umis supporting junction
) -> ContigAnnotation {
let mut vstart = -1_i32;
Expand Down Expand Up @@ -3146,6 +3149,7 @@ impl ContigAnnotation {
invalidated_umis,
is_cell: is_cellx,
productive: Some(productivex),
productive_criteria: Some(productive_criteria),
filtered: true,
junction_support: jsupp,
// These need to be populated by the assembler explicitly as needed
Expand Down Expand Up @@ -3180,13 +3184,11 @@ impl ContigAnnotation {
non_validated_umis: Option<Vec<String>>, // non-validated UMIs
invalidated_umis: Option<Vec<String>>, // invalidated UMIs
is_cell: bool, // was the barcode declared a cell?
is_gd: Option<bool>, // is gamma/delta mode
jsupp: Option<JunctionSupport>, // num reads, umis supporting junction
) -> ContigAnnotation {
let mut ann = Vec::<(i32, i32, i32, i32, i32)>::new();
annotate_seq(b, refdata, &mut ann, true, false, true);
let mut log = Vec::<u8>::new();
let productive = is_valid(b, refdata, &ann, false, &mut log, is_gd);
let (is_productive, productive_criteria) = is_productive_contig(b, refdata, &ann);
ContigAnnotation::from_annotate_seq(
b,
q,
Expand All @@ -3200,7 +3202,8 @@ impl ContigAnnotation {
non_validated_umis,
invalidated_umis,
is_cell,
productive,
is_productive,
productive_criteria,
jsupp,
)
}
Expand Down Expand Up @@ -3358,7 +3361,6 @@ mod tests {
None,
false, // is_cell, should be changed to None
None,
None,
);

// println!("{:#?}", annotation);
Expand Down
Loading

0 comments on commit b67e5a7

Please sign in to comment.