-
Notifications
You must be signed in to change notification settings - Fork 10
FF Entry
WARNING: This documentation is outdated and will soon be updated.
The GFFEntry
is build to handle data from GFF3 files. The parsing and the writing of the GFF3 entries strictly follow the GFF3 specification. Warning: If the a GFF3 entry not follow the GFF3 specification an error will be thrown while parsing.
The Javadoc of the GFFEntry
class is available here.
The GFFEntry
object is a very simple object. To create it, you just have to call the default constructor (the only constructor of the class). A GFFEntry
is reusable to parse several GFF entries.
GFFEntry gffEntry = new GFFEntry();
The fields of a GFFEnry can be set using setters:
gffEntry.setId(0);
gffEntry.setSeqId("ctg123");
gffEntry.setSource(".");
gffEntry.setType("gene");
gffEntry.setStart(1000);
gffEntry.setEnd(9000);
gffEntry.setScore(Double.NaN);
gffEntry.setStrand('+');
gffEntry.setPhase(-1);
The values of fields of the object can be get with the getters
gffEntry.getId(); // 0
gffEntry.getSeqId(); // "ctg123"
gffEntry.getSource(); // "."
gffEntry.getType(); // "gene"
gffEntry.getStart(); // 1000
gffEntry.getEnd(); //9000
gffEntry.getScore(); // Double.NaN
gffEntry.getStrand(); // '+'
gffEntry.getPhase(); // -1
There is actualy no validate()
method the values of a GFFEntry
.
You can clear data of GFFEntry using the clear()
method that also clear the attributes of the object but not the metadata.
The last field of a GFF3 file entry is dedicated to attributes. User can define several attributes in this field.
The setattributeValue()
method is used to add an attribute to the entry:
gffEntry.setAttributeValue("ID","gene00001");
gffEntry.setAttributeValue("Name","EDEN");
The attributes values and names can be accessed using getAttributeValue()
, getAttributesNames()
and isAttribute()
:
gffEntry.getAttributeValue("ID"); // "ID"
gffEntry.getAttributeValue("Name"); // "EDEN"
gffEntry.getAttributesNames(); // {"ID", "Name"}
gffEntry.isAttribute("Name"); // true
gffEntry.isAttribute("Parent"); // false
To remove an attribute use removeAttribute()
or the clear()
that clear all the field of the entry including attributes:
gffEntry.removeAttribute("ID");
gffEntry.isAttribute("ID"); // false
gffEntry.clear();
gffEntry.getAttributesNames(); // {}
GFF3 files contains header. The GFFEntry
class can handle this headers with the metadata methods. Metadata arw not removed after calling the parse()
method.
For our example, we use the following GFF3 header:
##gff-version 3
##sequence-region ctg123 1 1497228
We can access to the values of the header:
gffEntry.getMetaDataEntryValue("gff-version"); // 3
gffEntry.getMetaDataKeyNames(); // {"gff-version", sequence-region"}
gffEntry.isMetaDataEntry("gff-version"); // true
gffEntry.isMetaDataEntry("foo"); // false
To add metadata we use:
gffEntry.addMetaDataEntry("bar", "foo")
Metadata can also be removed:
gffEntry.removeMetaDataEntry("bar");
gffEntry.clearMetaData(); // Clear all the metadata
Paring GFF3 entries and writing an entry is quite simple with GFFEntry
:
GFFEntry gffEntry = new GFFEntry();
gffEntry.parsing("ctg123\t.\tgene\t1000\t9000\t.\t+\t.\tID=gene00001;Name=EDEN")
gffEntry.toString();
ctg123 . gene 1000 9000 . + . ID=gene00001;Name=EDEN