Sha256: 019debaa8d610ddb6087d30a45db95a68c0f200c0f1ad5821e76faa5c702bd59
Contents?: true
Size: 1.33 KB
Versions: 3
Compression:
Stored size: 1.33 KB
Contents
require 'bio' module GenomerPluginView::GffRecordHelper DEFAULT_GFF_MAPPING = {'product' => 'product', 'Note' => 'note', 'DBxref' => 'db_xref'} GFF_TO_TABLE = { 'gene' => { 'ID' => 'locus_tag', 'Name' => 'gene' }, 'CDS' => DEFAULT_GFF_MAPPING.merge({ 'ID' => 'protein_id', 'ec_number' => 'EC_number', 'function' => 'function', }), 'miscRNA' => DEFAULT_GFF_MAPPING, 'rRNA' => DEFAULT_GFF_MAPPING, 'tmRNA' => DEFAULT_GFF_MAPPING, 'tRNA' => DEFAULT_GFF_MAPPING } def negative_strand? self.strand == '-' end def coordinates if negative_strand? [self.end,self.start,self.feature] else [self.start,self.end,self.feature] end end def to_genbank_table_entry delimiter = "\t" indent = delimiter * 2 entries = table_attributes.inject([coordinates]) do |array,atr| array << atr.unshift(indent) end return entries.map{|line| line * delimiter} * "\n" + "\n" end def valid? GFF_TO_TABLE.include?(feature) end def table_attributes raise Genomer::Error, "Unknown feature type '#{feature}'" unless valid? attributes.map do |(k,v)| k = GFF_TO_TABLE[feature][k] k.nil? ? nil : [k,v] end.compact end end Bio::GFF::GFF3::Record.send(:include, GenomerPluginView::GffRecordHelper)
Version data entries
3 entries across 3 versions & 1 rubygems