Complete the move over to VariantContext so that we can remove dependence on Variation (in the VCF code)
git-svn-id: file:///humgen/gsa-scr1/gsa-engineering/svn_contents/trunk@3190 348d0f76-0448-11de-a6fe-93d51630548a
This commit is contained in:
parent
821e8b1c5f
commit
8c32bb8f0a
|
|
@ -4,11 +4,7 @@ import org.broadinstitute.sting.gatk.contexts.AlignmentContext;
|
||||||
import org.broadinstitute.sting.gatk.contexts.ReferenceContext;
|
import org.broadinstitute.sting.gatk.contexts.ReferenceContext;
|
||||||
import org.broadinstitute.sting.gatk.contexts.variantcontext.VariantContext;
|
import org.broadinstitute.sting.gatk.contexts.variantcontext.VariantContext;
|
||||||
import org.broadinstitute.sting.gatk.refdata.RefMetaDataTracker;
|
import org.broadinstitute.sting.gatk.refdata.RefMetaDataTracker;
|
||||||
import org.broadinstitute.sting.gatk.refdata.RodVCF;
|
|
||||||
import org.broadinstitute.sting.gatk.refdata.VariantContextAdaptors;
|
|
||||||
import org.broadinstitute.sting.gatk.refdata.utils.GATKFeature;
|
|
||||||
import org.broadinstitute.sting.gatk.walkers.RodWalker;
|
import org.broadinstitute.sting.gatk.walkers.RodWalker;
|
||||||
import org.broadinstitute.sting.utils.StingException;
|
|
||||||
import org.broadinstitute.sting.utils.cmdLine.Argument;
|
import org.broadinstitute.sting.utils.cmdLine.Argument;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
|
@ -108,26 +104,19 @@ public class AnalyzeAnnotationsWalker extends RodWalker<Integer, Integer> {
|
||||||
// First find out if this variant is in the truth sets
|
// First find out if this variant is in the truth sets
|
||||||
boolean isInTruthSet = false;
|
boolean isInTruthSet = false;
|
||||||
boolean isTrueVariant = false;
|
boolean isTrueVariant = false;
|
||||||
for( final GATKFeature feature : tracker.getAllRods() ) {
|
for ( VariantContext vc : tracker.getAllVariantContexts() ) {
|
||||||
Object rod = feature.getUnderlyingObject();
|
if( vc.getName().toUpperCase().startsWith("TRUTH") ) {
|
||||||
if( rod != null && feature.getName().toUpperCase().startsWith("TRUTH") ) {
|
|
||||||
isInTruthSet = true;
|
isInTruthSet = true;
|
||||||
VariantContext variantContext = VariantContextAdaptors.toVariantContext(feature.getName(),rod);
|
if (vc.isVariant())
|
||||||
// First check that the conversion to VC worked correctly; next see if the truth sets say this site is variant or reference
|
|
||||||
if (variantContext == null)
|
|
||||||
throw new StingException("Truth ROD is of type that can't be converted to a VariantContext ( type = " + feature.getName() + ")");
|
|
||||||
else if (variantContext.isSNP())
|
|
||||||
isTrueVariant = true;
|
isTrueVariant = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add each annotation in this VCF Record to the dataManager
|
// Add each annotation in this VCF Record to the dataManager
|
||||||
for( final GATKFeature feature : tracker.getAllRods() ) {
|
for ( VariantContext vc : tracker.getAllVariantContexts() ) {
|
||||||
Object rod = feature.getUnderlyingObject();
|
if( !vc.getName().toUpperCase().startsWith("TRUTH") ) {
|
||||||
if( rod != null && rod instanceof RodVCF && !feature.getName().toUpperCase().startsWith("TRUTH") ) {
|
if( vc.isVariant() ) {
|
||||||
final RodVCF variant = (RodVCF) rod;
|
dataManager.addAnnotations( vc, ref.getBase(), SAMPLE_NAME, isInTruthSet, isTrueVariant );
|
||||||
if( variant.isSNP() ) {
|
|
||||||
dataManager.addAnnotations( variant, SAMPLE_NAME, isInTruthSet, isTrueVariant );
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,10 @@
|
||||||
package org.broadinstitute.sting.playground.gatk.walkers.variantoptimizer;
|
package org.broadinstitute.sting.playground.gatk.walkers.variantoptimizer;
|
||||||
|
|
||||||
import org.broadinstitute.sting.gatk.refdata.RodVCF;
|
import org.broadinstitute.sting.gatk.refdata.VariantContextAdaptors;
|
||||||
|
import org.broadinstitute.sting.gatk.contexts.variantcontext.VariantContext;
|
||||||
import org.broadinstitute.sting.utils.BaseUtils;
|
import org.broadinstitute.sting.utils.BaseUtils;
|
||||||
import org.broadinstitute.sting.utils.StingException;
|
import org.broadinstitute.sting.utils.StingException;
|
||||||
|
import org.broadinstitute.sting.utils.genotype.vcf.VCFRecord;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
@ -52,14 +54,16 @@ public class AnnotationDataManager {
|
||||||
INDICATE_MEAN_NUM_VARS = _INDICATE_MEAN_NUM_VARS;
|
INDICATE_MEAN_NUM_VARS = _INDICATE_MEAN_NUM_VARS;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addAnnotations( final RodVCF variant, final String sampleName, final boolean isInTruthSet, final boolean isTrueVariant ) {
|
public void addAnnotations( final VariantContext vc, final char ref, final String sampleName, final boolean isInTruthSet, final boolean isTrueVariant ) {
|
||||||
|
|
||||||
if( sampleName != null ) { // Only process variants that are found in the sample with this sampleName
|
if( sampleName != null ) { // Only process variants that are found in the sample with this sampleName
|
||||||
if( variant.getGenotype(sampleName).isNoCall() ) { // This variant isn't found in this sample so break out
|
if( vc.getGenotype(sampleName).isNoCall() ) { // This variant isn't found in this sample so break out
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
} // else, process all samples
|
} // else, process all samples
|
||||||
|
|
||||||
|
VCFRecord variant = VariantContextAdaptors.toVCF(vc, ref);
|
||||||
|
|
||||||
// Loop over each annotation in the vcf record
|
// Loop over each annotation in the vcf record
|
||||||
final Map<String,String> infoField = variant.getInfoValues();
|
final Map<String,String> infoField = variant.getInfoValues();
|
||||||
infoField.put("QUAL", ((Double)variant.getQual()).toString() ); // add QUAL field to annotations
|
infoField.put("QUAL", ((Double)variant.getQual()).toString() ); // add QUAL field to annotations
|
||||||
|
|
@ -87,10 +91,12 @@ public class AnnotationDataManager {
|
||||||
final boolean isNovelVariant = variant.getID().equals(".");
|
final boolean isNovelVariant = variant.getID().equals(".");
|
||||||
|
|
||||||
// Decide if the variant is a transition or transversion
|
// Decide if the variant is a transition or transversion
|
||||||
if( BaseUtils.isTransition( (byte)variant.getReferenceForSNP(), (byte)variant.getAlternativeBaseForSNP()) ) {
|
if ( vc.isSNP() ) {
|
||||||
datum.incrementTi( isNovelVariant, isInTruthSet, isTrueVariant );
|
if( BaseUtils.isTransition( vc.getReference().getBases()[0], vc.getAlternateAllele(0).getBases()[0]) ) {
|
||||||
} else {
|
datum.incrementTi( isNovelVariant, isInTruthSet, isTrueVariant );
|
||||||
datum.incrementTv( isNovelVariant, isInTruthSet, isTrueVariant );
|
} else {
|
||||||
|
datum.incrementTv( isNovelVariant, isInTruthSet, isTrueVariant );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue