Record Class VariantCall
- Record Components:
flag- Flag indicating the state of this variant call wrt. filters.depth- The total read depth at the variant site.entropy- The normalized entropy of the call.alternatives- A list of alternative alleles associated with the variant call.
This record encapsulates the details of a variant call, including:
- A flag indicating the state of this call (e.g., filtered due to low frequency, reference call).
- The total read depth at the variant site.
- The normalized entropy of the call, representing the uncertainty in the variant call.
- A list of alternative alleles associated with the variant call, represented as
VariantCall.CallAlternativeobjects.
Variant calls are not stored in the model directly, but utilized by the VCFProcessor class to process VCF files. String
representations (see toString()) of variant calls are stored with respect to a Sample in the Variant.samples
map.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final recordRepresents one alternative in the context of a variant call.static enumEnumeration of flags representing the status of a variant call.static classSerializer for theVariantCallclass. -
Constructor Summary
ConstructorsConstructorDescriptionVariantCall(VariantCall.Flag flag, short depth, float entropy, List<VariantCall.CallAlternative> alternatives) Creates an instance of aVariantCallrecord class. -
Method Summary
Modifier and TypeMethodDescriptionReturns the value of thealternativesrecord component.shortdepth()Returns the value of thedepthrecord component.floatentropy()Returns the value of theentropyrecord component.booleanCompares this variant call to another object for equality.flag()Returns the value of theflagrecord component.static VariantCallfromString(String s) Creates aVariantCallobject from its string representation.Retrieves the alternative content of the first (called) alternative of this variant call.getAlternative(int i) Retrieves the alternative content of the i-th alternative of this variant call.Retrieves the reference content of the first (called) alternative of this variant call.getReference(int i) Retrieves the reference content of the i-th alternative of this variant call.inthashCode()Computes the hash code for this variant call.booleanChecks if the variant call is filtered.static booleanisFiltered(String s) Checks if a variant call string contains any filtered flags.toString()Converts the variant call to its string representation.
-
Constructor Details
-
VariantCall
public VariantCall(VariantCall.Flag flag, short depth, float entropy, List<VariantCall.CallAlternative> alternatives) Creates an instance of aVariantCallrecord class.- Parameters:
flag- the value for theflagrecord componentdepth- the value for thedepthrecord componententropy- the value for theentropyrecord componentalternatives- the value for thealternativesrecord component
-
-
Method Details
-
isFiltered
public boolean isFiltered()Checks if the variant call is filtered.This method determines whether the variant call has been flagged as filtered based on its status. A variant call is considered filtered if its flag is set to one of the following:
VariantCall.Flag.LOW_FREQUENCY- The variant call has a frequency below the minimum threshold.VariantCall.Flag.LOW_COVERAGE- The variant call has a coverage below the minimum threshold.VariantCall.Flag.MISSING_UPSTREAM_DELETION- The variant call is missing due to an upstream deletion.
- Returns:
trueif the variant call is filtered;falseotherwise.
-
getReference
Retrieves the reference content of the first (called) alternative of this variant call.This method assumes that the list of alternatives is not empty and returns the reference content of the first
VariantCall.CallAlternativeobject in the list.- Returns:
- The reference content of the called alternative as
String.
-
getReference
Retrieves the reference content of the i-th alternative of this variant call.This method returns the reference content of the i-th
VariantCall.CallAlternativeat the given index in the alternatives list. If the specified index exceeds the size of the list, the reference content of the last alternative is returned.- Parameters:
i- The index of the alternative in the list.- Returns:
- The reference content of the i-th alternative as
String.
-
getAlternative
Retrieves the alternative content of the first (called) alternative of this variant call.This method assumes that the list of alternatives is not empty and returns the alternative content of the first
VariantCall.CallAlternativeobject in the list.- Returns:
- The alternative content of the called alternative as
String.
-
getAlternative
Retrieves the alternative content of the i-th alternative of this variant call.This method returns the alternative content of the i-th
VariantCall.CallAlternativeat the given index in the alternatives list. If the specified index exceeds the size of the list, the alternative content of the last alternative is returned.- Parameters:
i- The index of the alternative in the list.- Returns:
- The alternative content of the i-th alternative as
String.
-
toString
Converts the variant call to its string representation.This method generates a string representation of the variant call, including its flag, total depth, entropy, and a formatted list of alternative alleles. Each alternative allele is represented by its string representation, and alternatives are separated by commas.
-
hashCode
public int hashCode()Computes the hash code for this variant call.This method calculates the hash code of the variant call based on its string representation.
-
equals
Compares this variant call to another object for equality.This method checks if the provided object is the same instance as this object. If not, it verifies that the object is of the same class and compares their string representations for equality.
- Specified by:
equalsin classRecord- Parameters:
obj- The object to compare with thisVariantCallinstance.- Returns:
trueif the objects are the same instance or if their string representations are equal;falseotherwise.
-
fromString
Creates aVariantCallobject from its string representation.This method parses a string representation of a variant call and constructs a
VariantCallinstance. The string is expected to have the following format:flag;depth;entropy;reference:alternative:depth,reference:alternative:depth,...
where:- flag: The state of the variant call, corresponding to a
VariantCall.Flagvalue. - depth: The total read depth at the variant site.
- entropy: The normalized entropy of the call.
- reference: The reference allele.
- alternative: The alternative allele.
- depth: The number of reads supporting the alternative allele.
If the string does not conform to the expected format, an
IllegalArgumentExceptionis thrown.- Parameters:
s- The string representation of the variant call.- Returns:
- A
VariantCallobject constructed from the string representation. - Throws:
IllegalArgumentException- If the string format is invalid.
- flag: The state of the variant call, corresponding to a
-
isFiltered
Checks if a variant call string contains any filtered flags.This method determines whether the provided variant call string contains any flags indicating that the variant call is filtered. A variant call is considered filtered if it starts with either
VariantCall.Flag.LOW_COVERAGE,VariantCall.Flag.LOW_FREQUENCY, orVariantCall.Flag.MISSING_UPSTREAM_DELETION. The input string can comprise contain multiple variant calls separated byConstants.PIPE.- Parameters:
s- The string representation of variant calls, with individual calls separated byConstants.PIPE.- Returns:
trueif any of the variant calls in the string are filtered;falseotherwise.
-
flag
Returns the value of theflagrecord component.- Returns:
- the value of the
flagrecord component
-
depth
public short depth()Returns the value of thedepthrecord component.- Returns:
- the value of the
depthrecord component
-
entropy
public float entropy()Returns the value of theentropyrecord component.- Returns:
- the value of the
entropyrecord component
-
alternatives
Returns the value of thealternativesrecord component.- Returns:
- the value of the
alternativesrecord component
-