/** * Name of the VCF filter * @return */ public String filter() { return filterheader.getID(); } /**
private static void addFilterLine(final VCFFilterHeaderLine line) { filterLines.put(line.getID(), line); }
/** * Check the filter declarations in the input VCF header to see if any ApplyRecalibration mode has been run * Here we assume that the tranches are named with a specific format: VQSRTranche[SNP|INDEL][lowerLimit]to[upperLimit] * @param inputHeaders */ private void checkForPreviousApplyRecalRun(final Set<VCFHeaderLine> inputHeaders) { for(final VCFHeaderLine header : inputHeaders) { if(header instanceof VCFFilterHeaderLine) { final String filterName = ((VCFFilterHeaderLine)header).getID(); if(filterName.length() < 12 || !filterName.substring(0, 11).equalsIgnoreCase(trancheFilterString)) { continue; } if(filterName.charAt(11) == 'S') { //for SNP tranches, get sensitivity limit final String sensitivityLimits = filterName.substring(14); if(trancheIntervalIsValid(sensitivityLimits)) foundSNPTranches = true; } else if(filterName.charAt(11) == 'I') { //for INDEL tranches, get sensitivity limit final String sensitivityLimits = filterName.substring(16); if(trancheIntervalIsValid(sensitivityLimits)) foundINDELTranches = true; } } } }
/** * load the format/info meta data maps (these are used for quick lookup by key name) */ private void loadMetaDataMaps() { for (final VCFHeaderLine line : mMetaData) { if ( line instanceof VCFInfoHeaderLine ) { final VCFInfoHeaderLine infoLine = (VCFInfoHeaderLine)line; addMetaDataMapBinding(mInfoMetaData, infoLine); } else if ( line instanceof VCFFormatHeaderLine ) { final VCFFormatHeaderLine formatLine = (VCFFormatHeaderLine)line; addMetaDataMapBinding(mFormatMetaData, formatLine); } else if ( line instanceof VCFFilterHeaderLine ) { final VCFFilterHeaderLine filterLine = (VCFFilterHeaderLine)line; mFilterMetaData.put(filterLine.getID(), filterLine); } else if ( line instanceof VCFContigHeaderLine ) { contigMetaData.add((VCFContigHeaderLine)line); } else { mOtherMetaData.put(line.getKey(), line); } } if ( hasFormatLine(VCFConstants.GENOTYPE_LIKELIHOODS_KEY) && ! hasFormatLine(VCFConstants.GENOTYPE_PL_KEY) ) { if ( GeneralUtils.DEBUG_MODE_ENABLED ) { System.err.println("Found " + VCFConstants.GENOTYPE_LIKELIHOODS_KEY + " format, but no " + VCFConstants.GENOTYPE_PL_KEY + " field. We now only manage PL fields internally" + " automatically adding a corresponding PL field to your VCF header"); } addMetaDataLine(new VCFFormatHeaderLine(VCFConstants.GENOTYPE_PL_KEY, VCFHeaderLineCount.G, VCFHeaderLineType.Integer, "Normalized, Phred-scaled likelihoods for genotypes as defined in the VCF specification")); } }
throw new IllegalStateException("Incompatible header types: " + line + " " + other ); } else if ( line instanceof VCFFilterHeaderLine ) { String lineName = ((VCFFilterHeaderLine) line).getID(); String otherName = ((VCFFilterHeaderLine) other).getID(); if ( ! lineName.equals(otherName) ) throw new IllegalStateException("Incompatible header types: " + line + " " + other );
throw new IllegalStateException("Incompatible header types: " + line + " " + other); } else if (line instanceof VCFFilterHeaderLine) { final String lineName = ((VCFFilterHeaderLine) line).getID(); final String otherName = ((VCFFilterHeaderLine) other).getID(); if (!lineName.equals(otherName)) throw new IllegalStateException("Incompatible header types: " + line + " " + other);
throw new IllegalStateException("Incompatible header types: " + line + " " + other); } else if (line instanceof VCFFilterHeaderLine) { final String lineName = ((VCFFilterHeaderLine) line).getID(); final String otherName = ((VCFFilterHeaderLine) other).getID(); if (!lineName.equals(otherName)) throw new IllegalStateException("Incompatible header types: " + line + " " + other);
/** * Add a single header line to the appropriate type-specific lookup table (but NOT to the master * list of lines in mMetaData -- this must be done separately if desired). * * If a header line is present that has the same key as an existing line, it will not be added. A warning * will be shown if this occurs when GeneralUtils.DEBUG_MODE_ENABLED is true, otherwise this will occur * silently. * * @param line header line to attempt to add to its type-specific lookup table * @return true if the line was added to the appropriate lookup table, false if there was an existing * line with the same key and the new line was not added */ private boolean addMetadataLineLookupEntry(final VCFHeaderLine line) { if ( line instanceof VCFInfoHeaderLine ) { final VCFInfoHeaderLine infoLine = (VCFInfoHeaderLine)line; return addMetaDataLineMapLookupEntry(mInfoMetaData, infoLine.getID(), infoLine); } else if ( line instanceof VCFFormatHeaderLine ) { final VCFFormatHeaderLine formatLine = (VCFFormatHeaderLine)line; return addMetaDataLineMapLookupEntry(mFormatMetaData, formatLine.getID(), formatLine); } else if ( line instanceof VCFFilterHeaderLine ) { final VCFFilterHeaderLine filterLine = (VCFFilterHeaderLine)line; return addMetaDataLineMapLookupEntry(mFilterMetaData, filterLine.getID(), filterLine); } else if ( line instanceof VCFContigHeaderLine ) { return addContigMetaDataLineLookupEntry((VCFContigHeaderLine) line); } else { return addMetaDataLineMapLookupEntry(mOtherMetaData, line.getKey(), line); } }
/** * Add a single header line to the appropriate type-specific lookup table (but NOT to the master * list of lines in mMetaData -- this must be done separately if desired). * * If a header line is present that has the same key as an existing line, it will not be added. A warning * will be shown if this occurs when GeneralUtils.DEBUG_MODE_ENABLED is true, otherwise this will occur * silently. * * @param line header line to attempt to add to its type-specific lookup table * @return true if the line was added to the appropriate lookup table, false if there was an existing * line with the same key and the new line was not added */ private boolean addMetadataLineLookupEntry(final VCFHeaderLine line) { if ( line instanceof VCFInfoHeaderLine ) { final VCFInfoHeaderLine infoLine = (VCFInfoHeaderLine)line; return addMetaDataLineMapLookupEntry(mInfoMetaData, infoLine.getID(), infoLine); } else if ( line instanceof VCFFormatHeaderLine ) { final VCFFormatHeaderLine formatLine = (VCFFormatHeaderLine)line; return addMetaDataLineMapLookupEntry(mFormatMetaData, formatLine.getID(), formatLine); } else if ( line instanceof VCFFilterHeaderLine ) { final VCFFilterHeaderLine filterLine = (VCFFilterHeaderLine)line; return addMetaDataLineMapLookupEntry(mFilterMetaData, filterLine.getID(), filterLine); } else if ( line instanceof VCFContigHeaderLine ) { return addContigMetaDataLineLookupEntry((VCFContigHeaderLine) line); } else { return addMetaDataLineMapLookupEntry(mOtherMetaData, line.getKey(), line); } }
VCFFilterHeaderLine filterHeaderLine = (VCFFilterHeaderLine) headerLine; infoBuilder.setName(filterHeaderLine.getID());