From e99871f587dca0e0cb004fdce118c773c8de034b Mon Sep 17 00:00:00 2001 From: Mark DePristo Date: Fri, 4 Nov 2011 13:20:54 -0400 Subject: [PATCH] Bug fix for decode loc -- decodeLoc() wasn't skipping input header lines, so the system blew up when there was an = line being split. --- .../utils/codecs/vcf/AbstractVCFCodec.java | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/public/java/src/org/broadinstitute/sting/utils/codecs/vcf/AbstractVCFCodec.java b/public/java/src/org/broadinstitute/sting/utils/codecs/vcf/AbstractVCFCodec.java index 3212e3904..0e0cb14bf 100755 --- a/public/java/src/org/broadinstitute/sting/utils/codecs/vcf/AbstractVCFCodec.java +++ b/public/java/src/org/broadinstitute/sting/utils/codecs/vcf/AbstractVCFCodec.java @@ -163,19 +163,26 @@ public abstract class AbstractVCFCodec implements FeatureCodec, NameAwareCodec, */ public Feature decodeLoc(String line) { lineNo++; - String[] locParts = new String[6]; + + // the same line reader is not used for parsing the header and parsing lines, if we see a #, we've seen a header line + if (line.startsWith(VCFHeader.HEADER_INDICATOR)) return null; + + // our header cannot be null, we need the genotype sample names and counts + if (header == null) throw new ReviewedStingException("VCF Header cannot be null when decoding a record"); + + final String[] locParts = new String[6]; int nParts = ParsingUtils.split(line, locParts, VCFConstants.FIELD_SEPARATOR_CHAR, true); if ( nParts != 6 ) throw new UserException.MalformedVCF("there aren't enough columns for line " + line, lineNo); // get our alleles (because the end position depends on them) - String ref = getCachedString(locParts[3].toUpperCase()); - String alts = getCachedString(locParts[4].toUpperCase()); - List alleles = parseAlleles(ref, alts, lineNo); + final String ref = getCachedString(locParts[3].toUpperCase()); + final String alts = getCachedString(locParts[4].toUpperCase()); + final List alleles = parseAlleles(ref, alts, lineNo); // find out our location - int start = Integer.valueOf(locParts[1]); + final int start = Integer.valueOf(locParts[1]); int stop = start; // ref alleles don't need to be single bases for monomorphic sites