javagene.seq
Class Feature

java.lang.Object
  extended by javagene.seq.Feature
All Implemented Interfaces:
FeatureI

public class Feature
extends java.lang.Object
implements FeatureI

A Feature corresponds to a single row in a GFF file.


Constructor Summary
Feature(Feature feature)
          Make a copy of the specified feature.
Feature(java.lang.String seqname, java.lang.String source, java.lang.String type, Location location, java.lang.Double score, int frame, java.lang.String attributes)
          Construct a new Feature from raw data (usually a GFF row).
 
Method Summary
 java.lang.String attributes()
          Get the string of key/value attributes.
 int frame()
          Get frame (aka phase).
 java.lang.String getAttribute(java.lang.String key)
          Get value of specified attribute key.
 java.lang.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(java.lang.String key)
          Check if the feature has a value defined for the specified key.
 boolean hasAttribute(java.lang.String key, java.lang.String value)
          Check if the feature attributes include the specified key/value pair.
 Location location()
          Get location of feature.
 double score()
          Get score.
 java.lang.String seqname()
          Get the sequence name.
 java.lang.String source()
          Get source (aka method).
 java.lang.String toString()
          A string representation of the feature.
 java.lang.String type()
          Get feature type, such as "exon" or "CDS".
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Feature

public Feature(Feature feature)
Make a copy of the specified feature.

Parameters:
feature - To clone.

Feature

public Feature(java.lang.String seqname,
               java.lang.String source,
               java.lang.String type,
               Location location,
               java.lang.Double score,
               int frame,
               java.lang.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

attributes

public java.lang.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.

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).

getAttribute

public java.lang.String getAttribute(java.lang.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 interface FeatureI
Parameters:
key - The key.
Returns:
The corresponding value. Null if the key has no value defined.

group

public java.lang.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.

Specified by:
group in interface FeatureI
Returns:
The group id. Everything before the first semicolon in the attributes string (minus trailing whitespace).

hasAttribute

public boolean hasAttribute(java.lang.String key)
Description copied from interface: FeatureI
Check if the feature has a value defined for the specified key.

Specified by:
hasAttribute in interface FeatureI
Parameters:
key - The key.
Returns:
True if a value is defined for this key.

hasAttribute

public boolean hasAttribute(java.lang.String key,
                            java.lang.String value)
Description copied from interface: FeatureI
Check if the feature attributes include the specified key/value pair.

Specified by:
hasAttribute in interface FeatureI
Parameters:
key - The key.
value - The value.
Returns:
True if the feature's value for this key matches the specified value.

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.

Specified by:
location in interface FeatureI
Returns:
Location of feature.

score

public double score()
Get score. (GFF field 7). The meaning of the score varies from file to file.

Returns:
Score value.

seqname

public java.lang.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.

Returns:
Sequence name.

source

public java.lang.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.

toString

public java.lang.String toString()
Description copied from interface: FeatureI
A string representation of the feature.

Specified by:
toString in interface FeatureI
Overrides:
toString in class java.lang.Object
Returns:
The string.

type

public java.lang.String type()
Get feature type, such as "exon" or "CDS". (GFF field 3).

Specified by:
type in interface FeatureI
Returns:
Feature type.