Skip to content
This repository was archived by the owner on May 22, 2026. It is now read-only.

Commit f9d94f0

Browse files
committed
Added adjustment method.
Added test case. Fixed subCnt to Maybe (issue with hicnt for Insertions found on that case).
1 parent 0b18acd commit f9d94f0

6 files changed

Lines changed: 47 additions & 3 deletions

File tree

src/main/java/com/astrazeneca/vardict/modules/SAMFileParser.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -648,10 +648,12 @@ && isHasAndEquals(querySequence.charAt(n), ref, start)
648648
// subCnt(getVariation(hash, inspos, ref.get(inspos).toString()), dir, tp, tmpq,
649649
// Qmean, nm, conf);
650650
if (inspos > position) {
651-
Variation tv = getVariation(hash, inspos, String.valueOf(querySequence.charAt(n - 1 - (start - 1 - inspos))));
651+
Variation tv = getVariationMaybe(hash, inspos, querySequence.charAt(n - 1 - (start - 1 - inspos)));
652652
//Substract count.
653-
subCnt(tv, dir, tp, queryQuality.charAt(n - 1 - (start -1 - inspos)) - 33,
654-
mappingQuality, nm - nmoff, conf.goodq);
653+
if (tv != null) {
654+
subCnt(tv, dir, tp, queryQuality.charAt(n - 1 - (start - 1 - inspos)) - 33,
655+
mappingQuality, nm - nmoff, conf.goodq);
656+
}
655657
}
656658
// #}
657659
// Adjust count if the insertion is at the edge so that the AF won't > 1

