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,475 @@
1
+ #
2
+ # = bio/sequence.rb - biological sequence class
3
+ #
4
+ # Copyright:: Copyright (C) 2000-2006
5
+ # Toshiaki Katayama <k@bioruby.org>,
6
+ # Yoshinori K. Okuji <okuji@enbug.org>,
7
+ # Naohisa Goto <ng@bioruby.org>,
8
+ # Ryan Raaum <ryan@raaum.org>,
9
+ # Jan Aerts <jan.aerts@bbsrc.ac.uk>
10
+ # License:: The Ruby License
11
+ #
12
+ # $Id: sequence.rb,v 0.58 2007/04/05 23:35:39 trevor Exp $
13
+ #
14
+
15
+ require 'bio/sequence/compat'
16
+
17
+ module Bio
18
+
19
+ # = DESCRIPTION
20
+ # Bio::Sequence objects represent annotated sequences in bioruby.
21
+ # A Bio::Sequence object is a wrapper around the actual sequence,
22
+ # represented as either a Bio::Sequence::NA or a Bio::Sequence::AA object.
23
+ # For most users, this encapsulation will be completely transparent.
24
+ # Bio::Sequence responds to all methods defined for Bio::Sequence::NA/AA
25
+ # objects using the same arguments and returning the same values (even though
26
+ # these methods are not documented specifically for Bio::Sequence).
27
+ #
28
+ # = USAGE
29
+ # # Create a nucleic or amino acid sequence
30
+ # dna = Bio::Sequence.auto('atgcatgcATGCATGCAAAA')
31
+ # rna = Bio::Sequence.auto('augcaugcaugcaugcaaaa')
32
+ # aa = Bio::Sequence.auto('ACDEFGHIKLMNPQRSTVWYU')
33
+ #
34
+ # # Print it out
35
+ # puts dna.to_s
36
+ # puts aa.to_s
37
+ #
38
+ # # Get a subsequence, bioinformatics style (first nucleotide is '1')
39
+ # puts dna.subseq(2,6)
40
+ #
41
+ # # Get a subsequence, informatics style (first nucleotide is '0')
42
+ # puts dna[2,6]
43
+ #
44
+ # # Print in FASTA format
45
+ # puts dna.output(:fasta)
46
+ #
47
+ # # Print all codons
48
+ # dna.window_search(3,3) do |codon|
49
+ # puts codon
50
+ # end
51
+ #
52
+ # # Splice or otherwise mangle your sequence
53
+ # puts dna.splicing("complement(join(1..5,16..20))")
54
+ # puts rna.splicing("complement(join(1..5,16..20))")
55
+ #
56
+ # # Convert a sequence containing ambiguity codes into a
57
+ # # regular expression you can use for subsequent searching
58
+ # puts aa.to_re
59
+ #
60
+ # # These should speak for themselves
61
+ # puts dna.complement
62
+ # puts dna.composition
63
+ # puts dna.molecular_weight
64
+ # puts dna.translate
65
+ # puts dna.gc_percent
66
+ class Sequence
67
+
68
+ autoload :Common, 'bio/sequence/common'
69
+ autoload :NA, 'bio/sequence/na'
70
+ autoload :AA, 'bio/sequence/aa'
71
+ autoload :Generic, 'bio/sequence/generic'
72
+ autoload :Format, 'bio/sequence/format'
73
+
74
+ # Create a new Bio::Sequence object
75
+ #
76
+ # s = Bio::Sequence.new('atgc')
77
+ # puts s #=> 'atgc'
78
+ #
79
+ # Note that this method does not intialize the contained sequence
80
+ # as any kind of bioruby object, only as a simple string
81
+ #
82
+ # puts s.seq.class #=> String
83
+ #
84
+ # See Bio::Sequence#na, Bio::Sequence#aa, and Bio::Sequence#auto
85
+ # for methods to transform the basic String of a just created
86
+ # Bio::Sequence object to a proper bioruby object
87
+ # ---
88
+ # *Arguments*:
89
+ # * (required) _str_: String or Bio::Sequence::NA/AA object
90
+ # *Returns*:: Bio::Sequence object
91
+ def initialize(str)
92
+ @seq = str
93
+ end
94
+
95
+ # Pass any unknown method calls to the wrapped sequence object. see
96
+ # http://www.rubycentral.com/book/ref_c_object.html#Object.method_missing
97
+ def method_missing(sym, *args, &block) #:nodoc:
98
+ @seq.send(sym, *args, &block)
99
+ end
100
+
101
+ # The sequence identifier. For example, for a sequence
102
+ # of Genbank origin, this is the accession number.
103
+ attr_accessor :entry_id
104
+
105
+ # A String with a description of the sequence
106
+ attr_accessor :definition
107
+
108
+ # An Array of Bio::Feature objects
109
+ attr_accessor :features
110
+
111
+ # An Array of Bio::Reference objects
112
+ attr_accessor :references
113
+
114
+ # A comment String
115
+ attr_accessor :comments
116
+
117
+ # Date from sequence source. Often date of deposition.
118
+ attr_accessor :date
119
+
120
+ # An Array of Strings
121
+ attr_accessor :keywords
122
+
123
+ # An Array of Strings; links to other database entries.
124
+ attr_accessor :dblinks
125
+
126
+ # A taxonomy String
127
+ attr_accessor :taxonomy
128
+
129
+ # Bio::Sequence::NA/AA
130
+ attr_accessor :moltype
131
+
132
+ # The sequence object, usually Bio::Sequence::NA/AA,
133
+ # but could be a simple String
134
+ attr_accessor :seq
135
+
136
+ # Using Bio::Sequence::Format, return a String with the Bio::Sequence
137
+ # object formatted in the given style.
138
+ #
139
+ # Formats currently implemented are: 'fasta', 'genbank', and 'embl'
140
+ #
141
+ # s = Bio::Sequence.new('atgc')
142
+ # puts s.output(:fasta) #=> "> \natgc\n"
143
+ #
144
+ # The style argument is given as a Ruby
145
+ # Symbol(http://www.ruby-doc.org/core/classes/Symbol.html)
146
+ # ---
147
+ # *Arguments*:
148
+ # * (required) _style_: :fasta, :genbank, *or* :embl
149
+ # *Returns*:: String object
150
+ def output(style)
151
+ extend Bio::Sequence::Format
152
+ case style
153
+ when :fasta
154
+ format_fasta
155
+ when :gff
156
+ format_gff
157
+ when :genbank
158
+ format_genbank
159
+ when :embl
160
+ format_embl
161
+ end
162
+ end
163
+
164
+ # Guess the type of sequence, Amino Acid or Nucleic Acid, and create a
165
+ # new sequence object (Bio::Sequence::AA or Bio::Sequence::NA) on the basis
166
+ # of this guess. This method will change the current Bio::Sequence object.
167
+ #
168
+ # s = Bio::Sequence.new('atgc')
169
+ # puts s.seq.class #=> String
170
+ # s.auto
171
+ # puts s.seq.class #=> Bio::Sequence::NA
172
+ # ---
173
+ # *Returns*:: Bio::Sequence::NA/AA object
174
+ def auto
175
+ @moltype = guess
176
+ if @moltype == NA
177
+ @seq = NA.new(@seq)
178
+ else
179
+ @seq = AA.new(@seq)
180
+ end
181
+ end
182
+
183
+ # Given a sequence String, guess its type, Amino Acid or Nucleic Acid, and
184
+ # return a new Bio::Sequence object wrapping a sequence of the guessed type
185
+ # (either Bio::Sequence::AA or Bio::Sequence::NA)
186
+ #
187
+ # s = Bio::Sequence.auto('atgc')
188
+ # puts s.seq.class #=> Bio::Sequence::NA
189
+ # ---
190
+ # *Arguments*:
191
+ # * (required) _str_: String *or* Bio::Sequence::NA/AA object
192
+ # *Returns*:: Bio::Sequence object
193
+ def self.auto(str)
194
+ seq = self.new(str)
195
+ seq.auto
196
+ return seq
197
+ end
198
+
199
+ # Guess the class of the current sequence. Returns the class
200
+ # (Bio::Sequence::AA or Bio::Sequence::NA) guessed. In general, used by
201
+ # developers only, but if you know what you are doing, feel free.
202
+ #
203
+ # s = Bio::Sequence.new('atgc')
204
+ # puts s.guess #=> Bio::Sequence::NA
205
+ #
206
+ # There are three parameters: `threshold`, `length`, and `index`.
207
+ #
208
+ # The `threshold` value (defaults to 0.9) is the frequency of
209
+ # nucleic acid bases [AGCTUagctu] required in the sequence for this method
210
+ # to produce a Bio::Sequence::NA "guess". In the default case, if less
211
+ # than 90% of the bases (after excluding [Nn]) are in the set [AGCTUagctu],
212
+ # then the guess is Bio::Sequence::AA.
213
+ #
214
+ # s = Bio::Sequence.new('atgcatgcqq')
215
+ # puts s.guess #=> Bio::Sequence::AA
216
+ # puts s.guess(0.8) #=> Bio::Sequence::AA
217
+ # puts s.guess(0.7) #=> Bio::Sequence::NA
218
+ #
219
+ # The `length` value is how much of the total sequence to use in the
220
+ # guess (default 10000). If your sequence is very long, you may
221
+ # want to use a smaller amount to reduce the computational burden.
222
+ #
223
+ # s = Bio::Sequence.new(A VERY LONG SEQUENCE)
224
+ # puts s.guess(0.9, 1000) # limit the guess to the first 1000 positions
225
+ #
226
+ # The `index` value is where to start the guess. Perhaps you know there
227
+ # are a lot of gaps at the start...
228
+ #
229
+ # s = Bio::Sequence.new('-----atgcc')
230
+ # puts s.guess #=> Bio::Sequence::AA
231
+ # puts s.guess(0.9,10000,5) #=> Bio::Sequence::NA
232
+ # ---
233
+ # *Arguments*:
234
+ # * (optional) _threshold_: Float in range 0,1 (default 0.9)
235
+ # * (optional) _length_: Fixnum (default 10000)
236
+ # * (optional) _index_: Fixnum (default 1)
237
+ # *Returns*:: Bio::Sequence::NA/AA
238
+ def guess(threshold = 0.9, length = 10000, index = 0)
239
+ str = @seq.to_s[index,length].to_s.extend Bio::Sequence::Common
240
+ cmp = str.composition
241
+
242
+ bases = cmp['A'] + cmp['T'] + cmp['G'] + cmp['C'] + cmp['U'] +
243
+ cmp['a'] + cmp['t'] + cmp['g'] + cmp['c'] + cmp['u']
244
+
245
+ total = str.length - cmp['N'] - cmp['n']
246
+
247
+ if bases.to_f / total > threshold
248
+ return NA
249
+ else
250
+ return AA
251
+ end
252
+ end
253
+
254
+ # Guess the class of a given sequence. Returns the class
255
+ # (Bio::Sequence::AA or Bio::Sequence::NA) guessed. In general, used by
256
+ # developers only, but if you know what you are doing, feel free.
257
+ #
258
+ # puts .guess('atgc') #=> Bio::Sequence::NA
259
+ #
260
+ # There are three optional parameters: `threshold`, `length`, and `index`.
261
+ #
262
+ # The `threshold` value (defaults to 0.9) is the frequency of
263
+ # nucleic acid bases [AGCTUagctu] required in the sequence for this method
264
+ # to produce a Bio::Sequence::NA "guess". In the default case, if less
265
+ # than 90% of the bases (after excluding [Nn]) are in the set [AGCTUagctu],
266
+ # then the guess is Bio::Sequence::AA.
267
+ #
268
+ # puts Bio::Sequence.guess('atgcatgcqq') #=> Bio::Sequence::AA
269
+ # puts Bio::Sequence.guess('atgcatgcqq', 0.8) #=> Bio::Sequence::AA
270
+ # puts Bio::Sequence.guess('atgcatgcqq', 0.7) #=> Bio::Sequence::NA
271
+ #
272
+ # The `length` value is how much of the total sequence to use in the
273
+ # guess (default 10000). If your sequence is very long, you may
274
+ # want to use a smaller amount to reduce the computational burden.
275
+ #
276
+ # # limit the guess to the first 1000 positions
277
+ # puts Bio::Sequence.guess('A VERY LONG SEQUENCE', 0.9, 1000)
278
+ #
279
+ # The `index` value is where to start the guess. Perhaps you know there
280
+ # are a lot of gaps at the start...
281
+ #
282
+ # puts Bio::Sequence.guess('-----atgcc') #=> Bio::Sequence::AA
283
+ # puts Bio::Sequence.guess('-----atgcc',0.9,10000,5) #=> Bio::Sequence::NA
284
+ # ---
285
+ # *Arguments*:
286
+ # * (required) _str_: String *or* Bio::Sequence::NA/AA object
287
+ # * (optional) _threshold_: Float in range 0,1 (default 0.9)
288
+ # * (optional) _length_: Fixnum (default 10000)
289
+ # * (optional) _index_: Fixnum (default 1)
290
+ # *Returns*:: Bio::Sequence::NA/AA
291
+ def self.guess(str, *args)
292
+ self.new(str).guess(*args)
293
+ end
294
+
295
+ # Transform the sequence wrapped in the current Bio::Sequence object
296
+ # into a Bio::Sequence::NA object. This method will change the current
297
+ # object. This method does not validate your choice, so be careful!
298
+ #
299
+ # s = Bio::Sequence.new('RRLE')
300
+ # puts s.seq.class #=> String
301
+ # s.na
302
+ # puts s.seq.class #=> Bio::Sequence::NA !!!
303
+ #
304
+ # However, if you know your sequence type, this method may be
305
+ # constructively used after initialization,
306
+ #
307
+ # s = Bio::Sequence.new('atgc')
308
+ # s.na
309
+ # ---
310
+ # *Returns*:: Bio::Sequence::NA
311
+ def na
312
+ @seq = NA.new(@seq)
313
+ @moltype = NA
314
+ end
315
+
316
+ # Transform the sequence wrapped in the current Bio::Sequence object
317
+ # into a Bio::Sequence::NA object. This method will change the current
318
+ # object. This method does not validate your choice, so be careful!
319
+ #
320
+ # s = Bio::Sequence.new('atgc')
321
+ # puts s.seq.class #=> String
322
+ # s.aa
323
+ # puts s.seq.class #=> Bio::Sequence::AA !!!
324
+ #
325
+ # However, if you know your sequence type, this method may be
326
+ # constructively used after initialization,
327
+ #
328
+ # s = Bio::Sequence.new('RRLE')
329
+ # s.aa
330
+ # ---
331
+ # *Returns*:: Bio::Sequence::AA
332
+ def aa
333
+ @seq = AA.new(@seq)
334
+ @moltype = AA
335
+ end
336
+
337
+ end # Sequence
338
+
339
+
340
+ end # Bio
341
+
342
+
343
+ if __FILE__ == $0
344
+
345
+ puts "== Test Bio::Sequence::NA.new"
346
+ p Bio::Sequence::NA.new('')
347
+ p na = Bio::Sequence::NA.new('atgcatgcATGCATGCAAAA')
348
+ p rna = Bio::Sequence::NA.new('augcaugcaugcaugcaaaa')
349
+
350
+ puts "\n== Test Bio::Sequence::AA.new"
351
+ p Bio::Sequence::AA.new('')
352
+ p aa = Bio::Sequence::AA.new('ACDEFGHIKLMNPQRSTVWYU')
353
+
354
+ puts "\n== Test Bio::Sequence#to_s"
355
+ p na.to_s
356
+ p aa.to_s
357
+
358
+ puts "\n== Test Bio::Sequence#subseq(2,6)"
359
+ p na
360
+ p na.subseq(2,6)
361
+
362
+ puts "\n== Test Bio::Sequence#[2,6]"
363
+ p na
364
+ p na[2,6]
365
+
366
+ puts "\n== Test Bio::Sequence#to_fasta('hoge', 8)"
367
+ puts na.to_fasta('hoge', 8)
368
+
369
+ puts "\n== Test Bio::Sequence#window_search(15)"
370
+ p na
371
+ na.window_search(15) {|x| p x}
372
+
373
+ puts "\n== Test Bio::Sequence#total({'a'=>0.1,'t'=>0.2,'g'=>0.3,'c'=>0.4})"
374
+ p na.total({'a'=>0.1,'t'=>0.2,'g'=>0.3,'c'=>0.4})
375
+
376
+ puts "\n== Test Bio::Sequence#composition"
377
+ p na
378
+ p na.composition
379
+ p rna
380
+ p rna.composition
381
+
382
+ puts "\n== Test Bio::Sequence::NA#splicing('complement(join(1..5,16..20))')"
383
+ p na
384
+ p na.splicing("complement(join(1..5,16..20))")
385
+ p rna
386
+ p rna.splicing("complement(join(1..5,16..20))")
387
+
388
+ puts "\n== Test Bio::Sequence::NA#complement"
389
+ p na.complement
390
+ p rna.complement
391
+ p Bio::Sequence::NA.new('tacgyrkmhdbvswn').complement
392
+ p Bio::Sequence::NA.new('uacgyrkmhdbvswn').complement
393
+
394
+ puts "\n== Test Bio::Sequence::NA#translate"
395
+ p na
396
+ p na.translate
397
+ p rna
398
+ p rna.translate
399
+
400
+ puts "\n== Test Bio::Sequence::NA#gc_percent"
401
+ p na.gc_percent
402
+ p rna.gc_percent
403
+
404
+ puts "\n== Test Bio::Sequence::NA#illegal_bases"
405
+ p na.illegal_bases
406
+ p Bio::Sequence::NA.new('tacgyrkmhdbvswn').illegal_bases
407
+ p Bio::Sequence::NA.new('abcdefghijklmnopqrstuvwxyz-!%#$@').illegal_bases
408
+
409
+ puts "\n== Test Bio::Sequence::NA#molecular_weight"
410
+ p na
411
+ p na.molecular_weight
412
+ p rna
413
+ p rna.molecular_weight
414
+
415
+ puts "\n== Test Bio::Sequence::NA#to_re"
416
+ p Bio::Sequence::NA.new('atgcrymkdhvbswn')
417
+ p Bio::Sequence::NA.new('atgcrymkdhvbswn').to_re
418
+ p Bio::Sequence::NA.new('augcrymkdhvbswn')
419
+ p Bio::Sequence::NA.new('augcrymkdhvbswn').to_re
420
+
421
+ puts "\n== Test Bio::Sequence::NA#names"
422
+ p na.names
423
+
424
+ puts "\n== Test Bio::Sequence::NA#pikachu"
425
+ p na.pikachu
426
+
427
+ puts "\n== Test Bio::Sequence::NA#randomize"
428
+ print "Orig : "; p na
429
+ print "Rand : "; p na.randomize
430
+ print "Rand : "; p na.randomize
431
+ print "Rand : "; p na.randomize.randomize
432
+ print "Block : "; na.randomize do |x| print x end; puts
433
+
434
+ print "Orig : "; p rna
435
+ print "Rand : "; p rna.randomize
436
+ print "Rand : "; p rna.randomize
437
+ print "Rand : "; p rna.randomize.randomize
438
+ print "Block : "; rna.randomize do |x| print x end; puts
439
+
440
+ puts "\n== Test Bio::Sequence::NA.randomize(counts)"
441
+ print "Count : "; p counts = {'a'=>10,'c'=>20,'g'=>30,'t'=>40}
442
+ print "Rand : "; p Bio::Sequence::NA.randomize(counts)
443
+ print "Count : "; p counts = {'a'=>10,'c'=>20,'g'=>30,'u'=>40}
444
+ print "Rand : "; p Bio::Sequence::NA.randomize(counts)
445
+ print "Block : "; Bio::Sequence::NA.randomize(counts) {|x| print x}; puts
446
+
447
+ puts "\n== Test Bio::Sequence::AA#codes"
448
+ p aa
449
+ p aa.codes
450
+
451
+ puts "\n== Test Bio::Sequence::AA#names"
452
+ p aa
453
+ p aa.names
454
+
455
+ puts "\n== Test Bio::Sequence::AA#molecular_weight"
456
+ p aa.subseq(1,20)
457
+ p aa.subseq(1,20).molecular_weight
458
+
459
+ puts "\n== Test Bio::Sequence::AA#randomize"
460
+ aaseq = 'MRVLKFGGTSVANAERFLRVADILESNARQGQVATVLSAPAKITNHLVAMIEKTISGQDA'
461
+ s = Bio::Sequence::AA.new(aaseq)
462
+ print "Orig : "; p s
463
+ print "Rand : "; p s.randomize
464
+ print "Rand : "; p s.randomize
465
+ print "Rand : "; p s.randomize.randomize
466
+ print "Block : "; s.randomize {|x| print x}; puts
467
+
468
+ puts "\n== Test Bio::Sequence::AA.randomize(counts)"
469
+ print "Count : "; p counts = s.composition
470
+ print "Rand : "; puts Bio::Sequence::AA.randomize(counts)
471
+ print "Block : "; Bio::Sequence::AA.randomize(counts) {|x| print x}; puts
472
+
473
+ end
474
+
475
+