Class FeatureList
- All Implemented Interfaces:
Serializable
,Cloneable
,Iterable<FeatureI>
,Collection<FeatureI>
,List<FeatureI>
,RandomAccess
A list of FeatureI objects implemented using a Java ArrayList; corresponds to a GFF file.
This class is implemented entirely using FeatureI objects, so everything here will work
correctly if you choose to implement your own feature class -- there are no dependencies
on JavaGene's native Feature class.
- Author:
- Hanno Hinsch, Carmelo Foti
- See Also:
-
Field Summary
Fields inherited from class java.util.AbstractList
modCount
-
Constructor Summary
ConstructorDescriptionConstruct an empty list.FeatureList
(Collection<FeatureI> features) Construct a new list containing the same features as the specified list. -
Method Summary
Modifier and TypeMethodDescriptionvoid
add
(Collection<FeatureI> list) Add all features in the specified list or collection to this list.boolean
Add specified feature to the end of the list.void
Add an attribute that will be used as index for queriesvoid
addIndexes
(List<String> indexes) Add a list of attributes that will be used as indexes for queriesattributeValues
(String key) Create a collection of the unique values for the specified key.bounds()
The union of all locations of all features in this list, mapped to the positive strand.Create a collection of all unique group ids in the list, as defined by the group() method of the features.boolean
hasAttribute
(String key) Check if any feature in list has the specified attribute key.boolean
hasAttribute
(String key, String value) Check if any feature in list has the specified attribute key/value pair.boolean
hasGaps
(int gapLength) Check size of gaps between successive features in list.static void
Deprecated.omitOverlapping
(String seqname, Location location, boolean useBothStrands) Create a list of all features that do not overlap the specified location on the specified sequence.selectByAttribute
(String key) Create a list of all features that include the specified attribute key.selectByAttribute
(String key, String value) Create a list of all features that include the specified attribute key/value pair.selectByGroup
(String groupid) Create a list of all features that have the specified group id, as defined by the group() method of the features.selectByType
(String type) Create a list of all features that are of the specified type, as defined by the type() method of the features.selectByUserData
(String key) Create a list of all features that include the specified key in their userMap().selectByUserData
(String key, Object value) Create a list of all features that include the specified key/value pair in their userMap().selectOverlapping
(String seqname, Location location, boolean useBothStrands) Create a list of all features that overlap the specified location on the specified sequence.Create a new list that is ordered by the starting index of the features' locations.splice
(DNASequence sequence) Concatenate successive portions of the specified sequence using the feature locations in the list.toString()
Return a string representation of all features in this list.Methods inherited from class java.util.ArrayList
add, addAll, addAll, clear, clone, contains, ensureCapacity, equals, forEach, get, hashCode, indexOf, isEmpty, iterator, lastIndexOf, listIterator, listIterator, remove, remove, removeAll, removeIf, removeRange, replaceAll, retainAll, set, size, sort, spliterator, subList, toArray, toArray, trimToSize
Methods inherited from class java.util.AbstractCollection
containsAll
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface java.util.Collection
parallelStream, stream, toArray
Methods inherited from interface java.util.List
containsAll
-
Constructor Details
-
FeatureList
public FeatureList()Construct an empty list. -
FeatureList
Construct a new list containing the same features as the specified list.- Parameters:
features
- An existing list or collection of FeatureI objects.
-
-
Method Details
-
add
Add specified feature to the end of the list. Updates the bounding location of the feature list, if needed. -
add
Add all features in the specified list or collection to this list.- Parameters:
list
- The collection of FeatureI objects.
-
bounds
The union of all locations of all features in this list, mapped to the positive strand. If an added feature is on the negative strand, its positive strand image is added to the union. The bounding location is not updated when a feature is removed from the list, so it is not guaranteed to be the minimal bounding location.- Returns:
- A location that is the union of all feature locations in the list.
-
hasGaps
public boolean hasGaps(int gapLength) Check size of gaps between successive features in list. The features in the list are assumed to be appropriately ordered.- Parameters:
gapLength
- The minimum gap length to consider. Use a gapLength of 0 to check if features are contiguous.- Returns:
- True if list has any gaps equal to or greater than gapLength.
-
splice
Concatenate successive portions of the specified sequence using the feature locations in the list. The list is assumed to be appropriately ordered.- Parameters:
sequence
- The source sequence from which portions should be selected.- Returns:
- The spliced data.
- Throws:
IllegalStateException
- Out of order or overlapping FeatureI locations detected.
-
groupValues
Create a collection of all unique group ids in the list, as defined by the group() method of the features. For example, if the features are from a GFF1 file, then each group id identifies a particular gene, and this method returns a collection of all gene ids.- Returns:
- A collection (suitable for iteration using Java's "for" loop) of all the group ids found in this list. The order of the values is undefined; it will not match the order of features in the list.
-
attributeValues
Create a collection of the unique values for the specified key. Example: For GTF files, using the "gene_id" key will give the names of all the genes in this list.- Returns:
- A collection (suitable for iteration using Java's "for" loop) of all the values found for this key. The order of the values is undefined; it will not match the order of features in the list.
-
selectByGroup
Create a list of all features that have the specified group id, as defined by the group() method of the features.- Parameters:
groupid
- The group to match.- Returns:
- A list of features having the specified group id.
-
selectByType
Create a list of all features that are of the specified type, as defined by the type() method of the features. This might be, for example, "exon" or "CDS".- Parameters:
type
- The type to match.- Returns:
- A list of features of the specified type.
-
selectByAttribute
Create a list of all features that include the specified attribute key/value pair. This method now properly supports adding the index before or after adding the features. Adding features, then then index, then more features is still not supported.- Parameters:
key
- The key to consider.value
- The value to consider.- Returns:
- A list of features that include the key/value pair.
-
selectByAttribute
Create a list of all features that include the specified attribute key.- Parameters:
key
- The key to consider.- Returns:
- A list of features that include the key.
-
selectByUserData
Create a list of all features that include the specified key/value pair in their userMap().- Parameters:
key
- The key to consider.value
- The value to consider.- Returns:
- A list of features that include the key/value pair.
-
selectByUserData
Create a list of all features that include the specified key in their userMap().- Parameters:
key
- The key to consider.- Returns:
- A list of features that include the key.
-
selectOverlapping
public FeatureList selectOverlapping(String seqname, Location location, boolean useBothStrands) throws Exception Create a list of all features that overlap the specified location on the specified sequence.- Parameters:
seqname
- The sequence name. Only features with this sequence name will be checked for overlap.location
- The location to check.useBothStrands
- If true, locations are mapped to their positive strand image before being checked for overlap. If false, only features whose locations are on the same strand as the specified location will be considered for inclusion.- Returns:
- The new list of features that overlap the location.
- Throws:
Exception
-
omitOverlapping
Create a list of all features that do not overlap the specified location on the specified sequence.- Parameters:
seqname
- The sequence name. Only features with this sequence name will be checked for overlap.location
- The location to check.useBothStrands
- If true, locations are mapped to their positive strand image before being checked for overlap. If false, all features whose locations are on the opposite strand from the specified location will be considered non-overlapping.- Returns:
- The new list of features that do not overlap the location.
-
hasAttribute
Check if any feature in list has the specified attribute key.- Parameters:
key
- The attribute key to consider.- Returns:
- True if at least one feature has the attribute key.
-
hasAttribute
Check if any feature in list has the specified attribute key/value pair.- Parameters:
key
- The attribute key to consider.value
- The attribute value to consider.- Returns:
- True if at least one feature has the key/value pair.
-
toString
Return a string representation of all features in this list.- Overrides:
toString
in classAbstractCollection<FeatureI>
- Returns:
- A string.
-
sortByStart
Create a new list that is ordered by the starting index of the features' locations. All locations must be on the same strand of the same sequence.- Returns:
- An ordered list.
- Throws:
IndexOutOfBoundsException
- Cannot compare/sort features whose locations are on opposite strands, or whose seqnames differ.
-
main
Deprecated. -
addIndexes
Add a list of attributes that will be used as indexes for queries- Parameters:
indexes
- the List containing the attribute_id
-
addIndex
Add an attribute that will be used as index for queries- Parameters:
index
- an attribute_id
-