Skip to content

Commit

Permalink
Neighbor matrix functions return all neighbor idxs
Browse files Browse the repository at this point in the history
  • Loading branch information
zacmon committed Dec 17, 2024
1 parent e0a4578 commit 9f47a00
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 7 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "tcrdist_rs"
version = "0.1.11"
version = "0.1.12"
edition = "2021"
license = "MIT"
description = "Rust tcrdist routines, including SMID-accelerated edit distances from triple_accel."
Expand Down
20 changes: 14 additions & 6 deletions src/distance.rs
Original file line number Diff line number Diff line change
Expand Up @@ -366,7 +366,8 @@ pub fn tcrdist_neighbor_matrix(
fixed_gappos,
);
if dist <= threshold {
v.push([idx, jdx + 1 + idx, dist as usize])
v.push([idx, jdx + 1 + idx, dist as usize]);
v.push([jdx + 1 + idx, idx, dist as usize]);
};
}
v
Expand Down Expand Up @@ -403,7 +404,8 @@ pub fn tcrdist_neighbor_matrix(
fixed_gappos,
);
if dist <= threshold {
v.push([idx, jdx + 1 + idx, dist as usize])
v.push([idx, jdx + 1 + idx, dist as usize]);
v.push([jdx + 1 + idx, idx, dist as usize]);
};
}
v
Expand Down Expand Up @@ -1222,7 +1224,8 @@ pub fn tcrdist_gene_neighbor_matrix(
let dist: u16 = v_gene_dist
+ tcrdist(s1_bytes, s2_bytes, 3, 12, ntrim, ctrim, false);
if dist <= threshold {
v.push([idx, jdx + 1 + idx, dist as usize])
v.push([idx, jdx + 1 + idx, dist as usize]);
v.push([jdx + 1 + idx, idx, dist as usize]);
};
}
}
Expand Down Expand Up @@ -1256,7 +1259,8 @@ pub fn tcrdist_gene_neighbor_matrix(
let dist: u16 = v_gene_dist
+ tcrdist(s1_bytes, s2_bytes, 3, 12, ntrim, ctrim, false);
if dist <= threshold {
v.push([idx, jdx + 1 + idx, dist as usize])
v.push([idx, jdx + 1 + idx, dist as usize]);
v.push([jdx + 1 + idx, idx, dist as usize]);
};
}
}
Expand Down Expand Up @@ -1694,7 +1698,8 @@ pub fn tcrdist_paired_gene_neighbor_matrix(
false,
);
if dist <= threshold {
v.push([idx, jdx + 1 + idx, dist as usize])
v.push([idx, jdx + 1 + idx, dist as usize]);
v.push([jdx + 1 + idx, idx, dist as usize]);
};
}
}
Expand Down Expand Up @@ -1758,7 +1763,8 @@ pub fn tcrdist_paired_gene_neighbor_matrix(
false,
);
if dist <= threshold {
v.push([idx, jdx + 1 + idx, dist as usize])
v.push([idx, jdx + 1 + idx, dist as usize]);
v.push([jdx + 1 + idx, idx, dist as usize]);
};
}
}
Expand Down Expand Up @@ -2236,6 +2242,7 @@ pub fn str_neighbor_matrix(
let dist: u32 = metric_fn(s1.as_bytes(), s2.as_bytes());
if dist <= threshold {
v.push([idx, idx + 1 + jdx, dist as usize]);
v.push([idx + 1 + jdx, idx, dist as usize]);
}
v
})
Expand All @@ -2253,6 +2260,7 @@ pub fn str_neighbor_matrix(
let dist: u32 = metric_fn(s1.as_bytes(), s2.as_bytes());
if dist <= threshold {
v.push([idx, idx + 1 + jdx, dist as usize]);
v.push([idx + 1 + jdx, idx, dist as usize]);
}
v
})
Expand Down

0 comments on commit 9f47a00

Please sign in to comment.