jandot-bio 1.2.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (335) hide show
  1. data/bin/bioruby +44 -0
  2. data/bin/br_biofetch.rb +47 -0
  3. data/bin/br_bioflat.rb +282 -0
  4. data/bin/br_biogetseq.rb +45 -0
  5. data/bin/br_pmfetch.rb +421 -0
  6. data/doc/Changes-0.7.rd +369 -0
  7. data/doc/KEGG_API.rd +1843 -0
  8. data/doc/KEGG_API.rd.ja +1834 -0
  9. data/doc/Tutorial.rd +1296 -0
  10. data/doc/Tutorial.rd.ja +2640 -0
  11. data/etc/bioinformatics/seqdatabase.ini +210 -0
  12. data/lib/bio.rb +279 -0
  13. data/lib/bio/alignment.rb +2518 -0
  14. data/lib/bio/appl/bl2seq/report.rb +334 -0
  15. data/lib/bio/appl/blast.rb +351 -0
  16. data/lib/bio/appl/blast/format0.rb +1438 -0
  17. data/lib/bio/appl/blast/format8.rb +83 -0
  18. data/lib/bio/appl/blast/report.rb +516 -0
  19. data/lib/bio/appl/blast/rexml.rb +135 -0
  20. data/lib/bio/appl/blast/rpsblast.rb +176 -0
  21. data/lib/bio/appl/blast/wublast.rb +550 -0
  22. data/lib/bio/appl/blast/xmlparser.rb +228 -0
  23. data/lib/bio/appl/blat/report.rb +489 -0
  24. data/lib/bio/appl/clustalw.rb +219 -0
  25. data/lib/bio/appl/clustalw/report.rb +152 -0
  26. data/lib/bio/appl/emboss.rb +203 -0
  27. data/lib/bio/appl/fasta.rb +237 -0
  28. data/lib/bio/appl/fasta/format10.rb +325 -0
  29. data/lib/bio/appl/gcg/msf.rb +212 -0
  30. data/lib/bio/appl/gcg/seq.rb +195 -0
  31. data/lib/bio/appl/genscan/report.rb +552 -0
  32. data/lib/bio/appl/hmmer.rb +126 -0
  33. data/lib/bio/appl/hmmer/report.rb +683 -0
  34. data/lib/bio/appl/iprscan/report.rb +374 -0
  35. data/lib/bio/appl/mafft.rb +259 -0
  36. data/lib/bio/appl/mafft/report.rb +226 -0
  37. data/lib/bio/appl/muscle.rb +52 -0
  38. data/lib/bio/appl/phylip/alignment.rb +129 -0
  39. data/lib/bio/appl/phylip/distance_matrix.rb +96 -0
  40. data/lib/bio/appl/probcons.rb +41 -0
  41. data/lib/bio/appl/psort.rb +548 -0
  42. data/lib/bio/appl/psort/report.rb +457 -0
  43. data/lib/bio/appl/pts1.rb +263 -0
  44. data/lib/bio/appl/sim4.rb +124 -0
  45. data/lib/bio/appl/sim4/report.rb +485 -0
  46. data/lib/bio/appl/sosui/report.rb +151 -0
  47. data/lib/bio/appl/spidey/report.rb +593 -0
  48. data/lib/bio/appl/targetp/report.rb +267 -0
  49. data/lib/bio/appl/tcoffee.rb +55 -0
  50. data/lib/bio/appl/tmhmm/report.rb +222 -0
  51. data/lib/bio/command.rb +337 -0
  52. data/lib/bio/data/aa.rb +349 -0
  53. data/lib/bio/data/codontable.rb +722 -0
  54. data/lib/bio/data/na.rb +223 -0
  55. data/lib/bio/db.rb +329 -0
  56. data/lib/bio/db/aaindex.rb +357 -0
  57. data/lib/bio/db/embl/common.rb +336 -0
  58. data/lib/bio/db/embl/embl.rb +402 -0
  59. data/lib/bio/db/embl/sptr.rb +1283 -0
  60. data/lib/bio/db/embl/swissprot.rb +42 -0
  61. data/lib/bio/db/embl/trembl.rb +41 -0
  62. data/lib/bio/db/embl/uniprot.rb +42 -0
  63. data/lib/bio/db/fantom.rb +599 -0
  64. data/lib/bio/db/fasta.rb +907 -0
  65. data/lib/bio/db/genbank/common.rb +290 -0
  66. data/lib/bio/db/genbank/ddbj.rb +22 -0
  67. data/lib/bio/db/genbank/genbank.rb +215 -0
  68. data/lib/bio/db/genbank/genpept.rb +60 -0
  69. data/lib/bio/db/genbank/refseq.rb +18 -0
  70. data/lib/bio/db/gff.rb +174 -0
  71. data/lib/bio/db/go.rb +481 -0
  72. data/lib/bio/db/kegg/brite.rb +41 -0
  73. data/lib/bio/db/kegg/compound.rb +131 -0
  74. data/lib/bio/db/kegg/drug.rb +98 -0
  75. data/lib/bio/db/kegg/enzyme.rb +148 -0
  76. data/lib/bio/db/kegg/expression.rb +155 -0
  77. data/lib/bio/db/kegg/genes.rb +263 -0
  78. data/lib/bio/db/kegg/genome.rb +241 -0
  79. data/lib/bio/db/kegg/glycan.rb +170 -0
  80. data/lib/bio/db/kegg/keggtab.rb +357 -0
  81. data/lib/bio/db/kegg/kgml.rb +256 -0
  82. data/lib/bio/db/kegg/orthology.rb +136 -0
  83. data/lib/bio/db/kegg/reaction.rb +82 -0
  84. data/lib/bio/db/kegg/taxonomy.rb +331 -0
  85. data/lib/bio/db/lasergene.rb +209 -0
  86. data/lib/bio/db/litdb.rb +107 -0
  87. data/lib/bio/db/medline.rb +323 -0
  88. data/lib/bio/db/nbrf.rb +191 -0
  89. data/lib/bio/db/newick.rb +658 -0
  90. data/lib/bio/db/nexus.rb +1854 -0
  91. data/lib/bio/db/pdb.rb +29 -0
  92. data/lib/bio/db/pdb/atom.rb +77 -0
  93. data/lib/bio/db/pdb/chain.rb +210 -0
  94. data/lib/bio/db/pdb/chemicalcomponent.rb +224 -0
  95. data/lib/bio/db/pdb/model.rb +148 -0
  96. data/lib/bio/db/pdb/pdb.rb +1911 -0
  97. data/lib/bio/db/pdb/residue.rb +176 -0
  98. data/lib/bio/db/pdb/utils.rb +399 -0
  99. data/lib/bio/db/prosite.rb +597 -0
  100. data/lib/bio/db/rebase.rb +457 -0
  101. data/lib/bio/db/soft.rb +404 -0
  102. data/lib/bio/db/transfac.rb +375 -0
  103. data/lib/bio/feature.rb +226 -0
  104. data/lib/bio/io/das.rb +461 -0
  105. data/lib/bio/io/dbget.rb +194 -0
  106. data/lib/bio/io/ddbjxml.rb +581 -0
  107. data/lib/bio/io/ebisoap.rb +158 -0
  108. data/lib/bio/io/ensembl.rb +229 -0
  109. data/lib/bio/io/fastacmd.rb +163 -0
  110. data/lib/bio/io/fetch.rb +181 -0
  111. data/lib/bio/io/flatfile.rb +1309 -0
  112. data/lib/bio/io/flatfile/bdb.rb +253 -0
  113. data/lib/bio/io/flatfile/index.rb +1371 -0
  114. data/lib/bio/io/flatfile/indexer.rb +787 -0
  115. data/lib/bio/io/higet.rb +73 -0
  116. data/lib/bio/io/hinv.rb +442 -0
  117. data/lib/bio/io/keggapi.rb +805 -0
  118. data/lib/bio/io/ncbirest.rb +256 -0
  119. data/lib/bio/io/ncbisoap.rb +155 -0
  120. data/lib/bio/io/pubmed.rb +307 -0
  121. data/lib/bio/io/registry.rb +292 -0
  122. data/lib/bio/io/soapwsdl.rb +119 -0
  123. data/lib/bio/io/sql.rb +365 -0
  124. data/lib/bio/location.rb +772 -0
  125. data/lib/bio/map.rb +410 -0
  126. data/lib/bio/pathway.rb +854 -0
  127. data/lib/bio/reference.rb +623 -0
  128. data/lib/bio/sequence.rb +475 -0
  129. data/lib/bio/sequence/aa.rb +125 -0
  130. data/lib/bio/sequence/common.rb +333 -0
  131. data/lib/bio/sequence/compat.rb +123 -0
  132. data/lib/bio/sequence/format.rb +181 -0
  133. data/lib/bio/sequence/generic.rb +24 -0
  134. data/lib/bio/sequence/na.rb +491 -0
  135. data/lib/bio/shell.rb +44 -0
  136. data/lib/bio/shell/core.rb +578 -0
  137. data/lib/bio/shell/demo.rb +146 -0
  138. data/lib/bio/shell/interface.rb +218 -0
  139. data/lib/bio/shell/irb.rb +95 -0
  140. data/lib/bio/shell/object.rb +71 -0
  141. data/lib/bio/shell/plugin/blast.rb +42 -0
  142. data/lib/bio/shell/plugin/codon.rb +218 -0
  143. data/lib/bio/shell/plugin/das.rb +58 -0
  144. data/lib/bio/shell/plugin/emboss.rb +23 -0
  145. data/lib/bio/shell/plugin/entry.rb +105 -0
  146. data/lib/bio/shell/plugin/flatfile.rb +101 -0
  147. data/lib/bio/shell/plugin/keggapi.rb +181 -0
  148. data/lib/bio/shell/plugin/midi.rb +430 -0
  149. data/lib/bio/shell/plugin/obda.rb +45 -0
  150. data/lib/bio/shell/plugin/psort.rb +56 -0
  151. data/lib/bio/shell/plugin/seq.rb +247 -0
  152. data/lib/bio/shell/plugin/soap.rb +87 -0
  153. data/lib/bio/shell/rails/vendor/plugins/bioruby/generators/bioruby/bioruby_generator.rb +29 -0
  154. data/lib/bio/shell/rails/vendor/plugins/bioruby/generators/bioruby/templates/_classes.rhtml +4 -0
  155. data/lib/bio/shell/rails/vendor/plugins/bioruby/generators/bioruby/templates/_log.rhtml +27 -0
  156. data/lib/bio/shell/rails/vendor/plugins/bioruby/generators/bioruby/templates/_methods.rhtml +11 -0
  157. data/lib/bio/shell/rails/vendor/plugins/bioruby/generators/bioruby/templates/_modules.rhtml +4 -0
  158. data/lib/bio/shell/rails/vendor/plugins/bioruby/generators/bioruby/templates/_variables.rhtml +7 -0
  159. data/lib/bio/shell/rails/vendor/plugins/bioruby/generators/bioruby/templates/bioruby-bg.gif +0 -0
  160. data/lib/bio/shell/rails/vendor/plugins/bioruby/generators/bioruby/templates/bioruby-gem.png +0 -0
  161. data/lib/bio/shell/rails/vendor/plugins/bioruby/generators/bioruby/templates/bioruby-link.gif +0 -0
  162. data/lib/bio/shell/rails/vendor/plugins/bioruby/generators/bioruby/templates/bioruby.css +368 -0
  163. data/lib/bio/shell/rails/vendor/plugins/bioruby/generators/bioruby/templates/bioruby.rhtml +47 -0
  164. data/lib/bio/shell/rails/vendor/plugins/bioruby/generators/bioruby/templates/bioruby_controller.rb +144 -0
  165. data/lib/bio/shell/rails/vendor/plugins/bioruby/generators/bioruby/templates/bioruby_helper.rb +47 -0
  166. data/lib/bio/shell/rails/vendor/plugins/bioruby/generators/bioruby/templates/commands.rhtml +8 -0
  167. data/lib/bio/shell/rails/vendor/plugins/bioruby/generators/bioruby/templates/history.rhtml +10 -0
  168. data/lib/bio/shell/rails/vendor/plugins/bioruby/generators/bioruby/templates/index.rhtml +26 -0
  169. data/lib/bio/shell/rails/vendor/plugins/bioruby/generators/bioruby/templates/spinner.gif +0 -0
  170. data/lib/bio/shell/script.rb +25 -0
  171. data/lib/bio/shell/setup.rb +109 -0
  172. data/lib/bio/shell/web.rb +102 -0
  173. data/lib/bio/tree.rb +850 -0
  174. data/lib/bio/util/color_scheme.rb +191 -0
  175. data/lib/bio/util/color_scheme/buried.rb +59 -0
  176. data/lib/bio/util/color_scheme/helix.rb +59 -0
  177. data/lib/bio/util/color_scheme/hydropathy.rb +64 -0
  178. data/lib/bio/util/color_scheme/nucleotide.rb +31 -0
  179. data/lib/bio/util/color_scheme/strand.rb +59 -0
  180. data/lib/bio/util/color_scheme/taylor.rb +50 -0
  181. data/lib/bio/util/color_scheme/turn.rb +59 -0
  182. data/lib/bio/util/color_scheme/zappo.rb +50 -0
  183. data/lib/bio/util/contingency_table.rb +370 -0
  184. data/lib/bio/util/restriction_enzyme.rb +228 -0
  185. data/lib/bio/util/restriction_enzyme/analysis.rb +249 -0
  186. data/lib/bio/util/restriction_enzyme/analysis_basic.rb +217 -0
  187. data/lib/bio/util/restriction_enzyme/cut_symbol.rb +107 -0
  188. data/lib/bio/util/restriction_enzyme/double_stranded.rb +321 -0
  189. data/lib/bio/util/restriction_enzyme/double_stranded/aligned_strands.rb +130 -0
  190. data/lib/bio/util/restriction_enzyme/double_stranded/cut_location_pair.rb +103 -0
  191. data/lib/bio/util/restriction_enzyme/double_stranded/cut_location_pair_in_enzyme_notation.rb +38 -0
  192. data/lib/bio/util/restriction_enzyme/double_stranded/cut_locations.rb +76 -0
  193. data/lib/bio/util/restriction_enzyme/double_stranded/cut_locations_in_enzyme_notation.rb +107 -0
  194. data/lib/bio/util/restriction_enzyme/enzymes.yaml +7061 -0
  195. data/lib/bio/util/restriction_enzyme/range/cut_range.rb +24 -0
  196. data/lib/bio/util/restriction_enzyme/range/cut_ranges.rb +47 -0
  197. data/lib/bio/util/restriction_enzyme/range/horizontal_cut_range.rb +67 -0
  198. data/lib/bio/util/restriction_enzyme/range/sequence_range.rb +257 -0
  199. data/lib/bio/util/restriction_enzyme/range/sequence_range/calculated_cuts.rb +242 -0
  200. data/lib/bio/util/restriction_enzyme/range/sequence_range/fragment.rb +51 -0
  201. data/lib/bio/util/restriction_enzyme/range/sequence_range/fragments.rb +41 -0
  202. data/lib/bio/util/restriction_enzyme/range/vertical_cut_range.rb +77 -0
  203. data/lib/bio/util/restriction_enzyme/single_strand.rb +199 -0
  204. data/lib/bio/util/restriction_enzyme/single_strand/cut_locations_in_enzyme_notation.rb +135 -0
  205. data/lib/bio/util/restriction_enzyme/single_strand_complement.rb +23 -0
  206. data/lib/bio/util/restriction_enzyme/string_formatting.rb +111 -0
  207. data/lib/bio/util/sirna.rb +288 -0
  208. data/sample/any2fasta.rb +59 -0
  209. data/sample/biofetch.rb +475 -0
  210. data/sample/color_scheme_na.rb +91 -0
  211. data/sample/dbget +37 -0
  212. data/sample/enzymes.rb +78 -0
  213. data/sample/fasta2tab.rb +99 -0
  214. data/sample/fastagrep.rb +72 -0
  215. data/sample/fastasort.rb +54 -0
  216. data/sample/fsplit.rb +51 -0
  217. data/sample/gb2fasta.rb +30 -0
  218. data/sample/gb2tab.rb +325 -0
  219. data/sample/gbtab2mysql.rb +161 -0
  220. data/sample/genes2nuc.rb +33 -0
  221. data/sample/genes2pep.rb +33 -0
  222. data/sample/genes2tab.rb +81 -0
  223. data/sample/genome2rb.rb +29 -0
  224. data/sample/genome2tab.rb +76 -0
  225. data/sample/goslim.rb +303 -0
  226. data/sample/gt2fasta.rb +47 -0
  227. data/sample/na2aa.rb +34 -0
  228. data/sample/pmfetch.rb +42 -0
  229. data/sample/pmsearch.rb +42 -0
  230. data/sample/psortplot_html.rb +214 -0
  231. data/sample/ssearch2tab.rb +96 -0
  232. data/sample/tdiary.rb +158 -0
  233. data/sample/tfastx2tab.rb +100 -0
  234. data/sample/vs-genes.rb +212 -0
  235. data/test/data/HMMER/hmmpfam.out +64 -0
  236. data/test/data/HMMER/hmmsearch.out +88 -0
  237. data/test/data/SOSUI/sample.report +11 -0
  238. data/test/data/TMHMM/sample.report +21 -0
  239. data/test/data/aaindex/DAYM780301 +30 -0
  240. data/test/data/aaindex/PRAM900102 +20 -0
  241. data/test/data/bl2seq/cd8a_cd8b_blastp.bl2seq +53 -0
  242. data/test/data/bl2seq/cd8a_p53_e-5blastp.bl2seq +37 -0
  243. data/test/data/blast/2.2.15.blastp.m7 +876 -0
  244. data/test/data/blast/b0002.faa +15 -0
  245. data/test/data/blast/b0002.faa.m0 +128 -0
  246. data/test/data/blast/b0002.faa.m7 +65 -0
  247. data/test/data/blast/b0002.faa.m8 +1 -0
  248. data/test/data/embl/AB090716.embl +65 -0
  249. data/test/data/embl/AB090716.embl.rel89 +63 -0
  250. data/test/data/fasta/example1.txt +75 -0
  251. data/test/data/fasta/example2.txt +21 -0
  252. data/test/data/genscan/sample.report +63 -0
  253. data/test/data/iprscan/merged.raw +32 -0
  254. data/test/data/iprscan/merged.txt +74 -0
  255. data/test/data/prosite/prosite.dat +2233 -0
  256. data/test/data/refseq/nm_126355.entret +64 -0
  257. data/test/data/soft/GDS100_partial.soft +92 -0
  258. data/test/data/soft/GSE3457_family_partial.soft +874 -0
  259. data/test/data/uniprot/p53_human.uniprot +1456 -0
  260. data/test/functional/bio/io/test_ensembl.rb +186 -0
  261. data/test/functional/bio/io/test_soapwsdl.rb +52 -0
  262. data/test/runner.rb +14 -0
  263. data/test/unit/bio/appl/bl2seq/test_report.rb +134 -0
  264. data/test/unit/bio/appl/blast/test_report.rb +417 -0
  265. data/test/unit/bio/appl/blast/test_xmlparser.rb +388 -0
  266. data/test/unit/bio/appl/genscan/test_report.rb +182 -0
  267. data/test/unit/bio/appl/hmmer/test_report.rb +342 -0
  268. data/test/unit/bio/appl/iprscan/test_report.rb +338 -0
  269. data/test/unit/bio/appl/mafft/test_report.rb +63 -0
  270. data/test/unit/bio/appl/sosui/test_report.rb +81 -0
  271. data/test/unit/bio/appl/targetp/test_report.rb +146 -0
  272. data/test/unit/bio/appl/test_blast.rb +163 -0
  273. data/test/unit/bio/appl/test_fasta.rb +130 -0
  274. data/test/unit/bio/appl/test_pts1.rb +140 -0
  275. data/test/unit/bio/appl/tmhmm/test_report.rb +126 -0
  276. data/test/unit/bio/data/test_aa.rb +90 -0
  277. data/test/unit/bio/data/test_codontable.rb +107 -0
  278. data/test/unit/bio/data/test_na.rb +80 -0
  279. data/test/unit/bio/db/embl/test_common.rb +117 -0
  280. data/test/unit/bio/db/embl/test_embl.rb +214 -0
  281. data/test/unit/bio/db/embl/test_embl_rel89.rb +219 -0
  282. data/test/unit/bio/db/embl/test_sptr.rb +1775 -0
  283. data/test/unit/bio/db/embl/test_uniprot.rb +31 -0
  284. data/test/unit/bio/db/kegg/test_genes.rb +45 -0
  285. data/test/unit/bio/db/pdb/test_pdb.rb +152 -0
  286. data/test/unit/bio/db/test_aaindex.rb +197 -0
  287. data/test/unit/bio/db/test_fasta.rb +250 -0
  288. data/test/unit/bio/db/test_gff.rb +127 -0
  289. data/test/unit/bio/db/test_lasergene.rb +95 -0
  290. data/test/unit/bio/db/test_newick.rb +293 -0
  291. data/test/unit/bio/db/test_nexus.rb +360 -0
  292. data/test/unit/bio/db/test_prosite.rb +1437 -0
  293. data/test/unit/bio/db/test_rebase.rb +101 -0
  294. data/test/unit/bio/db/test_soft.rb +138 -0
  295. data/test/unit/bio/io/test_ddbjxml.rb +75 -0
  296. data/test/unit/bio/io/test_ensembl.rb +109 -0
  297. data/test/unit/bio/io/test_fastacmd.rb +42 -0
  298. data/test/unit/bio/io/test_flatfile.rb +237 -0
  299. data/test/unit/bio/io/test_soapwsdl.rb +32 -0
  300. data/test/unit/bio/sequence/test_aa.rb +103 -0
  301. data/test/unit/bio/sequence/test_common.rb +174 -0
  302. data/test/unit/bio/sequence/test_compat.rb +69 -0
  303. data/test/unit/bio/sequence/test_na.rb +330 -0
  304. data/test/unit/bio/shell/plugin/test_seq.rb +185 -0
  305. data/test/unit/bio/test_alignment.rb +1025 -0
  306. data/test/unit/bio/test_command.rb +288 -0
  307. data/test/unit/bio/test_db.rb +96 -0
  308. data/test/unit/bio/test_feature.rb +116 -0
  309. data/test/unit/bio/test_location.rb +39 -0
  310. data/test/unit/bio/test_map.rb +230 -0
  311. data/test/unit/bio/test_pathway.rb +473 -0
  312. data/test/unit/bio/test_reference.rb +224 -0
  313. data/test/unit/bio/test_sequence.rb +329 -0
  314. data/test/unit/bio/test_shell.rb +18 -0
  315. data/test/unit/bio/test_tree.rb +593 -0
  316. data/test/unit/bio/util/restriction_enzyme/analysis/test_calculated_cuts.rb +299 -0
  317. data/test/unit/bio/util/restriction_enzyme/analysis/test_cut_ranges.rb +103 -0
  318. data/test/unit/bio/util/restriction_enzyme/analysis/test_sequence_range.rb +240 -0
  319. data/test/unit/bio/util/restriction_enzyme/double_stranded/test_aligned_strands.rb +101 -0
  320. data/test/unit/bio/util/restriction_enzyme/double_stranded/test_cut_location_pair.rb +75 -0
  321. data/test/unit/bio/util/restriction_enzyme/double_stranded/test_cut_location_pair_in_enzyme_notation.rb +73 -0
  322. data/test/unit/bio/util/restriction_enzyme/double_stranded/test_cut_locations.rb +53 -0
  323. data/test/unit/bio/util/restriction_enzyme/double_stranded/test_cut_locations_in_enzyme_notation.rb +104 -0
  324. data/test/unit/bio/util/restriction_enzyme/single_strand/test_cut_locations_in_enzyme_notation.rb +83 -0
  325. data/test/unit/bio/util/restriction_enzyme/test_analysis.rb +246 -0
  326. data/test/unit/bio/util/restriction_enzyme/test_cut_symbol.rb +44 -0
  327. data/test/unit/bio/util/restriction_enzyme/test_double_stranded.rb +115 -0
  328. data/test/unit/bio/util/restriction_enzyme/test_single_strand.rb +147 -0
  329. data/test/unit/bio/util/restriction_enzyme/test_single_strand_complement.rb +147 -0
  330. data/test/unit/bio/util/restriction_enzyme/test_string_formatting.rb +60 -0
  331. data/test/unit/bio/util/test_color_scheme.rb +33 -0
  332. data/test/unit/bio/util/test_contingency_table.rb +94 -0
  333. data/test/unit/bio/util/test_restriction_enzyme.rb +42 -0
  334. data/test/unit/bio/util/test_sirna.rb +245 -0
  335. metadata +479 -0
