jandot-bio 1.2.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (335) hide show
  1. data/bin/bioruby +44 -0
  2. data/bin/br_biofetch.rb +47 -0
  3. data/bin/br_bioflat.rb +282 -0
  4. data/bin/br_biogetseq.rb +45 -0
  5. data/bin/br_pmfetch.rb +421 -0
  6. data/doc/Changes-0.7.rd +369 -0
  7. data/doc/KEGG_API.rd +1843 -0
  8. data/doc/KEGG_API.rd.ja +1834 -0
  9. data/doc/Tutorial.rd +1296 -0
  10. data/doc/Tutorial.rd.ja +2640 -0
  11. data/etc/bioinformatics/seqdatabase.ini +210 -0
  12. data/lib/bio.rb +279 -0
  13. data/lib/bio/alignment.rb +2518 -0
  14. data/lib/bio/appl/bl2seq/report.rb +334 -0
  15. data/lib/bio/appl/blast.rb +351 -0
  16. data/lib/bio/appl/blast/format0.rb +1438 -0
  17. data/lib/bio/appl/blast/format8.rb +83 -0
  18. data/lib/bio/appl/blast/report.rb +516 -0
  19. data/lib/bio/appl/blast/rexml.rb +135 -0
  20. data/lib/bio/appl/blast/rpsblast.rb +176 -0
  21. data/lib/bio/appl/blast/wublast.rb +550 -0
  22. data/lib/bio/appl/blast/xmlparser.rb +228 -0
  23. data/lib/bio/appl/blat/report.rb +489 -0
  24. data/lib/bio/appl/clustalw.rb +219 -0
  25. data/lib/bio/appl/clustalw/report.rb +152 -0
  26. data/lib/bio/appl/emboss.rb +203 -0
  27. data/lib/bio/appl/fasta.rb +237 -0
  28. data/lib/bio/appl/fasta/format10.rb +325 -0
  29. data/lib/bio/appl/gcg/msf.rb +212 -0
  30. data/lib/bio/appl/gcg/seq.rb +195 -0
  31. data/lib/bio/appl/genscan/report.rb +552 -0
  32. data/lib/bio/appl/hmmer.rb +126 -0
  33. data/lib/bio/appl/hmmer/report.rb +683 -0
  34. data/lib/bio/appl/iprscan/report.rb +374 -0
  35. data/lib/bio/appl/mafft.rb +259 -0
  36. data/lib/bio/appl/mafft/report.rb +226 -0
  37. data/lib/bio/appl/muscle.rb +52 -0
  38. data/lib/bio/appl/phylip/alignment.rb +129 -0
  39. data/lib/bio/appl/phylip/distance_matrix.rb +96 -0
  40. data/lib/bio/appl/probcons.rb +41 -0
  41. data/lib/bio/appl/psort.rb +548 -0
  42. data/lib/bio/appl/psort/report.rb +457 -0
  43. data/lib/bio/appl/pts1.rb +263 -0
  44. data/lib/bio/appl/sim4.rb +124 -0
  45. data/lib/bio/appl/sim4/report.rb +485 -0
  46. data/lib/bio/appl/sosui/report.rb +151 -0
  47. data/lib/bio/appl/spidey/report.rb +593 -0
  48. data/lib/bio/appl/targetp/report.rb +267 -0
  49. data/lib/bio/appl/tcoffee.rb +55 -0
  50. data/lib/bio/appl/tmhmm/report.rb +222 -0
  51. data/lib/bio/command.rb +337 -0
  52. data/lib/bio/data/aa.rb +349 -0
  53. data/lib/bio/data/codontable.rb +722 -0
  54. data/lib/bio/data/na.rb +223 -0
  55. data/lib/bio/db.rb +329 -0
  56. data/lib/bio/db/aaindex.rb +357 -0
  57. data/lib/bio/db/embl/common.rb +336 -0
  58. data/lib/bio/db/embl/embl.rb +402 -0
  59. data/lib/bio/db/embl/sptr.rb +1283 -0
  60. data/lib/bio/db/embl/swissprot.rb +42 -0
  61. data/lib/bio/db/embl/trembl.rb +41 -0
  62. data/lib/bio/db/embl/uniprot.rb +42 -0
  63. data/lib/bio/db/fantom.rb +599 -0
  64. data/lib/bio/db/fasta.rb +907 -0
  65. data/lib/bio/db/genbank/common.rb +290 -0
  66. data/lib/bio/db/genbank/ddbj.rb +22 -0
  67. data/lib/bio/db/genbank/genbank.rb +215 -0
  68. data/lib/bio/db/genbank/genpept.rb +60 -0
  69. data/lib/bio/db/genbank/refseq.rb +18 -0
  70. data/lib/bio/db/gff.rb +174 -0
  71. data/lib/bio/db/go.rb +481 -0
  72. data/lib/bio/db/kegg/brite.rb +41 -0
  73. data/lib/bio/db/kegg/compound.rb +131 -0
  74. data/lib/bio/db/kegg/drug.rb +98 -0
  75. data/lib/bio/db/kegg/enzyme.rb +148 -0
  76. data/lib/bio/db/kegg/expression.rb +155 -0
  77. data/lib/bio/db/kegg/genes.rb +263 -0
  78. data/lib/bio/db/kegg/genome.rb +241 -0
  79. data/lib/bio/db/kegg/glycan.rb +170 -0
  80. data/lib/bio/db/kegg/keggtab.rb +357 -0
  81. data/lib/bio/db/kegg/kgml.rb +256 -0
  82. data/lib/bio/db/kegg/orthology.rb +136 -0
  83. data/lib/bio/db/kegg/reaction.rb +82 -0
  84. data/lib/bio/db/kegg/taxonomy.rb +331 -0
  85. data/lib/bio/db/lasergene.rb +209 -0
  86. data/lib/bio/db/litdb.rb +107 -0
  87. data/lib/bio/db/medline.rb +323 -0
  88. data/lib/bio/db/nbrf.rb +191 -0
  89. data/lib/bio/db/newick.rb +658 -0
  90. data/lib/bio/db/nexus.rb +1854 -0
  91. data/lib/bio/db/pdb.rb +29 -0
  92. data/lib/bio/db/pdb/atom.rb +77 -0
  93. data/lib/bio/db/pdb/chain.rb +210 -0
  94. data/lib/bio/db/pdb/chemicalcomponent.rb +224 -0
  95. data/lib/bio/db/pdb/model.rb +148 -0
  96. data/lib/bio/db/pdb/pdb.rb +1911 -0
  97. data/lib/bio/db/pdb/residue.rb +176 -0
  98. data/lib/bio/db/pdb/utils.rb +399 -0
  99. data/lib/bio/db/prosite.rb +597 -0
  100. data/lib/bio/db/rebase.rb +457 -0
  101. data/lib/bio/db/soft.rb +404 -0
  102. data/lib/bio/db/transfac.rb +375 -0
  103. data/lib/bio/feature.rb +226 -0
  104. data/lib/bio/io/das.rb +461 -0
  105. data/lib/bio/io/dbget.rb +194 -0
  106. data/lib/bio/io/ddbjxml.rb +581 -0
  107. data/lib/bio/io/ebisoap.rb +158 -0
  108. data/lib/bio/io/ensembl.rb +229 -0
  109. data/lib/bio/io/fastacmd.rb +163 -0
  110. data/lib/bio/io/fetch.rb +181 -0
  111. data/lib/bio/io/flatfile.rb +1309 -0
  112. data/lib/bio/io/flatfile/bdb.rb +253 -0
  113. data/lib/bio/io/flatfile/index.rb +1371 -0
  114. data/lib/bio/io/flatfile/indexer.rb +787 -0
  115. data/lib/bio/io/higet.rb +73 -0
  116. data/lib/bio/io/hinv.rb +442 -0
  117. data/lib/bio/io/keggapi.rb +805 -0
  118. data/lib/bio/io/ncbirest.rb +256 -0
  119. data/lib/bio/io/ncbisoap.rb +155 -0
  120. data/lib/bio/io/pubmed.rb +307 -0
  121. data/lib/bio/io/registry.rb +292 -0
  122. data/lib/bio/io/soapwsdl.rb +119 -0
  123. data/lib/bio/io/sql.rb +365 -0
  124. data/lib/bio/location.rb +772 -0
  125. data/lib/bio/map.rb +410 -0
  126. data/lib/bio/pathway.rb +854 -0
  127. data/lib/bio/reference.rb +623 -0
  128. data/lib/bio/sequence.rb +475 -0
  129. data/lib/bio/sequence/aa.rb +125 -0
  130. data/lib/bio/sequence/common.rb +333 -0
  131. data/lib/bio/sequence/compat.rb +123 -0
  132. data/lib/bio/sequence/format.rb +181 -0
  133. data/lib/bio/sequence/generic.rb +24 -0
  134. data/lib/bio/sequence/na.rb +491 -0
  135. data/lib/bio/shell.rb +44 -0
  136. data/lib/bio/shell/core.rb +578 -0
  137. data/lib/bio/shell/demo.rb +146 -0
  138. data/lib/bio/shell/interface.rb +218 -0
  139. data/lib/bio/shell/irb.rb +95 -0
  140. data/lib/bio/shell/object.rb +71 -0
  141. data/lib/bio/shell/plugin/blast.rb +42 -0
  142. data/lib/bio/shell/plugin/codon.rb +218 -0
  143. data/lib/bio/shell/plugin/das.rb +58 -0
  144. data/lib/bio/shell/plugin/emboss.rb +23 -0
  145. data/lib/bio/shell/plugin/entry.rb +105 -0
  146. data/lib/bio/shell/plugin/flatfile.rb +101 -0
  147. data/lib/bio/shell/plugin/keggapi.rb +181 -0
  148. data/lib/bio/shell/plugin/midi.rb +430 -0
  149. data/lib/bio/shell/plugin/obda.rb +45 -0
  150. data/lib/bio/shell/plugin/psort.rb +56 -0
  151. data/lib/bio/shell/plugin/seq.rb +247 -0
  152. data/lib/bio/shell/plugin/soap.rb +87 -0
  153. data/lib/bio/shell/rails/vendor/plugins/bioruby/generators/bioruby/bioruby_generator.rb +29 -0
  154. data/lib/bio/shell/rails/vendor/plugins/bioruby/generators/bioruby/templates/_classes.rhtml +4 -0
  155. data/lib/bio/shell/rails/vendor/plugins/bioruby/generators/bioruby/templates/_log.rhtml +27 -0
  156. data/lib/bio/shell/rails/vendor/plugins/bioruby/generators/bioruby/templates/_methods.rhtml +11 -0
  157. data/lib/bio/shell/rails/vendor/plugins/bioruby/generators/bioruby/templates/_modules.rhtml +4 -0
  158. data/lib/bio/shell/rails/vendor/plugins/bioruby/generators/bioruby/templates/_variables.rhtml +7 -0
  159. data/lib/bio/shell/rails/vendor/plugins/bioruby/generators/bioruby/templates/bioruby-bg.gif +0 -0
  160. data/lib/bio/shell/rails/vendor/plugins/bioruby/generators/bioruby/templates/bioruby-gem.png +0 -0
  161. data/lib/bio/shell/rails/vendor/plugins/bioruby/generators/bioruby/templates/bioruby-link.gif +0 -0
  162. data/lib/bio/shell/rails/vendor/plugins/bioruby/generators/bioruby/templates/bioruby.css +368 -0
  163. data/lib/bio/shell/rails/vendor/plugins/bioruby/generators/bioruby/templates/bioruby.rhtml +47 -0
  164. data/lib/bio/shell/rails/vendor/plugins/bioruby/generators/bioruby/templates/bioruby_controller.rb +144 -0
  165. data/lib/bio/shell/rails/vendor/plugins/bioruby/generators/bioruby/templates/bioruby_helper.rb +47 -0
  166. data/lib/bio/shell/rails/vendor/plugins/bioruby/generators/bioruby/templates/commands.rhtml +8 -0
  167. data/lib/bio/shell/rails/vendor/plugins/bioruby/generators/bioruby/templates/history.rhtml +10 -0
  168. data/lib/bio/shell/rails/vendor/plugins/bioruby/generators/bioruby/templates/index.rhtml +26 -0
  169. data/lib/bio/shell/rails/vendor/plugins/bioruby/generators/bioruby/templates/spinner.gif +0 -0
  170. data/lib/bio/shell/script.rb +25 -0
  171. data/lib/bio/shell/setup.rb +109 -0
  172. data/lib/bio/shell/web.rb +102 -0
  173. data/lib/bio/tree.rb +850 -0
  174. data/lib/bio/util/color_scheme.rb +191 -0
  175. data/lib/bio/util/color_scheme/buried.rb +59 -0
  176. data/lib/bio/util/color_scheme/helix.rb +59 -0
  177. data/lib/bio/util/color_scheme/hydropathy.rb +64 -0
  178. data/lib/bio/util/color_scheme/nucleotide.rb +31 -0
  179. data/lib/bio/util/color_scheme/strand.rb +59 -0
  180. data/lib/bio/util/color_scheme/taylor.rb +50 -0
  181. data/lib/bio/util/color_scheme/turn.rb +59 -0
  182. data/lib/bio/util/color_scheme/zappo.rb +50 -0
  183. data/lib/bio/util/contingency_table.rb +370 -0
  184. data/lib/bio/util/restriction_enzyme.rb +228 -0
  185. data/lib/bio/util/restriction_enzyme/analysis.rb +249 -0
  186. data/lib/bio/util/restriction_enzyme/analysis_basic.rb +217 -0
  187. data/lib/bio/util/restriction_enzyme/cut_symbol.rb +107 -0
  188. data/lib/bio/util/restriction_enzyme/double_stranded.rb +321 -0
  189. data/lib/bio/util/restriction_enzyme/double_stranded/aligned_strands.rb +130 -0
  190. data/lib/bio/util/restriction_enzyme/double_stranded/cut_location_pair.rb +103 -0
  191. data/lib/bio/util/restriction_enzyme/double_stranded/cut_location_pair_in_enzyme_notation.rb +38 -0
  192. data/lib/bio/util/restriction_enzyme/double_stranded/cut_locations.rb +76 -0
  193. data/lib/bio/util/restriction_enzyme/double_stranded/cut_locations_in_enzyme_notation.rb +107 -0
  194. data/lib/bio/util/restriction_enzyme/enzymes.yaml +7061 -0
  195. data/lib/bio/util/restriction_enzyme/range/cut_range.rb +24 -0
  196. data/lib/bio/util/restriction_enzyme/range/cut_ranges.rb +47 -0
  197. data/lib/bio/util/restriction_enzyme/range/horizontal_cut_range.rb +67 -0
  198. data/lib/bio/util/restriction_enzyme/range/sequence_range.rb +257 -0
  199. data/lib/bio/util/restriction_enzyme/range/sequence_range/calculated_cuts.rb +242 -0
  200. data/lib/bio/util/restriction_enzyme/range/sequence_range/fragment.rb +51 -0
  201. data/lib/bio/util/restriction_enzyme/range/sequence_range/fragments.rb +41 -0
  202. data/lib/bio/util/restriction_enzyme/range/vertical_cut_range.rb +77 -0
  203. data/lib/bio/util/restriction_enzyme/single_strand.rb +199 -0
  204. data/lib/bio/util/restriction_enzyme/single_strand/cut_locations_in_enzyme_notation.rb +135 -0
  205. data/lib/bio/util/restriction_enzyme/single_strand_complement.rb +23 -0
  206. data/lib/bio/util/restriction_enzyme/string_formatting.rb +111 -0
  207. data/lib/bio/util/sirna.rb +288 -0
  208. data/sample/any2fasta.rb +59 -0
  209. data/sample/biofetch.rb +475 -0
  210. data/sample/color_scheme_na.rb +91 -0
  211. data/sample/dbget +37 -0
  212. data/sample/enzymes.rb +78 -0
  213. data/sample/fasta2tab.rb +99 -0
  214. data/sample/fastagrep.rb +72 -0
  215. data/sample/fastasort.rb +54 -0
  216. data/sample/fsplit.rb +51 -0
  217. data/sample/gb2fasta.rb +30 -0
  218. data/sample/gb2tab.rb +325 -0
  219. data/sample/gbtab2mysql.rb +161 -0
  220. data/sample/genes2nuc.rb +33 -0
  221. data/sample/genes2pep.rb +33 -0
  222. data/sample/genes2tab.rb +81 -0
  223. data/sample/genome2rb.rb +29 -0
  224. data/sample/genome2tab.rb +76 -0
  225. data/sample/goslim.rb +303 -0
  226. data/sample/gt2fasta.rb +47 -0
  227. data/sample/na2aa.rb +34 -0
  228. data/sample/pmfetch.rb +42 -0
  229. data/sample/pmsearch.rb +42 -0
  230. data/sample/psortplot_html.rb +214 -0
  231. data/sample/ssearch2tab.rb +96 -0
  232. data/sample/tdiary.rb +158 -0
  233. data/sample/tfastx2tab.rb +100 -0
  234. data/sample/vs-genes.rb +212 -0
  235. data/test/data/HMMER/hmmpfam.out +64 -0
  236. data/test/data/HMMER/hmmsearch.out +88 -0
  237. data/test/data/SOSUI/sample.report +11 -0
  238. data/test/data/TMHMM/sample.report +21 -0
  239. data/test/data/aaindex/DAYM780301 +30 -0
  240. data/test/data/aaindex/PRAM900102 +20 -0
  241. data/test/data/bl2seq/cd8a_cd8b_blastp.bl2seq +53 -0
  242. data/test/data/bl2seq/cd8a_p53_e-5blastp.bl2seq +37 -0
  243. data/test/data/blast/2.2.15.blastp.m7 +876 -0
  244. data/test/data/blast/b0002.faa +15 -0
  245. data/test/data/blast/b0002.faa.m0 +128 -0
  246. data/test/data/blast/b0002.faa.m7 +65 -0
  247. data/test/data/blast/b0002.faa.m8 +1 -0
  248. data/test/data/embl/AB090716.embl +65 -0
  249. data/test/data/embl/AB090716.embl.rel89 +63 -0
  250. data/test/data/fasta/example1.txt +75 -0
  251. data/test/data/fasta/example2.txt +21 -0
  252. data/test/data/genscan/sample.report +63 -0
  253. data/test/data/iprscan/merged.raw +32 -0
  254. data/test/data/iprscan/merged.txt +74 -0
  255. data/test/data/prosite/prosite.dat +2233 -0
  256. data/test/data/refseq/nm_126355.entret +64 -0
  257. data/test/data/soft/GDS100_partial.soft +92 -0
  258. data/test/data/soft/GSE3457_family_partial.soft +874 -0
  259. data/test/data/uniprot/p53_human.uniprot +1456 -0
  260. data/test/functional/bio/io/test_ensembl.rb +186 -0
  261. data/test/functional/bio/io/test_soapwsdl.rb +52 -0
  262. data/test/runner.rb +14 -0
  263. data/test/unit/bio/appl/bl2seq/test_report.rb +134 -0
  264. data/test/unit/bio/appl/blast/test_report.rb +417 -0
  265. data/test/unit/bio/appl/blast/test_xmlparser.rb +388 -0
  266. data/test/unit/bio/appl/genscan/test_report.rb +182 -0
  267. data/test/unit/bio/appl/hmmer/test_report.rb +342 -0
  268. data/test/unit/bio/appl/iprscan/test_report.rb +338 -0
  269. data/test/unit/bio/appl/mafft/test_report.rb +63 -0
  270. data/test/unit/bio/appl/sosui/test_report.rb +81 -0
  271. data/test/unit/bio/appl/targetp/test_report.rb +146 -0
  272. data/test/unit/bio/appl/test_blast.rb +163 -0
  273. data/test/unit/bio/appl/test_fasta.rb +130 -0
  274. data/test/unit/bio/appl/test_pts1.rb +140 -0
  275. data/test/unit/bio/appl/tmhmm/test_report.rb +126 -0
  276. data/test/unit/bio/data/test_aa.rb +90 -0
  277. data/test/unit/bio/data/test_codontable.rb +107 -0
  278. data/test/unit/bio/data/test_na.rb +80 -0
  279. data/test/unit/bio/db/embl/test_common.rb +117 -0
  280. data/test/unit/bio/db/embl/test_embl.rb +214 -0
  281. data/test/unit/bio/db/embl/test_embl_rel89.rb +219 -0
  282. data/test/unit/bio/db/embl/test_sptr.rb +1775 -0
  283. data/test/unit/bio/db/embl/test_uniprot.rb +31 -0
  284. data/test/unit/bio/db/kegg/test_genes.rb +45 -0
  285. data/test/unit/bio/db/pdb/test_pdb.rb +152 -0
  286. data/test/unit/bio/db/test_aaindex.rb +197 -0
  287. data/test/unit/bio/db/test_fasta.rb +250 -0
  288. data/test/unit/bio/db/test_gff.rb +127 -0
  289. data/test/unit/bio/db/test_lasergene.rb +95 -0
  290. data/test/unit/bio/db/test_newick.rb +293 -0
  291. data/test/unit/bio/db/test_nexus.rb +360 -0
  292. data/test/unit/bio/db/test_prosite.rb +1437 -0
  293. data/test/unit/bio/db/test_rebase.rb +101 -0
  294. data/test/unit/bio/db/test_soft.rb +138 -0
  295. data/test/unit/bio/io/test_ddbjxml.rb +75 -0
  296. data/test/unit/bio/io/test_ensembl.rb +109 -0
  297. data/test/unit/bio/io/test_fastacmd.rb +42 -0
  298. data/test/unit/bio/io/test_flatfile.rb +237 -0
  299. data/test/unit/bio/io/test_soapwsdl.rb +32 -0
  300. data/test/unit/bio/sequence/test_aa.rb +103 -0
  301. data/test/unit/bio/sequence/test_common.rb +174 -0
  302. data/test/unit/bio/sequence/test_compat.rb +69 -0
  303. data/test/unit/bio/sequence/test_na.rb +330 -0
  304. data/test/unit/bio/shell/plugin/test_seq.rb +185 -0
  305. data/test/unit/bio/test_alignment.rb +1025 -0
  306. data/test/unit/bio/test_command.rb +288 -0
  307. data/test/unit/bio/test_db.rb +96 -0
  308. data/test/unit/bio/test_feature.rb +116 -0
  309. data/test/unit/bio/test_location.rb +39 -0
  310. data/test/unit/bio/test_map.rb +230 -0
  311. data/test/unit/bio/test_pathway.rb +473 -0
  312. data/test/unit/bio/test_reference.rb +224 -0
  313. data/test/unit/bio/test_sequence.rb +329 -0
  314. data/test/unit/bio/test_shell.rb +18 -0
  315. data/test/unit/bio/test_tree.rb +593 -0
  316. data/test/unit/bio/util/restriction_enzyme/analysis/test_calculated_cuts.rb +299 -0
  317. data/test/unit/bio/util/restriction_enzyme/analysis/test_cut_ranges.rb +103 -0
  318. data/test/unit/bio/util/restriction_enzyme/analysis/test_sequence_range.rb +240 -0
  319. data/test/unit/bio/util/restriction_enzyme/double_stranded/test_aligned_strands.rb +101 -0
  320. data/test/unit/bio/util/restriction_enzyme/double_stranded/test_cut_location_pair.rb +75 -0
  321. data/test/unit/bio/util/restriction_enzyme/double_stranded/test_cut_location_pair_in_enzyme_notation.rb +73 -0
  322. data/test/unit/bio/util/restriction_enzyme/double_stranded/test_cut_locations.rb +53 -0
  323. data/test/unit/bio/util/restriction_enzyme/double_stranded/test_cut_locations_in_enzyme_notation.rb +104 -0
  324. data/test/unit/bio/util/restriction_enzyme/single_strand/test_cut_locations_in_enzyme_notation.rb +83 -0
  325. data/test/unit/bio/util/restriction_enzyme/test_analysis.rb +246 -0
  326. data/test/unit/bio/util/restriction_enzyme/test_cut_symbol.rb +44 -0
  327. data/test/unit/bio/util/restriction_enzyme/test_double_stranded.rb +115 -0
  328. data/test/unit/bio/util/restriction_enzyme/test_single_strand.rb +147 -0
  329. data/test/unit/bio/util/restriction_enzyme/test_single_strand_complement.rb +147 -0
  330. data/test/unit/bio/util/restriction_enzyme/test_string_formatting.rb +60 -0
  331. data/test/unit/bio/util/test_color_scheme.rb +33 -0
  332. data/test/unit/bio/util/test_contingency_table.rb +94 -0
  333. data/test/unit/bio/util/test_restriction_enzyme.rb +42 -0
  334. data/test/unit/bio/util/test_sirna.rb +245 -0
  335. metadata +479 -0
