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) |
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() |
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 |
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 VariantContextBuilder copy()
public VariantContextBuilder alleles(java.util.Collection<Allele> alleles)
alleles
- public 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 any existing attributes withpublic 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
- public VariantContextBuilder filters(java.lang.String... filters)
filters
- public VariantContextBuilder filter(java.lang.String filter)
public VariantContextBuilder passFilters()
public VariantContextBuilder unfiltered()
public VariantContextBuilder genotypes(GenotypesContext genotypes)
VariantContext
should use this genotype's GenotypeContext
.
Note that genotypes can be null
-> meaning there are no genotypesgenotypes
- public 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
- public VariantContextBuilder genotypes(Genotype... genotypes)
VariantContext
should use a GenotypeContext
containing genotypesgenotypes
- public VariantContextBuilder noGenotypes()
public VariantContextBuilder id(java.lang.String ID)
ID
- public VariantContextBuilder noID()
public VariantContextBuilder log10PError(double log10PError)
log10PError
- public VariantContextBuilder source(java.lang.String source)
source
- public VariantContextBuilder loc(java.lang.String contig, long start, long stop)
contig
- start
- stop
- public VariantContextBuilder chr(java.lang.String contig)
contig
- public VariantContextBuilder start(long start)
start
- public VariantContextBuilder stop(long stop)
stop
- public 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)