public VariantContextBuilder(final VariantContextBuilder parent) { if ( parent == null ) throw new IllegalArgumentException("BUG: VariantContext parent argument cannot be null in VariantContextBuilder"); this.alleles = parent.alleles; this.attributesCanBeModified = false; this.contig = parent.contig; this.genotypes = parent.genotypes; this.ID = parent.ID; this.log10PError = parent.log10PError; this.source = parent.source; this.start = parent.start; this.stop = parent.stop; this.fullyDecoded = parent.fullyDecoded; this.attributes(parent.attributes); this.filters(parent.filters); }
public VariantContextBuilder(final VariantContextBuilder parent) { if ( parent == null ) throw new IllegalArgumentException("BUG: VariantContext parent argument cannot be null in VariantContextBuilder"); this.alleles = parent.alleles; this.attributesCanBeModified = false; this.contig = parent.contig; this.genotypes = parent.genotypes; this.ID = parent.ID; this.log10PError = parent.log10PError; this.source = parent.source; this.start = parent.start; this.stop = parent.stop; this.fullyDecoded = parent.fullyDecoded; this.attributes(parent.attributes); this.filters(parent.filters); }
public VariantContextBuilder(VariantContextBuilder parent) { if ( parent == null ) throw new IllegalArgumentException("BUG: VariantContext parent argument cannot be null in VariantContextBuilder"); this.alleles = parent.alleles; this.attributesCanBeModified = false; this.contig = parent.contig; this.genotypes = parent.genotypes; this.ID = parent.ID; this.log10PError = parent.log10PError; this.source = parent.source; this.start = parent.start; this.stop = parent.stop; this.fullyDecoded = parent.fullyDecoded; this.attributes(parent.attributes); this.filters(parent.filters); }
private void writeOne(final VariantContext vc, final String set, final String status) { final Map<String, Object> attrs = new HashMap<>(); if ( SET_KEY != null && set != null ) attrs.put(SET_KEY, set); if ( STATUS_KEY != null && status != null ) attrs.put(STATUS_KEY, status); writer.add(new VariantContextBuilder(vc).attributes(attrs).make()); }
/** * Update the attributes of the attributes map in the VariantContextBuilder to reflect the proper * chromosome-based VCF tags based on the current VC produced by builder.make() * * @param builder the VariantContextBuilder we are updating * @param removeStaleValues should we remove stale values from the mapping? */ public static void calculateChromosomeCounts(VariantContextBuilder builder, boolean removeStaleValues) { VariantContext vc = builder.make(); builder.attributes(calculateChromosomeCounts(vc, new HashMap<>(vc.getAttributes()), removeStaleValues, new HashSet<>(0))); }
/** * Update the attributes of the attributes map in the VariantContextBuilder to reflect the proper * chromosome-based VCF tags based on the current VC produced by builder.make() * * @param builder the VariantContextBuilder we are updating * @param removeStaleValues should we remove stale values from the mapping? */ public static void calculateChromosomeCounts(VariantContextBuilder builder, boolean removeStaleValues) { VariantContext vc = builder.make(); builder.attributes(calculateChromosomeCounts(vc, new HashMap<>(vc.getAttributes()), removeStaleValues, new HashSet<>(0))); }
/** * Update the attributes of the attributes map in the VariantContextBuilder to reflect the proper * chromosome-based VCF tags based on the current VC produced by builder.make() * * @param builder the VariantContextBuilder we are updating * @param removeStaleValues should we remove stale values from the mapping? */ public static void calculateChromosomeCounts(VariantContextBuilder builder, boolean removeStaleValues) { VariantContext vc = builder.make(); builder.attributes(calculateChromosomeCounts(vc, new HashMap<String, Object>(vc.getAttributes()), removeStaleValues, new HashSet<String>(0))); }
private final void fullyDecodeInfo(final VariantContextBuilder builder, final VCFHeader header, final boolean lenientDecoding) { builder.attributes(fullyDecodeAttributes(getAttributes(), header, lenientDecoding)); }
private final void fullyDecodeInfo(final VariantContextBuilder builder, final VCFHeader header, final boolean lenientDecoding) { builder.attributes(fullyDecodeAttributes(getAttributes(), header, lenientDecoding)); }
private final void fullyDecodeInfo(final VariantContextBuilder builder, final VCFHeader header, final boolean lenientDecoding) { builder.attributes(fullyDecodeAttributes(getAttributes(), header, lenientDecoding)); }
/** * Update the attributes of the attributes map in the VariantContextBuilder to reflect the proper * chromosome-based VCF tags based on the current VC produced by builder.make() * * @param builder the VariantContextBuilder we are updating * @param founderIds - Set of founders to take into account. AF and FC will be calculated over the founders only. * If empty or null, counts are generated for all samples as unrelated individuals * @param removeStaleValues should we remove stale values from the mapping? */ public static void calculateChromosomeCounts(VariantContextBuilder builder, boolean removeStaleValues, final Set<String> founderIds) { VariantContext vc = builder.make(); builder.attributes(calculateChromosomeCounts(vc, new HashMap<>(vc.getAttributes()), removeStaleValues, founderIds)); }
/** * Update the attributes of the attributes map in the VariantContextBuilder to reflect the proper * chromosome-based VCF tags based on the current VC produced by builder.make() * * @param builder the VariantContextBuilder we are updating * @param founderIds - Set of founders to take into account. AF and FC will be calculated over the founders only. * If empty or null, counts are generated for all samples as unrelated individuals * @param removeStaleValues should we remove stale values from the mapping? */ public static void calculateChromosomeCounts(VariantContextBuilder builder, boolean removeStaleValues, final Set<String> founderIds) { VariantContext vc = builder.make(); builder.attributes(calculateChromosomeCounts(vc, new HashMap<String, Object>(vc.getAttributes()), removeStaleValues, founderIds)); }
/** * Update the attributes of the attributes map in the VariantContextBuilder to reflect the proper * chromosome-based VCF tags based on the current VC produced by builder.make() * * @param builder the VariantContextBuilder we are updating * @param founderIds - Set of founders to take into account. AF and FC will be calculated over the founders only. * If empty or null, counts are generated for all samples as unrelated individuals * @param removeStaleValues should we remove stale values from the mapping? */ public static void calculateChromosomeCounts(VariantContextBuilder builder, boolean removeStaleValues, final Set<String> founderIds) { VariantContext vc = builder.make(); builder.attributes(calculateChromosomeCounts(vc, new HashMap<>(vc.getAttributes()), removeStaleValues, founderIds)); }
/** * 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); }
/** * Add genotyping-based annotations to the new VC * * @param originalAttributes the non-null annotations from the original VC * @param newVC the new non-null VC * @return a non-null VC */ private VariantContext addGenotypingAnnotations(final Map<String, Object> originalAttributes, final VariantContext newVC) { // we want to carry forward the attributes from the original VC but make sure to add the MLE-based annotations final Map<String, Object> attrs = new HashMap<>(originalAttributes); attrs.put(GATKVCFConstants.MLE_ALLELE_COUNT_KEY, newVC.getAttribute(GATKVCFConstants.MLE_ALLELE_COUNT_KEY)); attrs.put(GATKVCFConstants.MLE_ALLELE_FREQUENCY_KEY, newVC.getAttribute(GATKVCFConstants.MLE_ALLELE_FREQUENCY_KEY)); if (newVC.hasAttribute(GATKVCFConstants.NUMBER_OF_DISCOVERED_ALLELES_KEY)) attrs.put(GATKVCFConstants.NUMBER_OF_DISCOVERED_ALLELES_KEY, newVC.getAttribute(GATKVCFConstants.NUMBER_OF_DISCOVERED_ALLELES_KEY)); if (newVC.hasAttribute(GATKVCFConstants.AS_QUAL_KEY)) attrs.put(GATKVCFConstants.AS_QUAL_KEY, newVC.getAttribute(GATKVCFConstants.AS_QUAL_KEY)); return new VariantContextBuilder(newVC).attributes(attrs).make(); }
/** * 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); }
public VariantContext toVariantContext() { GenotypesContext gc = GenotypesContext.copy(this.genotypes.values()); return new VariantContextBuilder(name, contig, start, stop, alleles).id(id) .genotypes(gc).log10PError(log10PError).filters(filters).attributes(attributes).make(); }
private VariantContext createVCGeneral(final VCFHeader header, final String chrom, final int position) { final List<Allele> alleles = new ArrayList<Allele>(); final Map<String, Object> attributes = new HashMap<String,Object>(); final GenotypesContext genotypes = GenotypesContext.create(header.getGenotypeSamples().size()); alleles.add(Allele.create("A",true)); alleles.add(Allele.create("ACC",false)); attributes.put("DP","50"); for (final String name : header.getGenotypeSamples()) { final Genotype gt = new GenotypeBuilder(name,alleles.subList(1,2)).GQ(0).attribute("BB", "1").phased(true).make(); genotypes.add(gt); } return new VariantContextBuilder("RANDOM", chrom, position, position, alleles) .genotypes(genotypes).attributes(attributes).make(); }
public static VariantContextBuilder pruneVariantContext(final VariantContextBuilder builder, Collection<String> keysToPreserve ) { final VariantContext vc = builder.make(); if ( keysToPreserve == null ) keysToPreserve = Collections.emptyList(); // VC info final Map<String, Object> attributes = subsetAttributes(vc.getCommonInfo(), keysToPreserve); // Genotypes final GenotypesContext genotypes = GenotypesContext.create(vc.getNSamples()); for ( final Genotype g : vc.getGenotypes() ) { final GenotypeBuilder gb = new GenotypeBuilder(g); // remove AD, DP, PL, and all extended attributes, keeping just GT and GQ gb.noAD().noDP().noPL().noAttributes(); genotypes.add(gb.make()); } return builder.genotypes(genotypes).attributes(attributes); }