bio 1.2.1 → 1.3.0

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