/** * Loop over the info field key / value pairs in this BCF2 file and decode them into the builder * * @param builder * @param numInfoFields */ private void decodeInfo( final VariantContextBuilder builder, final int numInfoFields ) throws IOException { if ( numInfoFields == 0 ) // fast path, don't bother doing any work if there are no fields return; final Map<String, Object> infoFieldEntries = new HashMap<String, Object>(numInfoFields); for ( int i = 0; i < numInfoFields; i++ ) { final String key = getDictionaryString(); Object value = decoder.decodeTypedValue(); final VCFCompoundHeaderLine metaData = VariantContextUtils.getMetaDataForField(header, key); if ( metaData.getType() == VCFHeaderLineType.Flag ) value = true; // special case for flags infoFieldEntries.put(key, value); } builder.attributes(infoFieldEntries); }
/** * Loop over the info field key / value pairs in this BCF2 file and decode them into the builder * * @param builder * @param numInfoFields */ private void decodeInfo( final VariantContextBuilder builder, final int numInfoFields ) throws IOException { if ( numInfoFields == 0 ) // fast path, don't bother doing any work if there are no fields return; final Map<String, Object> infoFieldEntries = new HashMap<String, Object>(numInfoFields); for ( int i = 0; i < numInfoFields; i++ ) { final String key = getDictionaryString(); Object value = decoder.decodeTypedValue(); final VCFCompoundHeaderLine metaData = VariantContextUtils.getMetaDataForField(header, key); if ( metaData.getType() == VCFHeaderLineType.Flag ) value = true; // special case for flags infoFieldEntries.put(key, value); } builder.attributes(infoFieldEntries); }
private final Map<String, Object> fullyDecodeAttributes(final Map<String, Object> attributes, final VCFHeader header, final boolean lenientDecoding) { final Map<String, Object> newAttributes = new HashMap<>(10); for ( final Map.Entry<String, Object> attr : attributes.entrySet() ) { final String field = attr.getKey(); if ( field.equals(VCFConstants.GENOTYPE_FILTER_KEY) ) continue; // gross, FT is part of the extended attributes final VCFCompoundHeaderLine format = VariantContextUtils.getMetaDataForField(header, field); final Object decoded = decodeValue(field, attr.getValue(), format); if ( decoded != null && ! lenientDecoding && format.getCountType() != VCFHeaderLineCount.UNBOUNDED && format.getType() != VCFHeaderLineType.Flag ) { // we expect exactly the right number of elements final int obsSize = decoded instanceof List ? ((List) decoded).size() : 1; final int expSize = format.getCount(this); if ( obsSize != expSize ) { throw new TribbleException.InvalidHeader("Discordant field size detected for field " + field + " at " + getContig() + ":" + getStart() + ". Field had " + obsSize + " values " + "but the header says this should have " + expSize + " values based on header record " + format); } } newAttributes.put(field, decoded); } return newAttributes; }
private final Map<String, Object> fullyDecodeAttributes(final Map<String, Object> attributes, final VCFHeader header, final boolean lenientDecoding) { final Map<String, Object> newAttributes = new HashMap<>(10); for ( final Map.Entry<String, Object> attr : attributes.entrySet() ) { final String field = attr.getKey(); if ( field.equals(VCFConstants.GENOTYPE_FILTER_KEY) ) continue; // gross, FT is part of the extended attributes final VCFCompoundHeaderLine format = VariantContextUtils.getMetaDataForField(header, field); final Object decoded = decodeValue(field, attr.getValue(), format); if ( decoded != null && ! lenientDecoding && format.getCountType() != VCFHeaderLineCount.UNBOUNDED && format.getType() != VCFHeaderLineType.Flag ) { // we expect exactly the right number of elements final int obsSize = decoded instanceof List ? ((List) decoded).size() : 1; final int expSize = format.getCount(this); if ( obsSize != expSize ) { throw new TribbleException.InvalidHeader("Discordant field size detected for field " + field + " at " + getContig() + ":" + getStart() + ". Field had " + obsSize + " values " + "but the header says this should have " + expSize + " values based on header record " + format); } } newAttributes.put(field, decoded); } return newAttributes; }
private final Map<String, Object> fullyDecodeAttributes(final Map<String, Object> attributes, final VCFHeader header, final boolean lenientDecoding) { final Map<String, Object> newAttributes = new HashMap<String, Object>(10); for ( final Map.Entry<String, Object> attr : attributes.entrySet() ) { final String field = attr.getKey(); if ( field.equals(VCFConstants.GENOTYPE_FILTER_KEY) ) continue; // gross, FT is part of the extended attributes final VCFCompoundHeaderLine format = VariantContextUtils.getMetaDataForField(header, field); final Object decoded = decodeValue(field, attr.getValue(), format); if ( decoded != null && ! lenientDecoding && format.getCountType() != VCFHeaderLineCount.UNBOUNDED && format.getType() != VCFHeaderLineType.Flag ) { // we expect exactly the right number of elements final int obsSize = decoded instanceof List ? ((List) decoded).size() : 1; final int expSize = format.getCount(this); if ( obsSize != expSize ) { throw new TribbleException.InvalidHeader("Discordant field size detected for field " + field + " at " + getChr() + ":" + getStart() + ". Field had " + obsSize + " values " + "but the header says this should have " + expSize + " values based on header record " + format); } } newAttributes.put(field, decoded); } return newAttributes; }
/** * Loop over the info field key / value pairs in this BCF2 file and decode them into the builder * * @param builder * @param numInfoFields */ @Requires("numInfoFields >= 0") private void decodeInfo( final VariantContextBuilder builder, final int numInfoFields ) throws IOException { if ( numInfoFields == 0 ) // fast path, don't bother doing any work if there are no fields return; final Map<String, Object> infoFieldEntries = new HashMap<String, Object>(numInfoFields); for ( int i = 0; i < numInfoFields; i++ ) { final String key = getDictionaryString(); Object value = decoder.decodeTypedValue(); final VCFCompoundHeaderLine metaData = VariantContextUtils.getMetaDataForField(header, key); if ( metaData.getType() == VCFHeaderLineType.Flag ) value = true; // special case for flags infoFieldEntries.put(key, value); } builder.attributes(infoFieldEntries); }