From dcf66fc5619124d4df9a8e71cd7f8da187676875 Mon Sep 17 00:00:00 2001 From: zacmon <7682998+zacmon@users.noreply.github.com> Date: Thu, 31 Oct 2024 15:26:42 -0700 Subject: [PATCH] Added tcrdist neighbor functions. Fixed bug in tcrdist for equal lengths --- src/distance.rs | 483 +++++++++++++++++++++++++++++++++++++++--------- src/lib.rs | 280 +++++++++++++++++++--------- 2 files changed, 592 insertions(+), 171 deletions(-) diff --git a/src/distance.rs b/src/distance.rs index 9cb6ea5..c0185d4 100644 --- a/src/distance.rs +++ b/src/distance.rs @@ -63,7 +63,7 @@ pub fn tcrdist( for idx in ntrim..s1_len - ctrim { distance += match_table::amino_distances(&s1[idx], &s2[idx]); } - return distance; + return dist_weight * distance; } let len_diff: usize; @@ -326,6 +326,355 @@ pub fn tcrdist_pairwise( }) } } + +pub fn tcrdist_neighbor_matrix( + seqs: &[&str], + threshold: u16, + dist_weight: u16, + gap_penalty: u16, + ntrim: usize, + ctrim: usize, + fixed_gappos: bool, + parallel: bool, +) -> Vec<[usize; 3]> { + if parallel == false { + seqs.iter() + .enumerate() + .flat_map(|(idx, &s1)| { + seqs[idx + 1..] + .iter() + .enumerate() + .fold(Vec::new(), |mut v, (jdx, &s2)| { + let s1_bytes: &[u8] = s1.as_bytes(); + let s2_bytes: &[u8] = s2.as_bytes(); + let s1_len: usize = s1_bytes.len(); + let s2_len: usize = s2_bytes.len(); + let len_diff: u16 = if s1_len > s2_len { + (s1_len - s2_len) as u16 + } else { + (s2_len - s1_len) as u16 + }; + + if len_diff * gap_penalty <= threshold { + let dist: u16 = tcrdist( + s1_bytes, + s2_bytes, + dist_weight, + gap_penalty, + ntrim, + ctrim, + fixed_gappos, + ); + if dist <= threshold { + v.push([idx, jdx + 1 + idx, dist as usize]) + }; + } + v + }) + }) + .collect::>() + } else { + POOL.install(|| { + seqs.par_iter() + .enumerate() + .flat_map(|(idx, &s1)| { + seqs[idx + 1..] + .iter() + .enumerate() + .fold(Vec::new(), |mut v, (jdx, &s2)| { + let s1_bytes: &[u8] = s1.as_bytes(); + let s2_bytes: &[u8] = s2.as_bytes(); + let s1_len: usize = s1_bytes.len(); + let s2_len: usize = s2_bytes.len(); + let len_diff: u16 = if s1_len > s2_len { + (s1_len - s2_len) as u16 + } else { + (s2_len - s1_len) as u16 + }; + + if len_diff * gap_penalty <= threshold { + let dist: u16 = tcrdist( + s1_bytes, + s2_bytes, + dist_weight, + gap_penalty, + ntrim, + ctrim, + fixed_gappos, + ); + if dist <= threshold { + v.push([idx, jdx + 1 + idx, dist as usize]) + }; + } + v + }) + }) + .collect::>() + }) + } +} + +pub fn tcrdist_neighbor_pairwise( + seqs1: &[&str], + seqs2: &[&str], + threshold: u16, + dist_weight: u16, + gap_penalty: u16, + ntrim: usize, + ctrim: usize, + fixed_gappos: bool, + parallel: bool, +) -> Vec<[usize; 2]> { + if parallel == false { + seqs1 + .iter() + .enumerate() + .zip(seqs2.iter()) + .fold(Vec::new(), |mut v, ((idx, &s1), &s2)| { + let s1_bytes: &[u8] = s1.as_bytes(); + let s2_bytes: &[u8] = s2.as_bytes(); + let s1_len: usize = s1_bytes.len(); + let s2_len: usize = s2_bytes.len(); + let len_diff: u16 = if s1_len > s2_len { + (s1_len - s2_len) as u16 + } else { + (s2_len - s1_len) as u16 + }; + + if len_diff * gap_penalty <= threshold { + let dist: u16 = tcrdist( + s1_bytes, + s2_bytes, + dist_weight, + gap_penalty, + ntrim, + ctrim, + fixed_gappos, + ); + if dist <= threshold { + v.push([idx, dist as usize]) + }; + } + v + }) + } else { + seqs1 + .par_iter() + .enumerate() + .zip(seqs2.par_iter()) + .fold( + || Vec::new(), + |mut v, ((idx, &s1), &s2)| { + let s1_bytes: &[u8] = s1.as_bytes(); + let s2_bytes: &[u8] = s2.as_bytes(); + let s1_len: usize = s1_bytes.len(); + let s2_len: usize = s2_bytes.len(); + let len_diff: u16 = if s1_len > s2_len { + (s1_len - s2_len) as u16 + } else { + (s2_len - s1_len) as u16 + }; + + if len_diff * gap_penalty <= threshold { + let dist: u16 = tcrdist( + s1_bytes, + s2_bytes, + dist_weight, + gap_penalty, + ntrim, + ctrim, + fixed_gappos, + ); + if dist <= threshold { + v.push([idx, dist as usize]) + }; + } + v + }, + ) + .reduce( + || Vec::new(), + |mut combined, v| { + combined.extend(v); + combined + }, + ) + } +} + +pub fn tcrdist_neighbor_one_to_many( + seq: &str, + seqs: &[&str], + threshold: u16, + dist_weight: u16, + gap_penalty: u16, + ntrim: usize, + ctrim: usize, + fixed_gappos: bool, + parallel: bool, +) -> Vec<[usize; 2]> { + let seq_bytes: &[u8] = seq.as_bytes(); + let seq_len: usize = seq_bytes.len(); + + if parallel == false { + seqs.iter() + .enumerate() + .fold(Vec::new(), |mut v, (idx, &s)| { + let s_bytes: &[u8] = s.as_bytes(); + let s_len: usize = s_bytes.len(); + let len_diff: u16 = if seq_len > s_len { + (seq_len - s_len) as u16 + } else { + (s_len - seq_len) as u16 + }; + + if len_diff * gap_penalty <= threshold { + let dist: u16 = tcrdist( + seq_bytes, + s_bytes, + dist_weight, + gap_penalty, + ntrim, + ctrim, + fixed_gappos, + ); + if dist <= threshold { + v.push([idx, dist as usize]) + }; + } + v + }) + } else { + seqs.par_iter() + .enumerate() + .fold( + || Vec::new(), + |mut v, (idx, &s)| { + let s_bytes: &[u8] = s.as_bytes(); + let s_len: usize = s_bytes.len(); + let len_diff: u16 = if seq_len > s_len { + (seq_len - s_len) as u16 + } else { + (s_len - seq_len) as u16 + }; + + if len_diff * gap_penalty <= threshold { + let dist: u16 = tcrdist( + seq_bytes, + s_bytes, + dist_weight, + gap_penalty, + ntrim, + ctrim, + fixed_gappos, + ); + if dist <= threshold { + v.push([idx, dist as usize]) + }; + } + v + }, + ) + .reduce( + || Vec::new(), + |mut combined, v| { + combined.extend(v); + combined + }, + ) + } +} + +pub fn tcrdist_neighbor_many_to_many( + seqs1: &[&str], + seqs2: &[&str], + threshold: u16, + dist_weight: u16, + gap_penalty: u16, + ntrim: usize, + ctrim: usize, + fixed_gappos: bool, + parallel: bool, +) -> Vec<[usize; 3]> { + if parallel == false { + seqs1 + .iter() + .enumerate() + .flat_map(|(idx, &s1)| { + seqs2 + .iter() + .enumerate() + .fold(Vec::new(), |mut v, (jdx, &s2)| { + let s1_bytes: &[u8] = s1.as_bytes(); + let s2_bytes: &[u8] = s2.as_bytes(); + let s1_len: usize = s1_bytes.len(); + let s2_len: usize = s2_bytes.len(); + let len_diff: u16 = if s1_len > s2_len { + (s1_len - s2_len) as u16 + } else { + (s2_len - s1_len) as u16 + }; + + if len_diff * gap_penalty <= threshold { + let dist: u16 = tcrdist( + s1_bytes, + s2_bytes, + dist_weight, + gap_penalty, + ntrim, + ctrim, + fixed_gappos, + ); + if dist <= threshold { + v.push([idx, jdx, dist as usize]) + }; + } + v + }) + }) + .collect::>() + } else { + POOL.install(|| { + seqs1 + .par_iter() + .enumerate() + .flat_map(|(idx, &s1)| { + seqs2 + .iter() + .enumerate() + .fold(Vec::new(), |mut v, (jdx, &s2)| { + let s1_bytes: &[u8] = s1.as_bytes(); + let s2_bytes: &[u8] = s2.as_bytes(); + let s1_len: usize = s1_bytes.len(); + let s2_len: usize = s2_bytes.len(); + let len_diff: u16 = if s1_len > s2_len { + (s1_len - s2_len) as u16 + } else { + (s2_len - s1_len) as u16 + }; + + if len_diff * gap_penalty <= threshold { + let dist: u16 = tcrdist( + s1_bytes, + s2_bytes, + dist_weight, + gap_penalty, + ntrim, + ctrim, + fixed_gappos, + ); + if dist <= threshold { + v.push([idx, jdx, dist as usize]) + }; + } + v + }) + }) + .collect::>() + }) + } +} + /// Compute the distance between V alleles which are written as byte strings. /// /// This function is memoized to speed up V alleles distance computations further. @@ -676,11 +1025,11 @@ pub fn tcrdist_allele_pairwise( /// ``` pub fn tcrdist_gene(s1: [&str; 2], s2: [&str; 2], ntrim: usize, ctrim: usize) -> u16 { total_distance(s1[1].as_bytes(), s2[1].as_bytes()) - + 3 * tcrdist( + + tcrdist( s1[0].as_bytes(), s2[0].as_bytes(), - 1, - 4, + 3, + 12, ntrim, ctrim, false, @@ -839,7 +1188,7 @@ pub fn tcrdist_gene_neighbor( return false; } - (v_gene_dist + 3 * tcrdist(s1_bytes, s2_bytes, 1, 4, ntrim, ctrim, false)) <= threshold + (v_gene_dist + tcrdist(s1_bytes, s2_bytes, 3, 12, ntrim, ctrim, false)) <= threshold } pub fn tcrdist_gene_neighbor_matrix( @@ -871,7 +1220,7 @@ pub fn tcrdist_gene_neighbor_matrix( let v_gene_dist = total_distance(s1[1].as_bytes(), s2[1].as_bytes()); if v_gene_dist + len_diff <= threshold { let dist: u16 = v_gene_dist - + 3 * tcrdist(s1_bytes, s2_bytes, 1, 4, ntrim, ctrim, false); + + tcrdist(s1_bytes, s2_bytes, 3, 12, ntrim, ctrim, false); if dist <= threshold { v.push([idx, jdx + 1 + idx, dist as usize]) }; @@ -905,9 +1254,7 @@ pub fn tcrdist_gene_neighbor_matrix( total_distance(s1[1].as_bytes(), s2[1].as_bytes()); if v_gene_dist + len_diff <= threshold { let dist: u16 = v_gene_dist - + 3 * tcrdist( - s1_bytes, s2_bytes, 1, 4, ntrim, ctrim, false, - ); + + tcrdist(s1_bytes, s2_bytes, 3, 12, ntrim, ctrim, false); if dist <= threshold { v.push([idx, jdx + 1 + idx, dist as usize]) }; @@ -948,8 +1295,8 @@ pub fn tcrdist_gene_neighbor_pairwise( if len_diff * 12 <= threshold { let v_gene_dist = total_distance(s1[1].as_bytes(), s2[1].as_bytes()); if v_gene_dist + len_diff <= threshold { - let dist: u16 = v_gene_dist - + 3 * tcrdist(s1_bytes, s2_bytes, 1, 4, ntrim, ctrim, false); + let dist: u16 = + v_gene_dist + tcrdist(s1_bytes, s2_bytes, 3, 12, ntrim, ctrim, false); if dist <= threshold { v.push([idx, dist as usize]) }; @@ -979,7 +1326,7 @@ pub fn tcrdist_gene_neighbor_pairwise( let v_gene_dist = total_distance(s1[1].as_bytes(), s2[1].as_bytes()); if v_gene_dist + len_diff <= threshold { let dist: u16 = v_gene_dist - + 3 * tcrdist(s1_bytes, s2_bytes, 1, 4, ntrim, ctrim, false); + + tcrdist(s1_bytes, s2_bytes, 3, 12, ntrim, ctrim, false); if dist <= threshold { v.push([idx, dist as usize]) }; @@ -1025,8 +1372,8 @@ pub fn tcrdist_gene_neighbor_one_to_many( if len_diff * 12 <= threshold { let v_gene_dist = total_distance(seq_v, s[1].as_bytes()); if v_gene_dist + len_diff <= threshold { - let dist: u16 = v_gene_dist - + 3 * tcrdist(seq_bytes, s_bytes, 1, 4, ntrim, ctrim, false); + let dist: u16 = + v_gene_dist + tcrdist(seq_bytes, s_bytes, 3, 12, ntrim, ctrim, false); if dist <= threshold { v.push([idx, dist as usize]) }; @@ -1052,7 +1399,7 @@ pub fn tcrdist_gene_neighbor_one_to_many( let v_gene_dist = total_distance(seq_v, s[1].as_bytes()); if v_gene_dist + len_diff <= threshold { let dist: u16 = v_gene_dist - + 3 * tcrdist(seq_bytes, s_bytes, 1, 4, ntrim, ctrim, false); + + tcrdist(seq_bytes, s_bytes, 3, 12, ntrim, ctrim, false); if dist <= threshold { v.push([idx, dist as usize]) }; @@ -1102,7 +1449,7 @@ pub fn tcrdist_gene_neighbor_many_to_many( let v_gene_dist = total_distance(s1[1].as_bytes(), s2[1].as_bytes()); if v_gene_dist + len_diff <= threshold { let dist: u16 = v_gene_dist - + 3 * tcrdist(s1_bytes, s2_bytes, 1, 4, ntrim, ctrim, false); + + tcrdist(s1_bytes, s2_bytes, 3, 12, ntrim, ctrim, false); if dist <= threshold { v.push([idx, jdx, dist as usize]) }; @@ -1137,9 +1484,7 @@ pub fn tcrdist_gene_neighbor_many_to_many( total_distance(s1[1].as_bytes(), s2[1].as_bytes()); if v_gene_dist + len_diff <= threshold { let dist: u16 = v_gene_dist - + 3 * tcrdist( - s1_bytes, s2_bytes, 1, 4, ntrim, ctrim, false, - ); + + tcrdist(s1_bytes, s2_bytes, 3, 12, ntrim, ctrim, false); if dist <= threshold { v.push([idx, jdx, dist as usize]) }; @@ -1156,20 +1501,20 @@ pub fn tcrdist_gene_neighbor_many_to_many( pub fn tcrdist_paired_gene(s1: [&str; 4], s2: [&str; 4], ntrim: usize, ctrim: usize) -> u16 { total_distance(s1[1].as_bytes(), s2[1].as_bytes()) + total_distance(s1[3].as_bytes(), s2[3].as_bytes()) - + 3 * tcrdist( + + tcrdist( s1[0].as_bytes(), s2[0].as_bytes(), - 1, - 4, + 3, + 12, ntrim, ctrim, false, ) - + 3 * tcrdist( + + tcrdist( s1[2].as_bytes(), s2[2].as_bytes(), - 1, - 4, + 3, + 12, ntrim, ctrim, false, @@ -1338,20 +1683,12 @@ pub fn tcrdist_paired_gene_neighbor_matrix( let v_gene_dist = beta_v_gene_dist + alpha_v_gene_dist; if v_gene_dist + total_len_diff <= threshold { let dist: u16 = v_gene_dist - + 3 * tcrdist( - beta1_bytes, - beta2_bytes, - 1, - 4, - ntrim, - ctrim, - false, - ) - + 3 * tcrdist( + + tcrdist(beta1_bytes, beta2_bytes, 3, 12, ntrim, ctrim, false) + + tcrdist( alpha1_bytes, alpha2_bytes, - 1, - 4, + 3, + 12, ntrim, ctrim, false, @@ -1402,20 +1739,20 @@ pub fn tcrdist_paired_gene_neighbor_matrix( let v_gene_dist = beta_v_gene_dist + alpha_v_gene_dist; if v_gene_dist + total_len_diff <= threshold { let dist: u16 = v_gene_dist - + 3 * tcrdist( + + tcrdist( beta1_bytes, beta2_bytes, - 1, - 4, + 3, + 12, ntrim, ctrim, false, ) - + 3 * tcrdist( + + tcrdist( alpha1_bytes, alpha2_bytes, - 1, - 4, + 3, + 12, ntrim, ctrim, false, @@ -1473,8 +1810,8 @@ pub fn tcrdist_paired_gene_neighbor_pairwise( let v_gene_dist = beta_v_gene_dist + alpha_v_gene_dist; if v_gene_dist + total_len_diff <= threshold { let dist: u16 = v_gene_dist - + 3 * tcrdist(beta1_bytes, beta2_bytes, 1, 4, ntrim, ctrim, false) - + 3 * tcrdist(alpha1_bytes, alpha2_bytes, 1, 4, ntrim, ctrim, false); + + tcrdist(beta1_bytes, beta2_bytes, 3, 12, ntrim, ctrim, false) + + tcrdist(alpha1_bytes, alpha2_bytes, 3, 12, ntrim, ctrim, false); if dist <= threshold { v.push([idx, dist as usize]) }; @@ -1516,16 +1853,8 @@ pub fn tcrdist_paired_gene_neighbor_pairwise( let v_gene_dist = beta_v_gene_dist + alpha_v_gene_dist; if v_gene_dist + total_len_diff <= threshold { let dist: u16 = v_gene_dist - + 3 * tcrdist(beta1_bytes, beta2_bytes, 1, 4, ntrim, ctrim, false) - + 3 * tcrdist( - alpha1_bytes, - alpha2_bytes, - 1, - 4, - ntrim, - ctrim, - false, - ); + + tcrdist(beta1_bytes, beta2_bytes, 3, 12, ntrim, ctrim, false) + + tcrdist(alpha1_bytes, alpha2_bytes, 3, 12, ntrim, ctrim, false); if dist <= threshold { v.push([idx, dist as usize]) }; @@ -1585,8 +1914,8 @@ pub fn tcrdist_paired_gene_neighbor_one_to_many( let v_gene_dist = beta_v_gene_dist + alpha_v_gene_dist; if v_gene_dist + total_len_diff <= threshold { let dist: u16 = v_gene_dist - + 3 * tcrdist(beta1_bytes, beta2_bytes, 1, 4, ntrim, ctrim, false) - + 3 * tcrdist(alpha1_bytes, alpha2_bytes, 1, 4, ntrim, ctrim, false); + + tcrdist(beta1_bytes, beta2_bytes, 3, 12, ntrim, ctrim, false) + + tcrdist(alpha1_bytes, alpha2_bytes, 3, 12, ntrim, ctrim, false); if dist <= threshold { v.push([idx, dist as usize]) }; @@ -1622,16 +1951,8 @@ pub fn tcrdist_paired_gene_neighbor_one_to_many( let v_gene_dist = beta_v_gene_dist + alpha_v_gene_dist; if v_gene_dist + total_len_diff <= threshold { let dist: u16 = v_gene_dist - + 3 * tcrdist(beta1_bytes, beta2_bytes, 1, 4, ntrim, ctrim, false) - + 3 * tcrdist( - alpha1_bytes, - alpha2_bytes, - 1, - 4, - ntrim, - ctrim, - false, - ); + + tcrdist(beta1_bytes, beta2_bytes, 3, 12, ntrim, ctrim, false) + + tcrdist(alpha1_bytes, alpha2_bytes, 3, 12, ntrim, ctrim, false); if dist <= threshold { v.push([idx, dist as usize]) }; @@ -1695,20 +2016,12 @@ pub fn tcrdist_paired_gene_neighbor_many_to_many( let v_gene_dist = beta_v_gene_dist + alpha_v_gene_dist; if v_gene_dist + total_len_diff <= threshold { let dist: u16 = v_gene_dist - + 3 * tcrdist( - beta1_bytes, - beta2_bytes, - 1, - 4, - ntrim, - ctrim, - false, - ) - + 3 * tcrdist( + + tcrdist(beta1_bytes, beta2_bytes, 3, 12, ntrim, ctrim, false) + + tcrdist( alpha1_bytes, alpha2_bytes, - 1, - 4, + 3, + 12, ntrim, ctrim, false, @@ -1760,20 +2073,20 @@ pub fn tcrdist_paired_gene_neighbor_many_to_many( let v_gene_dist = beta_v_gene_dist + alpha_v_gene_dist; if v_gene_dist + total_len_diff <= threshold { let dist: u16 = v_gene_dist - + 3 * tcrdist( + + tcrdist( beta1_bytes, beta2_bytes, - 1, - 4, + 3, + 12, ntrim, ctrim, false, ) - + 3 * tcrdist( + + tcrdist( alpha1_bytes, alpha2_bytes, - 1, - 4, + 3, + 12, ntrim, ctrim, false, diff --git a/src/lib.rs b/src/lib.rs index 863af0b..fe496c9 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -67,15 +67,13 @@ fn hamming(s1: &str, s2: &str) -> PyResult { /// seqs : sequence of str /// The strings to be compared. They must all be the same length and have /// an appropriate representation in bytes. -/// parallel: bool, default False +/// parallel : bool, default True /// Bool to specify if computation should be parallelized. /// /// Returns /// ------- /// list of int /// The Hamming distances among the strings. -/// parallel: bool, default False -/// Bool to specify if computation should be parallelized. /// /// Examples /// -------- @@ -83,7 +81,7 @@ fn hamming(s1: &str, s2: &str) -> PyResult { /// >>> assert(hamming_matrix(seqs, parallel=False) == [1, 3, 2]) #[cfg(all(feature = "pyo3"))] #[pyfunction] -#[pyo3(signature = (seqs, parallel=false))] +#[pyo3(signature = (seqs, parallel=true))] fn hamming_matrix(seqs: Vec<&str>, parallel: bool) -> PyResult> { Ok(_distance::str_cmp_matrix(&seqs, parallel, "hamming")) } @@ -99,7 +97,7 @@ fn hamming_matrix(seqs: Vec<&str>, parallel: bool) -> PyResult> { /// The string against which all others will be compared. /// seqs : sequence of str /// The other strings being compared. -/// parallel: bool, default False +/// parallel : bool, default True /// Bool to specify if computation should be parallelized. /// /// Returns @@ -114,7 +112,7 @@ fn hamming_matrix(seqs: Vec<&str>, parallel: bool) -> PyResult> { /// >>> assert(hamming_one_to_many(seq, seqs, parallel=False) == [1, 1, 3]) #[cfg(all(feature = "pyo3"))] #[pyfunction] -#[pyo3(signature = (seq, seqs, parallel=false))] +#[pyo3(signature = (seq, seqs, parallel=true))] fn hamming_one_to_many(seq: &str, seqs: Vec<&str>, parallel: bool) -> PyResult> { Ok(_distance::str_cmp_one_to_many( &seq, &seqs, parallel, "hamming", @@ -132,7 +130,7 @@ fn hamming_one_to_many(seq: &str, seqs: Vec<&str>, parallel: bool) -> PyResult, parallel: bool) -> PyResult>> assert(hamming_many_to_many(seqs1, seqs2, parallel=False) == [1, 1, 3, 0, 1, 3]) #[cfg(all(feature = "pyo3"))] #[pyfunction] -#[pyo3(signature = (seqs1, seqs2, parallel=false))] +#[pyo3(signature = (seqs1, seqs2, parallel=true))] fn hamming_many_to_many(seqs1: Vec<&str>, seqs2: Vec<&str>, parallel: bool) -> PyResult> { Ok(_distance::str_cmp_many_to_many( &seqs1, &seqs2, parallel, "hamming", @@ -167,7 +165,7 @@ fn hamming_many_to_many(seqs1: Vec<&str>, seqs2: Vec<&str>, parallel: bool) -> P /// The first sequence of strings. /// seqs2 : sequence of str /// The other sequence of strings. -/// parallel: bool, default False +/// parallel : bool, default True /// Bool to specify if computation should be parallelized. /// /// Returns @@ -182,7 +180,7 @@ fn hamming_many_to_many(seqs1: Vec<&str>, seqs2: Vec<&str>, parallel: bool) -> P /// >>> assert(hamming_pairwise(seqs1, seqs2, parallel=False) == [1, 1]) #[cfg(all(feature = "pyo3"))] #[pyfunction] -#[pyo3(signature = (seqs1, seqs2, parallel=false))] +#[pyo3(signature = (seqs1, seqs2, parallel=true))] fn hamming_pairwise(seqs1: Vec<&str>, seqs2: Vec<&str>, parallel: bool) -> PyResult> { Ok(_distance::str_cmp_pairwise( &seqs1, &seqs2, parallel, "hamming", @@ -203,7 +201,7 @@ fn hamming_pairwise(seqs1: Vec<&str>, seqs2: Vec<&str>, parallel: bool) -> PyRes /// an appropriate representation in bytes. /// threshold : int /// The largest Hamming distance used to consider a pair of strings neighbors. -/// parallel: bool, default False +/// parallel : bool, default True /// Bool to specify if computation should be parallelized. /// /// Returns @@ -218,7 +216,7 @@ fn hamming_pairwise(seqs1: Vec<&str>, seqs2: Vec<&str>, parallel: bool) -> PyRes /// >>> assert(hamming_neighbor_matrix(seqs, 1, parallel=False) == [[0, 1, 1], [0, 3, 1], [1, 3, 1]]) #[cfg(all(feature = "pyo3"))] #[pyfunction] -#[pyo3(signature = (seqs, threshold, parallel=false))] +#[pyo3(signature = (seqs, threshold, parallel=true))] fn hamming_neighbor_matrix( seqs: Vec<&str>, threshold: u32, @@ -242,7 +240,7 @@ fn hamming_neighbor_matrix( /// The other strings being compared. /// threshold : int /// The largest Hamming distance used to consider a pair of strings neighbors. -/// parallel: bool, default False +/// parallel : bool, default True /// Bool to specify if computation should be parallelized. /// /// Returns @@ -258,7 +256,7 @@ fn hamming_neighbor_matrix( /// >>> assert(hamming_neighbor_one_to_many(seq, seqs, 1, parallel=False) == [[0, 1], [2, 0]]) #[cfg(all(feature = "pyo3"))] #[pyfunction] -#[pyo3(signature = (seq, seqs, threshold, parallel=false))] +#[pyo3(signature = (seq, seqs, threshold, parallel=true))] fn hamming_neighbor_one_to_many( seq: &str, seqs: Vec<&str>, @@ -285,7 +283,7 @@ fn hamming_neighbor_one_to_many( /// The other sequence of strings. /// threshold : int /// The largest Hamming distance used to consider a pair of strings neighbors. -/// parallel: bool, default False +/// parallel : bool, default True /// Bool to specify if computation should be parallelized. /// /// Returns @@ -301,7 +299,7 @@ fn hamming_neighbor_one_to_many( /// >>> assert(hamming_neighbor_many_to_many(seqs1, seqs2, 1, parallel=False) == [[0, 0, 1], [2, 1, 1], [4, 0, 1]]) #[cfg(all(feature = "pyo3"))] #[pyfunction] -#[pyo3(signature = (seqs1, seqs2, threshold, parallel=false))] +#[pyo3(signature = (seqs1, seqs2, threshold, parallel=true))] fn hamming_neighbor_many_to_many( seqs1: Vec<&str>, seqs2: Vec<&str>, @@ -331,7 +329,7 @@ fn hamming_neighbor_many_to_many( /// The other sequence of strings. /// threshold : int /// The largest Hamming distance used to consider a pair of strings neighbors. -/// parallel: bool, default False +/// parallel : bool, default True /// Bool to specify if computation should be parallelized. /// /// Returns @@ -348,7 +346,7 @@ fn hamming_neighbor_many_to_many( /// >>> assert(hamming_neighbor_pairwise(seqs1, seqs2, 1, parallel=False) == [[0, 1]]) #[cfg(all(feature = "pyo3"))] #[pyfunction] -#[pyo3(signature = (seqs1, seqs2, threshold, parallel=false))] +#[pyo3(signature = (seqs1, seqs2, threshold, parallel=true))] fn hamming_neighbor_pairwise( seqs1: Vec<&str>, seqs2: Vec<&str>, @@ -374,7 +372,7 @@ fn hamming_neighbor_pairwise( /// The first sequence of strings. /// seqs2 : sequence of str /// The other sequence of strings. -/// parallel: bool, default False +/// parallel : bool, default True /// Bool to specify if computation should be parallelized. /// /// Returns @@ -390,7 +388,7 @@ fn hamming_neighbor_pairwise( /// >>> assert out == [2, 0, 2, 16] #[cfg(all(feature = "pyo3"))] #[pyfunction] -#[pyo3(signature = (seqs1, seqs2, parallel=false))] +#[pyo3(signature = (seqs1, seqs2, parallel=true))] fn hamming_bin_many_to_many( seqs1: Vec<&str>, seqs2: Vec<&str>, @@ -437,7 +435,7 @@ fn levenshtein(s1: &str, s2: &str) -> PyResult { /// seqs : sequence str /// The strings to be compared. The must have an appropriate representation /// as byte strings. -/// parallel: bool, default False +/// parallel : bool, default True /// Bool to specify if computation should be parallelized. /// /// Returns @@ -451,7 +449,7 @@ fn levenshtein(s1: &str, s2: &str) -> PyResult { /// >>> assert(levenshtein_matrix(seqs, parallel=False) == [4, 5, 5, 4, 2, 5]) #[cfg(all(feature = "pyo3"))] #[pyfunction] -#[pyo3(signature = (seqs, parallel=false))] +#[pyo3(signature = (seqs, parallel=true))] fn levenshtein_matrix(seqs: Vec<&str>, parallel: bool) -> PyResult> { Ok(_distance::str_cmp_matrix(&seqs, parallel, "levenshtein")) } @@ -467,7 +465,7 @@ fn levenshtein_matrix(seqs: Vec<&str>, parallel: bool) -> PyResult> { /// The string against which all others will be compared. /// seqs : sequence of str /// The other strings being compared. -/// parallel: bool, default False +/// parallel : bool, default True /// Bool to specify if computation should be parallelized. /// /// Returns @@ -482,7 +480,7 @@ fn levenshtein_matrix(seqs: Vec<&str>, parallel: bool) -> PyResult> { /// >>> assert(levenshtein_one_to_many(seq, seqs, parallel=False) == [2, 3, 5, 4]) #[cfg(all(feature = "pyo3"))] #[pyfunction] -#[pyo3(signature = (seq, seqs, parallel=false))] +#[pyo3(signature = (seq, seqs, parallel=true))] fn levenshtein_one_to_many(seq: &str, seqs: Vec<&str>, parallel: bool) -> PyResult> { Ok(_distance::str_cmp_one_to_many( &seq, @@ -502,7 +500,7 @@ fn levenshtein_one_to_many(seq: &str, seqs: Vec<&str>, parallel: bool) -> PyResu /// The first sequence of strings. /// seqs : sequence of str /// The second sequence of strings. -/// parallel: bool, default False +/// parallel : bool, default True /// Bool to specify if computation should be parallelized. /// /// Returns @@ -517,7 +515,7 @@ fn levenshtein_one_to_many(seq: &str, seqs: Vec<&str>, parallel: bool) -> PyResu /// >>> assert(levenshtein_many_to_many(seqs1, seqs2, parallel=False) == [2, 3, 5, 5, 5, 6]) #[cfg(all(feature = "pyo3"))] #[pyfunction] -#[pyo3(signature = (seqs1, seqs2, parallel=false))] +#[pyo3(signature = (seqs1, seqs2, parallel=true))] fn levenshtein_many_to_many( seqs1: Vec<&str>, seqs2: Vec<&str>, @@ -533,7 +531,7 @@ fn levenshtein_many_to_many( #[cfg(all(feature = "pyo3"))] #[pyfunction] -#[pyo3(signature = (seqs1, seqs2, parallel=false))] +#[pyo3(signature = (seqs1, seqs2, parallel=true))] fn levenshtein_pairwise(seqs1: Vec<&str>, seqs2: Vec<&str>, parallel: bool) -> PyResult> { Ok(_distance::str_cmp_pairwise( &seqs1, @@ -544,7 +542,7 @@ fn levenshtein_pairwise(seqs1: Vec<&str>, seqs2: Vec<&str>, parallel: bool) -> P } #[cfg(all(feature = "pyo3"))] #[pyfunction] -#[pyo3(signature = (seqs, threshold, parallel=false))] +#[pyo3(signature = (seqs, threshold, parallel=true))] fn levenshtein_neighbor_matrix( seqs: Vec<&str>, threshold: u32, @@ -559,7 +557,7 @@ fn levenshtein_neighbor_matrix( } #[cfg(all(feature = "pyo3"))] #[pyfunction] -#[pyo3(signature = (seq, seqs, threshold, parallel=false))] +#[pyo3(signature = (seq, seqs, threshold, parallel=true))] fn levenshtein_neighbor_one_to_many( seq: &str, seqs: Vec<&str>, @@ -576,7 +574,7 @@ fn levenshtein_neighbor_one_to_many( } #[cfg(all(feature = "pyo3"))] #[pyfunction] -#[pyo3(signature = (seqs1, seqs2, threshold, parallel=false))] +#[pyo3(signature = (seqs1, seqs2, threshold, parallel=true))] fn levenshtein_neighbor_many_to_many( seqs1: Vec<&str>, seqs2: Vec<&str>, @@ -594,7 +592,7 @@ fn levenshtein_neighbor_many_to_many( #[cfg(all(feature = "pyo3"))] #[pyfunction] -#[pyo3(signature = (seqs1, seqs2, threshold, parallel=false))] +#[pyo3(signature = (seqs1, seqs2, threshold, parallel=true))] fn levenshtein_neighbor_pairwise( seqs1: Vec<&str>, seqs2: Vec<&str>, @@ -612,7 +610,7 @@ fn levenshtein_neighbor_pairwise( #[cfg(all(feature = "pyo3"))] #[pyfunction] -#[pyo3(signature = (seqs1, seqs2, parallel=false))] +#[pyo3(signature = (seqs1, seqs2, parallel=true))] fn levenshtein_bin_many_to_many( seqs1: Vec<&str>, seqs2: Vec<&str>, @@ -669,7 +667,7 @@ fn levenshtein_exp(s1: &str, s2: &str) -> PyResult { /// seqs : sequence str /// The strings to be compared. The must have an appropriate representation /// as byte strings. -/// parallel: bool, default False +/// parallel : bool, default True /// Bool to specify if computation should be parallelized. /// /// Returns @@ -683,7 +681,7 @@ fn levenshtein_exp(s1: &str, s2: &str) -> PyResult { /// >>> assert(levenshtein_exp_matrix(seqs, parallel=False) == [4, 5, 5, 4, 2, 5]) #[cfg(all(feature = "pyo3"))] #[pyfunction] -#[pyo3(signature = (seqs, parallel=false))] +#[pyo3(signature = (seqs, parallel=true))] fn levenshtein_exp_matrix(seqs: Vec<&str>, parallel: bool) -> PyResult> { Ok(_distance::str_cmp_matrix( &seqs, @@ -705,7 +703,7 @@ fn levenshtein_exp_matrix(seqs: Vec<&str>, parallel: bool) -> PyResult> /// The string against which all others will be compared. /// seqs : sequence of str /// The other strings being compared. -/// parallel: bool, default False +/// parallel : bool, default True /// Bool to specify if computation should be parallelized. /// /// Returns @@ -720,7 +718,7 @@ fn levenshtein_exp_matrix(seqs: Vec<&str>, parallel: bool) -> PyResult> /// >>> assert(levenshtein_one_to_many(seq, seqs, parallel=False) == [2, 3, 5, 4]) #[cfg(all(feature = "pyo3"))] #[pyfunction] -#[pyo3(signature = (seq, seqs, parallel=false))] +#[pyo3(signature = (seq, seqs, parallel=true))] fn levenshtein_exp_one_to_many(seq: &str, seqs: Vec<&str>, parallel: bool) -> PyResult> { Ok(_distance::str_cmp_one_to_many( &seq, @@ -742,7 +740,7 @@ fn levenshtein_exp_one_to_many(seq: &str, seqs: Vec<&str>, parallel: bool) -> Py /// The first sequence of strings. /// seqs : sequence of str /// The second sequence of strings. -/// parallel: bool, default False +/// parallel : bool, default True /// Bool to specify if computation should be parallelized. /// /// Returns @@ -757,7 +755,7 @@ fn levenshtein_exp_one_to_many(seq: &str, seqs: Vec<&str>, parallel: bool) -> Py /// >>> assert(levenshtein_many_to_many(seqs1, seqs2, parallel=False) == [2, 3, 5, 5, 5, 6]) #[cfg(all(feature = "pyo3"))] #[pyfunction] -#[pyo3(signature = (seqs1, seqs2, parallel=false))] +#[pyo3(signature = (seqs1, seqs2, parallel=true))] fn levenshtein_exp_many_to_many( seqs1: Vec<&str>, seqs2: Vec<&str>, @@ -773,7 +771,7 @@ fn levenshtein_exp_many_to_many( #[cfg(all(feature = "pyo3"))] #[pyfunction] -#[pyo3(signature = (seqs1, seqs2, parallel=false))] +#[pyo3(signature = (seqs1, seqs2, parallel=true))] fn levenshtein_exp_pairwise( seqs1: Vec<&str>, seqs2: Vec<&str>, @@ -788,7 +786,7 @@ fn levenshtein_exp_pairwise( } #[cfg(all(feature = "pyo3"))] #[pyfunction] -#[pyo3(signature = (seqs, threshold, parallel=false))] +#[pyo3(signature = (seqs, threshold, parallel=true))] fn levenshtein_exp_neighbor_matrix( seqs: Vec<&str>, threshold: u32, @@ -803,7 +801,7 @@ fn levenshtein_exp_neighbor_matrix( } #[cfg(all(feature = "pyo3"))] #[pyfunction] -#[pyo3(signature = (seq, seqs, threshold, parallel=false))] +#[pyo3(signature = (seq, seqs, threshold, parallel=true))] fn levenshtein_exp_neighbor_one_to_many( seq: &str, seqs: Vec<&str>, @@ -820,7 +818,7 @@ fn levenshtein_exp_neighbor_one_to_many( } #[cfg(all(feature = "pyo3"))] #[pyfunction] -#[pyo3(signature = (seqs1, seqs2, threshold, parallel=false))] +#[pyo3(signature = (seqs1, seqs2, threshold, parallel=true))] fn levenshtein_exp_neighbor_many_to_many( seqs1: Vec<&str>, seqs2: Vec<&str>, @@ -838,7 +836,7 @@ fn levenshtein_exp_neighbor_many_to_many( #[cfg(all(feature = "pyo3"))] #[pyfunction] -#[pyo3(signature = (seqs1, seqs2, threshold, parallel=false))] +#[pyo3(signature = (seqs1, seqs2, threshold, parallel=true))] fn levenshtein_exp_neighbor_pairwise( seqs1: Vec<&str>, seqs2: Vec<&str>, @@ -856,7 +854,7 @@ fn levenshtein_exp_neighbor_pairwise( #[cfg(all(feature = "pyo3"))] #[pyfunction] -#[pyo3(signature = (seqs1, seqs2, parallel=false))] +#[pyo3(signature = (seqs1, seqs2, parallel=true))] fn levenshtein_exp_bin_many_to_many( seqs1: Vec<&str>, seqs2: Vec<&str>, @@ -1026,10 +1024,10 @@ fn cdr2_distance(s1: &str, s2: &str) -> PyResult { /// A string. Ideally, this should be a string of amino acid residues. /// s2 : str /// A string. Ideally, this should be a string of amino acid residues. -/// dist_weight : int, default 1 +/// dist_weight : int, default 3 /// A weight applied to the mismatch distances. This weight is not applied /// to the gap penalties. -/// gap_penalty : int, default 4 +/// gap_penalty : int, default 12 /// The penalty given to the difference in length of the strings. /// ntrim : int, default 3 /// The position at which the distance calculation will begin. @@ -1060,7 +1058,7 @@ fn cdr2_distance(s1: &str, s2: &str) -> PyResult { /// >>> assert(dist == 40) #[cfg(all(feature = "pyo3"))] #[pyfunction] -#[pyo3(signature = (s1, s2, dist_weight=1, gap_penalty=4, ntrim=3, ctrim=2, fixed_gappos=false))] +#[pyo3(signature = (s1, s2, dist_weight=3, gap_penalty=12, ntrim=3, ctrim=2, fixed_gappos=false))] fn tcrdist( s1: &str, s2: &str, @@ -1089,10 +1087,10 @@ fn tcrdist( /// ---------- /// seqs : sequence of str /// Iterable of strings. -/// dist_weight : int, default 1 +/// dist_weight : int, default 3 /// A weight applied to the mismatch distances. This weight is not applied /// to the gap penalties. -/// gap_penalty : int, default 4 +/// gap_penalty : int, default 12 /// The penalty given to the difference in length of the strings. /// ntrim : int, default 3 /// The position at which the distance calculation will begin. @@ -1104,7 +1102,7 @@ fn tcrdist( /// If True, insert gaps at a fixed position after the cysteine residue /// starting the CDR3 (typically position 6). If False, find the "optimal" /// position for inserting the gaps to make up the difference in length. -/// parallel: bool, default False +/// parallel : bool, default True /// Bool to specify if computation should be parallelized. /// /// Returns @@ -1125,7 +1123,7 @@ fn tcrdist( /// >>> assert(dist == [40, 28, 28, 40, 40, 19]) #[cfg(all(feature = "pyo3"))] #[pyfunction] -#[pyo3(signature = (seqs, dist_weight=1, gap_penalty=4, ntrim=3, ctrim=2, fixed_gappos=false, parallel=false))] +#[pyo3(signature = (seqs, dist_weight=3, gap_penalty=12, ntrim=3, ctrim=2, fixed_gappos=false, parallel=true))] fn tcrdist_matrix( seqs: Vec<&str>, dist_weight: u16, @@ -1157,10 +1155,10 @@ fn tcrdist_matrix( /// The string against which all others will be compared. /// seqs : str /// The other strings being compared. -/// dist_weight : int, default 1 +/// dist_weight : int, default 3 /// A weight applied to the mismatch distances. This weight is not applied /// to the gap penalties. -/// gap_penalty : int, default 4 +/// gap_penalty : int, default 12 /// The penalty given to the difference in length of the strings. /// ntrim : int, default 3 /// The position at which the distance calculation will begin. @@ -1172,7 +1170,7 @@ fn tcrdist_matrix( /// If True, insert gaps at a fixed position after the cysteine residue /// starting the CDR3 (typically position 6). If False, find the "optimal" /// position for inserting the gaps to make up the difference in length. -/// parallel: bool, default False +/// parallel : bool, default True /// Bool to specify if computation should be parallelized. /// /// Returns @@ -1194,7 +1192,7 @@ fn tcrdist_matrix( /// >>> assert(dist == [52, 41, 52, 48]) #[cfg(all(feature = "pyo3"))] #[pyfunction] -#[pyo3(signature = (seq, seqs, dist_weight=1, gap_penalty=4, ntrim=3, ctrim=2, fixed_gappos=false, parallel=false))] +#[pyo3(signature = (seq, seqs, dist_weight=3, gap_penalty=12, ntrim=3, ctrim=2, fixed_gappos=false, parallel=true))] fn tcrdist_one_to_many( seq: &str, seqs: Vec<&str>, @@ -1227,10 +1225,10 @@ fn tcrdist_one_to_many( /// The first sequence of strings. /// seqs2 : sequence of str /// The other sequence of strings. -/// dist_weight : int, default 1 +/// dist_weight : int, default 3 /// A weight applied to the mismatch distances. This weight is not applied /// to the gap penalties. -/// gap_penalty : int, default 4 +/// gap_penalty : int, default 12 /// The penalty given to the difference in length of the strings. /// ntrim : int, default 3 /// The position at which the distance calculation will begin. @@ -1242,7 +1240,7 @@ fn tcrdist_one_to_many( /// If True, insert gaps at a fixed position after the cysteine residue /// starting the CDR3 (typically position 6). If False, find the "optimal" /// position for inserting the gaps to make up the difference in length. -/// parallel: bool, default False +/// parallel : bool, default True /// Bool to specify if computation should be parallelized. /// /// Returns @@ -1263,7 +1261,7 @@ fn tcrdist_one_to_many( /// >>> assert(dist == [52, 41, 52, 48]) #[cfg(all(feature = "pyo3"))] #[pyfunction] -#[pyo3(signature = (seqs1, seqs2, dist_weight=1, gap_penalty=4, ntrim=3, ctrim=2, fixed_gappos=false, parallel=false))] +#[pyo3(signature = (seqs1, seqs2, dist_weight=3, gap_penalty=12, ntrim=3, ctrim=2, fixed_gappos=false, parallel=true))] fn tcrdist_many_to_many( seqs1: Vec<&str>, seqs2: Vec<&str>, @@ -1288,7 +1286,7 @@ fn tcrdist_many_to_many( #[cfg(all(feature = "pyo3"))] #[pyfunction] -#[pyo3(signature = (seqs1, seqs2, dist_weight=1, gap_penalty=4, ntrim=3, ctrim=2, fixed_gappos=false, parallel=false))] +#[pyo3(signature = (seqs1, seqs2, dist_weight=3, gap_penalty=12, ntrim=3, ctrim=2, fixed_gappos=false, parallel=true))] fn tcrdist_pairwise( seqs1: Vec<&str>, seqs2: Vec<&str>, @@ -1310,6 +1308,111 @@ fn tcrdist_pairwise( parallel, )) } + +#[cfg(all(feature = "pyo3"))] +#[pyfunction] +#[pyo3(signature = (seqs, threshold, dist_weight=3, gap_penalty=12, ntrim=3, ctrim=2, fixed_gappos=false, parallel=true))] +fn tcrdist_neighbor_matrix( + seqs: Vec<&str>, + threshold: u16, + dist_weight: u16, + gap_penalty: u16, + ntrim: usize, + ctrim: usize, + fixed_gappos: bool, + parallel: bool, +) -> PyResult> { + Ok(_distance::tcrdist_neighbor_matrix( + &seqs, + threshold, + dist_weight, + gap_penalty, + ntrim, + ctrim, + fixed_gappos, + parallel, + )) +} + +#[cfg(all(feature = "pyo3"))] +#[pyfunction] +#[pyo3(signature = (seqs1, seqs2, threshold, dist_weight=3, gap_penalty=12, ntrim=3, ctrim=2, fixed_gappos=false, parallel=true))] +fn tcrdist_neighbor_pairwise( + seqs1: Vec<&str>, + seqs2: Vec<&str>, + threshold: u16, + dist_weight: u16, + gap_penalty: u16, + ntrim: usize, + ctrim: usize, + fixed_gappos: bool, + parallel: bool, +) -> PyResult> { + Ok(_distance::tcrdist_neighbor_pairwise( + &seqs1, + &seqs2, + threshold, + dist_weight, + gap_penalty, + ntrim, + ctrim, + fixed_gappos, + parallel, + )) +} +#[cfg(all(feature = "pyo3"))] +#[pyfunction] +#[pyo3(signature = (seq, seqs, threshold, dist_weight=3, gap_penalty=12, ntrim=3, ctrim=2, fixed_gappos=false, parallel=true))] +fn tcrdist_neighbor_one_to_many( + seq: &str, + seqs: Vec<&str>, + threshold: u16, + dist_weight: u16, + gap_penalty: u16, + ntrim: usize, + ctrim: usize, + fixed_gappos: bool, + parallel: bool, +) -> PyResult> { + Ok(_distance::tcrdist_neighbor_one_to_many( + &seq, + &seqs, + threshold, + dist_weight, + gap_penalty, + ntrim, + ctrim, + fixed_gappos, + parallel, + )) +} +#[cfg(all(feature = "pyo3"))] +#[pyfunction] +#[pyo3(signature = (seqs1, seqs2, threshold, dist_weight=3, gap_penalty=12, ntrim=3, ctrim=2, fixed_gappos=false, parallel=true))] +fn tcrdist_neighbor_many_to_many( + seqs1: Vec<&str>, + seqs2: Vec<&str>, + threshold: u16, + dist_weight: u16, + gap_penalty: u16, + ntrim: usize, + ctrim: usize, + fixed_gappos: bool, + parallel: bool, +) -> PyResult> { + Ok(_distance::tcrdist_neighbor_many_to_many( + &seqs1, + &seqs2, + threshold, + dist_weight, + gap_penalty, + ntrim, + ctrim, + fixed_gappos, + parallel, + )) +} + /// Compute the tcrdist between two CDR3-V allele pairs. /// /// This incorporates differences between the pMHC, CDR1, CDR2, and CDR3. @@ -1418,7 +1521,7 @@ fn tcrdist_allele( /// If True, insert gaps at a fixed position after the cysteine residue /// starting the CDR3 (typically position 6). If False, find the "optimal" /// position for inserting the gaps to make up the difference in length. -/// parallel: bool, default False +/// parallel : bool, default True /// Bool to specify if computation should be parallelized. /// /// Returns @@ -1441,7 +1544,7 @@ fn tcrdist_allele( /// >>> assert(dist == [168, 142, 134, 203, 163, 169, 148, 116, 189, 198]) #[cfg(all(feature = "pyo3"))] #[pyfunction] -#[pyo3(signature = (seqs, phmc_weight=1, cdr1_weight=1, cdr2_weight=1, cdr3_weight=3, gap_penalty=4, ntrim=3, ctrim=2, fixed_gappos=false, parallel=false))] +#[pyo3(signature = (seqs, phmc_weight=1, cdr1_weight=1, cdr2_weight=1, cdr3_weight=3, gap_penalty=4, ntrim=3, ctrim=2, fixed_gappos=false, parallel=true))] fn tcrdist_allele_matrix( seqs: Vec<[&str; 2]>, phmc_weight: u16, @@ -1498,7 +1601,7 @@ fn tcrdist_allele_matrix( /// If True, insert gaps at a fixed position after the cysteine residue /// starting the CDR3 (typically position 6). If False, find the "optimal" /// position for inserting the gaps to make up the difference in length. -/// parallel: bool, default False +/// parallel : bool, default True /// Bool to specify if computation should be parallelized. /// /// Returns @@ -1522,7 +1625,7 @@ fn tcrdist_allele_matrix( /// >>> assert(dist == [168, 142, 134, 203]) #[cfg(all(feature = "pyo3"))] #[pyfunction] -#[pyo3(signature = (seq, seqs, phmc_weight=1, cdr1_weight=1, cdr2_weight=1, cdr3_weight=3, gap_penalty=4, ntrim=3, ctrim=2, fixed_gappos=false, parallel=false))] +#[pyo3(signature = (seq, seqs, phmc_weight=1, cdr1_weight=1, cdr2_weight=1, cdr3_weight=3, gap_penalty=4, ntrim=3, ctrim=2, fixed_gappos=false, parallel=true))] fn tcrdist_allele_one_to_many( seq: [&str; 2], seqs: Vec<[&str; 2]>, @@ -1581,7 +1684,7 @@ fn tcrdist_allele_one_to_many( /// If True, insert gaps at a fixed position after the cysteine residue /// starting the CDR3 (typically position 6). If False, find the "optimal" /// position for inserting the gaps to make up the difference in length. -/// parallel: bool, default False +/// parallel : bool, default True /// Bool to specify if computation should be parallelized. /// /// Returns @@ -1605,7 +1708,7 @@ fn tcrdist_allele_one_to_many( /// >>> assert(dist == [168, 142, 134, 203, 104, 125, 143, 121]) #[cfg(all(feature = "pyo3"))] #[pyfunction] -#[pyo3(signature = (seqs1, seqs2, phmc_weight=1, cdr1_weight=1, cdr2_weight=1, cdr3_weight=3, gap_penalty=4, ntrim=3, ctrim=2, fixed_gappos=false, parallel=false))] +#[pyo3(signature = (seqs1, seqs2, phmc_weight=1, cdr1_weight=1, cdr2_weight=1, cdr3_weight=3, gap_penalty=4, ntrim=3, ctrim=2, fixed_gappos=false, parallel=true))] fn tcrdist_allele_many_to_many( seqs1: Vec<[&str; 2]>, seqs2: Vec<[&str; 2]>, @@ -1636,7 +1739,7 @@ fn tcrdist_allele_many_to_many( #[cfg(all(feature = "pyo3"))] #[pyfunction] -#[pyo3(signature = (seqs1, seqs2, phmc_weight=1, cdr1_weight=1, cdr2_weight=1, cdr3_weight=3, gap_penalty=4, ntrim=3, ctrim=2, fixed_gappos=false, parallel=false))] +#[pyo3(signature = (seqs1, seqs2, phmc_weight=1, cdr1_weight=1, cdr2_weight=1, cdr3_weight=3, gap_penalty=4, ntrim=3, ctrim=2, fixed_gappos=false, parallel=true))] fn tcrdist_allele_pairwise( seqs1: Vec<[&str; 2]>, seqs2: Vec<[&str; 2]>, @@ -1714,7 +1817,7 @@ fn tcrdist_gene(s1: [&str; 2], s2: [&str; 2], ntrim: usize, ctrim: usize) -> PyR /// ctrim : int, default 2 /// The position, counted from the end, at which the calculation will end. /// This parameter must be >= 0. -/// parallel: bool, default False +/// parallel : bool, default True /// Bool to specify if computation should be parallelized. /// /// Returns @@ -1731,7 +1834,7 @@ fn tcrdist_gene(s1: [&str; 2], s2: [&str; 2], ntrim: usize, ctrim: usize) -> PyR /// >>> assert(dist == [168, 142, 134, 203, 163, 169, 148, 116, 189, 198]) #[cfg(all(feature = "pyo3"))] #[pyfunction] -#[pyo3(signature = (seqs, ntrim=3, ctrim=2, parallel=false))] +#[pyo3(signature = (seqs, ntrim=3, ctrim=2, parallel=true))] fn tcrdist_gene_matrix( seqs: Vec<[&str; 2]>, ntrim: usize, @@ -1757,7 +1860,7 @@ fn tcrdist_gene_matrix( /// ctrim : int, default 2 /// The position, counted from the end, at which the calculation will end. /// This parameter must be >= 0. -/// parallel: bool, default False +/// parallel : bool, default True /// Bool to specify if computation should be parallelized. /// /// Returns @@ -1775,7 +1878,7 @@ fn tcrdist_gene_matrix( /// >>> assert(dist == [168, 142, 134, 203]) #[cfg(all(feature = "pyo3"))] #[pyfunction] -#[pyo3(signature = (seq, seqs, ntrim=3, ctrim=2, parallel=false))] +#[pyo3(signature = (seq, seqs, ntrim=3, ctrim=2, parallel=true))] fn tcrdist_gene_one_to_many( seq: [&str; 2], seqs: Vec<[&str; 2]>, @@ -1802,7 +1905,7 @@ fn tcrdist_gene_one_to_many( /// ctrim : int, default 2 /// The position, counted from the end, at which the calculation will end. /// This parameter must be >= 0. -/// parallel: bool, default False +/// parallel : bool, default True /// Bool to specify if computation should be parallelized. /// /// Returns @@ -1820,7 +1923,7 @@ fn tcrdist_gene_one_to_many( /// >>> assert(dist == [168, 142, 134, 203, 104, 125, 143, 121]) #[cfg(all(feature = "pyo3"))] #[pyfunction] -#[pyo3(signature = (seqs1, seqs2, ntrim=3, ctrim=2, parallel=false))] +#[pyo3(signature = (seqs1, seqs2, ntrim=3, ctrim=2, parallel=true))] fn tcrdist_gene_many_to_many( seqs1: Vec<[&str; 2]>, seqs2: Vec<[&str; 2]>, @@ -1835,7 +1938,7 @@ fn tcrdist_gene_many_to_many( #[cfg(all(feature = "pyo3"))] #[pyfunction] -#[pyo3(signature = (seqs1, seqs2, ntrim=3, ctrim=2, parallel=false))] +#[pyo3(signature = (seqs1, seqs2, ntrim=3, ctrim=2, parallel=true))] fn tcrdist_gene_pairwise( seqs1: Vec<[&str; 2]>, seqs2: Vec<[&str; 2]>, @@ -1901,7 +2004,7 @@ fn tcrdist_gene_neighbor( #[cfg(all(feature = "pyo3"))] #[pyfunction] -#[pyo3(signature = (seqs, threshold, ntrim=3, ctrim=2, parallel=false))] +#[pyo3(signature = (seqs, threshold, ntrim=3, ctrim=2, parallel=true))] fn tcrdist_gene_neighbor_matrix( seqs: Vec<[&str; 2]>, threshold: u16, @@ -1916,7 +2019,7 @@ fn tcrdist_gene_neighbor_matrix( #[cfg(all(feature = "pyo3"))] #[pyfunction] -#[pyo3(signature = (seq, seqs, threshold, ntrim=3, ctrim=2, parallel=false))] +#[pyo3(signature = (seq, seqs, threshold, ntrim=3, ctrim=2, parallel=true))] fn tcrdist_gene_neighbor_one_to_many( seq: [&str; 2], seqs: Vec<[&str; 2]>, @@ -1932,7 +2035,7 @@ fn tcrdist_gene_neighbor_one_to_many( #[cfg(all(feature = "pyo3"))] #[pyfunction] -#[pyo3(signature = (seqs1, seqs2, threshold, ntrim=3, ctrim=2, parallel=false))] +#[pyo3(signature = (seqs1, seqs2, threshold, ntrim=3, ctrim=2, parallel=true))] fn tcrdist_gene_neighbor_many_to_many( seqs1: Vec<[&str; 2]>, seqs2: Vec<[&str; 2]>, @@ -1948,7 +2051,7 @@ fn tcrdist_gene_neighbor_many_to_many( #[cfg(all(feature = "pyo3"))] #[pyfunction] -#[pyo3(signature = (seqs1, seqs2, threshold, ntrim=3, ctrim=2, parallel=false))] +#[pyo3(signature = (seqs1, seqs2, threshold, ntrim=3, ctrim=2, parallel=true))] fn tcrdist_gene_neighbor_pairwise( seqs1: Vec<[&str; 2]>, seqs2: Vec<[&str; 2]>, @@ -1971,7 +2074,7 @@ fn tcrdist_paired_gene(s1: [&str; 4], s2: [&str; 4], ntrim: usize, ctrim: usize) #[cfg(all(feature = "pyo3"))] #[pyfunction] -#[pyo3(signature = (seqs, ntrim=3, ctrim=2, parallel=false))] +#[pyo3(signature = (seqs, ntrim=3, ctrim=2, parallel=true))] fn tcrdist_paired_gene_matrix( seqs: Vec<[&str; 4]>, ntrim: usize, @@ -1985,7 +2088,7 @@ fn tcrdist_paired_gene_matrix( #[cfg(all(feature = "pyo3"))] #[pyfunction] -#[pyo3(signature = (seq, seqs, ntrim=3, ctrim=2, parallel=false))] +#[pyo3(signature = (seq, seqs, ntrim=3, ctrim=2, parallel=true))] fn tcrdist_paired_gene_one_to_many( seq: [&str; 4], seqs: Vec<[&str; 4]>, @@ -2000,7 +2103,7 @@ fn tcrdist_paired_gene_one_to_many( #[cfg(all(feature = "pyo3"))] #[pyfunction] -#[pyo3(signature = (seqs1, seqs2, ntrim=3, ctrim=2, parallel=false))] +#[pyo3(signature = (seqs1, seqs2, ntrim=3, ctrim=2, parallel=true))] fn tcrdist_paired_gene_many_to_many( seqs1: Vec<[&str; 4]>, seqs2: Vec<[&str; 4]>, @@ -2015,7 +2118,7 @@ fn tcrdist_paired_gene_many_to_many( #[cfg(all(feature = "pyo3"))] #[pyfunction] -#[pyo3(signature = (seqs1, seqs2, ntrim=3, ctrim=2, parallel=false))] +#[pyo3(signature = (seqs1, seqs2, ntrim=3, ctrim=2, parallel=true))] fn tcrdist_paired_gene_pairwise( seqs1: Vec<[&str; 4]>, seqs2: Vec<[&str; 4]>, @@ -2030,7 +2133,7 @@ fn tcrdist_paired_gene_pairwise( #[cfg(all(feature = "pyo3"))] #[pyfunction] -#[pyo3(signature = (seqs, threshold, ntrim=3, ctrim=2, parallel=false))] +#[pyo3(signature = (seqs, threshold, ntrim=3, ctrim=2, parallel=true))] fn tcrdist_paired_gene_neighbor_matrix( seqs: Vec<[&str; 4]>, threshold: u16, @@ -2045,7 +2148,7 @@ fn tcrdist_paired_gene_neighbor_matrix( #[cfg(all(feature = "pyo3"))] #[pyfunction] -#[pyo3(signature = (seq, seqs, threshold, ntrim=3, ctrim=2, parallel=false))] +#[pyo3(signature = (seq, seqs, threshold, ntrim=3, ctrim=2, parallel=true))] fn tcrdist_paired_gene_neighbor_one_to_many( seq: [&str; 4], seqs: Vec<[&str; 4]>, @@ -2061,7 +2164,7 @@ fn tcrdist_paired_gene_neighbor_one_to_many( #[cfg(all(feature = "pyo3"))] #[pyfunction] -#[pyo3(signature = (seqs1, seqs2, threshold, ntrim=3, ctrim=2, parallel=false))] +#[pyo3(signature = (seqs1, seqs2, threshold, ntrim=3, ctrim=2, parallel=true))] fn tcrdist_paired_gene_neighbor_many_to_many( seqs1: Vec<[&str; 4]>, seqs2: Vec<[&str; 4]>, @@ -2077,7 +2180,7 @@ fn tcrdist_paired_gene_neighbor_many_to_many( #[cfg(all(feature = "pyo3"))] #[pyfunction] -#[pyo3(signature = (seqs1, seqs2, threshold, ntrim=3, ctrim=2, parallel=false))] +#[pyo3(signature = (seqs1, seqs2, threshold, ntrim=3, ctrim=2, parallel=true))] fn tcrdist_paired_gene_neighbor_pairwise( seqs1: Vec<[&str; 4]>, seqs2: Vec<[&str; 4]>, @@ -2145,6 +2248,11 @@ pub fn tcrdist_rs(_py: Python<'_>, m: &PyModule) -> PyResult<()> { m.add_function(wrap_pyfunction!(tcrdist_many_to_many, m)?)?; m.add_function(wrap_pyfunction!(tcrdist_pairwise, m)?)?; + m.add_function(wrap_pyfunction!(tcrdist_neighbor_matrix, m)?)?; + m.add_function(wrap_pyfunction!(tcrdist_neighbor_one_to_many, m)?)?; + m.add_function(wrap_pyfunction!(tcrdist_neighbor_many_to_many, m)?)?; + m.add_function(wrap_pyfunction!(tcrdist_neighbor_pairwise, m)?)?; + m.add_function(wrap_pyfunction!(tcrdist_allele, m)?)?; m.add_function(wrap_pyfunction!(tcrdist_allele_matrix, m)?)?; m.add_function(wrap_pyfunction!(tcrdist_allele_one_to_many, m)?)?;