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

Refactor is_valid fn #388

Merged
merged 4 commits into from
Mar 7, 2024
Merged
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
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();
macklin-10x marked this conversation as resolved.
Show resolved Hide resolved
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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same kind of thing here.

Suggested change
productive_criteria: ContigStatus, // criteria used to asess productive status
/// Criteria used to asess productive status.
productive_criteria: ContigStatus,

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
Loading