@@ -0,0 +1,123 @@
1
+ #
2
+ # = bio/sequence/compat.rb - methods for backward compatibility
3
+ #
4
+ # Copyright:: Copyright (C) 2006
5
+ # Toshiaki Katayama <k@bioruby.org>,
6
+ # Ryan Raaum <ryan@raaum.org>
7
+ # License:: The Ruby License
8
+ #
9
+ # $Id: compat.rb,v 1.4 2007/04/05 23:35:41 trevor Exp $
10
+ #
11
+
12
+
13
+ module Bio
14
+
15
+ class Sequence
16
+
17
+ autoload :Common, 'bio/sequence/common'
18
+ autoload :NA, 'bio/sequence/na'
19
+ autoload :AA, 'bio/sequence/aa'
20
+
21
+ # Return sequence as
22
+ # String[http://corelib.rubyonrails.org/classes/String.html].
23
+ # The original sequence is unchanged.
24
+ #
25
+ # seq = Bio::Sequence.new('atgc')
26
+ # puts s.to_s #=> 'atgc'
27
+ # puts s.to_s.class #=> String
28
+ # puts s #=> 'atgc'
29
+ # puts s.class #=> Bio::Sequence
30
+ # ---
31
+ # *Returns*:: String object
32
+ def to_s
33
+ String.new(@seq)
34
+ end
35
+ alias to_str to_s
36
+
37
+
38
+ module Common
39
+
40
+ # *DEPRECIATED* Do not use! Use Bio::Sequence#output instead.
41
+ #
42
+ # Output the FASTA format string of the sequence. The 1st argument is
43
+ # used as the comment string. If the 2nd option is given, the output
44
+ # sequence will be folded.
45
+ # ---
46
+ # *Arguments*:
47
+ # * (optional) _header_: String object
48
+ # * (optional) _width_: Fixnum object (default nil)
49
+ # *Returns*:: String
50
+ def to_fasta(header = '', width = nil)
51
+ warn "Bio::Sequence#to_fasta is obsolete. Use Bio::Sequence#output(:fasta) instead" if $DEBUG
52
+ ">#{header}\n" +
53
+ if width
54
+ self.to_s.gsub(Regexp.new(".{1,#{width}}"), "\\0\n")
55
+ else
56
+ self.to_s + "\n"
57
+ end
58
+ end
59
+
60
+ end # Common
61
+
62
+
63
+ class NA
64
+
65
+ # Generate a new random sequence with the given frequency of bases.
66
+ # The sequence length is determined by their cumulative sum.
67
+ # (See also Bio::Sequence::Common#randomize which creates a new
68
+ # randomized sequence object using the base composition of an existing
69
+ # sequence instance).
70
+ #
71
+ # counts = {'a'=>1,'c'=>2,'g'=>3,'t'=>4}
72
+ # puts Bio::Sequence::NA.randomize(counts) #=> "ggcttgttac" (for example)
73
+ #
74
+ # You may also feed the output of randomize into a block
75
+ #
76
+ # actual_counts = {'a'=>0, 'c'=>0, 'g'=>0, 't'=>0}
77
+ # Bio::Sequence::NA.randomize(counts) {|x| actual_counts[x] += 1}
78
+ # actual_counts #=> {"a"=>1, "c"=>2, "g"=>3, "t"=>4}
79
+ # ---
80
+ # *Arguments*:
81
+ # * (optional) _hash_: Hash object
82
+ # *Returns*:: Bio::Sequence::NA object
83
+ def self.randomize(*arg, &block)
84
+ self.new('').randomize(*arg, &block)
85
+ end
86
+
87
+ def pikachu #:nodoc:
88
+ self.dna.tr("atgc", "pika") # joke, of course :-)
89
+ end
90
+
91
+ end # NA
92
+
93
+
94
+ class AA
95
+
96
+ # Generate a new random sequence with the given frequency of bases.
97
+ # The sequence length is determined by their cumulative sum.
98
+ # (See also Bio::Sequence::Common#randomize which creates a new
99
+ # randomized sequence object using the base composition of an existing
100
+ # sequence instance).
101
+ #
102
+ # counts = {'R'=>1,'L'=>2,'E'=>3,'A'=>4}
103
+ # puts Bio::Sequence::AA.randomize(counts) #=> "AAEAELALRE" (for example)
104
+ #
105
+ # You may also feed the output of randomize into a block
106
+ #
107
+ # actual_counts = {'R'=>0,'L'=>0,'E'=>0,'A'=>0}
108
+ # Bio::Sequence::AA.randomize(counts) {|x| actual_counts[x] += 1}
109
+ # actual_counts #=> {"A"=>4, "L"=>2, "E"=>3, "R"=>1}
110
+ # ---
111
+ # *Arguments*:
112
+ # * (optional) _hash_: Hash object
113
+ # *Returns*:: Bio::Sequence::AA object
114
+ def self.randomize(*arg, &block)
115
+ self.new('').randomize(*arg, &block)
116
+ end
117
+
118
+ end # AA
119
+
120
+
121
+ end # Sequence
122
+
123
+ end # Bio
@@ -0,0 +1,181 @@
1
+ #
2
+ # = bio/sequence/format.rb - various output format of the biological sequence
3
+ #
4
+ # Copyright:: Copyright (C) 2006
5
+ # Toshiaki Katayama <k@bioruby.org>,
6
+ # Naohisa Goto <ng@bioruby.org>,
7
+ # Ryan Raaum <ryan@raaum.org>
8
+ # License:: The Ruby License
9
+ #
10
+ # = TODO
11
+ #
12
+ # porting from N. Goto's feature-output.rb on BioRuby list.
13
+ #
14
+ # $Id: format.rb,v 1.4 2007/04/05 23:35:41 trevor Exp $
15
+ #
16
+
17
+
18
+ module Bio
19
+
20
+ autoload :Sequence, 'bio/sequence'
21
+
22
+ class Sequence
23
+
24
+ # = DESCRIPTION
25
+ # A Mixin[http://www.rubycentral.com/book/tut_modules.html]
26
+ # of methods used by Bio::Sequence#output to output sequences in
27
+ # common bioinformatic formats. These are not called in isolation.
28
+ #
29
+ # = USAGE
30
+ # # Given a Bio::Sequence object,
31
+ # puts s.output(:fasta)
32
+ # puts s.output(:genbank)
33
+ # puts s.output(:embl)
34
+ module Format
35
+
36
+ # INTERNAL USE ONLY, YOU SHOULD NOT CALL THIS METHOD. (And in any
37
+ # case, it would be difficult to successfully call this method outside
38
+ # its expected context).
39
+ #
40
+ # Output the FASTA format string of the sequence.
41
+ #
42
+ # UNFORTUNATLY, the current implementation of Bio::Sequence is incapable of
43
+ # using either the header or width arguments. So something needs to be
44
+ # changed...
45
+ #
46
+ # Currently, this method is used in Bio::Sequence#output like so,
47
+ #
48
+ # s = Bio::Sequence.new('atgc')
49
+ # puts s.output(:fasta) #=> "> \natgc\n"
50
+ # ---
51
+ # *Arguments*:
52
+ # * (optional) _header_: String (default nil)
53
+ # * (optional) _width_: Fixnum (default nil)
54
+ # *Returns*:: String object
55
+ def format_fasta(header = nil, width = nil)
56
+ header ||= "#{@entry_id} #{@definition}"
57
+
58
+ ">#{header}\n" +
59
+ if width
60
+ @seq.to_s.gsub(Regexp.new(".{1,#{width}}"), "\\0\n")
61
+ else
62
+ @seq.to_s + "\n"
63
+ end
64
+ end
65
+
66
+ # Not yet implemented :)
67
+ # Remove the nodoc command after implementation!
68
+ # ---
69
+ # *Returns*:: String object
70
+ def format_gff #:nodoc:
71
+ raise NotImplementedError
72
+ end
73
+
74
+ # INTERNAL USE ONLY, YOU SHOULD NOT CALL THIS METHOD. (And in any
75
+ # case, it would be difficult to successfully call this method outside
76
+ # its expected context).
77
+ #
78
+ # Output the Genbank format string of the sequence.
79
+ # Used in Bio::Sequence#output.
80
+ # ---
81
+ # *Returns*:: String object
82
+ def format_genbank
83
+ prefix = ' ' * 5
84
+ indent = prefix + ' ' * 16
85
+ fwidth = 79 - indent.length
86
+
87
+ format_features(prefix, indent, fwidth)
88
+ end
89
+
90
+ # INTERNAL USE ONLY, YOU SHOULD NOT CALL THIS METHOD. (And in any
91
+ # case, it would be difficult to successfully call this method outside
92
+ # its expected context).
93
+ #
94
+ # Output the EMBL format string of the sequence.
95
+ # Used in Bio::Sequence#output.
96
+ # ---
97
+ # *Returns*:: String object
98
+ def format_embl
99
+ prefix = 'FT '
100
+ indent = prefix + ' ' * 16
101
+ fwidth = 80 - indent.length
102
+
103
+ format_features(prefix, indent, fwidth)
104
+ end
105
+
106
+
107
+ private
108
+
109
+ def format_features(prefix, indent, width)
110
+ result = ''
111
+ @features.each do |feature|
112
+ result << prefix + sprintf("%-16s", feature.feature)
113
+
114
+ position = feature.position
115
+ #position = feature.locations.to_s
116
+
117
+ head = ''
118
+ wrap(position, width).each_line do |line|
119
+ result << head << line
120
+ head = indent
121
+ end
122
+
123
+ result << format_qualifiers(feature.qualifiers, width)
124
+ end
125
+ return result
126
+ end
127
+
128
+ def format_qualifiers(qualifiers, indent, width)
129
+ qualifiers.each do |qualifier|
130
+ q = qualifier.qualifier
131
+ v = qualifier.value.to_s
132
+
133
+ if v == true
134
+ lines = wrap('/' + q, width)
135
+ elsif q == 'translation'
136
+ lines = fold('/' + q + '=' + val, width)
137
+ else
138
+ if v[/\D/]
139
+ #v.delete!("\x00-\x1f\x7f-\xff")
140
+ v.gsub!(/"/, '""')
141
+ v = '"' + v + '"'
142
+ end
143
+ lines = wrap('/' + q + '=' + val, width)
144
+ end
145
+
146
+ return lines.gsub(/^/, indent)
147
+ end
148
+ end
149
+
150
+ def fold(str, width)
151
+ str.gsub(Regexp.new("(.{1,#{width}})"), "\\1\n")
152
+ end
153
+
154
+ def wrap(str, width)
155
+ result = []
156
+ left = str.dup
157
+ while left and left.length > width
158
+ line = nil
159
+ width.downto(1) do |i|
160
+ if left[i..i] == ' ' or /[,;]/ =~ left[(i-1)..(i-1)] then
161
+ line = left[0..(i-1)].sub(/ +\z/, '')
162
+ left = left[i..-1].sub(/\A +/, '')
163
+ break
164
+ end
165
+ end
166
+ if line.nil? then
167
+ line = left[0..(width-1)]
168
+ left = left[width..-1]
169
+ end
170
+ result << line
171
+ end
172
+ result << left if left
173
+ return result.join("\n")
174
+ end
175
+
176
+ end # Format
177
+
178
+ end # Sequence
179
+
180
+ end # Bio
181
+
@@ -0,0 +1,24 @@
1
+ #
2
+ # = bio/sequence/generic.rb - generic sequence class to store an intact string
3
+ #
4
+ # Copyright:: Copyright (C) 2006
5
+ # Toshiaki Katayama <k@bioruby.org>
6
+ # License:: The Ruby License
7
+ #
8
+ # $Id: generic.rb,v 1.5 2007/04/05 23:35:41 trevor Exp $
9
+ #
10
+
11
+ require 'bio/sequence/common'
12
+
13
+ module Bio
14
+ class Sequence
15
+
16
+ class Generic < String #:nodoc:
17
+
18
+ include Bio::Sequence::Common
19
+
20
+ end # Generic
21
+
22
+ end # Sequence
23
+ end # Bio
24
+
@@ -0,0 +1,491 @@
1
+ #
2
+ # = bio/sequence/na.rb - nucleic acid sequence class
3
+ #
4
+ # Copyright:: Copyright (C) 2006
5
+ # Toshiaki Katayama <k@bioruby.org>,
6
+ # Ryan Raaum <ryan@raaum.org>
7
+ # License:: The Ruby License
8
+ #
9
+ # $Id: na.rb,v 1.7 2007/04/23 16:43:51 trevor Exp $
10
+ #
11
+
12
+ require 'bio/sequence/common'
13
+
14
+ module Bio
15
+
16
+ autoload :NucleicAcid, 'bio/data/na'
17
+ autoload :CodonTable, 'bio/data/codontable'
18
+
19
+ class Sequence
20
+
21
+
22
+ # = DESCRIPTION
23
+ # Bio::Sequence::NA represents a bare Nucleic Acid sequence in bioruby.
24
+ #
25
+ # = USAGE
26
+ # # Create a Nucleic Acid sequence.
27
+ # dna = Bio::Sequence.auto('atgcatgcATGCATGCAAAA')
28
+ # rna = Bio::Sequence.auto('augcaugcaugcaugcaaaa')
29
+ #
30
+ # # What are the names of all the bases?
31
+ # puts dna.names
32
+ # puts rna.names
33
+ #
34
+ # # What is the GC percentage?
35
+ # puts dna.gc_percent
36
+ # puts rna.gc_percent
37
+ #
38
+ # # What is the molecular weight?
39
+ # puts dna.molecular_weight
40
+ # puts rna.molecular_weight
41
+ #
42
+ # # What is the reverse complement?
43
+ # puts dna.reverse_complement
44
+ # puts dna.complement
45
+ #
46
+ # # Is this sequence DNA or RNA?
47
+ # puts dna.rna?
48
+ #
49
+ # # Translate my sequence (see method docs for many options)
50
+ # puts dna.translate
51
+ # puts rna.translate
52
+ class NA < String
53
+
54
+ include Bio::Sequence::Common
55
+
56
+ # Generate an nucleic acid sequence object from a string.
57
+ #
58
+ # s = Bio::Sequence::NA.new("aagcttggaccgttgaagt")
59
+ #
60
+ # or maybe (if you have an nucleic acid sequence in a file)
61
+ #
62
+ # s = Bio::Sequence:NA.new(File.open('dna.txt').read)
63
+ #
64
+ # Nucleic Acid sequences are *always* all lowercase in bioruby
65
+ #
66
+ # s = Bio::Sequence::NA.new("AAGcTtGG")
67
+ # puts s #=> "aagcttgg"
68
+ #
69
+ # Whitespace is stripped from the sequence
70
+ #
71
+ # seq = Bio::Sequence::NA.new("atg\nggg\ttt\r gc")
72
+ # puts s #=> "atggggttgc"
73
+ # ---
74
+ # *Arguments*:
75
+ # * (required) _str_: String
76
+ # *Returns*:: Bio::Sequence::NA object
77
+ def initialize(str)
78
+ super
79
+ self.downcase!
80
+ self.tr!(" \t\n\r",'')
81
+ end
82
+
83
+ # Alias of Bio::Sequence::Common splice method, documented there.
84
+ def splicing(position) #:nodoc:
85
+ mRNA = super
86
+ if mRNA.rna?
87
+ mRNA.tr!('t', 'u')
88
+ else
89
+ mRNA.tr!('u', 't')
90
+ end
91
+ mRNA
92
+ end
93
+
94
+ # Returns a new complementary sequence object (without reversing).
95
+ # The original sequence object is not modified.
96
+ #
97
+ # s = Bio::Sequence::NA.new('atgc')
98
+ # puts s.forward_complement #=> 'tacg'
99
+ # puts s #=> 'atgc'
100
+ # ---
101
+ # *Returns*:: new Bio::Sequence::NA object
102
+ def forward_complement
103
+ s = self.class.new(self)
104
+ s.forward_complement!
105
+ s
106
+ end
107
+
108
+ # Converts the current sequence into its complement (without reversing).
109
+ # The original sequence object is modified.
110
+ #
111
+ # seq = Bio::Sequence::NA.new('atgc')
112
+ # puts s.forward_complement! #=> 'tacg'
113
+ # puts s #=> 'tacg'
114
+ # ---
115
+ # *Returns*:: current Bio::Sequence::NA object (modified)
116
+ def forward_complement!
117
+ if self.rna?
118
+ self.tr!('augcrymkdhvbswn', 'uacgyrkmhdbvswn')
119
+ else
120
+ self.tr!('atgcrymkdhvbswn', 'tacgyrkmhdbvswn')
121
+ end
122
+ self
123
+ end
124
+
125
+ # Returns a new sequence object with the reverse complement
126
+ # sequence to the original. The original sequence is not modified.
127
+ #
128
+ # s = Bio::Sequence::NA.new('atgc')
129
+ # puts s.reverse_complement #=> 'gcat'
130
+ # puts s #=> 'atgc'
131
+ # ---
132
+ # *Returns*:: new Bio::Sequence::NA object
133
+ def reverse_complement
134
+ s = self.class.new(self)
135
+ s.reverse_complement!
136
+ s
137
+ end
138
+
139
+ # Converts the original sequence into its reverse complement.
140
+ # The original sequence is modified.
141
+ #
142
+ # s = Bio::Sequence::NA.new('atgc')
143
+ # puts s.reverse_complement #=> 'gcat'
144
+ # puts s #=> 'gcat'
145
+ # ---
146
+ # *Returns*:: current Bio::Sequence::NA object (modified)
147
+ def reverse_complement!
148
+ self.reverse!
149
+ self.forward_complement!
150
+ end
151
+
152
+ # Alias for Bio::Sequence::NA#reverse_complement
153
+ alias complement reverse_complement
154
+
155
+ # Alias for Bio::Sequence::NA#reverse_complement!
156
+ alias complement! reverse_complement!
157
+
158
+
159
+ # Translate into an amino acid sequence.
160
+ #
161
+ # s = Bio::Sequence::NA.new('atggcgtga')
162
+ # puts s.translate #=> "MA*"
163
+ #
164
+ # By default, translate starts in reading frame position 1, but you
165
+ # can start in either 2 or 3 as well,
166
+ #
167
+ # puts s.translate(2) #=> "WR"
168
+ # puts s.translate(3) #=> "GV"
169
+ #
170
+ # You may also translate the reverse complement in one step by using frame
171
+ # values of -1, -2, and -3 (or 4, 5, and 6)
172
+ #
173
+ # puts s.translate(-1) #=> "SRH"
174
+ # puts s.translate(4) #=> "SRH"
175
+ # puts s.reverse_complement.translate(1) #=> "SRH"
176
+ #
177
+ # The default codon table in the translate function is the Standard
178
+ # Eukaryotic codon table. The translate function takes either a
179
+ # number or a Bio::CodonTable object for its table argument.
180
+ # The available tables are
181
+ # (NCBI[http://www.ncbi.nlm.nih.gov/Taxonomy/Utils/wprintgc.cgi?mode=t]):
182
+ #
183
+ # 1. "Standard (Eukaryote)"
184
+ # 2. "Vertebrate Mitochondrial"
185
+ # 3. "Yeast Mitochondorial"
186
+ # 4. "Mold, Protozoan, Coelenterate Mitochondrial and Mycoplasma/Spiroplasma"
187
+ # 5. "Invertebrate Mitochondrial"
188
+ # 6. "Ciliate Macronuclear and Dasycladacean"
189
+ # 9. "Echinoderm Mitochondrial"
190
+ # 10. "Euplotid Nuclear"
191
+ # 11. "Bacteria"
192
+ # 12. "Alternative Yeast Nuclear"
193
+ # 13. "Ascidian Mitochondrial"
194
+ # 14. "Flatworm Mitochondrial"
195
+ # 15. "Blepharisma Macronuclear"
196
+ # 16. "Chlorophycean Mitochondrial"
197
+ # 21. "Trematode Mitochondrial"
198
+ # 22. "Scenedesmus obliquus mitochondrial"
199
+ # 23. "Thraustochytrium Mitochondrial"
200
+ #
201
+ # If you are using anything other than the default table, you must specify
202
+ # frame in the translate method call,
203
+ #
204
+ # puts s.translate #=> "MA*" (using defaults)
205
+ # puts s.translate(1,1) #=> "MA*" (same as above, but explicit)
206
+ # puts s.translate(1,2) #=> "MAW" (different codon table)
207
+ #
208
+ # and using a Bio::CodonTable instance in the translate method call,
209
+ #
210
+ # mt_table = Bio::CodonTable[2]
211
+ # puts s.translate(1, mt_table) #=> "MAW"
212
+ #
213
+ # By default, any invalid or unknown codons (as could happen if the
214
+ # sequence contains ambiguities) will be represented by 'X' in the
215
+ # translated sequence.
216
+ # You may change this to any character of your choice.
217
+ #
218
+ # s = Bio::Sequence::NA.new('atgcNNtga')
219
+ # puts s.translate #=> "MX*"
220
+ # puts s.translate(1,1,'9') #=> "M9*"
221
+ #
222
+ # The translate method considers gaps to be unknown characters and treats
223
+ # them as such (i.e. does not collapse sequences prior to translation), so
224
+ #
225
+ # s = Bio::Sequence::NA.new('atgc--tga')
226
+ # puts s.translate #=> "MX*"
227
+ # ---
228
+ # *Arguments*:
229
+ # * (optional) _frame_: one of 1,2,3,4,5,6,-1,-2,-3 (default 1)
230
+ # * (optional) _table_: Fixnum in range 1,23 or Bio::CodonTable object
231
+ # (default 1)
232
+ # * (optional) _unknown_: Character (default 'X')
233
+ # *Returns*:: Bio::Sequence::AA object
234
+ def translate(frame = 1, table = 1, unknown = 'X')
235
+ if table.is_a?(Bio::CodonTable)
236
+ ct = table
237
+ else
238
+ ct = Bio::CodonTable[table]
239
+ end
240
+ naseq = self.dna
241
+ case frame
242
+ when 1, 2, 3
243
+ from = frame - 1
244
+ when 4, 5, 6
245
+ from = frame - 4
246
+ naseq.complement!
247
+ when -1, -2, -3
248
+ from = -1 - frame
249
+ naseq.complement!
250
+ else
251
+ from = 0
252
+ end
253
+ nalen = naseq.length - from
254
+ nalen -= nalen % 3
255
+ aaseq = naseq[from, nalen].gsub(/.{3}/) {|codon| ct[codon] or unknown}
256
+ return Bio::Sequence::AA.new(aaseq)
257
+ end
258
+
259
+ # Returns counts of each codon in the sequence in a hash.
260
+ #
261
+ # s = Bio::Sequence::NA.new('atggcgtga')
262
+ # puts s.codon_usage #=> {"gcg"=>1, "tga"=>1, "atg"=>1}
263
+ #
264
+ # This method does not validate codons! Any three letter group is a 'codon'. So,
265
+ #
266
+ # s = Bio::Sequence::NA.new('atggNNtga')
267
+ # puts s.codon_usage #=> {"tga"=>1, "gnn"=>1, "atg"=>1}
268
+ #
269
+ # seq = Bio::Sequence::NA.new('atgg--tga')
270
+ # puts s.codon_usage #=> {"tga"=>1, "g--"=>1, "atg"=>1}
271
+ #
272
+ # Also, there is no option to work in any frame other than the first.
273
+ # ---
274
+ # *Returns*:: Hash object
275
+ def codon_usage
276
+ hash = Hash.new(0)
277
+ self.window_search(3, 3) do |codon|
278
+ hash[codon] += 1
279
+ end
280
+ return hash
281
+ end
282
+
283
+ # Calculate the ratio of GC / ATGC bases as a percentage rounded to
284
+ # the nearest whole number. U is regarded as T.
285
+ #
286
+ # s = Bio::Sequence::NA.new('atggcgtga')
287
+ # puts s.gc_percent #=> 55
288
+ # ---
289
+ # *Returns*:: Fixnum
290
+ def gc_percent
291
+ count = self.composition
292
+ at = count['a'] + count['t'] + count['u']
293
+ gc = count['g'] + count['c']
294
+ return 0 if at + gc == 0
295
+ gc = 100 * gc / (at + gc)
296
+ return gc
297
+ end
298
+
299
+ # Calculate the ratio of GC / ATGC bases. U is regarded as T.
300
+ #
301
+ # s = Bio::Sequence::NA.new('atggcgtga')
302
+ # puts s.gc_content #=> 0.555555555555556
303
+ # ---
304
+ # *Returns*:: Float
305
+ def gc_content
306
+ count = self.composition
307
+ at = count['a'] + count['t'] + count['u']
308
+ gc = count['g'] + count['c']
309
+ return 0.0 if at + gc == 0
310
+ return gc.quo(at + gc)
311
+ end
312
+
313
+ # Calculate the ratio of AT / ATGC bases. U is regarded as T.
314
+ #
315
+ # s = Bio::Sequence::NA.new('atggcgtga')
316
+ # puts s.at_content #=> 0.444444444444444
317
+ # ---
318
+ # *Returns*:: Float
319
+ def at_content
320
+ count = self.composition
321
+ at = count['a'] + count['t'] + count['u']
322
+ gc = count['g'] + count['c']
323
+ return 0.0 if at + gc == 0
324
+ return at.quo(at + gc)
325
+ end
326
+
327
+ # Calculate the ratio of (G - C) / (G + C) bases.
328
+ #
329
+ # s = Bio::Sequence::NA.new('atggcgtga')
330
+ # puts s.gc_skew #=> 0.6
331
+ # ---
332
+ # *Returns*:: Float
333
+ def gc_skew
334
+ count = self.composition
335
+ g = count['g']
336
+ c = count['c']
337
+ return 0.0 if g + c == 0
338
+ return (g - c).quo(g + c)
339
+ end
340
+
341
+ # Calculate the ratio of (A - T) / (A + T) bases. U is regarded as T.
342
+ #
343
+ # s = Bio::Sequence::NA.new('atgttgttgttc')
344
+ # puts s.at_skew #=> -0.75
345
+ # ---
346
+ # *Returns*:: Float
347
+ def at_skew
348
+ count = self.composition
349
+ a = count['a']
350
+ t = count['t'] + count['u']
351
+ return 0.0 if a + t == 0
352
+ return (a - t).quo(a + t)
353
+ end
354
+
355
+ # Returns an alphabetically sorted array of any non-standard bases
356
+ # (other than 'atgcu').
357
+ #
358
+ # s = Bio::Sequence::NA.new('atgStgQccR')
359
+ # puts s.illegal_bases #=> ["q", "r", "s"]
360
+ # ---
361
+ # *Returns*:: Array object
362
+ def illegal_bases
363
+ self.scan(/[^atgcu]/).sort.uniq
364
+ end
365
+
366
+ # Estimate molecular weight (using the values from BioPerl's
367
+ # SeqStats.pm[http://doc.bioperl.org/releases/bioperl-1.0.1/Bio/Tools/SeqStats.html] module).
368
+ #
369
+ # s = Bio::Sequence::NA.new('atggcgtga')
370
+ # puts s.molecular_weight #=> 2841.00708
371
+ #
372
+ # RNA and DNA do not have the same molecular weights,
373
+ #
374
+ # s = Bio::Sequence::NA.new('auggcguga')
375
+ # puts s.molecular_weight #=> 2956.94708
376
+ # ---
377
+ # *Returns*:: Float object
378
+ def molecular_weight
379
+ if self.rna?
380
+ Bio::NucleicAcid.weight(self, true)
381
+ else
382
+ Bio::NucleicAcid.weight(self)
383
+ end
384
+ end
385
+
386
+ # Create a ruby regular expression instance
387
+ # (Regexp)[http://corelib.rubyonrails.org/classes/Regexp.html]
388
+ #
389
+ # s = Bio::Sequence::NA.new('atggcgtga')
390
+ # puts s.to_re #=> /atggcgtga/
391
+ # ---
392
+ # *Returns*:: Regexp object
393
+ def to_re
394
+ if self.rna?
395
+ Bio::NucleicAcid.to_re(self.dna, true)
396
+ else
397
+ Bio::NucleicAcid.to_re(self)
398
+ end
399
+ end
400
+
401
+ # Generate the list of the names of each nucleotide along with the
402
+ # sequence (full name). Names used in bioruby are found in the
403
+ # Bio::AminoAcid::NAMES hash.
404
+ #
405
+ # s = Bio::Sequence::NA.new('atg')
406
+ # puts s.names #=> ["Adenine", "Thymine", "Guanine"]
407
+ # ---
408
+ # *Returns*:: Array object
409
+ def names
410
+ array = []
411
+ self.each_byte do |x|
412
+ array.push(Bio::NucleicAcid.names[x.chr.upcase])
413
+ end
414
+ return array
415
+ end
416
+
417
+ # Returns a new sequence object with any 'u' bases changed to 't'.
418
+ # The original sequence is not modified.
419
+ #
420
+ # s = Bio::Sequence::NA.new('augc')
421
+ # puts s.dna #=> 'atgc'
422
+ # puts s #=> 'augc'
423
+ # ---
424
+ # *Returns*:: new Bio::Sequence::NA object
425
+ def dna
426
+ self.tr('u', 't')
427
+ end
428
+
429
+ # Changes any 'u' bases in the original sequence to 't'.
430
+ # The original sequence is modified.
431
+ #
432
+ # s = Bio::Sequence::NA.new('augc')
433
+ # puts s.dna! #=> 'atgc'
434
+ # puts s #=> 'atgc'
435
+ # ---
436
+ # *Returns*:: current Bio::Sequence::NA object (modified)
437
+ def dna!
438
+ self.tr!('u', 't')
439
+ end
440
+
441
+ # Returns a new sequence object with any 't' bases changed to 'u'.
442
+ # The original sequence is not modified.
443
+ #
444
+ # s = Bio::Sequence::NA.new('atgc')
445
+ # puts s.dna #=> 'augc'
446
+ # puts s #=> 'atgc'
447
+ # ---
448
+ # *Returns*:: new Bio::Sequence::NA object
449
+ def rna
450
+ self.tr('t', 'u')
451
+ end
452
+
453
+ # Changes any 't' bases in the original sequence to 'u'.
454
+ # The original sequence is modified.
455
+ #
456
+ # s = Bio::Sequence::NA.new('atgc')
457
+ # puts s.dna! #=> 'augc'
458
+ # puts s #=> 'augc'
459
+ # ---
460
+ # *Returns*:: current Bio::Sequence::NA object (modified)
461
+ def rna!
462
+ self.tr!('t', 'u')
463
+ end
464
+
465
+ def rna?
466
+ self.index('u')
467
+ end
468
+ protected :rna?
469
+
470
+ # Example:
471
+ #
472
+ # seq = Bio::Sequence::NA.new('gaattc')
473
+ # cuts = seq.cut_with_enzyme('EcoRI')
474
+ #
475
+ # _or_
476
+ #
477
+ # seq = Bio::Sequence::NA.new('gaattc')
478
+ # cuts = seq.cut_with_enzyme('g^aattc')
479
+ # ---
480
+ # See Bio::RestrictionEnzyme::Analysis.cut
481
+ def cut_with_enzyme(*args)
482
+ Bio::RestrictionEnzyme::Analysis.cut(self, *args)
483
+ end
484
+ alias cut_with_enzymes cut_with_enzyme
485
+
486
+ end # NA
487
+
488
+ end # Sequence
489
+
490
+ end # Bio
491
+