public int getCount() { if ( ! isFixedCount() ) throw new TribbleException("Asking for header line count when type is not an integer"); return count; }
public int getCount() { if (!isFixedCount()) throw new TribbleException("Asking for header line count when type is not an integer"); return count; }
public int getCount() { if (!isFixedCount()) throw new TribbleException("Asking for header line count when type is not an integer"); return count; }
public Flag(final VCFCompoundHeaderLine headerLine, final Map<String, Integer> dict ) { super(headerLine, dict, BCF2Type.INT8); if ( ! headerLine.isFixedCount() || headerLine.getCount() != 0 ) throw new IllegalStateException("Flag encoder only supports atomic flags for field " + getField()); }
public Flag(final VCFCompoundHeaderLine headerLine, final Map<String, Integer> dict ) { super(headerLine, dict, BCF2Type.INT8); if ( ! headerLine.isFixedCount() || headerLine.getCount() != 0 ) throw new IllegalStateException("Flag encoder only supports atomic flags for field " + getField()); }
public Flag(final VCFCompoundHeaderLine headerLine, final Map<String, Integer> dict ) { super(headerLine, dict, BCF2Type.INT8); if ( ! headerLine.isFixedCount() || headerLine.getCount() != 0 ) throw new IllegalStateException("Flag encoder only supports atomic flags for field " + getField()); }
private VariantSetMetadata convert(VCFCompoundHeaderLine hl) { VariantSetMetadata vsm = convertHeaderLine((VCFHeaderLine) hl); vsm.setId(hl.getID()); if (hl.isFixedCount()) { vsm.setNumber(Integer.toString(hl.getCount())); } else { vsm.setNumber(hl.getCountType().name()); } vsm.setType(hl.getType().name()); vsm.setDescription(hl.getDescription()); // Empty for the moment Map<String, List<String>> infoMap = Collections.emptyMap(); vsm.setInfo(infoMap); return vsm; }
private BCF2FieldEncoder createFieldEncoder(final VCFCompoundHeaderLine line, final BCF2Encoder encoder, final Map<String, Integer> dict, final boolean createGenotypesEncoders ) { if ( createGenotypesEncoders && intGenotypeFieldAccessors.getAccessor(line.getID()) != null ) { if ( GeneralUtils.DEBUG_MODE_ENABLED && line.getType() != VCFHeaderLineType.Integer ) System.err.println("Warning: field " + line.getID() + " expected to encode an integer but saw " + line.getType() + " for record " + line); return new BCF2FieldEncoder.IntArray(line, dict); } else if ( createGenotypesEncoders && line.getID().equals(VCFConstants.GENOTYPE_KEY) ) { return new BCF2FieldEncoder.GenericInts(line, dict); } else { switch ( line.getType() ) { case Character: case String: return new BCF2FieldEncoder.StringOrCharacter(line, dict); case Flag: return new BCF2FieldEncoder.Flag(line, dict); case Float: return new BCF2FieldEncoder.Float(line, dict); case Integer: if ( line.isFixedCount() && line.getCount() == 1 ) return new BCF2FieldEncoder.AtomicInt(line, dict); else return new BCF2FieldEncoder.GenericInts(line, dict); default: throw new IllegalArgumentException("Unexpected type for field " + line.getID()); } } }
private BCF2FieldEncoder createFieldEncoder(final VCFCompoundHeaderLine line, final BCF2Encoder encoder, final Map<String, Integer> dict, final boolean createGenotypesEncoders ) { if ( createGenotypesEncoders && intGenotypeFieldAccessors.getAccessor(line.getID()) != null ) { if ( GeneralUtils.DEBUG_MODE_ENABLED && line.getType() != VCFHeaderLineType.Integer ) System.err.println("Warning: field " + line.getID() + " expected to encode an integer but saw " + line.getType() + " for record " + line); return new BCF2FieldEncoder.IntArray(line, dict); } else if ( createGenotypesEncoders && line.getID().equals(VCFConstants.GENOTYPE_KEY) ) { return new BCF2FieldEncoder.GenericInts(line, dict); } else { switch ( line.getType() ) { case Character: case String: return new BCF2FieldEncoder.StringOrCharacter(line, dict); case Flag: return new BCF2FieldEncoder.Flag(line, dict); case Float: return new BCF2FieldEncoder.Float(line, dict); case Integer: if ( line.isFixedCount() && line.getCount() == 1 ) return new BCF2FieldEncoder.AtomicInt(line, dict); else return new BCF2FieldEncoder.GenericInts(line, dict); default: throw new IllegalArgumentException("Unexpected type for field " + line.getID()); } } }
private BCF2FieldEncoder createFieldEncoder(final VCFCompoundHeaderLine line, final BCF2Encoder encoder, final Map<String, Integer> dict, final boolean createGenotypesEncoders ) { if ( createGenotypesEncoders && intGenotypeFieldAccessors.getAccessor(line.getID()) != null ) { if ( GeneralUtils.DEBUG_MODE_ENABLED && line.getType() != VCFHeaderLineType.Integer ) System.err.println("Warning: field " + line.getID() + " expected to encode an integer but saw " + line.getType() + " for record " + line); return new BCF2FieldEncoder.IntArray(line, dict); } else if ( createGenotypesEncoders && line.getID().equals(VCFConstants.GENOTYPE_KEY) ) { return new BCF2FieldEncoder.GenericInts(line, dict); } else { switch ( line.getType() ) { case Character: case String: return new BCF2FieldEncoder.StringOrCharacter(line, dict); case Flag: return new BCF2FieldEncoder.Flag(line, dict); case Float: return new BCF2FieldEncoder.Float(line, dict); case Integer: if ( line.isFixedCount() && line.getCount() == 1 ) return new BCF2FieldEncoder.AtomicInt(line, dict); else return new BCF2FieldEncoder.GenericInts(line, dict); default: throw new IllegalArgumentException("Unexpected type for field " + line.getID()); } } }
VCFCompoundHeaderLine vcfLine = (VCFCompoundHeaderLine) line; String number; if (vcfLine.isFixedCount()) { number = String.valueOf(vcfLine.getCount()); } else if (vcfLine.getCountType().equals(VCFHeaderLineCount.UNBOUNDED)) {
public T repair(final T line) { final T standard = get(line.getID(), false); if ( standard != null ) { final boolean badCountType = line.getCountType() != standard.getCountType(); final boolean badCount = line.isFixedCount() && ! badCountType && line.getCount() != standard.getCount(); final boolean badType = line.getType() != standard.getType(); final boolean badDesc = ! line.getDescription().equals(standard.getDescription()); final boolean needsRepair = badCountType || badCount || badType || (REPAIR_BAD_DESCRIPTIONS && badDesc); if ( needsRepair ) { if ( GeneralUtils.DEBUG_MODE_ENABLED ) { System.err.println("Repairing standard header line for field " + line.getID() + " because" + (badCountType ? " -- count types disagree; header has " + line.getCountType() + " but standard is " + standard.getCountType() : "") + (badType ? " -- type disagree; header has " + line.getType() + " but standard is " + standard.getType() : "") + (badCount ? " -- counts disagree; header has " + line.getCount() + " but standard is " + standard.getCount() : "") + (badDesc ? " -- descriptions disagree; header has '" + line.getDescription() + "' but standard is '" + standard.getDescription() + "'": "")); } return standard; } else { return line; } } else { return line; } }
public T repair(final T line) { final T standard = get(line.getID(), false); if ( standard != null ) { final boolean badCountType = line.getCountType() != standard.getCountType(); final boolean badCount = line.isFixedCount() && ! badCountType && line.getCount() != standard.getCount(); final boolean badType = line.getType() != standard.getType(); final boolean badDesc = ! line.getDescription().equals(standard.getDescription()); final boolean needsRepair = badCountType || badCount || badType || (REPAIR_BAD_DESCRIPTIONS && badDesc); if ( needsRepair ) { if ( GeneralUtils.DEBUG_MODE_ENABLED ) { System.err.println("Repairing standard header line for field " + line.getID() + " because" + (badCountType ? " -- count types disagree; header has " + line.getCountType() + " but standard is " + standard.getCountType() : "") + (badType ? " -- type disagree; header has " + line.getType() + " but standard is " + standard.getType() : "") + (badCount ? " -- counts disagree; header has " + line.getCount() + " but standard is " + standard.getCount() : "") + (badDesc ? " -- descriptions disagree; header has '" + line.getDescription() + "' but standard is '" + standard.getDescription() + "'": "")); } return standard; } else { return line; } } else { return line; } }
@Requires("line != null") @Ensures({"result != null", "result.getID().equals(line.getID())"}) public T repair(final T line) { final T standard = get(line.getID(), false); if ( standard != null ) { final boolean badCountType = line.getCountType() != standard.getCountType(); final boolean badCount = line.isFixedCount() && ! badCountType && line.getCount() != standard.getCount(); final boolean badType = line.getType() != standard.getType(); final boolean badDesc = ! line.getDescription().equals(standard.getDescription()); final boolean needsRepair = badCountType || badCount || badType || (REPAIR_BAD_DESCRIPTIONS && badDesc); if ( needsRepair ) { if ( GeneralUtils.DEBUG_MODE_ENABLED ) { System.err.println("Repairing standard header line for field " + line.getID() + " because" + (badCountType ? " -- count types disagree; header has " + line.getCountType() + " but standard is " + standard.getCountType() : "") + (badType ? " -- type disagree; header has " + line.getType() + " but standard is " + standard.getType() : "") + (badCount ? " -- counts disagree; header has " + line.getCount() + " but standard is " + standard.getCount() : "") + (badDesc ? " -- descriptions disagree; header has '" + line.getDescription() + "' but standard is '" + standard.getDescription() + "'": "")); } return standard; } else return line; } else return line; }