Module: GenomerPluginView::GffRecordHelper

Defined in:
lib/genomer-plugin-view/gff_record_helper.rb

Constant Summary collapse

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
}

Instance Method Summary collapse

Instance Method Details

#coordinatesObject



27
28
29
30
31
32
33
# File 'lib/genomer-plugin-view/gff_record_helper.rb', line 27

def coordinates
  if negative_strand?
    [self.end,self.start,self.feature]
  else
    [self.start,self.end,self.feature]
  end
end

#negative_strand?Boolean

Returns:

  • (Boolean)


23
24
25
# File 'lib/genomer-plugin-view/gff_record_helper.rb', line 23

def negative_strand?
  self.strand == '-'
end

#table_attributesObject

Raises:

  • (Genomer::Error)


50
51
52
53
54
55
56
# File 'lib/genomer-plugin-view/gff_record_helper.rb', line 50

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

#to_genbank_table_entryObject



35
36
37
38
39
40
41
42
43
44
# File 'lib/genomer-plugin-view/gff_record_helper.rb', line 35

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

#valid?Boolean

Returns:

  • (Boolean)


46
47
48
# File 'lib/genomer-plugin-view/gff_record_helper.rb', line 46

def valid?
  GFF_TO_TABLE.include?(feature)
end