Skip to content

Latest commit

History

49 Commits

Folders and files

NameName
Last commit message
Last commit date

Repository files navigation

CodonTableParser

Parses the NCBI genetic code table with a multiline Regex, generating hash maps of each species' name, start codons, stop codons and codon table. The output can be easily customized and used to update the respective constants of BioRuby's CodonTable class whenever the original data changes.

Installation

$ gem install codon_table_parser

Usage

Without any parameters, the genetic code file is downloaded directly from the NCBI web site

parser=CodonTableParser.new

Alternatively, the genetic code file can be loaded from a path

file='path/to/genetic_code.txt'parser=CodonTableParser.new(file)

The first line of the file is read to determine if the content is correct. If not, an exception is thrown:

wrong_content='path/to/wrong_content.txt'parser=CodonTableParser.new(wrong_content)# Exception: This is not the NCBI genetic code table

Instance Methods

The following instance methods are available:

  • CodonTableParser#definitions
  • CodonTableParser#starts
  • CodonTableParser#stops
  • CodonTableParser#tables
  • CodonTableParser#bundle

Every intance method can take a :range option that specifies the ids of the species to be considered in the output. A range is specified as an array of integers, Ranges or both. Example:

:range=>[(1..3),5,9]# converted internally to [1, 2, 3, 5, 9]

ids not present in the originial data are ignored. Besides the :range option, several methods also take other options as demonstrated below.

CodonTableParser#definitions

parser=CodonTableParser.new# Return default hash map of namesdefinitions=parser.definitionsdefinitions# {1=>"Standard",# 2=>"Vertebrate Mitochondrial",# 3=>"Yeast Mitochondrial",# 4=>"Mold Mitochondrial; Protozoan Mitochondrial; Coelenterate Mitochondrial; Mycoplasma; Spiroplasma",# 5=>"Invertebrate Mitochondrial",# 6=>"Ciliate Nuclear; Dasycladacean Nuclear; Hexamita Nuclear",# 9=>"Echinoderm Mitochondrial; Flatworm Mitochondrial",# 10=>"Euplotid Nuclear",# 11=>"Bacterial and Plant Plastid",# 12=>"Alternative Yeast Nuclear",# 13=>"Ascidian Mitochondrial",# 14=>"Alternative Flatworm Mitochondrial",# 15=>"Blepharisma Macronuclear",# 16=>"Chlorophycean Mitochondrial",# 21=>"Trematode Mitochondrial",# 22=>"Scenedesmus obliquus Mitochondrial",# 23=>"Thraustochytrium Mitochondrial"}# Return the names names for the ids specified in :rangedefinitions=parser.definitions:range=>[(1..3),5,9]# Return default hash map with custom names for the ids 1 and 3definitions=parser.definitions:names=>{1=>"Standard (Eukaryote)",3=>"Yeast Mitochondorial"}definitions[1]# "Standard (Eukaryote)"definitions[3]# "Yeast Mitochondorial"# Return the names for the ids specified in :range, with custom names for the ids 1 and 3parser.definitions:range=>[(1..3),5,9],:names=>{1=>"Standard (Eukaryote)",3=>"Yeast Mitochondorial"}

CodonTableParser#starts

parser=CodonTableParser.new# Return default hash map of start codonsstart_codons=parser.startsstart_codons# {1=>["ttg", "ctg", "atg"],# 2=>["att", "atc", "ata", "atg", "gtg"],# 3=>["ata", "atg"],# 4=>["tta", "ttg", "ctg", "att", "atc", "ata", "atg", "gtg"],# 5=>["ttg", "att", "atc", "ata", "atg", "gtg"],# 6=>["atg"],# 9=>["atg", "gtg"],# 10=>["atg"],# 11=>["ttg", "ctg", "att", "atc", "ata", "atg", "gtg"],# 12=>["ctg", "atg"],# 13=>["ttg", "ata", "atg", "gtg"],# 14=>["atg"],# 15=>["atg"],# 16=>["atg"],# 21=>["atg", "gtg"],# 22=>["atg"],# 23=>["att", "atg", "gtg"]}# Return the start codons for the ids specified in :rangestart_codons=parser.starts:range=>[(1..3),5,9]# Add or remove start codons as necessarystart_codons=parser.starts1=>{:add=>['gtg']},13=>{:remove=>['ttg','ata','gtg']}start_codons[1]# ["ttg", "ctg", "atg", "gtg"]start_codons[13]# ["atg"]# Alternative syntax, normally only used in the bundle method described belowstart_codons=parser.starts:starts=>{1=>{:add=>['gtg']},13=>{:remove=>['ttg','ata','gtg']}}# Return the start codons for the ids specified with :range, add or remove codons from specific idsstart_codons=parser.starts:range=>[(1..3),13],1=>{:add=>['gtg']},13=>{:remove=>['ttg','ata','gtg']}

CodonTableParser#stops

