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.CallAlternative
objects.
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 record
Represents one alternative in the context of a variant call.static enum
Enumeration of flags representing the status of a variant call.static class
Serializer for theVariantCall
class. -
Constructor Summary
ConstructorsConstructorDescriptionVariantCall
(VariantCall.Flag flag, short depth, float entropy, List<VariantCall.CallAlternative> alternatives) Creates an instance of aVariantCall
record class. -
Method Summary
Modifier and TypeMethodDescriptionReturns the value of thealternatives
record component.short
depth()
Returns the value of thedepth
record component.float
entropy()
Returns the value of theentropy
record component.boolean
Compares this variant call to another object for equality.flag()
Returns the value of theflag
record component.static VariantCall
fromString
(String s) Creates aVariantCall
object 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.int
hashCode()
Computes the hash code for this variant call.boolean
Checks if the variant call is filtered.static boolean
isFiltered
(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 aVariantCall
record class.- Parameters:
flag
- the value for theflag
record componentdepth
- the value for thedepth
record componententropy
- the value for theentropy
record componentalternatives
- the value for thealternatives
record 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:
true
if the variant call is filtered;false
otherwise.
-
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.CallAlternative
object 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.CallAlternative
at 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.CallAlternative
object 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.CallAlternative
at 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:
equals
in classRecord
- Parameters:
obj
- The object to compare with thisVariantCall
instance.- Returns:
true
if the objects are the same instance or if their string representations are equal;false
otherwise.
-
fromString
Creates aVariantCall
object from its string representation.This method parses a string representation of a variant call and constructs a
VariantCall
instance. 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.Flag
value. - 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
IllegalArgumentException
is thrown.- Parameters:
s
- The string representation of the variant call.- Returns:
- A
VariantCall
object 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:
true
if any of the variant calls in the string are filtered;false
otherwise.
-
flag
Returns the value of theflag
record component.- Returns:
- the value of the
flag
record component
-
depth
public short depth()Returns the value of thedepth
record component.- Returns:
- the value of the
depth
record component
-
entropy
public float entropy()Returns the value of theentropy
record component.- Returns:
- the value of the
entropy
record component
-
alternatives
Returns the value of thealternatives
record component.- Returns:
- the value of the
alternatives
record component
-