public class GenomeFeatureBuilder
Created by jgw87 on 7/2/14. Builder class to create a GenomeFeature. All annoations are stored in a HashMap. Any annotation can be added through the addAnnotation() method, but the more common fields have their own convenience methods. Only the feature's own ID is required; all other annotations are optional
public GenomeFeatureBuilder()
Generic constructor which does nothing special
public GenomeFeatureBuilder(GenomeFeature feature)
Constructor to build a new feature off of an existing one.
feature - The genome feature to copypublic GenomeFeature build()
Public accessor method to get a new GenomeFeatureBuilder based off an existing GenomeFeature TODO: Get this matching other getInstance methods better; doesn't seem to fit, so commented out for now //@param feature //@return
public GenomeFeatureBuilder id(java.lang.String id)
public GenomeFeatureBuilder type(java.lang.String type)
public GenomeFeatureBuilder parentId(java.lang.String parentId)
public GenomeFeatureBuilder chromosome(Chromosome chr)
public GenomeFeatureBuilder chromosome(java.lang.String chr)
public GenomeFeatureBuilder chromosome(int chr)
public GenomeFeatureBuilder start(int start)
public GenomeFeatureBuilder start(java.lang.String start)
public GenomeFeatureBuilder stop(int stop)
public GenomeFeatureBuilder stop(java.lang.String stop)
public GenomeFeatureBuilder position(java.lang.String position)
public GenomeFeatureBuilder position(int position)
public GenomeFeatureBuilder addAnnotation(java.lang.String key, java.lang.String value)
public static java.lang.String synonymizeKeys(java.lang.String key)
Method that takes common synonyms of annotation types and standardizes them according to the following rules: (1) Make lowercase (2) Standardize according to following rules. (Any not on this list are returned as just lowercased) name, id -> id chr, chrom, chromosome -> chromosome stop, end -> stop parentid, parent_id, parent -> parent_id pos, position -> position
key - The key to standardizepublic GenomeFeatureBuilder loadAll(java.util.HashMap<java.lang.String,java.lang.String> newAnnotations)
Load all annotations from a hashmap. Keys become the annotations, and values the annotation value. Each key-value pair is added individually (instead of using a putAll() method) to allow for key standardization, etc.
public GenomeFeatureBuilder parseGffLine(java.lang.String line)
Create a GenomeFeature from a line of GFF file. This method is modified from the BioJava source code for the same purpose, in biojava3-genome/src/main/java/org/biojava3/genome/GFF3Reader.java
line - A single line from a GFF file as a stringpublic static java.lang.String getParentFromGffAttributes(java.lang.String attributes)
Parse a GFF attribute field to identify the parent of the current GenomeFeature. Tricky b/c of the different ways it can be represented. There's a hierarchy of accepted answers, with 'parent_id', 'Parent=', 'transcript_id', and 'gene_id' taken in that order. If nothing is found, returns an empty string ("")
attributes - The string from the attribute field of the GFF filepublic static java.lang.String getFeatureIdFromGffAttributes(java.lang.String attributes)
Parse a GFF attribute field to identify the name of the current GenomeFeature. Looks for 'ID=' and 'Name=' fields
attributes - The string from the attribute field of the GFF file. REturns null if not foundpublic GenomeFeatureBuilder parseJsonObject(org.json.simple.JSONObject featureData)