Now annotations that require reads return null if there's no alignment context, so that running without reads adds annotations only for the appropriate fields.

Added an integration test for the read-less case.


git-svn-id: file:///humgen/gsa-scr1/gsa-engineering/svn_contents/trunk@3525 348d0f76-0448-11de-a6fe-93d51630548a
This commit is contained in:
ebanks 2010-06-09 20:36:46 +00:00
parent 6941c81bfa
commit ca4eab1d23
10 changed files with 34 additions and 2 deletions

View File

@ -43,7 +43,9 @@ import java.util.Arrays;
public class AlleleBalance implements InfoFieldAnnotation, StandardAnnotation {
public Map<String, Object> annotate(RefMetaDataTracker tracker, ReferenceContext ref, Map<String, StratifiedAlignmentContext> stratifiedContexts, VariantContext vc) {
if ( stratifiedContexts.size() == 0 )
return null;
if ( !vc.isBiallelic() )
return null;
final Map<String, Genotype> genotypes = vc.getGenotypes();

View File

@ -17,6 +17,9 @@ import java.util.Arrays;
public class DepthOfCoverage implements InfoFieldAnnotation, StandardAnnotation {
public Map<String, Object> annotate(RefMetaDataTracker tracker, ReferenceContext ref, Map<String, StratifiedAlignmentContext> stratifiedContexts, VariantContext vc) {
if ( stratifiedContexts.size() == 0 )
return null;
int depth = 0;
for ( String sample : stratifiedContexts.keySet() )
depth += stratifiedContexts.get(sample).getContext(StratifiedAlignmentContext.StratifiedContextType.COMPLETE).size();

View File

@ -18,6 +18,9 @@ import java.util.Arrays;
public class LowMQ implements InfoFieldAnnotation {
public Map<String, Object> annotate(RefMetaDataTracker tracker, ReferenceContext ref, Map<String, StratifiedAlignmentContext> stratifiedContexts, VariantContext vc) {
if ( stratifiedContexts.size() == 0 )
return null;
double mq0 = 0;
double mq10 = 0;
double total = 0;

View File

@ -19,6 +19,9 @@ import java.util.Arrays;
public class MappingQualityZero implements InfoFieldAnnotation, StandardAnnotation {
public Map<String, Object> annotate(RefMetaDataTracker tracker, ReferenceContext ref, Map<String, StratifiedAlignmentContext> stratifiedContexts, VariantContext vc) {
if ( stratifiedContexts.size() == 0 )
return null;
int mq0 = 0;
for ( String sample : stratifiedContexts.keySet() ) {
ReadBackedPileup pileup = stratifiedContexts.get(sample).getContext(StratifiedAlignmentContext.StratifiedContextType.COMPLETE).getBasePileup();

View File

@ -17,6 +17,9 @@ import java.util.Arrays;
public class QualByDepth implements InfoFieldAnnotation, StandardAnnotation {
public Map<String, Object> annotate(RefMetaDataTracker tracker, ReferenceContext ref, Map<String, StratifiedAlignmentContext> stratifiedContexts, VariantContext vc) {
if ( stratifiedContexts.size() == 0 )
return null;
final Map<String, Genotype> genotypes = vc.getGenotypes();
if ( genotypes == null || genotypes.size() == 0 )
return null;

View File

@ -18,6 +18,9 @@ import java.util.*;
public class RMSMappingQuality implements InfoFieldAnnotation, StandardAnnotation {
public Map<String, Object> annotate(RefMetaDataTracker tracker, ReferenceContext ref, Map<String, StratifiedAlignmentContext> stratifiedContexts, VariantContext vc) {
if ( stratifiedContexts.size() == 0 )
return null;
ArrayList<Integer> qualities = new ArrayList<Integer>();
for ( String sample : stratifiedContexts.keySet() ) {
ReadBackedPileup pileup = stratifiedContexts.get(sample).getContext(StratifiedAlignmentContext.StratifiedContextType.COMPLETE).getBasePileup();

View File

@ -19,7 +19,9 @@ public abstract class RankSumTest implements InfoFieldAnnotation, WorkInProgress
private static final double minPValue = 1e-10;
public Map<String, Object> annotate(RefMetaDataTracker tracker, ReferenceContext ref, Map<String, StratifiedAlignmentContext> stratifiedContexts, VariantContext vc) {
if ( stratifiedContexts.size() == 0 )
return null;
if ( !vc.isBiallelic() || !vc.isSNP() )
return null;

View File

@ -53,6 +53,9 @@ public class SecondBaseSkew implements InfoFieldAnnotation, ExperimentalAnnotati
public List<VCFInfoHeaderLine> getDescriptions() { return Arrays.asList(new VCFInfoHeaderLine(KEY_NAME, 1, VCFInfoHeaderLine.INFO_TYPE.Float, "Chi-square Secondary Base Skew")); }
public Map<String, Object> annotate(RefMetaDataTracker tracker, ReferenceContext ref, Map<String, StratifiedAlignmentContext> stratifiedContexts, VariantContext vc) {
if ( stratifiedContexts.size() == 0 )
return null;
String annotation = getAnnotation(ref, stratifiedContexts, vc);
if ( annotation == null )
return null;

View File

@ -18,6 +18,9 @@ import java.util.Arrays;
public class SpanningDeletions implements InfoFieldAnnotation, StandardAnnotation {
public Map<String, Object> annotate(RefMetaDataTracker tracker, ReferenceContext ref, Map<String, StratifiedAlignmentContext> stratifiedContexts, VariantContext vc) {
if ( stratifiedContexts.size() == 0 )
return null;
int deletions = 0;
int depth = 0;
for ( String sample : stratifiedContexts.keySet() ) {

View File

@ -110,4 +110,11 @@ public class VariantAnnotatorIntegrationTest extends WalkerTest {
executeTest("test file doesn't have annotations, asking for annotations, #2", spec);
}
@Test
public void testNoReads() {
WalkerTestSpec spec = new WalkerTestSpec(
baseTestString() + " -G \"Standard\" -B variant,VCF," + validationDataLocation + "vcfexample3empty.vcf -L 1:10,000,000-10,050,000", 1,
Arrays.asList("07af9983127c62e96accc03db2fb523e"));
executeTest("test file doesn't have annotations, not passing it any reads", spec);
}
}