@@ -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