Package beagleutil
Class SampleIds
java.lang.Object
beagleutil.SampleIds
Class SampleIds
is a singleton class that represents a
list of sample identifiers.
SampleIds
is thread-safe.-
Method Summary
Modifier and TypeMethodDescriptionint
Returns the index of the specified sample identifier.int
Returns the index of the specified sampled identifier, or returns-1
if the specified sample identifier is not indexed.int[]
getIndices
(String[] ids) Returns an array of sample identifier indices corresponding to the specified array of sample identifiers.id
(int index) Returns the sample identifier with the specified index.int[]
idIndexToIndex
(Samples samples) Returns an array mapping sample identifier indices to sample indices.String[]
ids()
Returns the list of indexed sample identifiers as an array.String[]
ids
(int[] indices) Returns a list of sample identifiers with the specified indices.static SampleIds
instance()
Returns the singletonSampleIds
instance.int
size()
Returns the number of indexed sample identifiers.toString()
Returnsjava.util.Arrays.toString(this.ids())
.
-
Method Details
-
instance
Returns the singletonSampleIds
instance.- Returns:
- the singleton
SampleIds
instance
-
getIndex
Returns the index of the specified sample identifier. If the sample identifier is not yet indexed, the sample identifier will be indexed. Sample identifier indices are assigned in consecutive order beginning with 0.- Parameters:
id
- a sample identifier- Returns:
- the index of the specified sample identifier
- Throws:
IllegalArgumentException
- ifid.isEmpty()
NullPointerException
- ifid == null
-
getIndices
Returns an array of sample identifier indices corresponding to the specified array of sample identifiers. If a sample identifier is not yet indexed, the sample identifier will be indexed. Sample identifier indices are assigned in increasing order starting with 0.- Parameters:
ids
- an array of sample identifiers- Returns:
- an array of sample identifier indices
- Throws:
IllegalArgumentException
- if there is aj
satisfying(0 <= j && j < ids.length) && ids[j].isEmpty()
NullPointerException
- ifids == null
NullPointerException
- if there is aj
satisfying(0 <= j && j < ids.length) && (ids[j] == null)
-
idIndexToIndex
Returns an array mapping sample identifier indices to sample indices. Indices for sample identifiers not present in this list of samples are mapped to-1
.- Parameters:
samples
- a list of sample identifiers- Returns:
- an array mapping sample identifier indices to sample indices
- Throws:
IllegalArgumentException
- if two sample identifiers are the same stringNullPointerException
- ifsamples == null
-
getIndexIfIndexed
Returns the index of the specified sampled identifier, or returns-1
if the specified sample identifier is not indexed.- Parameters:
id
- a sample identifiers- Returns:
- the index of the specified sampled identifier, or
-1
if the specified sample identifier is not indexed - Throws:
IllegalArgumentException
- ifid.isEmpty()
NullPointerException
- ifid == null
-
size
public int size()Returns the number of indexed sample identifiers.- Returns:
- the number of indexed samples identifiers
-
id
Returns the sample identifier with the specified index.- Parameters:
index
- a sample identifier index- Returns:
- the specified sample identifier
- Throws:
IndexOutOfBoundsException
- ifindex < 0 || index >= this.size()
-
ids
Returns a list of sample identifiers with the specified indices.- Parameters:
indices
- an array of sample identifiers indices- Returns:
- a list of sample identifiers with the specified indices
- Throws:
IndexOutOfBoundsException
- if there exists aj
satisfying(0 <= j && j < indices.length) && (indices[j] < 0 || indices[j] >= this.size())
-
ids
Returns the list of indexed sample identifiers as an array. The returned array will have lengththis.size()
, and it will satisfythis.ids()[k].equals(this.id(k)) == true
for0 <= k && k < this.size()
.- Returns:
- an array of sample identifiers
-
toString
Returnsjava.util.Arrays.toString(this.ids())
.
-