Skip to content
This repository has been archived by the owner on Feb 23, 2024. It is now read-only.

Replace is_valid with refactored version #318

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
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
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::{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 @@ -228,16 +228,16 @@
}
}

pub fn annotate_seq_core(
b: &DnaString,
refdata: &RefData,
ann: &mut Vec<(i32, i32, i32, i32, i32)>,
allow_weak: bool,
allow_improper: bool,
abut: bool,
log: &mut Vec<u8>,
verbose: bool,
) {

Check warning on line 240 in vdj_ann/src/annotate.rs

View workflow job for this annotation

GitHub Actions / rust

this function has too many arguments (8/7)

warning: this function has too many arguments (8/7) --> vdj_ann/src/annotate.rs:231:1 | 231 | / pub fn annotate_seq_core( 232 | | b: &DnaString, 233 | | refdata: &RefData, 234 | | ann: &mut Vec<(i32, i32, i32, i32, i32)>, ... | 239 | | verbose: bool, 240 | | ) { | |__^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#too_many_arguments = note: `#[warn(clippy::too_many_arguments)]` on by default
// The DNA string representation is inefficient because it stores bases as packed k-mers
// which requires a lot of array bounds checks when unpacking which was a hot path
// we found when profiling the CI job. To avoid those in the inner
Expand Down Expand Up @@ -1596,8 +1596,8 @@
// deletion. Be very careful to respect this if editing!

let (mut win1, mut win2) = (false, false);
let c1 = m1 == m2 && !have_utr_align2 && err1_nu == err2_nu && outside1 > outside2;

Check warning on line 1599 in vdj_ann/src/annotate.rs

View workflow job for this annotation

GitHub Actions / rust

strict comparison of `f32` or `f64`

warning: strict comparison of `f32` or `f64` --> vdj_ann/src/annotate.rs:1599:54 | 1599 | let c1 = m1 == m2 && !have_utr_align2 && err1_nu == err2_nu && outside1 > outside2; | ^^^^^^^^^^^^^^^^^^ help: consider comparing them within some margin of error: `(err1_nu - err2_nu).abs() < error_margin` | = note: `f32::EPSILON` and `f64::EPSILON` are available for the `error_margin` = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#float_cmp = note: requested on the command line with `-W clippy::float-cmp`
let c2 = m2 == m1 && !have_utr_align1 && err2_nu == err1_nu && outside2 > outside1;

Check warning on line 1600 in vdj_ann/src/annotate.rs

View workflow job for this annotation

GitHub Actions / rust

strict comparison of `f32` or `f64`

warning: strict comparison of `f32` or `f64` --> vdj_ann/src/annotate.rs:1600:54 | 1600 | let c2 = m2 == m1 && !have_utr_align1 && err2_nu == err1_nu && outside2 > outside1; | ^^^^^^^^^^^^^^^^^^ help: consider comparing them within some margin of error: `(err2_nu - err1_nu).abs() < error_margin` | = note: `f32::EPSILON` and `f64::EPSILON` are available for the `error_margin` = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#float_cmp
if (zstop1 > zstop2 + 20 && (outside2 <= 10.0 || total2 - share <= 10))
|| (outside1 >= 10.0 && outside2 <= 1.0 && err1 - err2 <= 2.5)
{
Expand All @@ -1606,8 +1606,8 @@
} else if (outside2 <= 10.0 || total2 - share <= 10)
&& (m1 < m2
|| (m1 == m2 && err1 < err2 && !c2)
|| (m1 == m2 && err1 == err2 && outside1 > outside2)

Check warning on line 1609 in vdj_ann/src/annotate.rs

View workflow job for this annotation

GitHub Actions / rust

strict comparison of `f32` or `f64`

warning: strict comparison of `f32` or `f64` --> vdj_ann/src/annotate.rs:1609:37 | 1609 | || (m1 == m2 && err1 == err2 && outside1 > outside2) | ^^^^^^^^^^^^ help: consider comparing them within some margin of error: `(err1 - err2).abs() < error_margin` | = note: `f32::EPSILON` and `f64::EPSILON` are available for the `error_margin` = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#float_cmp
|| (m1 == m2 && err1 == err2 && outside1 == outside2 && t1 < t2)

Check warning on line 1610 in vdj_ann/src/annotate.rs

View workflow job for this annotation

GitHub Actions / rust

strict comparison of `f32` or `f64`

warning: strict comparison of `f32` or `f64` --> vdj_ann/src/annotate.rs:1610:37 | 1610 | || (m1 == m2 && err1 == err2 && outside1 == outside2 && t1 < t2) | ^^^^^^^^^^^^ help: consider comparing them within some margin of error: `(err1 - err2).abs() < error_margin` | = note: `f32::EPSILON` and `f64::EPSILON` are available for the `error_margin` = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#float_cmp

Check warning on line 1610 in vdj_ann/src/annotate.rs

View workflow job for this annotation

GitHub Actions / rust

strict comparison of `f32` or `f64`

warning: strict comparison of `f32` or `f64` --> vdj_ann/src/annotate.rs:1610:53 | 1610 | || (m1 == m2 && err1 == err2 && outside1 == outside2 && t1 < t2) | ^^^^^^^^^^^^^^^^^^^^ help: consider comparing them within some margin of error: `(outside1 - outside2).abs() < error_margin` | = note: `f32::EPSILON` and `f64::EPSILON` are available for the `error_margin` = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#float_cmp
|| c1)
{
win1 = true;
Expand All @@ -1623,8 +1623,8 @@
} else if (outside1 <= 10.0 || total1 - share <= 10)
&& (m2 < m1
|| (m2 == m1 && err2 < err1 && !c1)
|| (m2 == m1 && err2 == err1 && outside2 > outside1)

Check warning on line 1626 in vdj_ann/src/annotate.rs

View workflow job for this annotation

GitHub Actions / rust

strict comparison of `f32` or `f64`

warning: strict comparison of `f32` or `f64` --> vdj_ann/src/annotate.rs:1626:37 | 1626 | || (m2 == m1 && err2 == err1 && outside2 > outside1) | ^^^^^^^^^^^^ help: consider comparing them within some margin of error: `(err2 - err1).abs() < error_margin` | = note: `f32::EPSILON` and `f64::EPSILON` are available for the `error_margin` = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#float_cmp
|| (m2 == m1 && err2 == err1 && outside2 == outside1 && t2 < t1)

Check warning on line 1627 in vdj_ann/src/annotate.rs

View workflow job for this annotation

GitHub Actions / rust

strict comparison of `f32` or `f64`

warning: strict comparison of `f32` or `f64` --> vdj_ann/src/annotate.rs:1627:37 | 1627 | || (m2 == m1 && err2 == err1 && outside2 == outside1 && t2 < t1) | ^^^^^^^^^^^^ help: consider comparing them within some margin of error: `(err2 - err1).abs() < error_margin` | = note: `f32::EPSILON` and `f64::EPSILON` are available for the `error_margin` = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#float_cmp
|| c2)
{
win2 = true;
Expand Down Expand Up @@ -3018,7 +3018,9 @@
pub invalidated_umis: Option<Vec<String>>, // invalidated UMIs
pub is_cell: bool, // was the barcode declared a cell?
pub productive: Option<bool>, // productive? (null means not full length)
pub filtered: bool, // true and never changed (unused field)
#[serde(skip_serializing_if = "Option::is_none")]
pub productive_criteria: Option<ContigStatus>,
pub filtered: bool, // true and never changed (unused field)

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 @@ -3050,7 +3052,8 @@
invalidated_umis: Option<Vec<String>>, // invalidated UMIs
is_cellx: bool, // was the barcode declared a cell?
productivex: bool, // productive?
jsupp: Option<JunctionSupport>, // num reads, umis supporting junction
prod_criteria: ContigStatus, // criteria used to determine if a contig is productive
jsupp: Option<JunctionSupport>, // num reads, umis supporting junction
) -> ContigAnnotation {
let mut vstart = -1_i32;
for i in 0..ann.len() {
Expand Down Expand Up @@ -3139,6 +3142,7 @@
invalidated_umis,
is_cell: is_cellx,
productive: Some(productivex),
productive_criteria: Some(prod_criteria),
filtered: true,
junction_support: jsupp,
// These need to be populated by the assembler explicitly as needed
Expand Down Expand Up @@ -3173,13 +3177,11 @@
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 (productive, contig_status) = is_valid(b, refdata, &ann);
ContigAnnotation::from_annotate_seq(
b,
q,
Expand All @@ -3194,6 +3196,7 @@
invalidated_umis,
is_cell,
productive,
contig_status,
jsupp,
)
}
Expand Down Expand Up @@ -3351,7 +3354,6 @@
None,
false, // is_cell, should be changed to None
None,
None,
);

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