Skip to content

Instantly share code, notes, and snippets.

@danmaclean
Created April 20, 2013 14:30
Show Gist options
  • Save danmaclean/5426171 to your computer and use it in GitHub Desktop.
Save danmaclean/5426171 to your computer and use it in GitHub Desktop.
Predecessor#to_gff method
def to_gff(extra = {})
#arr should be hash of keys and values to add to the group attributes
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
old_id = self.old_id
old_id = 'nil' if self.old_id.nil?
gff.attributes << ['old_id', old_id]
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