Package model

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.

public record VariantCall(VariantCall.Flag flag, short depth, float entropy, List<VariantCall.CallAlternative> alternatives) extends Record
Represents a variant call in a biological sample.

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.

  • Constructor Details

    • VariantCall

      public VariantCall(VariantCall.Flag flag, short depth, float entropy, List<VariantCall.CallAlternative> alternatives)
      Creates an instance of a VariantCall record class.
      Parameters:
      flag - the value for the flag record component
      depth - the value for the depth record component
      entropy - the value for the entropy record component
      alternatives - the value for the alternatives 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:

      Returns:
      true if the variant call is filtered; false otherwise.
    • getReference

      public String 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

      public String getReference(int i)
      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

      public 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

      public String getAlternative(int i)
      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

      public 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.

      Specified by:
      toString in class Record
      Returns:
      A String representing the variant call.
    • 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.

      Specified by:
      hashCode in class Record
      Returns:
      The hash code of the variant call.
    • equals

      public boolean equals(Object obj)
      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 class Record
      Parameters:
      obj - The object to compare with this VariantCall instance.
      Returns:
      true if the objects are the same instance or if their string representations are equal; false otherwise.
    • fromString

      public static VariantCall fromString(String s)
      Creates a VariantCall 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.
    • isFiltered

      public static boolean isFiltered(String s)
      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, or VariantCall.Flag.MISSING_UPSTREAM_DELETION. The input string can comprise contain multiple variant calls separated by Constants.PIPE.

      Parameters:
      s - The string representation of variant calls, with individual calls separated by Constants.PIPE.
      Returns:
      true if any of the variant calls in the string are filtered; false otherwise.
    • flag

      public VariantCall.Flag flag()
      Returns the value of the flag record component.
      Returns:
      the value of the flag record component
    • depth

      public short depth()
      Returns the value of the depth record component.
      Returns:
      the value of the depth record component
    • entropy

      public float entropy()
      Returns the value of the entropy record component.
      Returns:
      the value of the entropy record component
    • alternatives

      public List<VariantCall.CallAlternative> alternatives()
      Returns the value of the alternatives record component.
      Returns:
      the value of the alternatives record component