Bugfixes on way to a working refactored VariantContext

This commit is contained in:
Mark DePristo 2011-11-15 17:20:14 -05:00
parent 231c47c039
commit 0be23aae4e
2 changed files with 13 additions and 3 deletions

View File

@ -24,6 +24,7 @@
package org.broadinstitute.sting.gatk.walkers.diffengine; package org.broadinstitute.sting.gatk.walkers.diffengine;
import org.apache.log4j.Logger;
import org.broad.tribble.readers.AsciiLineReader; import org.broad.tribble.readers.AsciiLineReader;
import org.broad.tribble.readers.LineReader; import org.broad.tribble.readers.LineReader;
import org.broadinstitute.sting.utils.codecs.vcf.*; import org.broadinstitute.sting.utils.codecs.vcf.*;
@ -46,6 +47,8 @@ import java.util.Map;
* Class implementing diffnode reader for VCF * Class implementing diffnode reader for VCF
*/ */
public class VCFDiffableReader implements DiffableReader { public class VCFDiffableReader implements DiffableReader {
private static Logger logger = Logger.getLogger(VCFDiffableReader.class);
@Override @Override
public String getName() { return "VCF"; } public String getName() { return "VCF"; }
@ -68,6 +71,9 @@ public class VCFDiffableReader implements DiffableReader {
String key = headerLine.getKey(); String key = headerLine.getKey();
if ( headerLine instanceof VCFNamedHeaderLine ) if ( headerLine instanceof VCFNamedHeaderLine )
key += "_" + ((VCFNamedHeaderLine) headerLine).getName(); key += "_" + ((VCFNamedHeaderLine) headerLine).getName();
if ( root.hasElement(key) )
logger.warn("Skipping duplicate header line: file=" + file + " line=" + headerLine.toString());
else
root.add(key, headerLine.toString()); root.add(key, headerLine.toString());
} }

View File

@ -388,11 +388,15 @@ public class VariantContext implements Feature { // to enable tribble intergrati
if ( this.ID.equals("") ) throw new IllegalArgumentException("ID field cannot be the empty string"); if ( this.ID.equals("") ) throw new IllegalArgumentException("ID field cannot be the empty string");
if ( !genotypesAreUnparsed && attributes != null ) { if ( !genotypesAreUnparsed && attributes != null ) {
if ( attributes.containsKey(UNPARSED_GENOTYPE_MAP_KEY) ) if ( attributes.containsKey(UNPARSED_GENOTYPE_MAP_KEY) ) {
attributes = new HashMap<String, Object>(attributes);
attributes.remove(UNPARSED_GENOTYPE_MAP_KEY); attributes.remove(UNPARSED_GENOTYPE_MAP_KEY);
if ( attributes.containsKey(UNPARSED_GENOTYPE_PARSER_KEY) ) }
if ( attributes.containsKey(UNPARSED_GENOTYPE_PARSER_KEY) ) {
attributes = new HashMap<String, Object>(attributes);
attributes.remove(UNPARSED_GENOTYPE_PARSER_KEY); attributes.remove(UNPARSED_GENOTYPE_PARSER_KEY);
} }
}
this.commonInfo = new CommonInfo(source, negLog10PError, filters, attributes); this.commonInfo = new CommonInfo(source, negLog10PError, filters, attributes);
filtersWereAppliedToContext = filters != null; filtersWereAppliedToContext = filters != null;