Package beagleutil
Class ChromIds
- java.lang.Object
-
- beagleutil.ChromIds
-
public final class ChromIds extends java.lang.Object
Class
The singleton instance ofChromIds
is a singleton class that represents a list of chromosome identifiers.ChromIds
is thread-safe.
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description int
getIndex(java.lang.String id)
Returns the index of the specified chromosome identifier.int
getIndexIfIndexed(java.lang.String id)
Returns the index of the specified chromosome identifier, or returns-1
if the specified chromosome identifier is not indexed.int[]
getIndices(java.lang.String[] ids)
Returns an array of chromosome identifier indices corresponding to the specified array of chromosome identifiers.java.lang.String
id(int index)
Returns the chromosome identifier with the specified index.java.lang.String[]
ids()
Returns the list of chromosome identifiers as an array.static ChromIds
instance()
Returns the singletonChromIds
instance.int
size()
Returns the number of indexed chromosomes identifiers.java.lang.String
toString()
Returnsjava.util.Arrays.toString(this.ids())
.
-
-
-
Method Detail
-
instance
public static ChromIds instance()
Returns the singletonChromIds
instance.- Returns:
- the singleton
ChromIds
instance
-
getIndex
public int getIndex(java.lang.String id)
Returns the index of the specified chromosome identifier. If the chromosome identifiers is not yet indexed, the chromosome identifier will be indexed. Chromosome identifier indices are assigned in consecutive order beginning with 0.- Parameters:
id
- a chromosome identifier- Returns:
- the index of the specified chromosome identifier
- Throws:
java.lang.IllegalArgumentException
- ifid.isEmpty()
java.lang.NullPointerException
- ifid == null
-
getIndices
public int[] getIndices(java.lang.String[] ids)
Returns an array of chromosome identifier indices corresponding to the specified array of chromosome 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:
java.lang.IllegalArgumentException
- if there is aj
satisfying(0 <= j && j < ids.length) && ids[j].isEmpty()
java.lang.NullPointerException
- ifids == null
java.lang.NullPointerException
- if there is aj
satisfying(0 <= j && j < ids.length) && (ids[j] == null)
-
getIndexIfIndexed
public int getIndexIfIndexed(java.lang.String id)
Returns the index of the specified chromosome identifier, or returns-1
if the specified chromosome identifier is not indexed.- Parameters:
id
- a chromosome identifier.- Returns:
- the index of the specified chromosome identifier, or
-1
if the specified chromosome identifier is not indexed. - Throws:
java.lang.IllegalArgumentException
- ifid.isEmpty()
java.lang.NullPointerException
- ifid == null
-
size
public int size()
Returns the number of indexed chromosomes identifiers.- Returns:
- the number of indexed chromosomes identifiers
-
id
public java.lang.String id(int index)
Returns the chromosome identifier with the specified index.- Parameters:
index
- a chromosome identifier index.- Returns:
- the specified chromosome identifier.
- Throws:
java.lang.IndexOutOfBoundsException
- ifindex < 0 || index >= this.size()
-
ids
public java.lang.String[] ids()
Returns the list of chromosome identifiers as an array. The returned array will have lengththis.size()
, and it will satisfythis.ids()[k].equals(this.id(k)) == true
for0 <= k < this.size()
.- Returns:
- an array of chromosome identifiers
-
toString
public java.lang.String toString()
Returnsjava.util.Arrays.toString(this.ids())
.- Overrides:
toString
in classjava.lang.Object
- Returns:
- a string representation of
this
-
-