ngoto-bio 1.2.9.9001

Sign up to get free protection for your applications and to get access to all the features.
Files changed (424) hide show
  1. data/ChangeLog +2046 -0
  2. data/README.rdoc +223 -0
  3. data/README_DEV.rdoc +285 -0
  4. data/Rakefile +70 -0
  5. data/bin/bioruby +44 -0
  6. data/bin/br_biofetch.rb +47 -0
  7. data/bin/br_bioflat.rb +293 -0
  8. data/bin/br_biogetseq.rb +45 -0
  9. data/bin/br_pmfetch.rb +421 -0
  10. data/bioruby.gemspec +463 -0
  11. data/bioruby.gemspec.erb +79 -0
  12. data/doc/Changes-0.7.rd +369 -0
  13. data/doc/Changes-1.3.rdoc +195 -0
  14. data/doc/KEGG_API.rd +1843 -0
  15. data/doc/KEGG_API.rd.ja +1834 -0
  16. data/doc/Tutorial.rd +1296 -0
  17. data/doc/Tutorial.rd.ja +2640 -0
  18. data/etc/bioinformatics/seqdatabase.ini +210 -0
  19. data/extconf.rb +2 -0
  20. data/lib/bio/alignment.rb +2518 -0
  21. data/lib/bio/appl/bl2seq/report.rb +334 -0
  22. data/lib/bio/appl/blast/ddbj.rb +142 -0
  23. data/lib/bio/appl/blast/format0.rb +1438 -0
  24. data/lib/bio/appl/blast/format8.rb +83 -0
  25. data/lib/bio/appl/blast/genomenet.rb +263 -0
  26. data/lib/bio/appl/blast/ncbioptions.rb +220 -0
  27. data/lib/bio/appl/blast/remote.rb +105 -0
  28. data/lib/bio/appl/blast/report.rb +767 -0
  29. data/lib/bio/appl/blast/rexml.rb +144 -0
  30. data/lib/bio/appl/blast/rpsblast.rb +277 -0
  31. data/lib/bio/appl/blast/wublast.rb +671 -0
  32. data/lib/bio/appl/blast/xmlparser.rb +236 -0
  33. data/lib/bio/appl/blast.rb +505 -0
  34. data/lib/bio/appl/blat/report.rb +530 -0
  35. data/lib/bio/appl/clustalw/report.rb +152 -0
  36. data/lib/bio/appl/clustalw.rb +219 -0
  37. data/lib/bio/appl/emboss.rb +203 -0
  38. data/lib/bio/appl/fasta/format10.rb +325 -0
  39. data/lib/bio/appl/fasta.rb +235 -0
  40. data/lib/bio/appl/gcg/msf.rb +212 -0
  41. data/lib/bio/appl/gcg/seq.rb +195 -0
  42. data/lib/bio/appl/genscan/report.rb +552 -0
  43. data/lib/bio/appl/hmmer/report.rb +683 -0
  44. data/lib/bio/appl/hmmer.rb +126 -0
  45. data/lib/bio/appl/iprscan/report.rb +374 -0
  46. data/lib/bio/appl/mafft/report.rb +226 -0
  47. data/lib/bio/appl/mafft.rb +259 -0
  48. data/lib/bio/appl/muscle.rb +52 -0
  49. data/lib/bio/appl/paml/baseml/report.rb +32 -0
  50. data/lib/bio/appl/paml/baseml.rb +95 -0
  51. data/lib/bio/appl/paml/codeml/rates.rb +67 -0
  52. data/lib/bio/appl/paml/codeml/report.rb +67 -0
  53. data/lib/bio/appl/paml/codeml.rb +242 -0
  54. data/lib/bio/appl/paml/common.rb +348 -0
  55. data/lib/bio/appl/paml/common_report.rb +38 -0
  56. data/lib/bio/appl/paml/yn00/report.rb +32 -0
  57. data/lib/bio/appl/paml/yn00.rb +103 -0
  58. data/lib/bio/appl/phylip/alignment.rb +129 -0
  59. data/lib/bio/appl/phylip/distance_matrix.rb +96 -0
  60. data/lib/bio/appl/probcons.rb +41 -0
  61. data/lib/bio/appl/psort/report.rb +457 -0
  62. data/lib/bio/appl/psort.rb +548 -0
  63. data/lib/bio/appl/pts1.rb +263 -0
  64. data/lib/bio/appl/sim4/report.rb +485 -0
  65. data/lib/bio/appl/sim4.rb +124 -0
  66. data/lib/bio/appl/sosui/report.rb +151 -0
  67. data/lib/bio/appl/spidey/report.rb +593 -0
  68. data/lib/bio/appl/targetp/report.rb +267 -0
  69. data/lib/bio/appl/tcoffee.rb +55 -0
  70. data/lib/bio/appl/tmhmm/report.rb +231 -0
  71. data/lib/bio/command.rb +593 -0
  72. data/lib/bio/compat/features.rb +157 -0
  73. data/lib/bio/compat/references.rb +128 -0
  74. data/lib/bio/data/aa.rb +349 -0
  75. data/lib/bio/data/codontable.rb +722 -0
  76. data/lib/bio/data/na.rb +223 -0
  77. data/lib/bio/db/aaindex.rb +357 -0
  78. data/lib/bio/db/biosql/biosql_to_biosequence.rb +67 -0
  79. data/lib/bio/db/biosql/sequence.rb +508 -0
  80. data/lib/bio/db/embl/common.rb +352 -0
  81. data/lib/bio/db/embl/embl.rb +500 -0
  82. data/lib/bio/db/embl/embl_to_biosequence.rb +85 -0
  83. data/lib/bio/db/embl/format_embl.rb +190 -0
  84. data/lib/bio/db/embl/sptr.rb +1283 -0
  85. data/lib/bio/db/embl/swissprot.rb +42 -0
  86. data/lib/bio/db/embl/trembl.rb +41 -0
  87. data/lib/bio/db/embl/uniprot.rb +42 -0
  88. data/lib/bio/db/fantom.rb +597 -0
  89. data/lib/bio/db/fasta/defline.rb +532 -0
  90. data/lib/bio/db/fasta/fasta_to_biosequence.rb +63 -0
  91. data/lib/bio/db/fasta/format_fasta.rb +97 -0
  92. data/lib/bio/db/fasta.rb +410 -0
  93. data/lib/bio/db/genbank/common.rb +307 -0
  94. data/lib/bio/db/genbank/ddbj.rb +22 -0
  95. data/lib/bio/db/genbank/format_genbank.rb +187 -0
  96. data/lib/bio/db/genbank/genbank.rb +250 -0
  97. data/lib/bio/db/genbank/genbank_to_biosequence.rb +86 -0
  98. data/lib/bio/db/genbank/genpept.rb +60 -0
  99. data/lib/bio/db/genbank/refseq.rb +18 -0
  100. data/lib/bio/db/gff.rb +1846 -0
  101. data/lib/bio/db/go.rb +481 -0
  102. data/lib/bio/db/kegg/brite.rb +41 -0
  103. data/lib/bio/db/kegg/compound.rb +131 -0
  104. data/lib/bio/db/kegg/drug.rb +98 -0
  105. data/lib/bio/db/kegg/enzyme.rb +148 -0
  106. data/lib/bio/db/kegg/expression.rb +155 -0
  107. data/lib/bio/db/kegg/genes.rb +263 -0
  108. data/lib/bio/db/kegg/genome.rb +241 -0
  109. data/lib/bio/db/kegg/glycan.rb +166 -0
  110. data/lib/bio/db/kegg/keggtab.rb +357 -0
  111. data/lib/bio/db/kegg/kgml.rb +256 -0
  112. data/lib/bio/db/kegg/orthology.rb +136 -0
  113. data/lib/bio/db/kegg/reaction.rb +82 -0
  114. data/lib/bio/db/kegg/taxonomy.rb +331 -0
  115. data/lib/bio/db/lasergene.rb +209 -0
  116. data/lib/bio/db/litdb.rb +107 -0
  117. data/lib/bio/db/medline.rb +326 -0
  118. data/lib/bio/db/nbrf.rb +191 -0
  119. data/lib/bio/db/newick.rb +658 -0
  120. data/lib/bio/db/nexus.rb +1854 -0
  121. data/lib/bio/db/pdb/atom.rb +77 -0
  122. data/lib/bio/db/pdb/chain.rb +210 -0
  123. data/lib/bio/db/pdb/chemicalcomponent.rb +224 -0
  124. data/lib/bio/db/pdb/model.rb +148 -0
  125. data/lib/bio/db/pdb/pdb.rb +1911 -0
  126. data/lib/bio/db/pdb/residue.rb +176 -0
  127. data/lib/bio/db/pdb/utils.rb +399 -0
  128. data/lib/bio/db/pdb.rb +29 -0
  129. data/lib/bio/db/prosite.rb +597 -0
  130. data/lib/bio/db/rebase.rb +456 -0
  131. data/lib/bio/db/soft.rb +404 -0
  132. data/lib/bio/db/transfac.rb +375 -0
  133. data/lib/bio/db.rb +329 -0
  134. data/lib/bio/feature.rb +139 -0
  135. data/lib/bio/io/biosql/biodatabase.rb +64 -0
  136. data/lib/bio/io/biosql/bioentry.rb +29 -0
  137. data/lib/bio/io/biosql/bioentry_dbxref.rb +11 -0
  138. data/lib/bio/io/biosql/bioentry_path.rb +12 -0
  139. data/lib/bio/io/biosql/bioentry_qualifier_value.rb +10 -0
  140. data/lib/bio/io/biosql/bioentry_reference.rb +10 -0
  141. data/lib/bio/io/biosql/bioentry_relationship.rb +10 -0
  142. data/lib/bio/io/biosql/biosequence.rb +11 -0
  143. data/lib/bio/io/biosql/comment.rb +7 -0
  144. data/lib/bio/io/biosql/config/database.yml +20 -0
  145. data/lib/bio/io/biosql/dbxref.rb +13 -0
  146. data/lib/bio/io/biosql/dbxref_qualifier_value.rb +12 -0
  147. data/lib/bio/io/biosql/location.rb +32 -0
  148. data/lib/bio/io/biosql/location_qualifier_value.rb +11 -0
  149. data/lib/bio/io/biosql/ontology.rb +10 -0
  150. data/lib/bio/io/biosql/reference.rb +9 -0
  151. data/lib/bio/io/biosql/seqfeature.rb +32 -0
  152. data/lib/bio/io/biosql/seqfeature_dbxref.rb +11 -0
  153. data/lib/bio/io/biosql/seqfeature_path.rb +11 -0
  154. data/lib/bio/io/biosql/seqfeature_qualifier_value.rb +20 -0
  155. data/lib/bio/io/biosql/seqfeature_relationship.rb +11 -0
  156. data/lib/bio/io/biosql/taxon.rb +12 -0
  157. data/lib/bio/io/biosql/taxon_name.rb +9 -0
  158. data/lib/bio/io/biosql/term.rb +27 -0
  159. data/lib/bio/io/biosql/term_dbxref.rb +11 -0
  160. data/lib/bio/io/biosql/term_path.rb +12 -0
  161. data/lib/bio/io/biosql/term_relationship.rb +13 -0
  162. data/lib/bio/io/biosql/term_relationship_term.rb +11 -0
  163. data/lib/bio/io/biosql/term_synonym.rb +10 -0
  164. data/lib/bio/io/das.rb +461 -0
  165. data/lib/bio/io/dbget.rb +194 -0
  166. data/lib/bio/io/ddbjxml.rb +638 -0
  167. data/lib/bio/io/ebisoap.rb +158 -0
  168. data/lib/bio/io/ensembl.rb +229 -0
  169. data/lib/bio/io/fastacmd.rb +163 -0
  170. data/lib/bio/io/fetch.rb +195 -0
  171. data/lib/bio/io/flatfile/autodetection.rb +545 -0
  172. data/lib/bio/io/flatfile/bdb.rb +253 -0
  173. data/lib/bio/io/flatfile/buffer.rb +237 -0
  174. data/lib/bio/io/flatfile/index.rb +1381 -0
  175. data/lib/bio/io/flatfile/indexer.rb +805 -0
  176. data/lib/bio/io/flatfile/splitter.rb +297 -0
  177. data/lib/bio/io/flatfile.rb +473 -0
  178. data/lib/bio/io/higet.rb +73 -0
  179. data/lib/bio/io/hinv.rb +442 -0
  180. data/lib/bio/io/keggapi.rb +805 -0
  181. data/lib/bio/io/ncbirest.rb +733 -0
  182. data/lib/bio/io/ncbisoap.rb +155 -0
  183. data/lib/bio/io/pubmed.rb +307 -0
  184. data/lib/bio/io/registry.rb +292 -0
  185. data/lib/bio/io/soapwsdl.rb +119 -0
  186. data/lib/bio/io/sql.rb +186 -0
  187. data/lib/bio/location.rb +867 -0
  188. data/lib/bio/map.rb +410 -0
  189. data/lib/bio/pathway.rb +960 -0
  190. data/lib/bio/reference.rb +602 -0
  191. data/lib/bio/sequence/aa.rb +125 -0
  192. data/lib/bio/sequence/adapter.rb +108 -0
  193. data/lib/bio/sequence/common.rb +310 -0
  194. data/lib/bio/sequence/compat.rb +123 -0
  195. data/lib/bio/sequence/dblink.rb +54 -0
  196. data/lib/bio/sequence/format.rb +358 -0
  197. data/lib/bio/sequence/format_raw.rb +23 -0
  198. data/lib/bio/sequence/generic.rb +24 -0
  199. data/lib/bio/sequence/na.rb +491 -0
  200. data/lib/bio/sequence.rb +456 -0
  201. data/lib/bio/shell/core.rb +578 -0
  202. data/lib/bio/shell/demo.rb +146 -0
  203. data/lib/bio/shell/interface.rb +218 -0
  204. data/lib/bio/shell/irb.rb +95 -0
  205. data/lib/bio/shell/object.rb +71 -0
  206. data/lib/bio/shell/plugin/blast.rb +42 -0
  207. data/lib/bio/shell/plugin/codon.rb +218 -0
  208. data/lib/bio/shell/plugin/das.rb +58 -0
  209. data/lib/bio/shell/plugin/emboss.rb +23 -0
  210. data/lib/bio/shell/plugin/entry.rb +105 -0
  211. data/lib/bio/shell/plugin/flatfile.rb +101 -0
  212. data/lib/bio/shell/plugin/keggapi.rb +181 -0
  213. data/lib/bio/shell/plugin/midi.rb +430 -0
  214. data/lib/bio/shell/plugin/obda.rb +45 -0
  215. data/lib/bio/shell/plugin/psort.rb +56 -0
  216. data/lib/bio/shell/plugin/seq.rb +247 -0
  217. data/lib/bio/shell/plugin/soap.rb +87 -0
  218. data/lib/bio/shell/rails/vendor/plugins/bioruby/generators/bioruby/bioruby_generator.rb +29 -0
  219. data/lib/bio/shell/rails/vendor/plugins/bioruby/generators/bioruby/templates/_classes.rhtml +4 -0
  220. data/lib/bio/shell/rails/vendor/plugins/bioruby/generators/bioruby/templates/_log.rhtml +27 -0
  221. data/lib/bio/shell/rails/vendor/plugins/bioruby/generators/bioruby/templates/_methods.rhtml +11 -0
  222. data/lib/bio/shell/rails/vendor/plugins/bioruby/generators/bioruby/templates/_modules.rhtml +4 -0
  223. data/lib/bio/shell/rails/vendor/plugins/bioruby/generators/bioruby/templates/_variables.rhtml +7 -0
  224. data/lib/bio/shell/rails/vendor/plugins/bioruby/generators/bioruby/templates/bioruby-bg.gif +0 -0
  225. data/lib/bio/shell/rails/vendor/plugins/bioruby/generators/bioruby/templates/bioruby-gem.png +0 -0
  226. data/lib/bio/shell/rails/vendor/plugins/bioruby/generators/bioruby/templates/bioruby-link.gif +0 -0
  227. data/lib/bio/shell/rails/vendor/plugins/bioruby/generators/bioruby/templates/bioruby.css +368 -0
  228. data/lib/bio/shell/rails/vendor/plugins/bioruby/generators/bioruby/templates/bioruby.rhtml +47 -0
  229. data/lib/bio/shell/rails/vendor/plugins/bioruby/generators/bioruby/templates/bioruby_controller.rb +144 -0
  230. data/lib/bio/shell/rails/vendor/plugins/bioruby/generators/bioruby/templates/bioruby_helper.rb +47 -0
  231. data/lib/bio/shell/rails/vendor/plugins/bioruby/generators/bioruby/templates/commands.rhtml +8 -0
  232. data/lib/bio/shell/rails/vendor/plugins/bioruby/generators/bioruby/templates/history.rhtml +10 -0
  233. data/lib/bio/shell/rails/vendor/plugins/bioruby/generators/bioruby/templates/index.rhtml +26 -0
  234. data/lib/bio/shell/rails/vendor/plugins/bioruby/generators/bioruby/templates/spinner.gif +0 -0
  235. data/lib/bio/shell/script.rb +25 -0
  236. data/lib/bio/shell/setup.rb +109 -0
  237. data/lib/bio/shell/web.rb +102 -0
  238. data/lib/bio/shell.rb +44 -0
  239. data/lib/bio/tree.rb +852 -0
  240. data/lib/bio/util/color_scheme/buried.rb +59 -0
  241. data/lib/bio/util/color_scheme/helix.rb +59 -0
  242. data/lib/bio/util/color_scheme/hydropathy.rb +64 -0
  243. data/lib/bio/util/color_scheme/nucleotide.rb +31 -0
  244. data/lib/bio/util/color_scheme/strand.rb +59 -0
  245. data/lib/bio/util/color_scheme/taylor.rb +50 -0
  246. data/lib/bio/util/color_scheme/turn.rb +59 -0
  247. data/lib/bio/util/color_scheme/zappo.rb +50 -0
  248. data/lib/bio/util/color_scheme.rb +191 -0
  249. data/lib/bio/util/contingency_table.rb +370 -0
  250. data/lib/bio/util/restriction_enzyme/analysis.rb +249 -0
  251. data/lib/bio/util/restriction_enzyme/analysis_basic.rb +217 -0
  252. data/lib/bio/util/restriction_enzyme/cut_symbol.rb +107 -0
  253. data/lib/bio/util/restriction_enzyme/double_stranded/aligned_strands.rb +130 -0
  254. data/lib/bio/util/restriction_enzyme/double_stranded/cut_location_pair.rb +103 -0
  255. data/lib/bio/util/restriction_enzyme/double_stranded/cut_location_pair_in_enzyme_notation.rb +38 -0
  256. data/lib/bio/util/restriction_enzyme/double_stranded/cut_locations.rb +76 -0
  257. data/lib/bio/util/restriction_enzyme/double_stranded/cut_locations_in_enzyme_notation.rb +107 -0
  258. data/lib/bio/util/restriction_enzyme/double_stranded.rb +321 -0
  259. data/lib/bio/util/restriction_enzyme/enzymes.yaml +7061 -0
  260. data/lib/bio/util/restriction_enzyme/range/cut_range.rb +24 -0
  261. data/lib/bio/util/restriction_enzyme/range/cut_ranges.rb +47 -0
  262. data/lib/bio/util/restriction_enzyme/range/horizontal_cut_range.rb +67 -0
  263. data/lib/bio/util/restriction_enzyme/range/sequence_range/calculated_cuts.rb +242 -0
  264. data/lib/bio/util/restriction_enzyme/range/sequence_range/fragment.rb +51 -0
  265. data/lib/bio/util/restriction_enzyme/range/sequence_range/fragments.rb +41 -0
  266. data/lib/bio/util/restriction_enzyme/range/sequence_range.rb +257 -0
  267. data/lib/bio/util/restriction_enzyme/range/vertical_cut_range.rb +77 -0
  268. data/lib/bio/util/restriction_enzyme/single_strand/cut_locations_in_enzyme_notation.rb +135 -0
  269. data/lib/bio/util/restriction_enzyme/single_strand.rb +200 -0
  270. data/lib/bio/util/restriction_enzyme/single_strand_complement.rb +23 -0
  271. data/lib/bio/util/restriction_enzyme/string_formatting.rb +111 -0
  272. data/lib/bio/util/restriction_enzyme.rb +228 -0
  273. data/lib/bio/util/sirna.rb +288 -0
  274. data/lib/bio.rb +300 -0
  275. data/rdoc.zsh +8 -0
  276. data/sample/any2fasta.rb +59 -0
  277. data/sample/biofetch.rb +475 -0
  278. data/sample/color_scheme_na.rb +91 -0
  279. data/sample/dbget +37 -0
  280. data/sample/demo_sequence.rb +158 -0
  281. data/sample/enzymes.rb +78 -0
  282. data/sample/fasta2tab.rb +99 -0
  283. data/sample/fastagrep.rb +72 -0
  284. data/sample/fastasort.rb +54 -0
  285. data/sample/fsplit.rb +51 -0
  286. data/sample/gb2fasta.rb +30 -0
  287. data/sample/gb2tab.rb +325 -0
  288. data/sample/gbtab2mysql.rb +161 -0
  289. data/sample/genes2nuc.rb +33 -0
  290. data/sample/genes2pep.rb +33 -0
  291. data/sample/genes2tab.rb +81 -0
  292. data/sample/genome2rb.rb +29 -0
  293. data/sample/genome2tab.rb +76 -0
  294. data/sample/goslim.rb +303 -0
  295. data/sample/gt2fasta.rb +47 -0
  296. data/sample/na2aa.rb +34 -0
  297. data/sample/pmfetch.rb +42 -0
  298. data/sample/pmsearch.rb +42 -0
  299. data/sample/psortplot_html.rb +214 -0
  300. data/sample/ssearch2tab.rb +96 -0
  301. data/sample/tdiary.rb +158 -0
  302. data/sample/tfastx2tab.rb +100 -0
  303. data/sample/vs-genes.rb +212 -0
  304. data/setup.rb +1596 -0
  305. data/test/data/HMMER/hmmpfam.out +64 -0
  306. data/test/data/HMMER/hmmsearch.out +88 -0
  307. data/test/data/SOSUI/sample.report +11 -0
  308. data/test/data/TMHMM/sample.report +21 -0
  309. data/test/data/aaindex/DAYM780301 +30 -0
  310. data/test/data/aaindex/PRAM900102 +20 -0
  311. data/test/data/bl2seq/cd8a_cd8b_blastp.bl2seq +53 -0
  312. data/test/data/bl2seq/cd8a_p53_e-5blastp.bl2seq +37 -0
  313. data/test/data/blast/2.2.15.blastp.m7 +876 -0
  314. data/test/data/blast/b0002.faa +15 -0
  315. data/test/data/blast/b0002.faa.m0 +128 -0
  316. data/test/data/blast/b0002.faa.m7 +65 -0
  317. data/test/data/blast/b0002.faa.m8 +1 -0
  318. data/test/data/blast/blastp-multi.m7 +188 -0
  319. data/test/data/command/echoarg2.bat +1 -0
  320. data/test/data/embl/AB090716.embl +65 -0
  321. data/test/data/embl/AB090716.embl.rel89 +63 -0
  322. data/test/data/fasta/example1.txt +75 -0
  323. data/test/data/fasta/example2.txt +21 -0
  324. data/test/data/genscan/sample.report +63 -0
  325. data/test/data/iprscan/merged.raw +32 -0
  326. data/test/data/iprscan/merged.txt +74 -0
  327. data/test/data/paml/codeml/control_file.txt +30 -0
  328. data/test/data/paml/codeml/output.txt +78 -0
  329. data/test/data/paml/codeml/rates +217 -0
  330. data/test/data/prosite/prosite.dat +2233 -0
  331. data/test/data/refseq/nm_126355.entret +64 -0
  332. data/test/data/rpsblast/misc.rpsblast +193 -0
  333. data/test/data/soft/GDS100_partial.soft +92 -0
  334. data/test/data/soft/GSE3457_family_partial.soft +874 -0
  335. data/test/data/uniprot/p53_human.uniprot +1456 -0
  336. data/test/functional/bio/appl/test_pts1.rb +115 -0
  337. data/test/functional/bio/io/test_ensembl.rb +229 -0
  338. data/test/functional/bio/io/test_soapwsdl.rb +52 -0
  339. data/test/functional/bio/sequence/test_output_embl.rb +51 -0
  340. data/test/functional/bio/test_command.rb +301 -0
  341. data/test/runner.rb +23 -0
  342. data/test/unit/bio/appl/bl2seq/test_report.rb +134 -0
  343. data/test/unit/bio/appl/blast/test_ncbioptions.rb +112 -0
  344. data/test/unit/bio/appl/blast/test_report.rb +1135 -0
  345. data/test/unit/bio/appl/blast/test_rpsblast.rb +398 -0
  346. data/test/unit/bio/appl/genscan/test_report.rb +182 -0
  347. data/test/unit/bio/appl/hmmer/test_report.rb +342 -0
  348. data/test/unit/bio/appl/iprscan/test_report.rb +338 -0
  349. data/test/unit/bio/appl/mafft/test_report.rb +63 -0
  350. data/test/unit/bio/appl/paml/codeml/test_rates.rb +45 -0
  351. data/test/unit/bio/appl/paml/codeml/test_report.rb +45 -0
  352. data/test/unit/bio/appl/paml/test_codeml.rb +174 -0
  353. data/test/unit/bio/appl/sosui/test_report.rb +81 -0
  354. data/test/unit/bio/appl/targetp/test_report.rb +146 -0
  355. data/test/unit/bio/appl/test_blast.rb +277 -0
  356. data/test/unit/bio/appl/test_fasta.rb +130 -0
  357. data/test/unit/bio/appl/test_pts1.rb +77 -0
  358. data/test/unit/bio/appl/tmhmm/test_report.rb +126 -0
  359. data/test/unit/bio/data/test_aa.rb +90 -0
  360. data/test/unit/bio/data/test_codontable.rb +107 -0
  361. data/test/unit/bio/data/test_na.rb +80 -0
  362. data/test/unit/bio/db/embl/test_common.rb +117 -0
  363. data/test/unit/bio/db/embl/test_embl.rb +214 -0
  364. data/test/unit/bio/db/embl/test_embl_rel89.rb +219 -0
  365. data/test/unit/bio/db/embl/test_embl_to_bioseq.rb +203 -0
  366. data/test/unit/bio/db/embl/test_sptr.rb +1812 -0
  367. data/test/unit/bio/db/embl/test_uniprot.rb +31 -0
  368. data/test/unit/bio/db/kegg/test_genes.rb +45 -0
  369. data/test/unit/bio/db/pdb/test_pdb.rb +152 -0
  370. data/test/unit/bio/db/test_aaindex.rb +197 -0
  371. data/test/unit/bio/db/test_fasta.rb +250 -0
  372. data/test/unit/bio/db/test_gff.rb +1190 -0
  373. data/test/unit/bio/db/test_lasergene.rb +95 -0
  374. data/test/unit/bio/db/test_medline.rb +127 -0
  375. data/test/unit/bio/db/test_newick.rb +293 -0
  376. data/test/unit/bio/db/test_nexus.rb +364 -0
  377. data/test/unit/bio/db/test_prosite.rb +1437 -0
  378. data/test/unit/bio/db/test_rebase.rb +101 -0
  379. data/test/unit/bio/db/test_soft.rb +138 -0
  380. data/test/unit/bio/io/flatfile/test_autodetection.rb +375 -0
  381. data/test/unit/bio/io/flatfile/test_buffer.rb +251 -0
  382. data/test/unit/bio/io/flatfile/test_splitter.rb +369 -0
  383. data/test/unit/bio/io/test_ddbjxml.rb +80 -0
  384. data/test/unit/bio/io/test_ensembl.rb +109 -0
  385. data/test/unit/bio/io/test_fastacmd.rb +42 -0
  386. data/test/unit/bio/io/test_flatfile.rb +488 -0
  387. data/test/unit/bio/io/test_soapwsdl.rb +32 -0
  388. data/test/unit/bio/sequence/test_aa.rb +103 -0
  389. data/test/unit/bio/sequence/test_common.rb +373 -0
  390. data/test/unit/bio/sequence/test_compat.rb +69 -0
  391. data/test/unit/bio/sequence/test_dblink.rb +58 -0
  392. data/test/unit/bio/sequence/test_na.rb +330 -0
  393. data/test/unit/bio/shell/plugin/test_seq.rb +185 -0
  394. data/test/unit/bio/test_alignment.rb +1025 -0
  395. data/test/unit/bio/test_command.rb +349 -0
  396. data/test/unit/bio/test_db.rb +96 -0
  397. data/test/unit/bio/test_feature.rb +144 -0
  398. data/test/unit/bio/test_location.rb +599 -0
  399. data/test/unit/bio/test_map.rb +230 -0
  400. data/test/unit/bio/test_pathway.rb +499 -0
  401. data/test/unit/bio/test_reference.rb +252 -0
  402. data/test/unit/bio/test_sequence.rb +329 -0
  403. data/test/unit/bio/test_shell.rb +18 -0
  404. data/test/unit/bio/test_tree.rb +593 -0
  405. data/test/unit/bio/util/restriction_enzyme/analysis/test_calculated_cuts.rb +299 -0
  406. data/test/unit/bio/util/restriction_enzyme/analysis/test_cut_ranges.rb +103 -0
  407. data/test/unit/bio/util/restriction_enzyme/analysis/test_sequence_range.rb +240 -0
  408. data/test/unit/bio/util/restriction_enzyme/double_stranded/test_aligned_strands.rb +101 -0
  409. data/test/unit/bio/util/restriction_enzyme/double_stranded/test_cut_location_pair.rb +75 -0
  410. data/test/unit/bio/util/restriction_enzyme/double_stranded/test_cut_location_pair_in_enzyme_notation.rb +73 -0
  411. data/test/unit/bio/util/restriction_enzyme/double_stranded/test_cut_locations.rb +53 -0
  412. data/test/unit/bio/util/restriction_enzyme/double_stranded/test_cut_locations_in_enzyme_notation.rb +104 -0
  413. data/test/unit/bio/util/restriction_enzyme/single_strand/test_cut_locations_in_enzyme_notation.rb +83 -0
  414. data/test/unit/bio/util/restriction_enzyme/test_analysis.rb +246 -0
  415. data/test/unit/bio/util/restriction_enzyme/test_cut_symbol.rb +44 -0
  416. data/test/unit/bio/util/restriction_enzyme/test_double_stranded.rb +115 -0
  417. data/test/unit/bio/util/restriction_enzyme/test_single_strand.rb +147 -0
  418. data/test/unit/bio/util/restriction_enzyme/test_single_strand_complement.rb +147 -0
  419. data/test/unit/bio/util/restriction_enzyme/test_string_formatting.rb +60 -0
  420. data/test/unit/bio/util/test_color_scheme.rb +33 -0
  421. data/test/unit/bio/util/test_contingency_table.rb +94 -0
  422. data/test/unit/bio/util/test_restriction_enzyme.rb +42 -0
  423. data/test/unit/bio/util/test_sirna.rb +245 -0
  424. metadata +484 -0
