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

Commit bac5faa

Browse files
authored
Merge pull request #297 from PolinaBevad/fix_issue_294
Fix for REF variants in amplicon pileup mode
2 parents 2505c58 + 2e7d912 commit bac5faa

4 files changed

Lines changed: 105 additions & 123 deletions

File tree

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

Lines changed: 9 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -952,41 +952,17 @@ else if (deletionLength < instance().conf.SVMINLEN) {
952952
}
953953
} else if (variationsAtPos.referenceVariant != null ) { //no variant reads are detected
954954
Variant vref = variationsAtPos.referenceVariant;
955-
updateRefVariant(position, totalPosCoverage, vref, debugLines,
956-
referenceForwardCoverage, referenceReverseCoverage);
955+
updateRefVariant(position, totalPosCoverage, vref, debugLines, referenceForwardCoverage, referenceReverseCoverage);
957956
} else {
958957
variationsAtPos.referenceVariant = new Variant();
959958
}
960959

961-
// Update reference variants if there were indels and start position were changed, so after update
962-
// ref variants can be output in pileup
963-
if (positionsForChangedRefVariant.contains(position) && variationsAtPos.referenceVariant != null) {
960+
// Update reference variants if there were indels and start position were changed, or we work with amplicons
961+
// so after update ref variants can be output in pileup
962+
if (variationsAtPos.referenceVariant != null && instance().conf.doPileup &&
963+
(positionsForChangedRefVariant.contains(position)|| instance().ampliconBasedCalling != null)) {
964964
Variant vref = variationsAtPos.referenceVariant;
965-
updateRefVariant(position, totalPosCoverage, vref, debugLines,
966-
referenceForwardCoverage, referenceReverseCoverage);
967-
}
968-
969-
if (instance().conf.doPileup && variationsAtPos.referenceVariant != null) {
970-
Variant refVar = variationsAtPos.referenceVariant;
971-
fillReferenceVarInPileup(position, refVar);
972-
}
973-
}
974-
975-
/**
976-
* Fill reference variant fields for pileup: positions, varallele and refallele
977-
* @param position current position in reference
978-
* @param refVar reference Variant
979-
*/
980-
private void fillReferenceVarInPileup(int position, Variant refVar) {
981-
refVar.startPosition = position;
982-
refVar.endPosition = position;
983-
984-
char emptyChar = 0;
985-
if (refVar.refallele.equals("")) {
986-
refVar.refallele = ref.getOrDefault(position, emptyChar).toString();
987-
}
988-
if (refVar.varallele.equals("")) {
989-
refVar.varallele = ref.getOrDefault(position, emptyChar).toString();
965+
updateRefVariant(position, totalPosCoverage, vref, debugLines, referenceForwardCoverage, referenceReverseCoverage);
990966
}
991967
}
992968

@@ -1001,7 +977,9 @@ private void updateRefVariant(int position, int totalPosCoverage, Variant vref,
1001977
vref.varsCountOnReverse = 0;
1002978
vref.msi = 0;
1003979
vref.msint = 0;
1004-
vref.strandBiasFlag += ";0";
980+
if (vref.strandBiasFlag.indexOf(';') == -1) {
981+
vref.strandBiasFlag += ";0";
982+
}
1005983
vref.shift3 = 0;
1006984
vref.startPosition = position;
1007985
vref.endPosition = position;

src/main/java/com/astrazeneca/vardict/postprocessmodules/AmpliconPostProcessModule.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,8 +164,10 @@ public void process(Region rg, List<Map<Integer, Vars>> vars,
164164
if (goodmap.contains(format("%s-%s-%s", amp, vref.refallele, vref.varallele))) {
165165
continue;
166166
}
167+
if (instance().conf.doPileup && vref.refallele.equals(vref.varallele)) {
168+
continue;
169+
}
167170
if (vref.startPosition >= reg.insertStart && vref.endPosition <= reg.insertEnd) {
168-
169171
String regStr = reg.chr + ":" + reg.start + "-" + reg.end;
170172

171173
if (vars.get(amp).containsKey(position) && vars.get(amp).get(position).variants.size() > 0) {

src/main/java/com/astrazeneca/vardict/variations/Variant.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -291,7 +291,9 @@ private StringBuilder debugVariantsContent(String n) {
291291
*/
292292
public String varType() {
293293
Matcher mm = ANY_SV.matcher(varallele);
294-
if (refallele.length() == 1 && varallele.length() == 1) {
294+
if (refallele.equals(varallele) && refallele.length() == 1) {
295+
return "";
296+
} else if (refallele.length() == 1 && varallele.length() == 1) {
295297
return "SNV";
296298
} else if (mm.find()) {
297299
return mm.group(1);

0 commit comments

Comments
 (0)