public class VariantContextBuilder
extends java.lang.Object
Builder class for VariantContext
.
Some basic assumptions here:
builder.source("a").genotypes(gc).id("x").make()
=>VariantContext
new VariantContextBuilder(vc).make()
=> a copy of VC
make()
call, so a
VariantContextBuilder
can exist in an inconsistent state as long as those issues
are resolved before the call to make()
is issued.
Constructor and Description |
---|
VariantContextBuilder()
Create an empty VariantContextBuilder where all values adopt their default values.
|
VariantContextBuilder(java.lang.String source,
java.lang.String contig,
long start,
long stop,
java.util.Collection<Allele> alleles)
Create an empty VariantContextBuilder where all values adopt their default values, but the bare min.
|
VariantContextBuilder(VariantContext parent)
Returns a new builder based on parent -- the new VC will have all fields initialized
to their corresponding values in parent.
|
VariantContextBuilder(VariantContextBuilder parent) |
Modifier and Type | Method and Description |
---|---|
VariantContextBuilder |
alleles(java.util.Collection<Allele> alleles)
Tells this builder to use this collection of alleles for the resulting VariantContext
|
VariantContextBuilder |
alleles(java.util.List<java.lang.String> alleleStrings) |
VariantContextBuilder |
alleles(java.lang.String... alleleStrings) |
VariantContextBuilder |
attribute(java.lang.String key,
java.lang.Object value)
Puts the key -> value mapping into this builder's attributes
|
VariantContextBuilder |
attributes(java.util.Map<java.lang.String,?> attributes)
Tells this builder to use this map of attributes for the resulting
VariantContext . |
VariantContextBuilder |
chr(java.lang.String contig)
Tells us that the resulting VariantContext should have the specified contig chr
|
VariantContextBuilder |
computeEndFromAlleles(java.util.List<Allele> alleles,
int start) |
VariantContextBuilder |
computeEndFromAlleles(java.util.List<Allele> alleles,
int start,
int endForSymbolicAlleles)
Compute the end position for this VariantContext from the alleles themselves
assigns this builder the stop position computed.
|
VariantContextBuilder |
copy() |
VariantContextBuilder |
filter(java.lang.String filter)
Adds the given filter to the list of filters
|
VariantContextBuilder |
filters(java.util.Set<java.lang.String> filters)
This builder's filters are set to this value
filters can be
null -> meaning there are no filters |
VariantContextBuilder |
filters(java.lang.String... filters)
|
VariantContextBuilder |
fullyDecoded(boolean isFullyDecoded)
Sets this builder's fully decoded state to true.
|
VariantContextBuilder |
genotypes(java.util.Collection<Genotype> genotypes)
Tells this builder that the resulting
VariantContext should use a GenotypeContext containing genotypes
Note that genotypes can be null , meaning there are no genotypes |
VariantContextBuilder |
genotypes(Genotype... genotypes)
Tells this builder that the resulting
VariantContext should use a GenotypeContext containing genotypes |
VariantContextBuilder |
genotypes(GenotypesContext genotypes)
Tells this builder that the resulting
VariantContext should use this genotype's GenotypeContext . |
VariantContextBuilder |
genotypesNoValidation(GenotypesContext genotypes) |
java.util.List<Allele> |
getAlleles() |
java.util.Map<java.lang.String,java.lang.Object> |
getAttributes()
Getter for attributes (DANGEROUS!!! DOES NOT MAKE A COPY!!!)
|
java.lang.String |
getContig()
Getter for contig
|
java.util.Set<java.lang.String> |
getFilters()
Getter for filters (DANGEROUS!!! DOES NOT MAKE A COPY!!!)
|
GenotypesContext |
getGenotypes()
Getter for genotypes (DANGEROUS!!! DOES NOT MAKE A COPY!!!)
|
java.lang.String |
getID()
Getter for id of variant
|
long |
getStart()
Getter for start position
|
long |
getStop()
Getter for stop position
|
VariantContextBuilder |
id(java.lang.String ID)
Tells us that the resulting VariantContext should have ID
|
boolean |
isFullyDecoded() |
VariantContextBuilder |
loc(java.lang.String contig,
long start,
long stop)
Tells us that the resulting VariantContext should have the specified location
|
VariantContextBuilder |
log10PError(double log10PError)
Tells us that the resulting VariantContext should have log10PError
|
VariantContext |
make()
Takes all of the builder data provided up to this point, and instantiates
a freshly allocated VariantContext with all of the builder data.
|
VariantContext |
make(boolean leaveModifyableAsIs) |
VariantContextBuilder |
noGenotypes()
Tells this builder that the resulting VariantContext should not contain any GenotypeContext
|
VariantContextBuilder |
noID()
Tells us that the resulting VariantContext should not have an ID
|
VariantContextBuilder |
passFilters()
Tells this builder that the resulting VariantContext should have PASS filters
|
VariantContextBuilder |
putAttributes(java.util.Map<java.lang.String,?> attributes)
Tells this builder to put this map of attributes into the resulting
VariantContext . |
VariantContextBuilder |
rmAttribute(java.lang.String key)
Removes key if present in the attributes
|
VariantContextBuilder |
rmAttributes(java.util.List<java.lang.String> keys)
Removes list of keys if present in the attributes
|
VariantContextBuilder |
source(java.lang.String source)
Tells us that the resulting VariantContext should have source field set to source
|
VariantContextBuilder |
start(long start)
Tells us that the resulting VariantContext should have the specified contig start
|
VariantContextBuilder |
stop(long stop)
Tells us that the resulting VariantContext should have the specified contig stop
|
VariantContextBuilder |
unfiltered()
Tells this builder that the resulting VariantContext be unfiltered
|
public VariantContextBuilder()
public VariantContextBuilder(java.lang.String source, java.lang.String contig, long start, long stop, java.util.Collection<Allele> alleles)
public VariantContextBuilder(VariantContext parent)
parent
- Cannot be nullpublic VariantContextBuilder(VariantContextBuilder parent)
public java.lang.String getContig()
public long getStart()
public long getStop()
public java.lang.String getID()
public GenotypesContext getGenotypes()
public java.util.Set<java.lang.String> getFilters()
public java.util.Map<java.lang.String,java.lang.Object> getAttributes()
public VariantContextBuilder copy()
public VariantContextBuilder alleles(java.util.Collection<Allele> alleles)
alleles
- a Collection of alleles to set as the alleles of this builderpublic VariantContextBuilder alleles(java.util.List<java.lang.String> alleleStrings)
public VariantContextBuilder alleles(java.lang.String... alleleStrings)
public java.util.List<Allele> getAlleles()
public VariantContextBuilder attributes(java.util.Map<java.lang.String,?> attributes)
VariantContext
. The
contents of the Map are copied to a new Map to ensure that modifications to the provided Map post-invocation
don't affect the VariantContext and also to ensure additional attributes can be added in case the provided
map doesn't support changes (e.g. UnmodifiableMap).
Attributes can be null
-> meaning there are no attributes. After
calling this routine the builder assumes it can modify the attributes
object here, if subsequent calls are made to set attribute values
Value for each attribute must be of a type that implements Serializable
or else
serialization will fail.attributes
- a Map of attributes to replace existing attributes withpublic VariantContextBuilder putAttributes(java.util.Map<java.lang.String,?> attributes)
VariantContext
. The
contents of the Map are copied to the current Map (or a new one is created if null)
After calling this routine the builder assumes it can modify the attributes
object here, if subsequent calls are made to set attribute values
Value for each attribute must be of a type that implements Serializable
or else
serialization will fail.attributes
- a Map of attributes to complement any existing attributes with, overwriting any that
share the same key.public VariantContextBuilder attribute(java.lang.String key, java.lang.Object value)
key
- key for the attributevalue
- value for the attribute (must be of a type that implements Serializable
or else serialization will fail)public VariantContextBuilder rmAttribute(java.lang.String key)
key
- key to removepublic VariantContextBuilder rmAttributes(java.util.List<java.lang.String> keys)
keys
- list of keys to removepublic VariantContextBuilder filters(java.util.Set<java.lang.String> filters)
null
-> meaning there are no filtersfilters
- Set of strings to set as the filters for this builder
This set will be copied so that external set can be
safely changed.public VariantContextBuilder filters(java.lang.String... filters)
filters
- Strings to set as the filters for this builderpublic VariantContextBuilder filter(java.lang.String filter)
filter
- public VariantContextBuilder passFilters()
public VariantContextBuilder unfiltered()
public VariantContextBuilder genotypes(GenotypesContext genotypes)
VariantContext
should use this genotype's GenotypeContext
.
Note that this method will call the immutable method on the provided genotypes object
to ensure that the user will not modify it further.
Note that genotypes can be null
-> meaning there are no genotypesgenotypes
- GenotypeContext to use in this builderpublic VariantContextBuilder genotypesNoValidation(GenotypesContext genotypes)
public VariantContextBuilder genotypes(java.util.Collection<Genotype> genotypes)
VariantContext
should use a GenotypeContext
containing genotypes
Note that genotypes can be null
, meaning there are no genotypesgenotypes
- Collection of genotypes to set as genotypes for this builderpublic VariantContextBuilder genotypes(Genotype... genotypes)
VariantContext
should use a GenotypeContext
containing genotypesgenotypes
- genotypes to set as genotypes for this builderpublic VariantContextBuilder noGenotypes()
public VariantContextBuilder id(java.lang.String ID)
ID
- id of variantpublic VariantContextBuilder noID()
public VariantContextBuilder log10PError(double log10PError)
log10PError
- value of QUAL field for this builderpublic VariantContextBuilder source(java.lang.String source)
source
- string describing the source of the variantpublic VariantContextBuilder loc(java.lang.String contig, long start, long stop)
contig
- the contig the variant is on (must be in the dictionary)start
- the start position of the variantstop
- the end position of the variantpublic VariantContextBuilder chr(java.lang.String contig)
contig
- the contig of the variantpublic VariantContextBuilder start(long start)
start
- the start position of the variantpublic VariantContextBuilder stop(long stop)
stop
- the stop position of the variantpublic VariantContextBuilder computeEndFromAlleles(java.util.List<Allele> alleles, int start)
with endForSymbolicAlleles == -1
public VariantContextBuilder computeEndFromAlleles(java.util.List<Allele> alleles, int start, int endForSymbolicAlleles)
alleles
- the list of alleles to consider. The reference allele must be the first onestart
- the known start position of this eventendForSymbolicAlleles
- the end position to use if any of the alleles is symbolic. Can be -1
if no is expected but will throw an error if one is foundpublic boolean isFullyDecoded()
public VariantContextBuilder fullyDecoded(boolean isFullyDecoded)
isFullyDecoded
- public VariantContext make()
public VariantContext make(boolean leaveModifyableAsIs)