Skip to content

Commit 8fc5696

Browse files
authored
Merge pull request #136 from PolinaBevad/f_fix_string_out_of_bound_three_del_ins
Fix StringOutOfBoundException for cases of three indels/three deletions/two deletions
2 parents 3bac523 + a017b1a commit 8fc5696

27 files changed

+150
-5
lines changed

src/main/java/com/astrazeneca/vardict/VarDict.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -524,6 +524,9 @@ static int somdict(Region segs, Map<Integer, Vars> vars1, Map<Integer, Vars> var
524524
Collections.sort(pp);
525525

526526
for (Integer p : pp) {
527+
if (p < segs.start || p > segs.end) {
528+
continue;
529+
}
527530
Vars v1 = vars1.get(p);
528531
Vars v2 = vars2.get(p);
529532
if (v1 == null && v2 == null) { // both samples have no coverage

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ public static Tuple.Tuple2<Integer, String> modifyCigar(int indel,
194194

195195
//number of bases after refoff/rdoff that match in reference and read
196196
int rn = 0;
197-
while (isHasAndEquals(querySeq.charAt(rdoff + rn), ref, refoff + rn)) {
197+
while (rdoff + rn < querySeq.length() && isHasAndEquals(querySeq.charAt(rdoff + rn), ref, refoff + rn)) {
198198
rn++;
199199
}
200200
RDOFF += rn;
@@ -247,7 +247,7 @@ public static Tuple.Tuple2<Integer, String> modifyCigar(int indel,
247247

248248
//number of bases after refoff/rdoff that match in reference and read
249249
int rn = 0;
250-
while (isHasAndEquals(querySeq.charAt(rdoff + rn), ref, refoff + rn)) {
250+
while (rdoff + rn < querySeq.length() && isHasAndEquals(querySeq.charAt(rdoff + rn), ref, refoff + rn)) {
251251
rn++;
252252
}
253253
RDOFF += rn;
@@ -301,7 +301,7 @@ public static Tuple.Tuple2<Integer, String> modifyCigar(int indel,
301301
}
302302

303303
int rn = 0;
304-
while (isHasAndEquals(querySeq.charAt(rdoff + rn), ref, refoff + rn)) {
304+
while (rdoff + rn < querySeq.length() && isHasAndEquals(querySeq.charAt(rdoff + rn), ref, refoff + rn)) {
305305
rn++;
306306
}
307307
RDOFF += rn;

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1102,7 +1102,7 @@ static void findINVdisc (Map<Integer, VariationMap<String, Variation>> hash,
11021102
ins = SequenceUtil.reverseComplement(joinRef(ref, bp, pe));
11031103
}
11041104
if (conf.y) {
1105-
System.err.printf(" Found INV with discordant pairs only: cnt: %d Len: %d %d-%d<->%d-%d %s\n",
1105+
System.err.printf(" Found INV with discordant pairs only 5': cnt: %d Len: %d %d-%d<->%d-%d %s\n",
11061106
cnt, len, end, rstart, me, rms, ins);
11071107
}
11081108
final Variation vref = getVariation(hash, bp,"-" + len + "^" + ins);
@@ -1185,7 +1185,7 @@ static void findINVdisc (Map<Integer, VariationMap<String, Variation>> hash,
11851185
ins = SequenceUtil.reverseComplement(joinRef(ref, bp, pe));
11861186
}
11871187
if (conf.y) {
1188-
System.err.printf(" Found INV with discordant pairs only: cnt: %d Len: %d %d-%d<->%d-%d %s\n",
1188+
System.err.printf(" Found INV with discordant pairs only 3': cnt: %d Len: %d %d-%d<->%d-%d %s\n",
11891189
cnt, len, me, rms, end, rstart, ins);
11901190
}
11911191
final Variation vref = getVariation(hash, bp,"-" + len + "^" + ins);
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.

0 commit comments

Comments
 (0)