CalculateChromosomeCounts() now only calculates AC, AF, and AN when there are genotypes. Can now combine variants with headers that differ in only whether a field is a integer or a float. Updated CombineVariants integrationtest, as incorrect AC values where being calculated in the previous GS outputs.

git-svn-id: file:///humgen/gsa-scr1/gsa-engineering/svn_contents/trunk@5383 348d0f76-0448-11de-a6fe-93d51630548a
This commit is contained in:
depristo 2011-03-06 19:25:52 +00:00
parent 5b8fdc5b1f
commit af71576a07
3 changed files with 28 additions and 19 deletions

View File

@ -113,26 +113,28 @@ public class VariantContextUtils {
return;
}
attributes.put(VCFConstants.ALLELE_NUMBER_KEY, vc.getChromosomeCount());
if ( vc.hasGenotypes() ) {
attributes.put(VCFConstants.ALLELE_NUMBER_KEY, vc.getChromosomeCount());
// if there are alternate alleles, record the relevant tags
if ( vc.getAlternateAlleles().size() > 0 ) {
ArrayList<String> alleleFreqs = new ArrayList<String>();
ArrayList<Integer> alleleCounts = new ArrayList<Integer>();
double totalChromosomes = (double)vc.getChromosomeCount();
for ( Allele allele : vc.getAlternateAlleles() ) {
int altChromosomes = vc.getChromosomeCount(allele);
alleleCounts.add(altChromosomes);
String freq = String.format(makePrecisionFormatStringFromDenominatorValue(totalChromosomes), ((double)altChromosomes / totalChromosomes));
alleleFreqs.add(freq);
// if there are alternate alleles, record the relevant tags
if ( vc.getAlternateAlleles().size() > 0 ) {
ArrayList<String> alleleFreqs = new ArrayList<String>();
ArrayList<Integer> alleleCounts = new ArrayList<Integer>();
double totalChromosomes = (double)vc.getChromosomeCount();
for ( Allele allele : vc.getAlternateAlleles() ) {
int altChromosomes = vc.getChromosomeCount(allele);
alleleCounts.add(altChromosomes);
String freq = String.format(makePrecisionFormatStringFromDenominatorValue(totalChromosomes), ((double)altChromosomes / totalChromosomes));
alleleFreqs.add(freq);
}
attributes.put(VCFConstants.ALLELE_COUNT_KEY, alleleCounts.size() == 1 ? alleleCounts.get(0) : alleleCounts);
attributes.put(VCFConstants.ALLELE_FREQUENCY_KEY, alleleFreqs.size() == 1 ? alleleFreqs.get(0) : alleleFreqs);
}
else {
attributes.put(VCFConstants.ALLELE_COUNT_KEY, 0);
attributes.put(VCFConstants.ALLELE_FREQUENCY_KEY, 0.0);
}
attributes.put(VCFConstants.ALLELE_COUNT_KEY, alleleCounts);
attributes.put(VCFConstants.ALLELE_FREQUENCY_KEY, alleleFreqs);
}
else {
attributes.put(VCFConstants.ALLELE_COUNT_KEY, 0);
attributes.put(VCFConstants.ALLELE_FREQUENCY_KEY, 0.0);
}
}

View File

@ -156,6 +156,13 @@ public class VCFUtils {
// values varies, is unknown, or is unbounded, then this value should be '.'.
if ( logger != null ) logger.warn("Promoting header field Number to . due to number differences in header lines: " + line + " " + other);
compOther.setNumberToUnbounded();
} else if ( compLine.getType() == VCFHeaderLineType.Integer && compOther.getType() == VCFHeaderLineType.Float ) {
// promote key to Float
if ( logger != null ) logger.warn("Promoting Integer to Float in header: " + compOther);
map.put(key, compOther);
} else if ( compLine.getType() == VCFHeaderLineType.Float && compOther.getType() == VCFHeaderLineType.Integer ) {
// promote key to Float
if ( logger != null ) logger.warn("Promoting Integer to Float in header: " + compOther);
} else {
throw new IllegalStateException("Incompatible header types, collision between these two types: " + line + " " + other );
}

View File

@ -87,7 +87,7 @@ public class CombineVariantsIntegrationTest extends WalkerTest {
" -priority NA19240_BGI,NA19240_ILLUMINA,NA19240_WUGSC,denovoInfo" +
" -genotypeMergeOptions UNIQUIFY -L 1"),
1,
Arrays.asList("00c431243201e7dec99c2c1a1a863438"));
Arrays.asList("a07995587b855f3214fb71940bf23c0f"));
executeTest("threeWayWithRefs", spec);
}