Created
April 20, 2013 14:23
-
-
Save danmaclean/5426143 to your computer and use it in GitHub Desktop.
Feature#to_gff method improved for adding any other stuff from the database
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def to_gff(extra = {}) | |
#arr should be hash of keys and values to add to the group attributes | |
#can't use symbols as keys | |
arr = extra.to_a | |
gff = Bio::GFF::GFF3::Record.new( | |
seqid = Reference.find(self.reference_id).name, | |
source = self.source, | |
feature = self.feature, | |
start = self.start, | |
stop = self.end, | |
score = self.score, | |
strand = self.strand, | |
phase = self.phase, | |
attributes = JSON.parse(self.group) | |
) | |
##any extra attributes to be added to the group field done in here | |
##eg the created by edited by stuff | |
gff.attributes << ['gfu_id', self.id.to_s] | |
gff.attributes += arr | |
gff.to_s | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment