Class Feature
- java.lang.Object
-
- org.biojava.nbio.genome.parsers.gff.Feature
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description String
attributes()
Get the string of key/value attributes.int
frame()
Get frame (aka phase).String
getAttribute(String key)
Get value of specified attribute key.String
getAttributeOld(String key)
HashMap<String,String>
getAttributes()
String
group()
Get the first item (everything before first semicolon, if it has one) in the attribute field, which is assumed to be a group identifer.boolean
hasAttribute(String key)
Check if the feature has a value defined for the specified key.boolean
hasAttribute(String key, String value)
Check if the feature attributes include the specified key/value pair.Location
location()
Get location of feature.double
score()
Get score.String
seqname()
Get the sequence name.String
source()
Get source (aka method).String
toString()
A string representation of the feature.String
type()
Get feature type, such as "exon" or "CDS".HashMap<String,String>
userData()
Get HashMap of user data.
-
-
-
Constructor Detail
-
Feature
public Feature(Feature feature)
Make a copy of the specified feature. The mappings in the userMap() HashMap are copied, so each feature has independent user data. Note, however, that the actual objects in the HashMap are shared (not copied), so a change to such an object may affect multiple features.- Parameters:
feature
- Feature to clone.
-
Feature
public Feature(String seqname, String source, String type, Location location, Double score, int frame, String attributes)
Construct a new Feature from raw data (usually a GFF row).- Parameters:
seqname
- The sequence name field (field 1).source
- The source or method field (field 2).type
- The type of feature field (field 3).location
- The location of the feature. (calculated from GFF start, end and strand fields).score
- The score field (field 7).frame
- The frame or phase field (field 8).attributes
- A string of key/value pairs separated by semicolons (field 9).
-
-
Method Detail
-
seqname
public String seqname()
Get the sequence name. (GFF field 1). Note that feature objects have no link or reference to the actual sequence object to which they refer; they are completely uncoupled.
-
source
public String source()
Get source (aka method). (GFF field 2). This is often the name of the program or procedure that created the features.- Returns:
- Source field.
-
location
public Location location()
Get location of feature. Note that feature objects have no link or reference to the actual sequence object to which they refer; they are completely uncoupled.
-
score
public double score()
Get score. (GFF field 7). The meaning of the score varies from file to file.- Returns:
- Score value.
-
frame
public int frame()
Get frame (aka phase). (GFF field 8). Specifies the offset of the first nucleotide of the first in-frame codon, assuming this feature is a dna/rna sequence that codes for a protein. If you intend to use this field, you probably want to look it up on the web first.- Returns:
- The frame (0, 1, 2).
-
attributes
public String attributes()
Get the string of key/value attributes. (GFF field 9). The format and meaning of this field varies from flavor to flavor of GFF/GTF. This method simply returns the whole string. Other methods in this class make assumptions about its format and provide additional utility.- Returns:
- The attribute string.
-
userData
public HashMap<String,String> userData()
Get HashMap of user data. Each Feature object has a Java HashMap object which can be used to annotate the Feature. JavaGene does not use or interpret the keys or values. The values can be any subtype of the Java Object class.
If a Feature is constructed from data fields, the initial HashMap has no mappings (is empty). If a Feature is constructed from another Feature, a copy of the mappings is made. Note that the Objects in the copied mapping are shared, even though the mapping itself is copied (not shared). Thus removing or adding a mapping to one Feature will not affect the other, but changing an Object which is part of an established mapping may affect both Features.
-
getAttribute
public String getAttribute(String key)
Get value of specified attribute key. Returns null if the attribute key has no value (does not exist). Keys are case-sensitive. Assumes attributes are correctly formatted in GFF style. Known bug: a semicolon within a quoted value will cause parse failure.- Specified by:
getAttribute
in interfaceFeatureI
- Parameters:
key
- The key.- Returns:
- The corresponding value. Null if the key has no value defined.
-
getAttributeOld
public String getAttributeOld(String key)
-
hasAttribute
public boolean hasAttribute(String key)
Description copied from interface:FeatureI
Check if the feature has a value defined for the specified key.- Specified by:
hasAttribute
in interfaceFeatureI
- Parameters:
key
- The key.- Returns:
- True if a value is defined for this key.
-
hasAttribute
public boolean hasAttribute(String key, String value)
Description copied from interface:FeatureI
Check if the feature attributes include the specified key/value pair.- Specified by:
hasAttribute
in interfaceFeatureI
- Parameters:
key
- The key.value
- The value.- Returns:
- True if the feature's value for this key matches the specified value.
-
group
public String group()
Get the first item (everything before first semicolon, if it has one) in the attribute field, which is assumed to be a group identifer. This is appropriate for GFF1 files and variants. It is not appropriate for GTF and GFF2 files, although they may use a named attribute key, such as "gene_id" or "transcript_id", for grouping.
-
toString
public String toString()
Description copied from interface:FeatureI
A string representation of the feature.
-
getAttributes
public HashMap<String,String> getAttributes()
- Specified by:
getAttributes
in interfaceFeatureI
-
-