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

Commit 2e7d912

Browse files
committed
Added update for pileup amplicon references (only amplicon as somatic and simple are counted correctly) using reference result.
1 parent f132443 commit 2e7d912

2 files changed

Lines changed: 58 additions & 80 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;

0 commit comments

Comments
 (0)