parser=CodonTableParser.new# Return the default hash map of stop codonsstop_codons=parser.stopsstops# {1=>["taa", "tag", "tga"],# 2=>["taa", "tag", "aga", "agg"],# 3=>["taa", "tag"],# 4=>["taa", "tag"],# 5=>["taa", "tag"],# 6=>["tga"],# 9=>["taa", "tag"],# 10=>["taa", "tag"],# 11=>["taa", "tag", "tga"],# 12=>["taa", "tag", "tga"],# 13=>["taa", "tag"],# 14=>["tag"],# 15=>["taa", "tga"],# 16=>["taa", "tga"],# 21=>["taa", "tag"],# 22=>["tca", "taa", "tga"],# 23=>["tta", "taa", "tag", "tga"]}# Return the stop codons for the ids specified with :rangestop_codons=parser.stops:range=>[(1..3),5,9]# Add or remove stop codons as necessarystop_codons=parser.stops1=>{:add=>['gtg'],:remove=>['taa']},13=>{:add=>['gcc'],:remove=>['taa','tag']}stop_codons[1]# ["tag", "tga", "gtg"]stop_codons[13]# ["gcc"]# Alternative syntax, normally only used in the bundle method described belowstop_codons=parser.stops:stops=>{1=>{:add=>['gtg'],:remove=>['taa']},13=>{:add=>['gcc'],:remove=>['taa','tag']}}# Return the stop codons for the ids specified with :range, add or remove codons from specific idsstop_codons=parser.stops:range=>[(1..3),5,13],1=>{:add=>['gtg'],:remove=>['taa']},13=>{:add=>['gcc'],:remove=>['taa','tag']}

CodonTableParser#tables

parser=CodonTableParser.new# Return codon tables of all speciescodon_tables=parser.tablestables# {# 1 => {# 'ttt' => 'F', 'tct' => 'S', 'tat' => 'Y', 'tgt' => 'C',# 'ttc' => 'F', 'tcc' => 'S', 'tac' => 'Y', 'tgc' => 'C',# 'tta' => 'L', 'tca' => 'S', 'taa' => '*', 'tga' => '*',# 'ttg' => 'L', 'tcg' => 'S', 'tag' => '*', 'tgg' => 'W',# # 'ctt' => 'L', 'cct' => 'P', 'cat' => 'H', 'cgt' => 'R',# 'ctc' => 'L', 'ccc' => 'P', 'cac' => 'H', 'cgc' => 'R',# 'cta' => 'L', 'cca' => 'P', 'caa' => 'Q', 'cga' => 'R',# 'ctg' => 'L', 'ccg' => 'P', 'cag' => 'Q', 'cgg' => 'R',# # 'att' => 'I', 'act' => 'T', 'aat' => 'N', 'agt' => 'S',# 'atc' => 'I', 'acc' => 'T', 'aac' => 'N', 'agc' => 'S',# 'ata' => 'I', 'aca' => 'T', 'aaa' => 'K', 'aga' => 'R',# 'atg' => 'M', 'acg' => 'T', 'aag' => 'K', 'agg' => 'R',# # 'gtt' => 'V', 'gct' => 'A', 'gat' => 'D', 'ggt' => 'G',# 'gtc' => 'V', 'gcc' => 'A', 'gac' => 'D', 'ggc' => 'G',# 'gta' => 'V', 'gca' => 'A', 'gaa' => 'E', 'gga' => 'G',# 'gtg' => 'V', 'gcg' => 'A', 'gag' => 'E', 'ggg' => 'G',# },# 2 => { ... },# 3 => { ... },# ...# 23 => { ... }# }# Return the codon tables for the ids specified with :rangecodon_tables=parser.tables:range=>[(1..3),5,9,23]

CodonTableParser#bundle

parser=CodonTableParser.new# Return the definitions, codon table, start and stop codons for all species as a hash mapbundle=parser.bundlebundle# {:definitions => {return value of the 'definitions' method}# :starts => {return value of the 'starts' method}# :stops => {return value of the 'stops' method}# :tables => {return value of the 'tables' method}# }

The bundle method accepts all options from the methods described above, that is:

  • :range (applied to all methods)
  • :names (applied to the definitions method)
  • :starts (applied to the starts method)
  • :stops (applied to the stops method)

To return the same values as are assigned to the constants DEFINITIONS, STARTS, STOPS, and TABLES of BioRuby's CodonTable class, calling bundle with the following options will do:

bundle=parser.bundle:names=>{1=>"Standard (Eukaryote)",4=>"Mold, Protozoan, Coelenterate Mitochondrial and Mycoplasma/Spiroplasma",3=>"Yeast Mitochondorial",6=>"Ciliate Macronuclear and Dasycladacean",9=>"Echinoderm Mitochondrial",11=>"Bacteria",14=>"Flatworm Mitochondrial",22=>"Scenedesmus obliquus mitochondrial"},:starts=>{1=>{:add=>['gtg']},13=>{:remove=>['ttg','ata','gtg']}}

About

Parses the NCBI genetic code table, generating hash maps of each species' name, start codons, stop codons and codon table. The output of CodonTableParser can be customized easily and used to update the respective constants of BioRuby's CodonTable class whenever the original data has changed.

Resources

Stars

1 star

Watchers

2 watching

Forks

Releases

Packages

Used by

Contributors

Languages