Skip to content

Commit

Permalink
Merge pull request #297 from PolinaBevad/fix_issue_294
Browse files Browse the repository at this point in the history
Fix for REF variants in amplicon pileup mode
  • Loading branch information
pcingola authored Jul 7, 2020
2 parents 2505c58 + 2e7d912 commit bac5faa
Show file tree
Hide file tree
Showing 4 changed files with 105 additions and 123 deletions.
40 changes: 9 additions & 31 deletions src/main/java/com/astrazeneca/vardict/modules/ToVarsBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -952,41 +952,17 @@ else if (deletionLength < instance().conf.SVMINLEN) {
}
} else if (variationsAtPos.referenceVariant != null ) { //no variant reads are detected
Variant vref = variationsAtPos.referenceVariant;
updateRefVariant(position, totalPosCoverage, vref, debugLines,
referenceForwardCoverage, referenceReverseCoverage);
updateRefVariant(position, totalPosCoverage, vref, debugLines, referenceForwardCoverage, referenceReverseCoverage);
} else {
variationsAtPos.referenceVariant = new Variant();
}

// Update reference variants if there were indels and start position were changed, so after update
// ref variants can be output in pileup
if (positionsForChangedRefVariant.contains(position) && variationsAtPos.referenceVariant != null) {
// Update reference variants if there were indels and start position were changed, or we work with amplicons
// so after update ref variants can be output in pileup
if (variationsAtPos.referenceVariant != null && instance().conf.doPileup &&
(positionsForChangedRefVariant.contains(position)|| instance().ampliconBasedCalling != null)) {
Variant vref = variationsAtPos.referenceVariant;
updateRefVariant(position, totalPosCoverage, vref, debugLines,
referenceForwardCoverage, referenceReverseCoverage);
}

if (instance().conf.doPileup && variationsAtPos.referenceVariant != null) {
Variant refVar = variationsAtPos.referenceVariant;
fillReferenceVarInPileup(position, refVar);
}
}

/**
* Fill reference variant fields for pileup: positions, varallele and refallele
* @param position current position in reference
* @param refVar reference Variant
*/
private void fillReferenceVarInPileup(int position, Variant refVar) {
refVar.startPosition = position;
refVar.endPosition = position;

char emptyChar = 0;
if (refVar.refallele.equals("")) {
refVar.refallele = ref.getOrDefault(position, emptyChar).toString();
}
if (refVar.varallele.equals("")) {
refVar.varallele = ref.getOrDefault(position, emptyChar).toString();
updateRefVariant(position, totalPosCoverage, vref, debugLines, referenceForwardCoverage, referenceReverseCoverage);
}
}

Expand All @@ -1001,7 +977,9 @@ private void updateRefVariant(int position, int totalPosCoverage, Variant vref,
vref.varsCountOnReverse = 0;
vref.msi = 0;
vref.msint = 0;
vref.strandBiasFlag += ";0";
if (vref.strandBiasFlag.indexOf(';') == -1) {
vref.strandBiasFlag += ";0";
}
vref.shift3 = 0;
vref.startPosition = position;
vref.endPosition = position;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -164,8 +164,10 @@ public void process(Region rg, List<Map<Integer, Vars>> vars,
if (goodmap.contains(format("%s-%s-%s", amp, vref.refallele, vref.varallele))) {
continue;
}
if (instance().conf.doPileup && vref.refallele.equals(vref.varallele)) {
continue;
}
if (vref.startPosition >= reg.insertStart && vref.endPosition <= reg.insertEnd) {

String regStr = reg.chr + ":" + reg.start + "-" + reg.end;

if (vars.get(amp).containsKey(position) && vars.get(amp).get(position).variants.size() > 0) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,9 @@ private StringBuilder debugVariantsContent(String n) {
*/
public String varType() {
Matcher mm = ANY_SV.matcher(varallele);
if (refallele.length() == 1 && varallele.length() == 1) {
if (refallele.equals(varallele) && refallele.length() == 1) {
return "";
} else if (refallele.length() == 1 && varallele.length() == 1) {
return "SNV";
} else if (mm.find()) {
return mm.group(1);
Expand Down
Loading

0 comments on commit bac5faa

Please sign in to comment.