Class Sample
This class provides a structure to store and manage variant calls associated with a biological sample. Furthermore, it allows the
association with an allele per feature. It extends the Attributes
class to inherit functionality for managing attributes
associated with the sample.
Samples are stored in the Storage.samples
property of the model.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
addRelation
(String featureIdentifier, String alleleIdentifier) Associates a specific allele of a feature with this sample.boolean
Compares this sample to another object for equality.getRelatedAllele
(String featureIdentifier) Retrieves the allele associated with a specific feature in this sample.Retrieves all feature-allele associations in this sample.int
Retrieves the number of alternate alleles in this sample.int
hashCode()
Computes the hash code for this sample.toString()
Converts the sample to its string representation.Methods inherited from class model.Attributes
attributesAsString, attributesAsString, clearAttributes, extendAttribute, extendAttributes, getAttribute, getAttributeOrDefault, getAttributes, getAttributeSet, hasAnyAttribute, hasAttribute, removeAttribute, setAttribute, setAttributeIfAbsent, setAttributes, setAttributesIfAbsent
-
Field Details
-
_id
Unique identifier of this sample.This field serves as the unique identifier for the sample and is used to reference it in the model. This should be at best a database identifier, such as a NCBI accession number, or strain identifier.
-
-
Constructor Details
-
Sample
Constructs a newSample
instance with the specified id and initial capacity for the alleles map.This constructor initializes a
Sample
object with the given identifier and allocates aHashMap
instance for thealleles
field with the specified initial capacity. The_id
field is set to the provided identifier, and the superclass constructor is invoked to initialize inherited properties.Instances of this class are not related to variants from within this constructor. Instead, variants are linked via the
Variant.samples
andAllele
classes.- Parameters:
identifier
- The unique identifier of the sample, used as its unique key.capacityFeatures
- The initial capacity for thealleles
map, which stores feature-allele associations.
-
-
Method Details
-
addRelation
Associates a specific allele of a feature with this sample.This method updates the
alleles
map by setting the sequence type (allele) for the specified feature. The feature and allele are identified by their id.- Parameters:
featureIdentifier
- The id of the feature (Feature._id
) to associate with the allele.alleleIdentifier
- The unique identifier of the allele (SequenceType._id
) to set for the feature.
-
getRelatedAllele
Retrieves the allele associated with a specific feature in this sample.This method looks up the
alleles
map to find the allele associated with the given feature identifier. If no association exists, it returns the default reference allele defined inConstants.REFERENCE
.- Parameters:
featureIdentifier
- The unique identifier of the feature (Feature.name
) to retrieve the associated allele for.- Returns:
- The unique identifier of the allele (
SequenceType._id
) associated with the feature, or the default reference allele if no association exists.
-
getRelatedAlleles
Retrieves all feature-allele associations in this sample.This method converts the
alleles
map, which stores feature names as keys and their associated allele identifiers as values, into a collection ofTuple
objects. Each tuple contains a feature name and its corresponding allele identifier.- Returns:
- A
Set
ofTuple
objects, where each tuple represents a feature-allele association.
-
getRelatedAllelesCount
public int getRelatedAllelesCount()Retrieves the number of alternate alleles in this sample.This method returns the size of the
alleles
map, which represents the number of unique alleles associated with features in this sample. This corresponds to the number of non-reference alleles present in the sample.- Returns:
- The number of alleles in this sample.
-
toString
Converts the sample to its string representation.This method returns the unique identifier of the sample as its string representation.
-
hashCode
public int hashCode()Computes the hash code for this sample.This method calculates the hash code of the sample based on its unique identifier.
-
equals
Compares this sample to another object for equality.This method checks if the provided object is the same instance as this sample. If not, it verifies that the object is of the same class and compares their unique identifiers for equality.
-