Package beagleutil
Class ChromIds
java.lang.Object
beagleutil.ChromIds
Class ChromIds is a singleton class that represents a
list of chromosome identifiers.
ChromIds is thread-safe.-
Method Summary
Modifier and TypeMethodDescriptionintReturns the index of the specified chromosome identifier.intReturns the index of the specified chromosome identifier, or returns-1if the specified chromosome identifier is not indexed.int[]getIndices(String[] ids) Returns an array of chromosome identifier indices corresponding to the specified array of chromosome identifiers.id(int index) Returns the chromosome identifier with the specified index.String[]ids()Returns the list of chromosome identifiers as an array.static ChromIdsinstance()Returns the singletonChromIdsinstance.intsize()Returns the number of indexed chromosomes identifiers.toString()Returnsjava.util.Arrays.toString(this.ids()).
-
Method Details
-
instance
Returns the singletonChromIdsinstance.- Returns:
- the singleton
ChromIdsinstance
-
getIndex
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:
IllegalArgumentException- ifid.isEmpty()NullPointerException- ifid == null
-
getIndices
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:
IllegalArgumentException- if there is ajsatisfying(0 <= j && j < ids.length) && ids[j].isEmpty()NullPointerException- ifids == nullNullPointerException- if there is ajsatisfying(0 <= j && j < ids.length) && (ids[j] == null)
-
getIndexIfIndexed
Returns the index of the specified chromosome identifier, or returns-1if the specified chromosome identifier is not indexed.- Parameters:
id- a chromosome identifier.- Returns:
- the index of the specified chromosome identifier, or
-1if the specified chromosome identifier is not indexed. - Throws:
IllegalArgumentException- ifid.isEmpty()NullPointerException- ifid == null
-
size
public int size()Returns the number of indexed chromosomes identifiers.- Returns:
- the number of indexed chromosomes identifiers
-
id
Returns the chromosome identifier with the specified index.- Parameters:
index- a chromosome identifier index.- Returns:
- the specified chromosome identifier.
- Throws:
IndexOutOfBoundsException- ifindex < 0 || index >= this.size()
-
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)) == truefor0 <= k < this.size().- Returns:
- an array of chromosome identifiers
-
toString
Returnsjava.util.Arrays.toString(this.ids()).
-