Skip to content

Commit

Permalink
Merge pull request #4 from oxfordmmm/fix/snp-after-indel
Browse files Browse the repository at this point in the history
Fix/snp after indel
  • Loading branch information
JeremyWesthead authored Aug 20, 2024
2 parents ce8a7bd + b3617fe commit 1ebaae4
Show file tree
Hide file tree
Showing 6 changed files with 19 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 = "grumpy"
version = "0.1.12"
version = "0.1.13"
edition = "2021"
description = "Genetic analysis in Rust."
license-file = "LICENSE"
Expand Down
2 changes: 2 additions & 0 deletions src/difference.rs
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ pub struct Mutation {
}

#[pyclass]
#[derive(Debug)]
/// Struct to hold the difference between two genomes
pub struct GenomeDifference {
#[pyo3(get, set)]
Expand All @@ -120,6 +121,7 @@ pub struct GenomeDifference {
}

#[pyclass]
#[derive(Debug)]
/// Struct to hold the difference between two genes
pub struct GeneDifference {
#[pyo3(get, set)]
Expand Down
13 changes: 11 additions & 2 deletions src/genome.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6782,8 +6782,17 @@ mod tests {

let diff = GenomeDifference::new(genome.clone(), sample.clone(), MinorType::COV);

for variant in diff.variants.iter() {
assert_eq!(variant.variant, "2406843_del_c".to_string());
// Just check the variants and mutations strings here (that's the part with the possible bugs)
let expected_variants = [
// This first variant lies in 2 genes, so gets 2 variants
"2406843_del_c",
"2406843_del_c",
"3820407a>g",
"3820444_ins_ca",
"3820446g>c",
];
for (idx, variant) in diff.variants.iter().enumerate() {
assert_eq!(variant.variant, expected_variants[idx]);
}
assert_eq!(diff.minor_variants.len(), 0);

Expand Down
2 changes: 1 addition & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ fn main() {
let mut sample = mutate(&reference, vcf);
let sample_end = SystemTime::now();

let target_gene = "Rv2147c";
let target_gene = "Rv0043c";

let genome_start = SystemTime::now();
let mut difference = GenomeDifference::new(reference.clone(), sample.clone(), MinorType::COV);
Expand Down
4 changes: 2 additions & 2 deletions src/vcf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -572,9 +572,9 @@ impl VCFFile {
let a = _x.chars().nth(i - offset).unwrap();
if r != 'N' && a != 'N' && r != a {
if _indel_type == AltType::DEL {
calls.push((i as i64, AltType::SNP, a.to_string()));
calls.push(((i - offset) as i64, AltType::SNP, a.to_string()));
} else {
calls.push((i as i64, AltType::SNP, r.to_string()));
calls.push(((i - offset) as i64, AltType::SNP, r.to_string()));
}
}
}
Expand Down
3 changes: 2 additions & 1 deletion test/revcomp-del-first-pos.vcf
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,5 @@
##FILTER=<ID=MIN_GCP,Description="Minimum GT_CONF_PERCENTILE of 0.5">
##FILTER=<ID=MAX_DP,Description="Maximum DP of 199.9427646539246 (= 3.0 standard deviations from the mean read depth 72.044)">
#CHROM POS ID REF ALT QUAL FILTER INFO FORMAT site.01.iso.1.subject.01-DR0011.lab_id.DR0011.seq_reps.1
NC_000962.3 2406842 . AC A . PASS . GT:DP:ALLELE_DP:FRS:COV_TOTAL:COV:GT_CONF:GT_CONF_PERCENTILE 1/1:94:0,94:1.0:94:0,94:598.3:74.67
NC_000962.3 2406842 . AC A . PASS . GT:DP:ALLELE_DP:FRS:COV_TOTAL:COV:GT_CONF:GT_CONF_PERCENTILE 1/1:94:0,94:1.0:94:0,94:598.3:74.67
NC_000962.3 3820390 . TTTAGCCCGGTGACGATACGGGCCGCGTAGCGGCCCGAGGAGGAGCCGGGCAATCGGC TTTAGCCCGGTGACGATGCGGGCCGCGTAGCGGCCCGAGGAGGAGCCGGGCAATCCAGCC . PASS . GT:DP:ALLELE_DP:FRS:COV_TOTAL:COV:GT_CONF:GT_CONF_PERCENTILE 1/1:35.8667:0.7931,35.8667:1.0:54:0,27:214.15:19.64

0 comments on commit 1ebaae4

Please sign in to comment.