Bug fix in reverse trim alleles for the case of mixed records.
This commit is contained in:
parent
1bbb156afa
commit
2b5dd28550
|
|
@ -642,7 +642,7 @@ public abstract class AbstractVCFCodec implements FeatureCodec, NameAwareCodec {
|
|||
boolean stillClipping = true;
|
||||
|
||||
while ( stillClipping ) {
|
||||
for ( Allele a : unclippedAlleles ) {
|
||||
for ( final Allele a : unclippedAlleles ) {
|
||||
if ( a.isSymbolic() )
|
||||
continue;
|
||||
|
||||
|
|
|
|||
|
|
@ -160,7 +160,7 @@ import java.util.*;
|
|||
*
|
||||
* @author depristo
|
||||
*/
|
||||
public class VariantContext implements Feature { // to enable tribble intergration
|
||||
public class VariantContext implements Feature { // to enable tribble integration
|
||||
protected CommonInfo commonInfo = null;
|
||||
public final static double NO_LOG10_PERROR = CommonInfo.NO_LOG10_PERROR;
|
||||
|
||||
|
|
@ -377,7 +377,7 @@ public class VariantContext implements Feature { // to enable tribble intergrati
|
|||
*
|
||||
* Not currently supported:
|
||||
*
|
||||
* Heterozygous sequencea
|
||||
* Heterozygous sequence
|
||||
* The term heterozygous is used to specify a region detected by certain methods that do not
|
||||
* resolve the polymorphism into a specific sequence motif. In these cases, a unique flanking
|
||||
* sequence must be provided to define a sequence context for the variation.
|
||||
|
|
|
|||
|
|
@ -620,8 +620,8 @@ public class VariantContextUtils {
|
|||
String key = p.getKey();
|
||||
// if we don't like the key already, don't go anywhere
|
||||
if ( ! inconsistentAttributes.contains(key) ) {
|
||||
boolean alreadyFound = attributes.containsKey(key);
|
||||
Object boundValue = attributes.get(key);
|
||||
final boolean alreadyFound = attributes.containsKey(key);
|
||||
final Object boundValue = attributes.get(key);
|
||||
final boolean boundIsMissingValue = alreadyFound && boundValue.equals(VCFConstants.MISSING_VALUE_v4);
|
||||
|
||||
if ( alreadyFound && ! boundValue.equals(p.getValue()) && ! boundIsMissingValue ) {
|
||||
|
|
@ -802,17 +802,16 @@ public class VariantContextUtils {
|
|||
return inputVC;
|
||||
}
|
||||
|
||||
public static VariantContext reverseTrimAlleles(VariantContext inputVC) {
|
||||
public static VariantContext reverseTrimAlleles( final VariantContext inputVC ) {
|
||||
// see if we need to trim common reference base from all alleles
|
||||
|
||||
final int trimExtent = AbstractVCFCodec.computeReverseClipping(inputVC.getAlleles(), inputVC.getReference().getDisplayString().getBytes(), 0, true, -1);
|
||||
if ( trimExtent <= 0 )
|
||||
return inputVC;
|
||||
if ( trimExtent <= 0 || inputVC.getAlleles().size() <= 1 )
|
||||
return inputVC;
|
||||
|
||||
final List<Allele> alleles = new ArrayList<Allele>();
|
||||
GenotypesContext genotypes = GenotypesContext.create();
|
||||
|
||||
Map<Allele, Allele> originalToTrimmedAlleleMap = new HashMap<Allele, Allele>();
|
||||
final GenotypesContext genotypes = GenotypesContext.create();
|
||||
final Map<Allele, Allele> originalToTrimmedAlleleMap = new HashMap<Allele, Allele>();
|
||||
|
||||
for (final Allele a : inputVC.getAlleles()) {
|
||||
if (a.isSymbolic()) {
|
||||
|
|
@ -820,8 +819,8 @@ public class VariantContextUtils {
|
|||
originalToTrimmedAlleleMap.put(a, a);
|
||||
} else {
|
||||
// get bases for current allele and create a new one with trimmed bases
|
||||
byte[] newBases = Arrays.copyOfRange(a.getBases(), 0, a.length()-trimExtent);
|
||||
Allele trimmedAllele = Allele.create(newBases, a.isReference());
|
||||
final byte[] newBases = Arrays.copyOfRange(a.getBases(), 0, a.length()-trimExtent);
|
||||
final Allele trimmedAllele = Allele.create(newBases, a.isReference());
|
||||
alleles.add(trimmedAllele);
|
||||
originalToTrimmedAlleleMap.put(a, trimmedAllele);
|
||||
}
|
||||
|
|
@ -829,9 +828,8 @@ public class VariantContextUtils {
|
|||
|
||||
// now we can recreate new genotypes with trimmed alleles
|
||||
for ( final Genotype genotype : inputVC.getGenotypes() ) {
|
||||
|
||||
List<Allele> originalAlleles = genotype.getAlleles();
|
||||
List<Allele> trimmedAlleles = new ArrayList<Allele>();
|
||||
final List<Allele> originalAlleles = genotype.getAlleles();
|
||||
final List<Allele> trimmedAlleles = new ArrayList<Allele>();
|
||||
for ( final Allele a : originalAlleles ) {
|
||||
if ( a.isCalled() )
|
||||
trimmedAlleles.add(originalToTrimmedAlleleMap.get(a));
|
||||
|
|
@ -841,8 +839,7 @@ public class VariantContextUtils {
|
|||
genotypes.add(Genotype.modifyAlleles(genotype, trimmedAlleles));
|
||||
}
|
||||
|
||||
final VariantContextBuilder builder = new VariantContextBuilder(inputVC).stop(inputVC.getStart() + alleles.get(0).length());
|
||||
return builder.alleles(alleles).genotypes(genotypes).make();
|
||||
return new VariantContextBuilder(inputVC).stop(inputVC.getEnd() - trimExtent).alleles(alleles).genotypes(genotypes).make();
|
||||
}
|
||||
|
||||
public static GenotypesContext stripPLs(GenotypesContext genotypes) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue