Refactored the quasi-useful IndelType annotation into the more useful VariantType.

The indels are still annotated as before, but now all other variant types are annotated too.
I'm doing this because of requests on the forum but am not making it standard.  If we find it to be useful we can turn it on by default later.
This commit is contained in:
Eric Banks 2012-12-17 11:54:47 -05:00
parent 6171419e6c
commit e6f468b647
2 changed files with 27 additions and 33 deletions

View File

@ -15,9 +15,9 @@ import org.broadinstitute.sting.utils.variantcontext.VariantContext;
import java.util.*; import java.util.*;
/** /**
* Rough category of indel type (insertion, deletion, multi-allelic, other) * Assigns a roughly correct category of the variant type (SNP, MNP, insertion, deletion, etc.)
*/ */
public class IndelType extends InfoFieldAnnotation implements ExperimentalAnnotation { public class VariantType extends InfoFieldAnnotation implements ExperimentalAnnotation {
public Map<String, Object> annotate(final RefMetaDataTracker tracker, public Map<String, Object> annotate(final RefMetaDataTracker tracker,
final AnnotatorCompatible walker, final AnnotatorCompatible walker,
@ -26,41 +26,35 @@ public class IndelType extends InfoFieldAnnotation implements ExperimentalAnnota
final VariantContext vc, final VariantContext vc,
final Map<String, PerReadAlleleLikelihoodMap> stratifiedPerReadAlleleLikelihoodMap) { final Map<String, PerReadAlleleLikelihoodMap> stratifiedPerReadAlleleLikelihoodMap) {
int run; StringBuffer type = new StringBuffer("");
if (vc.isMixed()) { if ( vc.isVariant() && !vc.isBiallelic() )
Map<String, Object> map = new HashMap<String, Object>(); type.append("MULTIALLELIC_");
map.put(getKeyNames().get(0), String.format("%s", "MIXED"));
return map;
}
else if ( vc.isIndel() ) {
String type="";
if (!vc.isBiallelic())
type = "MULTIALLELIC_INDEL";
else {
if (vc.isSimpleInsertion())
type = "INS.";
else if (vc.isSimpleDeletion())
type = "DEL.";
else
type = "OTHER.";
ArrayList<Integer> inds = IndelUtils.findEventClassificationIndex(vc, ref);
for (int k : inds) {
type = type+ IndelUtils.getIndelClassificationName(k)+".";
}
}
Map<String, Object> map = new HashMap<String, Object>();
map.put(getKeyNames().get(0), String.format("%s", type));
return map;
if ( !vc.isIndel() ) {
type.append(vc.getType().toString());
} else { } else {
return null; if (vc.isSimpleInsertion())
type.append("INSERTION.");
else if (vc.isSimpleDeletion())
type.append("DELETION.");
else
type.append("COMPLEX.");
ArrayList<Integer> inds = IndelUtils.findEventClassificationIndex(vc, ref);
type.append(IndelUtils.getIndelClassificationName(inds.get(0)));
for (int i = 1; i < inds.size(); i++ ) {
type.append(".");
type.append(IndelUtils.getIndelClassificationName(inds.get(i)));
}
} }
Map<String, Object> map = new HashMap<String, Object>();
map.put(getKeyNames().get(0), String.format("%s", type));
return map;
} }
public List<String> getKeyNames() { return Arrays.asList("IndelType"); } public List<String> getKeyNames() { return Arrays.asList("VariantType"); }
public List<VCFInfoHeaderLine> getDescriptions() { return Arrays.asList(new VCFInfoHeaderLine("IndelType", 1, VCFHeaderLineType.String, "Indel type description")); } public List<VCFInfoHeaderLine> getDescriptions() { return Arrays.asList(new VCFInfoHeaderLine("VariantType", 1, VCFHeaderLineType.String, "Variant type description")); }
} }

View File

@ -122,9 +122,9 @@ public class IndelUtils {
ArrayList<Integer> inds = new ArrayList<Integer>(); ArrayList<Integer> inds = new ArrayList<Integer>();
if ( vc.isSimpleInsertion() ) { if ( vc.isSimpleInsertion() ) {
indelAlleleString = vc.getAlternateAllele(0).getDisplayString(); indelAlleleString = vc.getAlternateAllele(0).getDisplayString().substring(1);
} else if ( vc.isSimpleDeletion() ) { } else if ( vc.isSimpleDeletion() ) {
indelAlleleString = vc.getReference().getDisplayString(); indelAlleleString = vc.getReference().getDisplayString().substring(1);
} }
else { else {
inds.add(IND_FOR_OTHER_EVENT); inds.add(IND_FOR_OTHER_EVENT);