@@ -0,0 +1,223 @@
1
+ #
2
+ # = bio/data/na.rb - Nucleic Acids
3
+ #
4
+ # Copyright:: Copyright (C) 2001, 2005
5
+ # Toshiaki Katayama <k@bioruby.org>
6
+ # License:: The Ruby License
7
+ #
8
+ # $Id: na.rb,v 0.23 2007/04/06 04:41:28 k Exp $
9
+ #
10
+ # == Synopsis
11
+ #
12
+ # Bio::NucleicAcid class contains data related to nucleic acids.
13
+ #
14
+ # == Usage
15
+ #
16
+ # Examples:
17
+ #
18
+ # require 'bio'
19
+ #
20
+ # puts "### na = Bio::NucleicAcid.new"
21
+ # na = Bio::NucleicAcid.new
22
+ #
23
+ # puts "# na.to_re('yrwskmbdhvnatgc')"
24
+ # p na.to_re('yrwskmbdhvnatgc')
25
+ #
26
+ # puts "# Bio::NucleicAcid.to_re('yrwskmbdhvnatgc')"
27
+ # p Bio::NucleicAcid.to_re('yrwskmbdhvnatgc')
28
+ #
29
+ # puts "# na.weight('A')"
30
+ # p na.weight('A')
31
+ #
32
+ # puts "# Bio::NucleicAcid.weight('A')"
33
+ # p Bio::NucleicAcid.weight('A')
34
+ #
35
+ # puts "# na.weight('atgc')"
36
+ # p na.weight('atgc')
37
+ #
38
+ # puts "# Bio::NucleicAcid.weight('atgc')"
39
+ # p Bio::NucleicAcid.weight('atgc')
40
+ #
41
+
42
+ module Bio
43
+
44
+ class NucleicAcid
45
+
46
+ module Data
47
+
48
+ # IUPAC code
49
+ # * Faisst and Meyer (Nucleic Acids Res. 20:3-26, 1992)
50
+ # * http://www.ncbi.nlm.nih.gov/collab/FT/
51
+
52
+ NAMES = {
53
+
54
+ 'y' => '[tc]',
55
+ 'r' => '[ag]',
56
+ 'w' => '[at]',
57
+ 's' => '[gc]',
58
+ 'k' => '[tg]',
59
+ 'm' => '[ac]',
60
+
61
+ 'b' => '[tgc]',
62
+ 'd' => '[atg]',
63
+ 'h' => '[atc]',
64
+ 'v' => '[agc]',
65
+
66
+ 'n' => '[atgc]',
67
+
68
+ 'a' => 'a',
69
+ 't' => 't',
70
+ 'g' => 'g',
71
+ 'c' => 'c',
72
+ 'u' => 'u',
73
+
74
+ 'A' => 'Adenine',
75
+ 'T' => 'Thymine',
76
+ 'G' => 'Guanine',
77
+ 'C' => 'Cytosine',
78
+ 'U' => 'Uracil',
79
+
80
+ 'Y' => 'pYrimidine',
81
+ 'R' => 'puRine',
82
+ 'W' => 'Weak',
83
+ 'S' => 'Strong',
84
+ 'K' => 'Keto',
85
+ 'M' => 'aroMatic',
86
+
87
+ 'B' => 'not A',
88
+ 'D' => 'not C',
89
+ 'H' => 'not G',
90
+ 'V' => 'not T',
91
+ }
92
+
93
+ WEIGHT = {
94
+
95
+ # Calculated by BioPerl's Bio::Tools::SeqStats.pm :-)
96
+
97
+ 'a' => 135.15,
98
+ 't' => 126.13,
99
+ 'g' => 151.15,
100
+ 'c' => 111.12,
101
+ 'u' => 112.10,
102
+
103
+ :adenine => 135.15,
104
+ :thymine => 126.13,
105
+ :guanine => 151.15,
106
+ :cytosine => 111.12,
107
+ :uracil => 112.10,
108
+
109
+ :deoxyribose_phosphate => 196.11,
110
+ :ribose_phosphate => 212.11,
111
+
112
+ :hydrogen => 1.00794,
113
+ :water => 18.015,
114
+
115
+ }
116
+
117
+ def weight(x = nil, rna = nil)
118
+ if x
119
+ if x.length > 1
120
+ if rna
121
+ phosphate = WEIGHT[:ribose_phosphate]
122
+ else
123
+ phosphate = WEIGHT[:deoxyribose_phosphate]
124
+ end
125
+ hydrogen = WEIGHT[:hydrogen]
126
+ water = WEIGHT[:water]
127
+
128
+ total = 0.0
129
+ x.each_byte do |byte|
130
+ base = byte.chr.downcase
131
+ if WEIGHT[base]
132
+ total += WEIGHT[base] + phosphate - hydrogen * 2
133
+ else
134
+ raise "Error: invalid nucleic acid '#{base}'"
135
+ end
136
+ end
137
+ total -= water * (x.length - 1)
138
+ else
139
+ WEIGHT[x.to_s.downcase]
140
+ end
141
+ else
142
+ WEIGHT
143
+ end
144
+ end
145
+
146
+ def [](x)
147
+ NAMES[x]
148
+ end
149
+
150
+ # backward compatibility
151
+ def names
152
+ NAMES
153
+ end
154
+ alias na names
155
+
156
+ def name(x)
157
+ NAMES[x.to_s.upcase]
158
+ end
159
+
160
+ def to_re(seq, rna = false)
161
+ replace = {
162
+ 'y' => '[tcy]',
163
+ 'r' => '[agr]',
164
+ 'w' => '[atw]',
165
+ 's' => '[gcw]',
166
+ 'k' => '[tgk]',
167
+ 'm' => '[acm]',
168
+ 'b' => '[tgcyskb]',
169
+ 'd' => '[atgrwkd]',
170
+ 'h' => '[atcwmyh]',
171
+ 'v' => '[agcmrsv]',
172
+ 'n' => '[atgcyrwskmbdhvn]'
173
+ }
174
+ replace.default = '.'
175
+
176
+ str = seq.to_s.downcase
177
+ str.gsub!(/[^atgcu]/) { |na|
178
+ replace[na]
179
+ }
180
+ if rna
181
+ str.tr!("t", "u")
182
+ end
183
+ Regexp.new(str)
184
+ end
185
+
186
+ end
187
+
188
+
189
+ # as instance methods
190
+ include Data
191
+
192
+ # as class methods
193
+ extend Data
194
+
195
+ end
196
+
197
+ end # module Bio
198
+
199
+
200
+ if __FILE__ == $0
201
+
202
+ puts "### na = Bio::NucleicAcid.new"
203
+ na = Bio::NucleicAcid.new
204
+
205
+ puts "# na.to_re('yrwskmbdhvnatgc')"
206
+ p na.to_re('yrwskmbdhvnatgc')
207
+
208
+ puts "# Bio::NucleicAcid.to_re('yrwskmbdhvnatgc')"
209
+ p Bio::NucleicAcid.to_re('yrwskmbdhvnatgc')
210
+
211
+ puts "# na.weight('A')"
212
+ p na.weight('A')
213
+
214
+ puts "# Bio::NucleicAcid.weight('A')"
215
+ p Bio::NucleicAcid.weight('A')
216
+
217
+ puts "# na.weight('atgc')"
218
+ p na.weight('atgc')
219
+
220
+ puts "# Bio::NucleicAcid.weight('atgc')"
221
+ p Bio::NucleicAcid.weight('atgc')
222
+
223
+ end
@@ -0,0 +1,329 @@
1
+ #
2
+ # = bio/db.rb - common API for database parsers
3
+ #
4
+ # Copyright:: Copyright (C) 2001, 2002, 2005
5
+ # Toshiaki Katayama <k@bioruby.org>
6
+ # License:: The Ruby License
7
+ #
8
+ # $Id: db.rb,v 0.38 2007/05/08 17:02:13 nakao Exp $
9
+ #
10
+ # == On-demand parsing and cache
11
+ #
12
+ # The flatfile parsers (sub classes of the Bio::DB) split the original entry
13
+ # into a Hash and store the hash in the @orig instance variable. To parse
14
+ # in detail is delayed until the method is called which requires a further
15
+ # parsing of a content of the @orig hash. Fully parsed data is cached in the
16
+ # another hash, @data, separately.
17
+ #
18
+ # == Guide lines for the developers to create an new database class
19
+ #
20
+ # --- Bio::DB.new(entry)
21
+ #
22
+ # The 'new' method should accept the entire entry in one String and
23
+ # return the parsed database object.
24
+ #
25
+ # --- Bio::DB#entry_id
26
+ #
27
+ # Database classes should implement the following methods if appropriate:
28
+ #
29
+ # * entry_id
30
+ # * definition
31
+ #
32
+ # Every sub class should define the following constants if appropriate:
33
+ #
34
+ # * DELIMITER (RS)
35
+ # * entry separator of the flatfile of the database.
36
+ # * RS (= record separator) is an alias for the DELIMITER in short.
37
+ #
38
+ # * TAGSIZE
39
+ # * length of the tag field in the FORTRAN-like format.
40
+ #
41
+ # |<- tag ->||<- data ---->|
42
+ # ENTRY_ID A12345
43
+ # DEFINITION Hoge gene of the Pokemonia pikachuae
44
+ #
45
+ # === Template of the sub class
46
+ #
47
+ # module Bio
48
+ # class Hoge < DB
49
+ #
50
+ # DELIMITER = RS = "\n//\n"
51
+ # TAGSIZE = 12 # You can omit this line if not needed
52
+ #
53
+ # def initialize(entry)
54
+ # end
55
+ #
56
+ # def entry_id
57
+ # end
58
+ #
59
+ # end # class Hoge
60
+ # end # module Bio
61
+ #
62
+ # === Recommended method names for sub classes
63
+ #
64
+ # In general, the method name should be in the singular form when returns
65
+ # a Object (including the case when the Object is a String), and should be
66
+ # the plural form when returns same Objects in Array. It depends on the
67
+ # database classes that which form of the method name can be use.
68
+ #
69
+ # For example, GenBank has several REFERENCE fields in one entry, so define
70
+ # Bio::GenBank#references and this method should return an Array of the
71
+ # Reference objects. On the other hand, MEDLINE has one REFERENCE information
72
+ # per one entry, so define Bio::MEDLINE#reference method and this should
73
+ # return a Reference object.
74
+ #
75
+ # The method names used in the sub classes should be taken from the following
76
+ # list if appropriate:
77
+ #
78
+ # --- entry_id #=> String
79
+ #
80
+ # The entry identifier.
81
+ #
82
+ # --- definition #=> String
83
+ #
84
+ # The description of the entry.
85
+ #
86
+ # --- reference #=> Bio::Reference
87
+ # --- references #=> Array of Bio::Reference
88
+ #
89
+ # The reference field(s) of the entry.
90
+ #
91
+ # --- dblink #=> String
92
+ # --- dblinks #=> Array of String
93
+ #
94
+ # The link(s) to the other database entry.
95
+ #
96
+ # --- naseq #=> Bio::Sequence::NA
97
+ #
98
+ # The DNA/RNA sequence of the entry.
99
+ #
100
+ # --- nalen #=> Integer
101
+ #
102
+ # The length of the DNA/RNA sequence of the entry.
103
+ #
104
+ # --- aaseq #=> Bio::Sequence::AA
105
+ #
106
+ # The amino acid sequence of the entry.
107
+ #
108
+ # --- aalen #=> Integer
109
+ #
110
+ # The length of the amino acid sequence of the entry.
111
+ #
112
+ # --- seq #=> Bio::Sequence::NA or Bio::Sequence::AA
113
+ #
114
+ # Returns an appropriate sequence object.
115
+ #
116
+ # --- position #=> String
117
+ #
118
+ # The position of the sequence in the entry or in the genome (depends on
119
+ # the database).
120
+ #
121
+ # --- locations #=> Bio::Locations
122
+ #
123
+ # Returns Bio::Locations.new(position).
124
+ #
125
+ # --- division #=> String
126
+ #
127
+ # The sub division name of the database.
128
+ #
129
+ # * Example:
130
+ # * EST, VRL etc. for GenBank
131
+ # * PATTERN, RULE etc. for PROSITE
132
+ #
133
+ # --- date #=> String
134
+ #
135
+ # The date of the entry.
136
+ # Should we use Date (by ParseDate) instead of String?
137
+ #
138
+ # --- gene #=> String
139
+ # --- genes #=> Array of String
140
+ #
141
+ # The name(s) of the gene.
142
+ #
143
+ # --- organism #=> String
144
+ #
145
+ # The name of the organism.
146
+ #
147
+
148
+ require 'bio/sequence'
149
+ require 'bio/reference'
150
+ require 'bio/feature'
151
+
152
+ module Bio
153
+
154
+ class DB
155
+
156
+ def self.open(filename, *mode, &block)
157
+ Bio::FlatFile.open(self, filename, *mode, &block)
158
+ end
159
+
160
+ # Returns an entry identifier as a String. This method must be
161
+ # implemented in every database classes by overriding this method.
162
+ def entry_id
163
+ raise NotImplementedError
164
+ end
165
+
166
+ # Returns a list of the top level tags of the entry as an Array of String.
167
+ def tags
168
+ @orig.keys
169
+ end
170
+
171
+ # Returns true or false - wether the entry contains the field of the
172
+ # given tag name.
173
+ def exists?(tag)
174
+ @orig.include?(tag)
175
+ end
176
+
177
+ # Returns an intact field of the tag as a String.
178
+ def get(tag)
179
+ @orig[tag]
180
+ end
181
+
182
+ # Similar to the get method, however, fetch returns the content of the
183
+ # field without its tag and any extra white spaces stripped.
184
+ def fetch(tag, skip = 0)
185
+ field = @orig[tag].split(/\n/, skip + 1).last.to_s
186
+ truncate(field.gsub(/^.{0,#{@tagsize}}/,''))
187
+ end
188
+
189
+
190
+ private
191
+
192
+ # Returns a String with successive white spaces are replaced by one
193
+ # space and stripeed.
194
+ def truncate(str)
195
+ str ||= ""
196
+ return str.gsub(/\s+/, ' ').strip
197
+ end
198
+
199
+ # Returns a tag name of the field as a String.
200
+ def tag_get(str)
201
+ str ||= ""
202
+ return str[0,@tagsize].strip
203
+ end
204
+
205
+ # Returns a String of the field without a tag name.
206
+ def tag_cut(str)
207
+ str ||= ""
208
+ str[0,@tagsize] = ''
209
+ return str
210
+ end
211
+
212
+ # Returns the content of the field as a String like the fetch method.
213
+ # Furthermore, field_fetch stores the result in the @data hash.
214
+ def field_fetch(tag, skip = 0)
215
+ unless @data[tag]
216
+ @data[tag] = fetch(tag, skip)
217
+ end
218
+ return @data[tag]
219
+ end
220
+
221
+ # Returns an Array containing each line of the field without a tag.
222
+ # lines_fetch also stores the result in the @data hash.
223
+ def lines_fetch(tag)
224
+ unless @data[tag]
225
+ list = []
226
+ lines = get(tag).split(/\n/)
227
+ lines.each do |line|
228
+ data = tag_cut(line)
229
+ if data[/^\S/] # next sub field
230
+ list << data
231
+ else # continued sub field
232
+ data.strip!
233
+ if list.last[/\-$/] # folded
234
+ list[-1] += data
235
+ else
236
+ list[-1] += " #{data}" # rest of list
237
+ end
238
+ end
239
+ end
240
+ @data[tag] = list
241
+ end
242
+ @data[tag]
243
+ end
244
+
245
+ end # class DB
246
+
247
+
248
+ # Stores a NCBI style (GenBank, KEGG etc.) entry.
249
+ class NCBIDB < DB
250
+
251
+ autoload :Common, 'bio/db/genbank/common'
252
+
253
+ # The entire entry is passed as a String. The length of the tag field is
254
+ # passed as an Integer. Parses the entry roughly by the entry2hash method
255
+ # and returns a database object.
256
+ def initialize(entry, tagsize)
257
+ @tagsize = tagsize
258
+ @orig = entry2hash(entry.strip) # Hash of the original entry
259
+ @data = {} # Hash of the parsed entry
260
+ end
261
+
262
+ private
263
+
264
+ # Splits an entry into an Array of Strings at the level of top tags.
265
+ def toptag2array(str)
266
+ sep = "\001"
267
+ str.gsub(/\n([A-Za-z\/\*])/, "\n#{sep}\\1").split(sep)
268
+ end
269
+
270
+ # Splits a field into an Array of Strings at the level of sub tags.
271
+ def subtag2array(str)
272
+ sep = "\001"
273
+ str.gsub(/\n(\s{1,#{@tagsize-1}}\S)/, "\n#{sep}\\1").split(sep)
274
+ end
275
+
276
+ # Returns the contents of the entry as a Hash with the top level tags as
277
+ # its keys.
278
+ def entry2hash(entry)
279
+ hash = Hash.new('')
280
+
281
+ fields = toptag2array(entry)
282
+
283
+ fields.each do |field|
284
+ tag = tag_get(field)
285
+ hash[tag] += field
286
+ end
287
+ return hash
288
+ end
289
+
290
+ end # class NCBIDB
291
+
292
+
293
+ # Class for KEGG databases. Inherits a NCBIDB class.
294
+ class KEGGDB < NCBIDB
295
+ end
296
+
297
+
298
+ # Stores an EMBL style (EMBL, TrEMBL, Swiss-Prot etc.) entry.
299
+ class EMBLDB < DB
300
+
301
+ autoload :Common, 'bio/db/embl/common'
302
+
303
+ # The entire entry is passed as a String. The length of the tag field is
304
+ # passed as an Integer. Parses the entry roughly by the entry2hash method
305
+ # and returns a database object.
306
+ def initialize(entry, tagsize)
307
+ @tagsize = tagsize
308
+ @orig = entry2hash(entry.strip) # Hash of the original entry
309
+ @data = {} # Hash of the parsed entry
310
+ end
311
+
312
+ private
313
+
314
+ # Returns the contents of the entry as a Hash.
315
+ def entry2hash(entry)
316
+ hash = Hash.new { |h,k| h[k] = '' }
317
+ entry.each_line do |line|
318
+ tag = tag_get(line)
319
+ next if tag == 'XX'
320
+ tag = 'R' if tag =~ /^R./ # Reference lines
321
+ hash[tag].concat line
322
+ end
323
+ return hash
324
+ end
325
+
326
+ end # class EMBLDB
327
+
328
+ end # module Bio
329
+