src/main/java/com/astrazeneca/vardict/modules/ToVarsBuilder.java

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -629,6 +629,9 @@ else if (dellen < conf.SVMINLEN) {
629629
} else {
630630
vref.bias = "0;" + vref.bias;
631631
}
632+
633+
adjustVariantCounts(p, vref);
634+
632635
if (conf.debug) {
633636
StringBuilder sb = new StringBuilder();
634637
for (String str : tmp) {
@@ -688,6 +691,33 @@ else if (dellen < conf.SVMINLEN) {
688691
return tuple(Rlen, vars);
689692
}
690693

694+
/**
695+
* Adjust variant negative counts of fields FWD, REV, RFC, RRC to zeros and print the information message to console
696+
* @param p start position of variant
697+
* @param vref variant to adjust
698+
*/
699+
private static void adjustVariantCounts(int p, Variant vref) {
700+
String message = "column in variant on position: " + p + " " + vref.refallele + "->" +
701+
vref.varallele + " was negative, adjusted to zero.";
702+
703+
if (vref.rfc < 0 ) {
704+
vref.rfc = 0;
705+
System.err.println("Reference forward count " + message);
706+
}
707+
if (vref.rrc < 0) {
708+
vref.rrc = 0;
709+
System.err.println("Reference reverse count " + message);
710+
}
711+
if (vref.fwd < 0) {
712+
vref.fwd = 0;
713+
System.err.println("Variant forward count " + message);
714+
}
715+
if (vref.rev < 0 ) {
716+
vref.rev = 0;
717+
System.err.println("Variant reverse count " + message);
718+
}
719+
}
720+
691721
private static int calcHicov(VariationMap<String, Variation> iv,
692722
VariationMap<String, Variation> v) {
693723
int hicov = 0;
Binary file not shown.
Binary file not shown.

testdata/fastas/hg38.fa.csv

Lines changed: 1 addition & 0 deletions
Large diffs are not rendered by default.
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
Simple,hg38.fa,NAP1L1.NegativeRRC.bam,chr12,76036587,76085033,-f 0.1
2+
NAP1L1.NegativeRRC testbed chr12 76047375 76047375 T TA 86 43 18 24 19 24 T/+1 0.5000 2;2 41.1 1 35.0 1 60.0 42.000 0.5122 0.0465 0 17.000 1 1.3 42 82 AACCCAAAGAAAATGAATTT TTTTTTTTTTTTTAAAAGAA chr12:76036588-76085033 Insertion 0 0
3+
NAP1L1.NegativeRRC testbed chr12 76045954 76045954 C T 8 8 0 0 4 4 T/T 1.0000 0;2 52.4 1 37.0 0 60.0 16.000 1.0000 0 1 3.000 1 1.1 8 8 AGATAACTCAGAATAATAAC CAGAATATAACCTATCAGGA chr12:76036588-76085033 SNV 0 0
4+
NAP1L1.NegativeRRC testbed chr12 76046488 76046488 T TA 91 16 42 20 9 6 T/+1 0.1758 2;2 38.9 1 37.0 1 60.0 32.000 0.2025 0.0330 11 12.000 1 0.4 16 79 GCATTTCGATGAACTATGGT AAAAAAAAAAAGCACATAGT chr12:76036588-76085033 Insertion 0 0
5+
NAP1L1.NegativeRRC testbed chr12 76060186 76060186 G A 1345 696 304 342 334 362 G/A 0.5175 2;2 42.8 1 36.6 1 54.7 173.000 0.5246 0 0 1.000 1 1.1 692 1319 GCATACTTCCTTTCAAGATC TGAACTTCCTCATAGAATTT chr12:76036588-76085033 SNV 0 0
6+
NAP1L1.NegativeRRC testbed chr12 76059796 76059796 A ACCT 19 3 17 0 1 2 A/+3 0.1579 2;2 41.0 1 37.0 0 40.0 6.000 0.6000 0 2 2.000 1 1.0 3 5 CCAAAATAAAGTTGGTACTA CCGAAATCTCATCTTCTTCA chr12:76036588-76085033 Insertion 0 0
7+
NAP1L1.NegativeRRC testbed chr12 76048101 76048102 CA C 105 17 47 38 9 8 A/-1 0.1619 2;2 39.8 1 36.8 1 60.0 34.000 0.1650 0.0286 13 14.000 1 0.9 17 103 GTTCTTCAAGGAAAAAATTA AAAAAAAAAAAAAGGTATTT chr12:76036588-76085033 Deletion 0 0
8+
NAP1L1.NegativeRRC testbed chr12 76056120 76056120 T C 1439 1434 0 0 559 875 C/C 0.9965 0;2 35.1 1 35.3 1 55.6 31.591 0.9993 0 0 6.000 1 1.3 1390 1391 GGGTCTTCTTTTTCTTCATC TTTTTCTCATCTTCAATCTT chr12:76036588-76085033 SNV 0 0
9+
NAP1L1.NegativeRRC testbed chr12 76051637 76051637 C T 2 2 0 0 1 1 T/T 1.0000 0;2 38.5 1 37.0 0 60.0 4.000 1.0000 0 0 1.000 1 1.0 2 2 CGCCACCAGAGCAGCTGGGA TACAGGTGCCTGAAGCTGTA chr12:76036588-76085033 SNV 0 0
10+
NAP1L1.NegativeRRC testbed chr12 76036918 76036918 C CA 2 2 0 0 1 1 +1/+1 1.0000 0;2 53.2 1 40.2 0 65.2 4.000 1.0000 0 14 15.000 1 1.6 2 2 CCCCGTCTCTACTAAAAATA AAAAAAAAAAAAAACCCACA chr12:76036588-76085033 Insertion 0 0
11+
NAP1L1.NegativeRRC testbed chr12 76045879 76045879 A G 8 4 4 0 1 3 A/G 0.5000 0;2 47.0 1 37.0 0 60.0 8.000 0.5000 0 2 1.000 1 1.5 4 8 AGACTTACTTGGCAGTGTGC TGGGCTGCTGGAAACTACAA chr12:76036588-76085033 SNV 0 0

0 commit comments

Comments
 (0)