data/doc/Tutorial.rd ADDED
@@ -0,0 +1,1296 @@
1
+ # This document is generated with a version of rd2html (part of Hiki)
2
+ #
3
+ # A possible test run could be from rdtool (on Debian package rdtool)
4
+ #
5
+ # ruby -I lib ./bin/rd2 ~/cvs/opensource/bioruby/doc/Tutorial.rd
6
+ #
7
+ # or with style sheet:
8
+ #
9
+ # ruby -I lib ./bin/rd2 -r rd/rd2html-lib.rb --with-c
10
+ ss=bioruby.css ~/cvs/opensource/bioruby/doc/Tutorial.rd > ~/bioruby.html
11
+ #
12
+ # in Debian:
13
+ #
14
+ # rd2 -r rd/rd2html-lib --with-css="/home/wrk/izip/cvs/opensource/bioruby/lib/bio/shell/rails/vendor/plugins/bioruby/generators/bioruby/templates/bioruby.css" Tutorial.rd > index.html
15
+ #
16
+ # A common problem is tabs in the text file! TABs are not allowed.
17
+ #
18
+ # To add tests run Toshiaki's bioruby shell and paste in the query plus
19
+ # results.
20
+ #
21
+ # To run the embedded Ruby doctests you can get the doctest.rb from Pjotr.
22
+
23
+ =begin
24
+ #doctest Testing bioruby
25
+
26
+ = BioRuby Tutorial
27
+
28
+ Editor: PjotrPrins <p .at. bioruby.org>
29
+
30
+ * Copyright (C) 2001-2003 KATAYAMA Toshiaki <k .at. bioruby.org>
31
+ * Copyright (C) 2005-2008 Pjotr Prins, Naohisa Goto and others
32
+
33
+ The latest version resides in the CVS repository ./doc/((<Tutorial.rd|URL:http://cvs.open-bio.org/cgi-bin/viewcvs/viewcvs.cgi/*checkout*/bioruby/doc/Tutorial.rd?rev=HEAD&cvsroot=bioruby&content-type=text/plain>)). This one was updated:
34
+
35
+ $Id: Tutorial.rd,v 1.22 2008/05/19 12:22:05 pjotr Exp $
36
+
37
+ in preparation for the ((<BioHackathlon 2008|URL:http://hackathon.dbcls.jp/>))
38
+
39
+ == Introduction
40
+
41
+ This is a tutorial for using Bioruby. A basic knowledge of Ruby is required.
42
+ If you want to know more about the programming langauge Ruby we recommend the
43
+ excellent book ((<Programming Ruby|URL:http://www.pragprog.com/titles/ruby>))
44
+ by Dave Thomas and Andy Hunt - some of it is online
45
+ ((<here|URL:http://www.rubycentral.com/pickaxe/>)).
46
+
47
+ For BioRuby you need to install Ruby and the BioRuby package on your computer
48
+
49
+ You can check whether Ruby is installed on your computer and what
50
+ version it has with the
51
+
52
+ % ruby -v
53
+
54
+ command. Showing something like:
55
+
56
+ ruby 1.8.5 (2006-08-25) [powerpc-linux]
57
+
58
+ If you see no such thing you'll have to install Ruby using your installation
59
+ manager. For more information see the
60
+ ((<Ruby|URL:http://www.ruby-lang.org/en/>)) website.
61
+
62
+ Once Ruby is works download and install Bioruby using the links on the
63
+ ((<Bioruby|URL:http://bioruby.org/>)) website.
64
+
65
+ A lot of BioRuby's documentation exists in the source code and unit tests. To
66
+ really dive in you will need the latest source code tree. The embedded rdoc
67
+ documentation can be viewed online at
68
+ ((<bioruby's rdoc|URL:http://bioruby.org/rdoc/>)). But first lets start!
69
+
70
+ == Trying Bioruby
71
+
72
+ Bioruby comes with its own shell. After unpacking the sources run the
73
+ following command
74
+
75
+ ./bin/bioruby or
76
+ ruby -I lib bin/bioruby
77
+
78
+ and you should see a prompt
79
+
80
+ bioruby>
81
+
82
+ Now test the following:
83
+
84
+ bioruby> seq = Bio::Sequence::NA.new("atgcatgcaaaa")
85
+ ==> "atgcatgcaaaa"
86
+
87
+ bioruby> seq.complement
88
+ ==> "ttttgcatgcat"
89
+
90
+ See the the Bioruby shell section below for more tweaking. If you have trouble running
91
+ examples also check the section below on trouble shooting. You can also post a
92
+ question to the mailing list. BioRuby developers usually try to help.
93
+
94
+ == Working with nucleic / amino acid sequences (Bio::Sequence class)
95
+
96
+ The Bio::Sequence class allows the usual sequence transformations and
97
+ translations. In the example below the DNA sequence "atgcatgcaaaa" is
98
+ converted into the complemental strand, spliced into a subsequence,
99
+ next the nucleic acid composition is calculated and the sequence is
100
+ translated into the amino acid sequence, the molecular weight
101
+ calculated, and so on. When translating into amino acid sequences the
102
+ frame can be specified and optionally the condon table selected (as
103
+ defined in codontable.rb).
104
+
105
+ bioruby> seq = Bio::Sequence::NA.new("atgcatgcaaaa")
106
+ ==> "atgcatgcaaaa"
107
+
108
+ # complemental sequence (Bio::Sequence::NA object)
109
+ bioruby> seq.complement
110
+ ==> "ttttgcatgcat"
111
+
112
+ bioruby> seq.subseq(3,8) # gets subsequence of positions 3 to 8
113
+ ==> "gcatgc"
114
+ bioruby> seq.gc_percent
115
+ ==> 33
116
+ bioruby> seq.composition
117
+ ==> {"a"=>6, "c"=>2, "g"=>2, "t"=>2}
118
+ bioruby> seq.translate
119
+ ==> "MHAK"
120
+ bioruby> seq.translate(2) # translate from frame 2
121
+ ==> "CMQ"
122
+ bioruby> seq.translate(1,11) # codon table 11
123
+ ==> "MHAK"
124
+ bioruby> seq.translate.codes
125
+ ==> ["Met", "His", "Ala", "Lys"]
126
+ bioruby> seq.translate.names
127
+ ==> ["methionine", "histidine", "alanine", "lysine"]
128
+ bioruby> seq.translate.composition
129
+ ==> {"K"=>1, "A"=>1, "M"=>1, "H"=>1}
130
+ bioruby> seq.translate.molecular_weight
131
+ ==> 485.605
132
+ bioruby> seq.complement.translate
133
+ ==> "FCMH"
134
+
135
+ get a random sequence with the same NA count:
136
+
137
+ bioruby> counts = {'a'=>seq.count('a'),'c'=>seq.count('c'),'g'=>seq.count('g'),'t'=>seq.count('t')}
138
+ ==> {"a"=>6, "c"=>2, "g"=>2, "t"=>2}
139
+ bioruby!> randomseq = Bio::Sequence::NA.randomize(counts)
140
+ ==!> "aaacatgaagtc"
141
+
142
+ bioruby!> print counts
143
+ a6c2g2t2
144
+ bioruby!> p counts
145
+ {"a"=>6, "c"=>2, "g"=>2, "t"=>2}
146
+
147
+
148
+ The p, print and puts methods are standard Ruby ways of outputting to
149
+ the screen. If you want to know more about standard Ruby commands you
150
+ can use the 'ri' command on the command line (or the help command in
151
+ Windows). For example
152
+
153
+ % ri puts
154
+ % ri p
155
+ % ri File.open
156
+
157
+ Nucleic acid sequence is an object of Bio::Sequence::NA class, and
158
+ amino acid sequence is an object of Bio::Sequence::AA class. Shared
159
+ methods are in the parent Bio::Sequence class.
160
+
161
+ As Bio::Sequence class inherits Ruby's String class, you can use
162
+ String class methods. For example, to get a subsequence, you can
163
+ not only use subseq(from, to) but also String#[].
164
+
165
+ Please take note that the Ruby's string's are base 0 - i.e. the first letter
166
+ has index 0, for example:
167
+
168
+ bioruby> s = 'abc'
169
+ ==> "abc"
170
+ bioruby> s[0].chr
171
+ ==> "a"
172
+ bioruby> s[0..1]
173
+ ==> "ab"
174
+
175
+ So when using String methods, you should subtract 1 from positions
176
+ conventionally used in biology. (subseq method will throw an exception if you
177
+ specify positions smaller than or equal to 0 for either one of the "from" or
178
+ "to".)
179
+
180
+ The window_search(window_size, step_size) method shows a typical Ruby
181
+ way of writing concise and clear code using 'closures'. Each sliding
182
+ window creates a subsequence which is supplied to the enclosed block
183
+ through a variable named +s+.
184
+
185
+ Show average percentage of GC content for 20 bases (stepping the default one base at a time)
186
+
187
+ bioruby> seq = Bio::Sequence::NA.new("atgcatgcaattaagctaatcccaattagatcatcccgatcatcaaaaaaaaaa")
188
+ ==> "atgcatgcaattaagctaatcccaattagatcatcccgatcatcaaaaaaaaaa"
189
+
190
+ bioruby> a=[]; seq.window_search(20) { |s| a.push s.gc_percent }
191
+ bioruby> a
192
+ ==> [30, 35, 40, 40, 35, 35, 35, 30, 25, 30, 30, 30, 35, 35, 35, 35, 35, 40, 45, 45, 45, 45, 40, 35, 40, 40, 40, 40, 40, 35, 35, 35, 30, 30, 30]
193
+
194
+
195
+ Since the class of each subsequence is the same as original sequence
196
+ (Bio::Sequence::NA or Bio::Sequence::AA or Bio::Sequence), you can
197
+ use all methods on the subsequence. For example,
198
+
199
+ Shows translation results for 15 bases shifting a codon at a time
200
+
201
+ bioruby> a = []
202
+ bioruby> seq.window_search(15, 3) do |s|
203
+ bioruby> a.push s.translate
204
+ bioruby> end
205
+ bioruby> a
206
+ ==> ["MHAIK", "HAIKL", "AIKLI", "IKLIP", "KLIPI", "LIPIR", "IPIRS", "PIRSS", "IRSSR", "RSSRS", "SSRSS", "SRSSK", "RSSKK", "SSKKK"]
207
+
208
+
209
+ Finally, the window_search method returns the last leftover
210
+ subsequence. This allows for example
211
+
212
+ Divide a genome sequence into sections of 10000bp and
213
+ output FASTA formatted sequences (line width 60 chars). The 1000bp at the
214
+ start and end of each subsequence overlapped. At the 3' end of the sequence
215
+ the leftover is also added:
216
+
217
+ i = 1
218
+ textwidth=60
219
+ remainder = seq.window_search(10000, 9000) do |s|
220
+ puts s.to_fasta("segment #{i}", textwidth)
221
+ i += 1
222
+ end
223
+ if remainder
224
+ puts remainder.to_fasta("segment #{i}", textwidth)
225
+ end
226
+
227
+ If you don't want the overlapping window, set window size and stepping
228
+ size to equal values.
229
+
230
+ Other examples
231
+
232
+ Count the codon usage
233
+
234
+ bioruby> codon_usage = Hash.new(0)
235
+ bioruby> seq.window_search(3, 3) do |s|
236
+ bioruby> codon_usage[s] += 1
237
+ bioruby> end
238
+ bioruby> codon_usage
239
+ ==> {"cat"=>1, "aaa"=>3, "cca"=>1, "att"=>2, "aga"=>1, "atc"=>1, "cta"=>1, "gca"=>1, "cga"=>1, "tca"=>3, "aag"=>1, "tcc"=>1, "atg"=>1}
240
+
241
+
242
+ Calculate molecular weight for each 10-aa peptide (or 10-nt nucleic acid)
243
+
244
+ bioruby> a = []
245
+ bioruby> seq.window_search(10, 10) do |s|
246
+ bioruby> a.push s.molecular_weight
247
+ bioruby> end
248
+ bioruby> a
249
+ ==> [3096.2062, 3086.1962, 3056.1762, 3023.1262, 3073.2262]
250
+
251
+ In most cases, sequences are read from files or retrieved from databases.
252
+ For example:
253
+
254
+ require 'bio'
255
+
256
+ input_seq = ARGF.read # reads all files in arguments
257
+
258
+ my_naseq = Bio::Sequence::NA.new(input_seq)
259
+ my_aaseq = my_naseq.translate
260
+
261
+ puts my_aaseq
262
+
263
+ Save the program as na2aa.rb. Prepare a nucleic acid sequence
264
+ described below and saves it as my_naseq.txt:
265
+
266
+ gtggcgatctttccgaaagcgatgactggagcgaagaaccaaagcagtgacatttgtctg
267
+ atgccgcacgtaggcctgataagacgcggacagcgtcgcatcaggcatcttgtgcaaatg
268
+ tcggatgcggcgtga
269
+
270
+ na2aa.rb translates a nucleic acid sequence to a protein sequence.
271
+ For example, translates my_naseq.txt:
272
+
273
+ % ruby na2aa.rb my_naseq.txt
274
+
275
+ or use a pipe!
276
+
277
+ % cat my_naseq.txt|ruby na2aa.rb
278
+
279
+ Outputs
280
+
281
+ VAIFPKAMTGAKNQSSDICLMPHVGLIRRGQRRIRHLVQMSDAA*
282
+
283
+ You can also write this, a bit fanciful, as a one-liner script.
284
+
285
+ % ruby -r bio -e 'p Bio::Sequence::NA.new($<.read).translate' my_naseq.txt
286
+
287
+ In the next section we will retrieve data from databases instead of using raw
288
+ sequence files. One generic example of the above can be found in
289
+ ./sample/na2aa.rb.
290
+
291
+ == Parsing GenBank data (Bio::GenBank class)
292
+
293
+ We assume that you already have some GenBank data files. (If you don't,
294
+ download some .seq files from ftp://ftp.ncbi.nih.gov/genbank/)
295
+
296
+ As an example we fetch the ID, definition and sequence of each entry
297
+ from the GenBank format and convert it to FASTA. This is also an example
298
+ script in the BioRuby distribution.
299
+
300
+ A first attempt could be to use the Bio::GenBank class for reading in
301
+ the data:
302
+
303
+ #!/usr/bin/env ruby
304
+
305
+ require 'bio'
306
+
307
+ # Read all lines from STDIN split by the GenBank delimiter
308
+ while entry = gets(Bio::GenBank::DELIMITER)
309
+ gb = Bio::GenBank.new(entry) # creates GenBank object
310
+
311
+ print ">#{gb.accession} " # Accession
312
+ puts gb.definition # Definition
313
+ puts gb.naseq # Nucleic acid sequence
314
+ # (Bio::Sequence::NA object)
315
+ end
316
+
317
+ But that has the disadvantage the code is tied to GenBank input. A more
318
+ generic method is to use Bio::FlatFile which allows you to use different
319
+ input formats:
320
+
321
+ #!/usr/bin/env ruby
322
+
323
+ require 'bio'
324
+
325
+ ff = Bio::FlatFile.new(Bio::GenBank, ARGF)
326
+ ff.each_entry do |gb|
327
+ definition = "#{gb.accession} #{gb.definition}"
328
+ puts gb.naseq.to_fasta(definition, 60)
329
+ end
330
+
331
+ For example, in turn, reading FASTA format files:
332
+
333
+ #!/usr/bin/env ruby
334
+
335
+ require 'bio'
336
+
337
+ ff = Bio::FlatFile.new(Bio::FastaFormat, ARGF)
338
+ ff.each_entry do |f|
339
+ puts "definition : " + f.definition
340
+ puts "nalen : " + f.nalen.to_s
341
+ puts "naseq : " + f.naseq
342
+ end
343
+
344
+ In above two scripts, the first arguments of Bio::FlatFile.new are
345
+ database classes of BioRuby. This is expanded on in a later section.
346
+
347
+ Again another option is to use the Bio::DB.open class:
348
+
349
+ #!/usr/bin/env ruby
350
+
351
+ require 'bio'
352
+
353
+ ff = Bio::GenBank.open("gbvrl1.seq")
354
+ ff.each_entry do |gb|
355
+ definition = "#{gb.accession} #{gb.definition}"
356
+ puts gb.naseq.to_fasta(definition, 60)
357
+ end
358
+
359
+ Next, we are going to parse the GenBank 'features', which is normally
360
+ very complicated:
361
+
362
+ #!/usr/bin/env ruby
363
+
364
+ require 'bio'
365
+
366
+ ff = Bio::FlatFile.new(Bio::GenBank, ARGF)
367
+
368
+ # iterates over each GenBank entry
369
+ ff.each_entry do |gb|
370
+
371
+ # shows accession and organism
372
+ puts "# #{gb.accession} - #{gb.organism}"
373
+
374
+ # iterates over each element in 'features'
375
+ gb.features.each do |feature|
376
+ position = feature.position
377
+ hash = feature.assoc # put into Hash
378
+
379
+ # skips the entry if "/translation=" is not found
380
+ next unless hash['translation']
381
+
382
+ # collects gene name and so on and joins it into a string
383
+ gene_info = [
384
+ hash['gene'], hash['product'], hash['note'], hash['function']
385
+ ].compact.join(', ')
386
+
387
+ # shows nucleic acid sequence
388
+ puts ">NA splicing('#{position}') : #{gene_info}"
389
+ puts gb.naseq.splicing(position)
390
+
391
+ # shows amino acid sequence translated from nucleic acid sequence
392
+ puts ">AA translated by splicing('#{position}').translate"
393
+ puts gb.naseq.splicing(position).translate
394
+
395
+ # shows amino acid sequence in the database entry (/translation=)
396
+ puts ">AA original translation"
397
+ puts hash['translation']
398
+ end
399
+ end
400
+
401
+ Note: In this example Feature#assoc method makes a Hash from a
402
+ feature object. It is useful because you can get data from the hash
403
+ by using qualifiers as keys.
404
+ (But there is a risk some information is lost when two or more
405
+ qualifiers are the same. Therefore an Array is returned by
406
+ Feature#feature)
407
+
408
+ Bio::Sequence#splicing splices subsequence from nucleic acid sequence
409
+ according to location information used in GenBank, EMBL and DDBJ.
410
+
411
+ When the specified translation table is different from the default
412
+ (universal), or when the first codon is not "atg" or the protein
413
+ contains selenocysteine, the two amino acid sequences will differ.
414
+
415
+ The Bio::Sequence#splicing method takes not only DDBJ/EMBL/GenBank
416
+ feature style location text but also Bio::Locations object. For more
417
+ information about location format and Bio::Locations class, see
418
+ bio/location.rb.
419
+
420
+ Splice according to location string used in a GenBank entry
421
+
422
+ naseq.splicing('join(2035..2050,complement(1775..1818),13..345')
423
+
424
+ Generate Bio::Locations object and pass the splicing method
425
+
426
+ locs = Bio::Locations.new('join((8298.8300)..10206,1..855)')
427
+ naseq.splicing(locs)
428
+
429
+ You can also use the splicing method for amino acid sequences
430
+ (Bio::Sequence::AA objects).
431
+
432
+ Splicing peptide from a protein (e.g. signal peptide)
433
+
434
+ aaseq.splicing('21..119')
435
+
436
+
437
+ === More databases
438
+
439
+ Databases in BioRuby are essentially accessed like that of GenBank
440
+ with classes like Bio::GenBank, Bio::KEGG::GENES. A full list can be found in
441
+ the ./lib/bio/db directory of the BioRuby source tree.
442
+
443
+ In many cases the Bio::DatabaseClass acts as a factory pattern
444
+ and recognises the database type automatically - returning a
445
+ parsed object. For example using Bio::FlatFile
446
+
447
+ Bio::FlatFile class as described above. The first argument of the
448
+ Bio::FlatFile.new is database class name in BioRuby (such as Bio::GenBank,
449
+ Bio::KEGG::GENES and so on).
450
+
451
+ ff = Bio::FlatFile.new(Bio::DatabaseClass, ARGF)
452
+
453
+ Isn't it wonderful that Bio::FlatFile automagically recognizes each
454
+ database class?
455
+
456
+ #!/usr/bin/env ruby
457
+
458
+ require 'bio'
459
+
460
+ ff = Bio::FlatFile.auto(ARGF)
461
+ ff.each_entry do |entry|
462
+ p entry.entry_id # identifier of the entry
463
+ p entry.definition # definition of the entry
464
+ p entry.seq # sequence data of the entry
465
+ end
466
+
467
+ An example that can take any input, filter using a regular expression to output
468
+ to a FASTA file can be found in sample/any2fasta.rb. With this technique it is
469
+ possible to write a Unix type grep/sort pipe for sequence information. One
470
+ example using scripts in the BIORUBY sample folder:
471
+
472
+ fastagrep.rb '/At|Dm/' database.seq | fastasort.rb
473
+
474
+ greps the database for Arabidopsis and Drosophila entries and sorts the output
475
+ to FASTA.
476
+
477
+ Other methods to extract specific data from database objects can be
478
+ different between databases, though some methods are common (see the
479
+ guidelines for common methods as described in bio/db.rb).
480
+
481
+ * entry_id --> gets ID of the entry
482
+ * definition --> gets definition of the entry
483
+ * reference --> gets references as Bio::Reference object
484
+ * organism --> gets species
485
+ * seq, naseq, aaseq --> returns sequence as corresponding sequence object
486
+
487
+ Refer to the documents of each database to find the exact naming
488
+ of the included methods.
489
+
490
+ In principal BioRuby uses the following conventions: when a method
491
+ name is plural the method returns some object as an Array. For
492
+ example, some classes have a "references" method which returns
493
+ multiple Bio::Reference objects as an Array. And some classes have a
494
+ "reference" method which returns a single Bio::Reference object.
495
+
496
+ === Alignments (Bio::Alignment)
497
+
498
+ Bio::Alignment class in bio/alignment.rb is a container class like Ruby's Hash,
499
+ Array and BioPerl's Bio::SimpleAlign. A very simple example is:
500
+
501
+ bioruby> seqs = [ 'atgca', 'aagca', 'acgca', 'acgcg' ]
502
+ bioruby> seqs = seqs.collect{ |x| Bio::Sequence::NA.new(x) }
503
+ # creates alignment object
504
+ bioruby> a = Bio::Alignment.new(seqs)
505
+ bioruby> a.consensus
506
+ ==> "a?gc?"
507
+ # shows IUPAC consensus
508
+ a.consensus_iupac
509
+ ==> "ahgcr"
510
+ # iterates over each seq
511
+ a.each { |x| p x }
512
+ # ==>
513
+ # "atgca"
514
+ # "aagca"
515
+ # "acgca"
516
+ # "acgcg"
517
+ # iterates over each site
518
+ a.each_site { |x| p x }
519
+ # ==>
520
+ # ["a", "a", "a", "a"]
521
+ # ["t", "a", "c", "c"]
522
+ # ["g", "g", "g", "g"]
523
+ # ["c", "c", "c", "c"]
524
+ # ["a", "a", "a", "g"]
525
+
526
+ # doing alignment by using CLUSTAL W.
527
+ # clustalw command must be installed.
528
+ factory = Bio::ClustalW.new
529
+ a2 = a.do_align(factory)
530
+
531
+ == Restriction Enzymes (Bio::RE)
532
+
533
+ BioRuby has extensive support for restriction enzymes (REs). It contains a full
534
+ library of commonly used REs (from REBASE) which can be used to cut single
535
+ stranded RNA or dubbel stranded DNA into fragments. To list all enzymes:
536
+
537
+ rebase = Bio::RestrictionEnzyme.rebase
538
+ rebase.each do |enzyme_name, info|
539
+ p enzyme_name
540
+ end
541
+
542
+ and cut a sequence with an enzyme follow up with:
543
+
544
+ res = seq.cut_with_enzyme('EcoRII', {:max_permutations => 0},
545
+ {:view_ranges => true})
546
+ if res.kind_of? Symbol #error
547
+ err = Err.find_by_code(res.to_s)
548
+ unless err
549
+ err = Err.new(:code => res.to_s)
550
+ end
551
+ end
552
+ res.each do |frag|
553
+ em = EnzymeMatch.new
554
+
555
+ em.p_left = frag.p_left
556
+ em.p_right = frag.p_right
557
+ em.c_left = frag.c_left
558
+ em.c_right = frag.c_right
559
+
560
+ em.err = nil
561
+ em.enzyme = ar_enz
562
+ em.sequence = ar_seq
563
+ p em
564
+ end
565
+
566
+
567
+ == Sequence homology search by using the FASTA program (Bio::Fasta)
568
+
569
+ Let's start with a query.pep file which contains a sequence in FASTA
570
+ format. In this example we are going to execute a homology search
571
+ from a remote internet site or on your local machine. Note that you
572
+ can use the ssearch program instead of fasta when you use them in your
573
+ local machine.
574
+
575
+ === using FASTA in local machine
576
+
577
+ Install the fasta program on your machine (the command name looks like
578
+ fasta34. FASTA can be downloaded from ftp://ftp.virginia.edu/pub/fasta/).
579
+ First, you must prepare your FASTA-formatted database sequence file
580
+ target.pep and FASTA-formatted query.pep.
581
+
582
+ #!/usr/bin/env ruby
583
+
584
+ require 'bio'
585
+
586
+ # Creates FASTA factory object ("ssearch" instead of
587
+ # "fasta34" can also work)
588
+ factory = Bio::Fasta.local('fasta34', ARGV.pop)
589
+ (EDITOR's NOTE: not consistent pop command)
590
+
591
+ ff = Bio::FlatFile.new(Bio::FastaFormat, ARGF)
592
+
593
+ # Iterates over each entry. the variable "entry" is a
594
+ # Bio::FastaFormat object:
595
+ ff.each do |entry|
596
+ # shows definition line (begins with '>') to the standard error output
597
+ $stderr.puts "Searching ... " + entry.definition
598
+
599
+ # executes homology search. Returns Bio::Fasta::Report object.
600
+ report = factory.query(entry)
601
+
602
+ # Iterates over each hit
603
+ report.each do |hit|
604
+ # If E-value is smaller than 0.0001
605
+ if hit.evalue < 0.0001
606
+ # shows identifier of query and hit, E-value, start and
607
+ # end positions of homologous region
608
+ print "#{hit.query_id} : evalue #{hit.evalue}\t#{hit.target_id} at "
609
+ p hit.lap_at
610
+ end
611
+ end
612
+ end
613
+
614
+ We named above script as f_search.rb. You can execute as follows:
615
+
616
+ % ./f_search.rb query.pep target.pep > f_search.out
617
+
618
+ In above script, the variable "factory" is a factory object for executing
619
+ FASTA many times easily. Instead of using Fasta#query method,
620
+ Bio::Sequence#fasta method can be used.
621
+
622
+ seq = ">test seq\nYQVLEEIGRGSFGSVRKVIHIPTKKLLVRKDIKYGHMNSKE"
623
+ seq.fasta(factory)
624
+
625
+ When you want to add options to FASTA command, you can set the
626
+ third argument of Bio::Fasta.local method. For example, setting ktup to 1
627
+ and getting top-10 hits:
628
+
629
+ factory = Bio::Fasta.local('fasta34', 'target.pep', '-b 10')
630
+ factory.ktup = 1
631
+
632
+ Bio::Fasta#query returns Bio::Fasta::Report object.
633
+ We can get almost all information described in FASTA report text
634
+ with the Report object. For example, getting information for hits:
635
+
636
+ report.each do |hit|
637
+ puts hit.evalue # E-value
638
+ puts hit.sw # Smith-Waterman score (*)
639
+ puts hit.identity # % identity
640
+ puts hit.overlap # length of overlapping region
641
+ puts hit.query_id # identifier of query sequence
642
+ puts hit.query_def # definition(comment line) of query sequence
643
+ puts hit.query_len # length of query sequence
644
+ puts hit.query_seq # sequence of homologous region
645
+ puts hit.target_id # identifier of hit sequence
646
+ puts hit.target_def # definition(comment line) of hit sequence
647
+ puts hit.target_len # length of hit sequence
648
+ puts hit.target_seq # hit of homologous region of hit sequence
649
+ puts hit.query_start # start position of homologous
650
+ # region in query sequence
651
+ puts hit.query_end # end position of homologous region
652
+ # in query sequence
653
+ puts hit.target_start # start posiotion of homologous region
654
+ # in hit(target) sequence
655
+ puts hit.target_end # end position of homologous region
656
+ # in hit(target) sequence
657
+ puts hit.lap_at # array of above four numbers
658
+ end
659
+
660
+ Most of above methods are common with the Bio::Blast::Report described
661
+ below. Please refer to document of Bio::Fasta::Report class for
662
+ FASTA-specific details.
663
+
664
+ If you need original output text of FASTA program you can use the "output"
665
+ method of the factory object after the "query" method.
666
+
667
+ report = factory.query(entry)
668
+ puts factory.output
669
+
670
+
671
+ === using FASTA from a remote internet site
672
+
673
+ * Note: Currently, only GenomeNet (fasta.genome.jp) is
674
+ supported. check the class documentation for updates.
675
+
676
+ For accessing a remote site the Bio::Fasta.remote method is used
677
+ instead of Bio::Fasta.local. When using a remote method, the
678
+ databases available may be limited, but, otherwise, you can do the
679
+ same things as with a local method.
680
+
681
+ Available databases in GenomeNet:
682
+
683
+ * Protein database
684
+ * nr-aa, genes, vgenes.pep, swissprot, swissprot-upd, pir, prf, pdbstr
685
+
686
+ * Nucleic acid database
687
+ * nr-nt, genbank-nonst, gbnonst-upd, dbest, dbgss, htgs, dbsts,
688
+ embl-nonst, embnonst-upd, genes-nt, genome, vgenes.nuc
689
+
690
+ Select the databases you require. Next, give the search program from
691
+ the type of query sequence and database.
692
+
693
+ * When query is a amino acid sequence
694
+ * When protein database, program is "fasta".
695
+ * When nucleic database, program is "tfasta".
696
+
697
+ * When query is a nucleic acid sequence
698
+ * When nucleic database, program is "fasta".
699
+ * (When protein database, you would fail to search.)
700
+
701
+ For example:
702
+
703
+ program = 'fasta'
704
+ database = 'genes'
705
+
706
+ factory = Bio::Fasta.remote(program, database)
707
+
708
+ and try out the same commands as with the local search shown earlier.
709
+
710
+ == Homology search by using BLAST (Bio::Blast class)
711
+
712
+ The BLAST interface is very similar to that of FASTA and
713
+ both local and remote execution are supported. Basically
714
+ replace above examples Bio::Fasta with Bio::Blast!
715
+
716
+ For example the BLAST version of f_search.rb is:
717
+
718
+ # create BLAST factory object
719
+ factory = Bio::Blast.local('blastp', ARGV.pop)
720
+
721
+ For remote execution of BLAST in GenomeNet, Bio::Blast.remote is used.
722
+ The parameter "program" is different from FASTA - as you can expect:
723
+
724
+ * When query is a amino acid sequence
725
+ * When protein database, program is "blastp".
726
+ * When nucleic database, program is "tblastn".
727
+
728
+ * When query is a nucleic acid sequence
729
+ * When protein database, program is "blastx"
730
+ * When nucleic database, program is "blastn".
731
+ * ("tblastx" for six-frame search.)
732
+
733
+ Bio::BLAST uses "-m 7" XML output of BLAST by default when either
734
+ XMLParser or REXML (both of them are XML parser libraries for Ruby -
735
+ of the two XMLParser is the fastest) is installed on your computer. In
736
+ Ruby version 1.8.0, or later, REXML is bundled with Ruby's
737
+ distribution.
738
+
739
+ When no XML parser library is present, Bio::BLAST uses "-m 8" tabular
740
+ deliminated format. Available information is limited with the
741
+ "-m 8" format so installing an XML parser is recommended.
742
+
743
+ Again, the methods in Bio::Fasta::Report and Bio::Blast::Report (and
744
+ Bio::Fasta::Report::Hit and Bio::Blast::Report::Hit) are similar.
745
+ There are some additional BLAST methods, for example, bit_score and
746
+ midline.
747
+
748
+ report.each do |hit|
749
+ puts hit.bit_score
750
+ puts hit.query_seq
751
+ puts hit.midline
752
+ puts hit.target_seq
753
+
754
+ puts hit.evalue
755
+ puts hit.identity
756
+ puts hit.overlap
757
+ puts hit.query_id
758
+ puts hit.query_def
759
+ puts hit.query_len
760
+ puts hit.target_id
761
+ puts hit.target_def
762
+ puts hit.target_len
763
+ puts hit.query_start
764
+ puts hit.query_end
765
+ puts hit.target_start
766
+ puts hit.target_end
767
+ puts hit.lap_at
768
+ end
769
+
770
+ For simplicity and API compatibility, some information such as score
771
+ are extracted from the first Hsp (High-scoring Segment Pair).
772
+
773
+ Check the documentation for Bio::Blast::Report to see what can be
774
+ retrieved. For now suffice to state that Bio::Blast::Report has a
775
+ hierarchical structure mirroring the general BLAST output stream:
776
+
777
+ * In a Bio::Blast::Report object, @iteratinos is an array of
778
+ Bio::Blast::Report::Iteration objects.
779
+ * In a Bio::Blast::Report::Iteration object, @hits is an array of
780
+ Bio::Blast::Report::Hits objects.
781
+ * In a Bio::Blast::Report::Hits object, @hsps is an array of
782
+ Bio::Blast::Report::Hsp objects.
783
+
784
+ See bio/appl/blast.rb and bio/appl/blast/*.rb for more information.
785
+
786
+ === Parsing existing BLAST output files
787
+
788
+ When you already have BLAST output files and you want to parse them,
789
+ you can directly create Bio::Blast::Report objects without the
790
+ Bio::Blast factory object. For this purpose use Bio::Blast.reports,
791
+ which supports the "-m 0" default and "-m 7" XML type output format.
792
+
793
+ #!/usr/bin/env ruby
794
+
795
+ require 'bio'
796
+
797
+ # Iterates over each XML result.
798
+ # The variable "report" is a Bio::Blast::Report object.
799
+ Bio::Blast.reports(ARGF) do |report|
800
+ puts "Hits for " + report.query_def + " against " + report.db
801
+ report.each do |hit|
802
+ print hit.target_id, "\t", hit.evalue, "\n" if hit.evalue < 0.001
803
+ end
804
+ end
805
+
806
+ Save the script as hits_under_0.001.rb and to process BLAST output
807
+ files *.xml, you can
808
+
809
+ % ruby hits_under_0.001.rb *.xml
810
+
811
+ Sometimes BLAST XML output may be wrong and can not be parsed. We
812
+ recommended to install BLAST 2.2.5 or later, and try combinations of
813
+ the -D and -m options when you encounter problems.
814
+
815
+
816
+ === Add remote BLAST search sites
817
+
818
+ Note: this section is an advanced topic
819
+
820
+ Here a more advanced application for using BLAST sequence homology
821
+ search services. BioRuby currently only supports GenomeNet. If you
822
+ want to add other sites, you must write the following:
823
+
824
+ * the calling CGI (command-line options must be processed for the site).
825
+ * make sure you get BLAST output text as supported format by BioRuby
826
+ (e.g. "-m 8", "-m 7" or default("-m 0")).
827
+
828
+ In addition, you must write a private class method in Bio::Blast
829
+ named "exec_MYSITE" to get query sequence and to pass the result to
830
+ Bio::Blast::Report.new(or Bio::Blast::Default::Report.new):
831
+
832
+ factory = Bio::Blast.remote(program, db, option, 'MYSITE')
833
+
834
+ When you write above routines, please send to the BioRuby project and
835
+ they may be included.
836
+
837
+ == Generate a reference list using PubMed (Bio::PubMed)
838
+
839
+ Below script is an example which seaches PubMed and creates a reference list.
840
+
841
+ #!/usr/bin/env ruby
842
+
843
+ require 'bio'
844
+
845
+ ARGV.each do |id|
846
+ entry = Bio::PubMed.query(id) # searches PubMed and get entry
847
+ medline = Bio::MEDLINE.new(entry) # creates Bio::MEDLINE object from entry text
848
+ reference = medline.reference # converts into Bio::Reference object
849
+ puts reference.bibtex # shows BibTeX formatted text
850
+ end
851
+
852
+ We named the script pmfetch.rb.
853
+
854
+ % ./pmfetch.rb 11024183 10592278 10592173
855
+
856
+ To give some PubMed ID (PMID) in arguments, the script retrieves informations
857
+ from NCBI, parses MEDLINE format text, converts into BibTeX format and
858
+ shows them.
859
+
860
+ A keyword search is also available.
861
+
862
+ #!/usr/bin/env ruby
863
+
864
+ require 'bio'
865
+
866
+ # Concatinates argument keyword list to a string
867
+ keywords = ARGV.join(' ')
868
+
869
+ # PubMed keyword search
870
+ entries = Bio::PubMed.search(keywords)
871
+
872
+ entries.each do |entry|
873
+ medline = Bio::MEDLINE.new(entry) # creates Bio::MEDLINE object from text
874
+ reference = medline.reference # converts into Bio::Reference object
875
+ puts reference.bibtex # shows BibTeX format text
876
+ end
877
+
878
+ We named the script pmsearch.rb.
879
+
880
+ % ./pmsearch.rb genome bioinformatics
881
+
882
+ To give keywords in arguments, the script searches PubMed by given
883
+ keywords and shows bibliography informations in a BibTex format. Other
884
+ output formats are also avaialble like the bibitem method described
885
+ below. Some journal formats like nature and nar can be used, but lack
886
+ bold and italic font output.
887
+
888
+ (EDITORs NOTE: do we have some simple object that can be queried for
889
+ author, title etc.?)
890
+
891
+ Nowadays using NCBI E-Utils is recommended. Use Bio::PubMed.esearch
892
+ and Bio::PubMed.efetch instead of above methods.
893
+
894
+
895
+ #!/usr/bin/env ruby
896
+
897
+ require 'bio'
898
+
899
+ keywords = ARGV.join(' ')
900
+
901
+ options = {
902
+ 'maxdate' => '2003/05/31',
903
+ 'retmax' => 1000,
904
+ }
905
+
906
+ entries = Bio::PubMed.esearch(keywords, options)
907
+
908
+ Bio::PubMed.efetch(entries).each do |entry|
909
+ medline = Bio::MEDLINE.new(entry)
910
+ reference = medline.reference
911
+ puts reference.bibtex
912
+ end
913
+
914
+ The script works same as pmsearch.rb. But, by using NCBI E-Utils, more
915
+ options are available. For example published dates to search and
916
+ maximum number of hits to show results can be specified.
917
+
918
+ See the ((<help page of
919
+ E-Utils|URL:http://eutils.ncbi.nlm.nih.gov/entrez/query/static/eutils_help.html>))
920
+ for more details.
921
+
922
+
923
+
924
+ === More about BibTeX
925
+
926
+ In this section, we explain the simple usage of TeX for the BibTeX format
927
+ bibliography list collected by above scripts. For example, to save
928
+ BibTeX format bibliography data to a file named genoinfo.bib.
929
+
930
+ % ./pmfetch.rb 10592173 >> genoinfo.bib
931
+ % ./pmsearch.rb genome bioinformatics >> genoinfo.bib
932
+
933
+ The BibTeX can be used with Tex or LaTeX to form bibliography
934
+ information with your journal article. For more information
935
+ on BibTex see (EDITORS NOTE: insert URL). A quick example:
936
+
937
+ Save this to hoge.tex:
938
+
939
+ \documentclass{jarticle}
940
+ \begin{document}
941
+ \bibliographystyle{plain}
942
+ foo bar KEGG database~\cite{PMID:10592173} baz hoge fuga.
943
+ \bibliography{genoinfo}
944
+ \end{document}
945
+
946
+ Then,
947
+
948
+ % latex hoge
949
+ % bibtex hoge # processes genoinfo.bib
950
+ % latex hoge # creates bibliography list
951
+ % latex hoge # inserts correct bibliography reference
952
+
953
+ Now, you get hoge.dvi and hoge.ps - the latter you can view any
954
+ Postscript viewer.
955
+
956
+ === Bio::Reference#bibitem
957
+
958
+ When you don't want to create a bib file, you can use
959
+ Bio::Reference#bibitem method instead of Bio::Reference#bibtex.
960
+ In above pmfetch.rb and pmsearch.rb scripts, change
961
+
962
+ puts reference.bibtex
963
+ to
964
+ puts reference.bibitem
965
+
966
+
967
+ Output documents should be bundled in \begin{thebibliography}
968
+ and \end{thebibliography}. Save the following to hoge.tex
969
+
970
+ \documentclass{jarticle}
971
+ \begin{document}
972
+ foo bar KEGG database~\cite{PMID:10592173} baz hoge fuga.
973
+
974
+ \begin{thebibliography}{00}
975
+
976
+ \bibitem{PMID:10592173}
977
+ Kanehisa, M., Goto, S.
978
+ KEGG: kyoto encyclopedia of genes and genomes.,
979
+ {\em Nucleic Acids Res}, 28(1):27--30, 2000.
980
+
981
+ \end{thebibliography}
982
+ \end{document}
983
+
984
+ and run
985
+
986
+ % latex hoge # creates bibliography list
987
+ % latex hoge # inserts corrent bibliography reference
988
+
989
+
990
+ = OBDA
991
+
992
+ OBDA (Open Bio Database Access) is a standardized method of sequence
993
+ database access developed by the Open Bioinformatics Foundation. It
994
+ was created during the BioHackathon by BioPerl, BioJava, BioPython,
995
+ BioRuby and other projects' members (2002).
996
+
997
+ * BioRegistry (Directory)
998
+ * Mechanism to specify how and where to retrieve sequence data for each database.
999
+
1000
+ * BioFlat
1001
+ * Flatfile indexing by using binary tree or BDB(Berkeley DB).
1002
+
1003
+ * BioFetch
1004
+ * Server-client model for getting entry from database via http.
1005
+
1006
+ * BioSQL
1007
+ * Schemas to store sequence data to relational database such as
1008
+ MySQL and PostgreSQL, and methods to retrieve entries from the database.
1009
+
1010
+ Here we give a quick overview. Check out
1011
+ ((<URL:http://obda.open-bio.org/>)) for more extensive details.
1012
+
1013
+ The specification is stored on CVS repository at cvs.open-bio.org,
1014
+ also available via http from:
1015
+ ((<URL:http://cvs.open-bio.org/cgi-bin/viewcvs/viewcvs.cgi/obda-specs/?cvsroot=obf-common>))
1016
+
1017
+ == BioRegistry
1018
+
1019
+ BioRegistry allows for locating retrieval methods and database
1020
+ locations through configuration files. The priorities are
1021
+
1022
+ * The file specified with method's parameter
1023
+ * ~/.bioinformatics/seqdatabase.ini
1024
+ * /etc/bioinformatics/seqdatabase.ini
1025
+ * http://www.open-bio.org/registry/seqdatabase.ini
1026
+
1027
+ Note that the last locaation refers to www.open-bio.org and is only used
1028
+ when all local configulation files are not available.
1029
+
1030
+ In the current BioRuby implementation all local configulation files
1031
+ are read. For databases with the same name settings encountered first
1032
+ are used. This means that if you don't like some settings of a
1033
+ database in system global configuration file
1034
+ (/etc/bioinformatics/seqdatabase.ini), you can easily override it by
1035
+ writing settings to ~/.bioinformatics/seqdatabase.ini.
1036
+
1037
+ The syntax of the configuration file is called a stanza format. For example
1038
+
1039
+ [DatabaseName]
1040
+ protocol=ProtocolName
1041
+ location=ServeName
1042
+
1043
+ You can write a description like above entry for every database.
1044
+
1045
+ The database name is a local label for yourself, so you can name it
1046
+ freely and it can differ from the name of the actual databases. In the
1047
+ actual specification of BioRegistry where there are two or more
1048
+ settings for a database of the same name, it is proposed that
1049
+ connection to the database is tried sequentially with the order
1050
+ written in configuration files. However, this has not (yet) been
1051
+ implemented in BioRuby.
1052
+
1053
+ In addition, for some protocol, you must set additional options
1054
+ other than locations (e.g. user name of MySQL). In the BioRegistory
1055
+ specification, current available protocols are:
1056
+
1057
+ * index-flat
1058
+ * index-berkeleydb
1059
+ * biofetch
1060
+ * biosql
1061
+ * bsane-corba
1062
+ * xembl
1063
+
1064
+ In BioRuby, you can use index-flat, index-berkleydb, biofetch and biosql.
1065
+ Note that the BioRegistry specification sometimes gets updated and BioRuby
1066
+ does not always follow quickly.
1067
+
1068
+ Here an example. Create a Bio::Registry object. It reads the configuration
1069
+ files:
1070
+
1071
+ reg = Bio::Registry.new
1072
+
1073
+ # connects to the database "genbank"
1074
+ serv = reg.get_database('genbank')
1075
+
1076
+ # gets entry of the ID
1077
+ entry = serv.get_by_id('AA2CG')
1078
+
1079
+
1080
+ The variable "serv" is a server object corresponding to the setting
1081
+ written in configuration files. The class of the object is one of
1082
+ Bio::SQL, Bio::Fetch, and so on. Note that Bio::Registry#get_database("name")
1083
+ returns nil if no database is found.
1084
+
1085
+ After that, you can use get_by_id method and some specific methods.
1086
+ Please refer to below documents.
1087
+
1088
+ == BioFlat
1089
+
1090
+ BioFlat is a mechanism to create index files of flat files and to retrieve
1091
+ these entries fast. There are two index types. index-flat is a simple index
1092
+ performing binary search without using an external library of Ruby. index-berkeleydb
1093
+ uses Berkeley DB for indexing - but requires installing bdb on your computer,
1094
+ as well as the BDB Ruby package. For creating the index itself, you can use
1095
+ br_bioflat.rb command bundled with BioRuby.
1096
+
1097
+ % br_bioflat.rb --makeindex database_name [--format data_format] filename...
1098
+
1099
+ The format can be omitted because BioRuby has autodetection. If that
1100
+ does not work you can try specifying data format as a name of BioRuby
1101
+ database class.
1102
+
1103
+ Search and retrieve data from database:
1104
+
1105
+ % br_bioflat.rb database_name identifier
1106
+
1107
+ For example, to create index of GenBank files gbbct*.seq and get entry
1108
+ from the database:
1109
+
1110
+ % br_bioflat.rb --makeindex my_bctdb --format GenBank gbbct*.seq
1111
+ % br_bioflat.rb my_bctdb A16STM262
1112
+
1113
+ If you have Berkeley DB on your system and installed the bdb extension
1114
+ module of Ruby (see http://raa.ruby-lang.org/project/bdb/), you can
1115
+ create and search indexes with Berkeley DB - a very fast alternative
1116
+ that uses little computer memory. When creating the index, use the
1117
+ "--makeindex-bdb" option instead of "--makeindex".
1118
+
1119
+ % br_bioflat.rb --makeindex-bdb database_name [--format data_format] filename...
1120
+
1121
+ == BioFetch
1122
+
1123
+ Note: this section is an advanced topic
1124
+
1125
+ BioFetch is a database retrieval mechanism via CGI. CGI Parameters,
1126
+ options and error codes are standardized. There client access via
1127
+ http is possible giving the database name, identifiers and format to
1128
+ retrieve entries.
1129
+
1130
+ The BioRuby project has a BioFetch server in bioruby.org. It uses
1131
+ GenomeNet's DBGET system as a backend. The source code of the
1132
+ server is in sample/ directory. Currently, there are only two
1133
+ BioFetch servers in the world: bioruby.org and EBI.
1134
+
1135
+ Here are some methods to retrieve entries from our BioFetch server.
1136
+
1137
+ (1) Using a web browser
1138
+
1139
+ http://bioruby.org/cgi-bin/biofetch.rb
1140
+
1141
+ (2) Using the br_biofetch.rb command
1142
+
1143
+ % br_biofetch.rb db_name entry_id
1144
+
1145
+ (3) Directly using Bio::Fetch in a script
1146
+
1147
+ serv = Bio::Fetch.new(server_url)
1148
+ entry = serv.fetch(db_name, entry_id)
1149
+
1150
+ (4) Indirectly using Bio::Fetch via BioRegistry in script
1151
+
1152
+ reg = Bio::Registry.new
1153
+ serv = reg.get_database('genbank')
1154
+ entry = serv.get_by_id('AA2CG')
1155
+
1156
+ If you want to use (4), you, obviously, have to include some settings
1157
+ in seqdatabase.ini. E.g.
1158
+
1159
+ [genbank]
1160
+ protocol=biofetch
1161
+ location=http://bioruby.org/cgi-bin/biofetch.rb
1162
+ biodbname=genbank
1163
+
1164
+ === The combination of BioFetch, Bio::KEGG::GENES and Bio::AAindex1
1165
+
1166
+ Bioinformatics is often about glueing things together. Here we give an
1167
+ example to get the bacteriorhodopsin gene (VNG1467G) of the archaea
1168
+ Halobacterium from KEGG GENES database and to get alpha-helix index
1169
+ data (BURA740101) from the AAindex (Amino acid indices and similarity
1170
+ matrices) database, and show the helix score for each 15-aa length
1171
+ overlapping window.
1172
+
1173
+ #!/usr/bin/env ruby
1174
+
1175
+ require 'bio'
1176
+
1177
+ entry = Bio::Fetch.query('hal', 'VNG1467G')
1178
+ aaseq = Bio::KEGG::GENES.new(entry).aaseq
1179
+
1180
+ entry = Bio::Fetch.query('aax1', 'BURA740101')
1181
+ helix = Bio::AAindex1.new(entry).index
1182
+
1183
+ position = 1
1184
+ win_size = 15
1185
+
1186
+ aaseq.window_search(win_size) do |subseq|
1187
+ score = subseq.total(helix)
1188
+ puts [ position, score ].join("\t")
1189
+ position += 1
1190
+ end
1191
+
1192
+ The special method Bio::Fetch.query uses preset BioFetch server
1193
+ in bioruby.org. (The server internally get data from GenomeNet.
1194
+ Because the KEGG/GENES database and AAindex database are not available
1195
+ from other BioFetch servers, we used bioruby.org server with
1196
+ Bio::Fetch.query method.)
1197
+
1198
+ == BioSQL
1199
+
1200
+ to be written...
1201
+
1202
+ == The BioRuby example programs
1203
+
1204
+ Some sample programs are stored in ./samples/ directory. Run for example:
1205
+
1206
+ ./sample/na2aa.rb test/data/fasta/example1.txt
1207
+
1208
+ == Unit testing and doctests
1209
+
1210
+ BioRuby comes with an extensive testing framework with over 1300 tests and 2700
1211
+ assertions. To run the unit tests:
1212
+
1213
+ cd test
1214
+ ruby runner.rb
1215
+
1216
+ We have also started with doctest for Ruby. We are porting the examples
1217
+ in this tutorial to doctest - more info upcoming.
1218
+
1219
+ == Further reading
1220
+
1221
+ See the BioRuby in anger Wiki. A lot of BioRuby's documentation exists in the
1222
+ source code and unit tests. To really dive in you will need the latest source
1223
+ code tree. The embedded rdoc documentation can be viewed online at
1224
+ ((<URL:http://bioruby.org/rdoc/>)).
1225
+
1226
+ == BioRuby Shell
1227
+
1228
+ The BioRuby shell implementation you find in ./lib/bio/shell. It is very interesting
1229
+ as it uses IRB (the Ruby intepreter) which is a powerful environment described in
1230
+ ((<Programming Ruby's irb chapter|URL:http://ruby-doc.org/docs/ProgrammingRuby/html/irb.html>)). IRB commands can directly be typed in the shell, e.g.
1231
+
1232
+ bioruby!> IRB.conf[:PROMPT_MODE]
1233
+ ==!> :PROMPT_C
1234
+
1235
+ optionally you also may want to install the optional Ruby readline support -
1236
+ with Debian libreadline-ruby. To edit a previous line you may have to press
1237
+ line down (arrow down) first.
1238
+
1239
+ = Helpful tools
1240
+
1241
+ Apart from rdoc you may also want to use rtags - which allows jumping around
1242
+ source code by clicking on class and method names.
1243
+
1244
+ cd bioruby/lib
1245
+ rtags -R --vi
1246
+
1247
+ For a tutorial see ((<URL:http://rtags.rubyforge.org/>))
1248
+
1249
+ = APPENDIX
1250
+
1251
+ == KEGG API
1252
+
1253
+ Please refer to KEGG_API.rd.ja (English version: ((<URL:http://www.genome.jp/kegg/soap/doc/keggapi_manual.html>)) ) and
1254
+
1255
+ * ((<URL:http://www.genome.jp/kegg/soap/>))
1256
+
1257
+ == Comparing BioProjects
1258
+
1259
+ For a quick functional comparison of BioRuby, BioPerl, BioPython and Bioconductor (R) see ((<URL:http://sciruby.codeforpeople.com/sr.cgi/BioProjects>))
1260
+
1261
+ == Using BioRuby with R
1262
+
1263
+ Using Ruby with R Pjotr wrote a section on SciRuby. See ((<URL:http://sciruby.codeforpeople.com/sr.cgi/RubyWithRlang>))
1264
+
1265
+ == Using BioPerl or BioPython from Ruby
1266
+
1267
+ At the moment there is no easy way of accessing BioPerl from Ruby. The best way, perhaps, is to create a Perl server that gets accessed through XML/RPC or SOAP.
1268
+
1269
+ == Installing required external library
1270
+
1271
+ At this point for using BioRuby no additional libraries are needed.
1272
+ This may change, so keep an eye on the Bioruby website. Also when
1273
+ a package is missing BioRuby should show an informative message.
1274
+
1275
+ At this point installing third party Ruby packages can be a bit
1276
+ painful, as the gem standard for packages evolved late and some still
1277
+ force you to copy things by hand. Therefore read the README's
1278
+ carefully that come with each package.
1279
+
1280
+ == Trouble shooting
1281
+
1282
+ * Error: in `require': no such file to load -- bio (LoadError)
1283
+
1284
+ Ruby fails to find the BioRuby libraries - add it to the RUBYLIB path, or pass
1285
+ it to the interpeter. For example:
1286
+
1287
+ ruby -I~/cvs/bioruby/lib yourprogram.rb
1288
+
1289
+ == Modifying this page
1290
+
1291
+ IMPORTANT NOTICE: This page is maintained in the BioRuby CVS
1292
+ repository. Please edit the file there otherwise changes may get
1293
+ lost. See ((<BioRuby Developer Information>)) for CVS and mailing list
1294
+ access.
1295
+
1296
+ =end