Skip to content

Instantly share code, notes, and snippets.

@danmaclean
Created April 20, 2013 14:23
Show Gist options
  • Save danmaclean/5426143 to your computer and use it in GitHub Desktop.
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
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