ngoto-bio 1.2.9.9001

Sign up to get free protection for your applications and to get access to all the features.
Files changed (424) hide show
  1. data/ChangeLog +2046 -0
  2. data/README.rdoc +223 -0
  3. data/README_DEV.rdoc +285 -0
  4. data/Rakefile +70 -0
  5. data/bin/bioruby +44 -0
  6. data/bin/br_biofetch.rb +47 -0
  7. data/bin/br_bioflat.rb +293 -0
  8. data/bin/br_biogetseq.rb +45 -0
  9. data/bin/br_pmfetch.rb +421 -0
  10. data/bioruby.gemspec +463 -0
  11. data/bioruby.gemspec.erb +79 -0
  12. data/doc/Changes-0.7.rd +369 -0
  13. data/doc/Changes-1.3.rdoc +195 -0
  14. data/doc/KEGG_API.rd +1843 -0
  15. data/doc/KEGG_API.rd.ja +1834 -0
  16. data/doc/Tutorial.rd +1296 -0
  17. data/doc/Tutorial.rd.ja +2640 -0
  18. data/etc/bioinformatics/seqdatabase.ini +210 -0
  19. data/extconf.rb +2 -0
  20. data/lib/bio/alignment.rb +2518 -0
  21. data/lib/bio/appl/bl2seq/report.rb +334 -0
  22. data/lib/bio/appl/blast/ddbj.rb +142 -0
  23. data/lib/bio/appl/blast/format0.rb +1438 -0
  24. data/lib/bio/appl/blast/format8.rb +83 -0
  25. data/lib/bio/appl/blast/genomenet.rb +263 -0
  26. data/lib/bio/appl/blast/ncbioptions.rb +220 -0
  27. data/lib/bio/appl/blast/remote.rb +105 -0
  28. data/lib/bio/appl/blast/report.rb +767 -0
  29. data/lib/bio/appl/blast/rexml.rb +144 -0
  30. data/lib/bio/appl/blast/rpsblast.rb +277 -0
  31. data/lib/bio/appl/blast/wublast.rb +671 -0
  32. data/lib/bio/appl/blast/xmlparser.rb +236 -0
  33. data/lib/bio/appl/blast.rb +505 -0
  34. data/lib/bio/appl/blat/report.rb +530 -0
  35. data/lib/bio/appl/clustalw/report.rb +152 -0
  36. data/lib/bio/appl/clustalw.rb +219 -0
  37. data/lib/bio/appl/emboss.rb +203 -0
  38. data/lib/bio/appl/fasta/format10.rb +325 -0
  39. data/lib/bio/appl/fasta.rb +235 -0
  40. data/lib/bio/appl/gcg/msf.rb +212 -0
  41. data/lib/bio/appl/gcg/seq.rb +195 -0
  42. data/lib/bio/appl/genscan/report.rb +552 -0
  43. data/lib/bio/appl/hmmer/report.rb +683 -0
  44. data/lib/bio/appl/hmmer.rb +126 -0
  45. data/lib/bio/appl/iprscan/report.rb +374 -0
  46. data/lib/bio/appl/mafft/report.rb +226 -0
  47. data/lib/bio/appl/mafft.rb +259 -0
  48. data/lib/bio/appl/muscle.rb +52 -0
  49. data/lib/bio/appl/paml/baseml/report.rb +32 -0
  50. data/lib/bio/appl/paml/baseml.rb +95 -0
  51. data/lib/bio/appl/paml/codeml/rates.rb +67 -0
  52. data/lib/bio/appl/paml/codeml/report.rb +67 -0
  53. data/lib/bio/appl/paml/codeml.rb +242 -0
  54. data/lib/bio/appl/paml/common.rb +348 -0
  55. data/lib/bio/appl/paml/common_report.rb +38 -0
  56. data/lib/bio/appl/paml/yn00/report.rb +32 -0
  57. data/lib/bio/appl/paml/yn00.rb +103 -0
  58. data/lib/bio/appl/phylip/alignment.rb +129 -0
  59. data/lib/bio/appl/phylip/distance_matrix.rb +96 -0
  60. data/lib/bio/appl/probcons.rb +41 -0
  61. data/lib/bio/appl/psort/report.rb +457 -0
  62. data/lib/bio/appl/psort.rb +548 -0
  63. data/lib/bio/appl/pts1.rb +263 -0
  64. data/lib/bio/appl/sim4/report.rb +485 -0
  65. data/lib/bio/appl/sim4.rb +124 -0
  66. data/lib/bio/appl/sosui/report.rb +151 -0
  67. data/lib/bio/appl/spidey/report.rb +593 -0
  68. data/lib/bio/appl/targetp/report.rb +267 -0
  69. data/lib/bio/appl/tcoffee.rb +55 -0
  70. data/lib/bio/appl/tmhmm/report.rb +231 -0
  71. data/lib/bio/command.rb +593 -0
  72. data/lib/bio/compat/features.rb +157 -0
  73. data/lib/bio/compat/references.rb +128 -0
  74. data/lib/bio/data/aa.rb +349 -0
  75. data/lib/bio/data/codontable.rb +722 -0
  76. data/lib/bio/data/na.rb +223 -0
  77. data/lib/bio/db/aaindex.rb +357 -0
  78. data/lib/bio/db/biosql/biosql_to_biosequence.rb +67 -0
  79. data/lib/bio/db/biosql/sequence.rb +508 -0
  80. data/lib/bio/db/embl/common.rb +352 -0
  81. data/lib/bio/db/embl/embl.rb +500 -0
  82. data/lib/bio/db/embl/embl_to_biosequence.rb +85 -0
  83. data/lib/bio/db/embl/format_embl.rb +190 -0
  84. data/lib/bio/db/embl/sptr.rb +1283 -0
  85. data/lib/bio/db/embl/swissprot.rb +42 -0
  86. data/lib/bio/db/embl/trembl.rb +41 -0
  87. data/lib/bio/db/embl/uniprot.rb +42 -0
  88. data/lib/bio/db/fantom.rb +597 -0
  89. data/lib/bio/db/fasta/defline.rb +532 -0
  90. data/lib/bio/db/fasta/fasta_to_biosequence.rb +63 -0
  91. data/lib/bio/db/fasta/format_fasta.rb +97 -0
  92. data/lib/bio/db/fasta.rb +410 -0
  93. data/lib/bio/db/genbank/common.rb +307 -0
  94. data/lib/bio/db/genbank/ddbj.rb +22 -0
  95. data/lib/bio/db/genbank/format_genbank.rb +187 -0
  96. data/lib/bio/db/genbank/genbank.rb +250 -0
  97. data/lib/bio/db/genbank/genbank_to_biosequence.rb +86 -0
  98. data/lib/bio/db/genbank/genpept.rb +60 -0
  99. data/lib/bio/db/genbank/refseq.rb +18 -0
  100. data/lib/bio/db/gff.rb +1846 -0
  101. data/lib/bio/db/go.rb +481 -0
  102. data/lib/bio/db/kegg/brite.rb +41 -0
  103. data/lib/bio/db/kegg/compound.rb +131 -0
  104. data/lib/bio/db/kegg/drug.rb +98 -0
  105. data/lib/bio/db/kegg/enzyme.rb +148 -0
  106. data/lib/bio/db/kegg/expression.rb +155 -0
  107. data/lib/bio/db/kegg/genes.rb +263 -0
  108. data/lib/bio/db/kegg/genome.rb +241 -0
  109. data/lib/bio/db/kegg/glycan.rb +166 -0
  110. data/lib/bio/db/kegg/keggtab.rb +357 -0
  111. data/lib/bio/db/kegg/kgml.rb +256 -0
  112. data/lib/bio/db/kegg/orthology.rb +136 -0
  113. data/lib/bio/db/kegg/reaction.rb +82 -0
  114. data/lib/bio/db/kegg/taxonomy.rb +331 -0
  115. data/lib/bio/db/lasergene.rb +209 -0
  116. data/lib/bio/db/litdb.rb +107 -0
  117. data/lib/bio/db/medline.rb +326 -0
  118. data/lib/bio/db/nbrf.rb +191 -0
  119. data/lib/bio/db/newick.rb +658 -0
  120. data/lib/bio/db/nexus.rb +1854 -0
  121. data/lib/bio/db/pdb/atom.rb +77 -0
  122. data/lib/bio/db/pdb/chain.rb +210 -0
  123. data/lib/bio/db/pdb/chemicalcomponent.rb +224 -0
  124. data/lib/bio/db/pdb/model.rb +148 -0
  125. data/lib/bio/db/pdb/pdb.rb +1911 -0
  126. data/lib/bio/db/pdb/residue.rb +176 -0
  127. data/lib/bio/db/pdb/utils.rb +399 -0
  128. data/lib/bio/db/pdb.rb +29 -0
  129. data/lib/bio/db/prosite.rb +597 -0
  130. data/lib/bio/db/rebase.rb +456 -0
  131. data/lib/bio/db/soft.rb +404 -0
  132. data/lib/bio/db/transfac.rb +375 -0
  133. data/lib/bio/db.rb +329 -0
  134. data/lib/bio/feature.rb +139 -0
  135. data/lib/bio/io/biosql/biodatabase.rb +64 -0
  136. data/lib/bio/io/biosql/bioentry.rb +29 -0
  137. data/lib/bio/io/biosql/bioentry_dbxref.rb +11 -0
  138. data/lib/bio/io/biosql/bioentry_path.rb +12 -0
  139. data/lib/bio/io/biosql/bioentry_qualifier_value.rb +10 -0
  140. data/lib/bio/io/biosql/bioentry_reference.rb +10 -0
  141. data/lib/bio/io/biosql/bioentry_relationship.rb +10 -0
  142. data/lib/bio/io/biosql/biosequence.rb +11 -0
  143. data/lib/bio/io/biosql/comment.rb +7 -0
  144. data/lib/bio/io/biosql/config/database.yml +20 -0
  145. data/lib/bio/io/biosql/dbxref.rb +13 -0
  146. data/lib/bio/io/biosql/dbxref_qualifier_value.rb +12 -0
  147. data/lib/bio/io/biosql/location.rb +32 -0
  148. data/lib/bio/io/biosql/location_qualifier_value.rb +11 -0
  149. data/lib/bio/io/biosql/ontology.rb +10 -0
  150. data/lib/bio/io/biosql/reference.rb +9 -0
  151. data/lib/bio/io/biosql/seqfeature.rb +32 -0
  152. data/lib/bio/io/biosql/seqfeature_dbxref.rb +11 -0
  153. data/lib/bio/io/biosql/seqfeature_path.rb +11 -0
  154. data/lib/bio/io/biosql/seqfeature_qualifier_value.rb +20 -0
  155. data/lib/bio/io/biosql/seqfeature_relationship.rb +11 -0
  156. data/lib/bio/io/biosql/taxon.rb +12 -0
  157. data/lib/bio/io/biosql/taxon_name.rb +9 -0
  158. data/lib/bio/io/biosql/term.rb +27 -0
  159. data/lib/bio/io/biosql/term_dbxref.rb +11 -0
  160. data/lib/bio/io/biosql/term_path.rb +12 -0
  161. data/lib/bio/io/biosql/term_relationship.rb +13 -0
  162. data/lib/bio/io/biosql/term_relationship_term.rb +11 -0
  163. data/lib/bio/io/biosql/term_synonym.rb +10 -0
  164. data/lib/bio/io/das.rb +461 -0
  165. data/lib/bio/io/dbget.rb +194 -0
  166. data/lib/bio/io/ddbjxml.rb +638 -0
  167. data/lib/bio/io/ebisoap.rb +158 -0
  168. data/lib/bio/io/ensembl.rb +229 -0
  169. data/lib/bio/io/fastacmd.rb +163 -0
  170. data/lib/bio/io/fetch.rb +195 -0
  171. data/lib/bio/io/flatfile/autodetection.rb +545 -0
  172. data/lib/bio/io/flatfile/bdb.rb +253 -0
  173. data/lib/bio/io/flatfile/buffer.rb +237 -0
  174. data/lib/bio/io/flatfile/index.rb +1381 -0
  175. data/lib/bio/io/flatfile/indexer.rb +805 -0
  176. data/lib/bio/io/flatfile/splitter.rb +297 -0
  177. data/lib/bio/io/flatfile.rb +473 -0
  178. data/lib/bio/io/higet.rb +73 -0
  179. data/lib/bio/io/hinv.rb +442 -0
  180. data/lib/bio/io/keggapi.rb +805 -0
  181. data/lib/bio/io/ncbirest.rb +733 -0
  182. data/lib/bio/io/ncbisoap.rb +155 -0
  183. data/lib/bio/io/pubmed.rb +307 -0
  184. data/lib/bio/io/registry.rb +292 -0
  185. data/lib/bio/io/soapwsdl.rb +119 -0
  186. data/lib/bio/io/sql.rb +186 -0
  187. data/lib/bio/location.rb +867 -0
  188. data/lib/bio/map.rb +410 -0
  189. data/lib/bio/pathway.rb +960 -0
  190. data/lib/bio/reference.rb +602 -0
  191. data/lib/bio/sequence/aa.rb +125 -0
  192. data/lib/bio/sequence/adapter.rb +108 -0
  193. data/lib/bio/sequence/common.rb +310 -0
  194. data/lib/bio/sequence/compat.rb +123 -0
  195. data/lib/bio/sequence/dblink.rb +54 -0
  196. data/lib/bio/sequence/format.rb +358 -0
  197. data/lib/bio/sequence/format_raw.rb +23 -0
  198. data/lib/bio/sequence/generic.rb +24 -0
  199. data/lib/bio/sequence/na.rb +491 -0
  200. data/lib/bio/sequence.rb +456 -0
  201. data/lib/bio/shell/core.rb +578 -0
  202. data/lib/bio/shell/demo.rb +146 -0
  203. data/lib/bio/shell/interface.rb +218 -0
  204. data/lib/bio/shell/irb.rb +95 -0
  205. data/lib/bio/shell/object.rb +71 -0
  206. data/lib/bio/shell/plugin/blast.rb +42 -0
  207. data/lib/bio/shell/plugin/codon.rb +218 -0
  208. data/lib/bio/shell/plugin/das.rb +58 -0
  209. data/lib/bio/shell/plugin/emboss.rb +23 -0
  210. data/lib/bio/shell/plugin/entry.rb +105 -0
  211. data/lib/bio/shell/plugin/flatfile.rb +101 -0
  212. data/lib/bio/shell/plugin/keggapi.rb +181 -0
  213. data/lib/bio/shell/plugin/midi.rb +430 -0
  214. data/lib/bio/shell/plugin/obda.rb +45 -0
  215. data/lib/bio/shell/plugin/psort.rb +56 -0
  216. data/lib/bio/shell/plugin/seq.rb +247 -0
  217. data/lib/bio/shell/plugin/soap.rb +87 -0
  218. data/lib/bio/shell/rails/vendor/plugins/bioruby/generators/bioruby/bioruby_generator.rb +29 -0
  219. data/lib/bio/shell/rails/vendor/plugins/bioruby/generators/bioruby/templates/_classes.rhtml +4 -0
  220. data/lib/bio/shell/rails/vendor/plugins/bioruby/generators/bioruby/templates/_log.rhtml +27 -0
  221. data/lib/bio/shell/rails/vendor/plugins/bioruby/generators/bioruby/templates/_methods.rhtml +11 -0
  222. data/lib/bio/shell/rails/vendor/plugins/bioruby/generators/bioruby/templates/_modules.rhtml +4 -0
  223. data/lib/bio/shell/rails/vendor/plugins/bioruby/generators/bioruby/templates/_variables.rhtml +7 -0
  224. data/lib/bio/shell/rails/vendor/plugins/bioruby/generators/bioruby/templates/bioruby-bg.gif +0 -0
  225. data/lib/bio/shell/rails/vendor/plugins/bioruby/generators/bioruby/templates/bioruby-gem.png +0 -0
  226. data/lib/bio/shell/rails/vendor/plugins/bioruby/generators/bioruby/templates/bioruby-link.gif +0 -0
  227. data/lib/bio/shell/rails/vendor/plugins/bioruby/generators/bioruby/templates/bioruby.css +368 -0
  228. data/lib/bio/shell/rails/vendor/plugins/bioruby/generators/bioruby/templates/bioruby.rhtml +47 -0
  229. data/lib/bio/shell/rails/vendor/plugins/bioruby/generators/bioruby/templates/bioruby_controller.rb +144 -0
  230. data/lib/bio/shell/rails/vendor/plugins/bioruby/generators/bioruby/templates/bioruby_helper.rb +47 -0
  231. data/lib/bio/shell/rails/vendor/plugins/bioruby/generators/bioruby/templates/commands.rhtml +8 -0
  232. data/lib/bio/shell/rails/vendor/plugins/bioruby/generators/bioruby/templates/history.rhtml +10 -0
  233. data/lib/bio/shell/rails/vendor/plugins/bioruby/generators/bioruby/templates/index.rhtml +26 -0
  234. data/lib/bio/shell/rails/vendor/plugins/bioruby/generators/bioruby/templates/spinner.gif +0 -0
  235. data/lib/bio/shell/script.rb +25 -0
  236. data/lib/bio/shell/setup.rb +109 -0
  237. data/lib/bio/shell/web.rb +102 -0
  238. data/lib/bio/shell.rb +44 -0
  239. data/lib/bio/tree.rb +852 -0
  240. data/lib/bio/util/color_scheme/buried.rb +59 -0
  241. data/lib/bio/util/color_scheme/helix.rb +59 -0
  242. data/lib/bio/util/color_scheme/hydropathy.rb +64 -0
  243. data/lib/bio/util/color_scheme/nucleotide.rb +31 -0
  244. data/lib/bio/util/color_scheme/strand.rb +59 -0
  245. data/lib/bio/util/color_scheme/taylor.rb +50 -0
  246. data/lib/bio/util/color_scheme/turn.rb +59 -0
  247. data/lib/bio/util/color_scheme/zappo.rb +50 -0
  248. data/lib/bio/util/color_scheme.rb +191 -0
  249. data/lib/bio/util/contingency_table.rb +370 -0
  250. data/lib/bio/util/restriction_enzyme/analysis.rb +249 -0
  251. data/lib/bio/util/restriction_enzyme/analysis_basic.rb +217 -0
  252. data/lib/bio/util/restriction_enzyme/cut_symbol.rb +107 -0
  253. data/lib/bio/util/restriction_enzyme/double_stranded/aligned_strands.rb +130 -0
  254. data/lib/bio/util/restriction_enzyme/double_stranded/cut_location_pair.rb +103 -0
  255. data/lib/bio/util/restriction_enzyme/double_stranded/cut_location_pair_in_enzyme_notation.rb +38 -0
  256. data/lib/bio/util/restriction_enzyme/double_stranded/cut_locations.rb +76 -0
  257. data/lib/bio/util/restriction_enzyme/double_stranded/cut_locations_in_enzyme_notation.rb +107 -0
  258. data/lib/bio/util/restriction_enzyme/double_stranded.rb +321 -0
  259. data/lib/bio/util/restriction_enzyme/enzymes.yaml +7061 -0
  260. data/lib/bio/util/restriction_enzyme/range/cut_range.rb +24 -0
  261. data/lib/bio/util/restriction_enzyme/range/cut_ranges.rb +47 -0
  262. data/lib/bio/util/restriction_enzyme/range/horizontal_cut_range.rb +67 -0
  263. data/lib/bio/util/restriction_enzyme/range/sequence_range/calculated_cuts.rb +242 -0
  264. data/lib/bio/util/restriction_enzyme/range/sequence_range/fragment.rb +51 -0
  265. data/lib/bio/util/restriction_enzyme/range/sequence_range/fragments.rb +41 -0
  266. data/lib/bio/util/restriction_enzyme/range/sequence_range.rb +257 -0
  267. data/lib/bio/util/restriction_enzyme/range/vertical_cut_range.rb +77 -0
  268. data/lib/bio/util/restriction_enzyme/single_strand/cut_locations_in_enzyme_notation.rb +135 -0
  269. data/lib/bio/util/restriction_enzyme/single_strand.rb +200 -0
  270. data/lib/bio/util/restriction_enzyme/single_strand_complement.rb +23 -0
  271. data/lib/bio/util/restriction_enzyme/string_formatting.rb +111 -0
  272. data/lib/bio/util/restriction_enzyme.rb +228 -0
  273. data/lib/bio/util/sirna.rb +288 -0
  274. data/lib/bio.rb +300 -0
  275. data/rdoc.zsh +8 -0
  276. data/sample/any2fasta.rb +59 -0
  277. data/sample/biofetch.rb +475 -0
  278. data/sample/color_scheme_na.rb +91 -0
  279. data/sample/dbget +37 -0
  280. data/sample/demo_sequence.rb +158 -0
  281. data/sample/enzymes.rb +78 -0
  282. data/sample/fasta2tab.rb +99 -0
  283. data/sample/fastagrep.rb +72 -0
  284. data/sample/fastasort.rb +54 -0
  285. data/sample/fsplit.rb +51 -0
  286. data/sample/gb2fasta.rb +30 -0
  287. data/sample/gb2tab.rb +325 -0
  288. data/sample/gbtab2mysql.rb +161 -0
  289. data/sample/genes2nuc.rb +33 -0
  290. data/sample/genes2pep.rb +33 -0
  291. data/sample/genes2tab.rb +81 -0
  292. data/sample/genome2rb.rb +29 -0
  293. data/sample/genome2tab.rb +76 -0
  294. data/sample/goslim.rb +303 -0
  295. data/sample/gt2fasta.rb +47 -0
  296. data/sample/na2aa.rb +34 -0
  297. data/sample/pmfetch.rb +42 -0
  298. data/sample/pmsearch.rb +42 -0
  299. data/sample/psortplot_html.rb +214 -0
  300. data/sample/ssearch2tab.rb +96 -0
  301. data/sample/tdiary.rb +158 -0
  302. data/sample/tfastx2tab.rb +100 -0
  303. data/sample/vs-genes.rb +212 -0
  304. data/setup.rb +1596 -0
  305. data/test/data/HMMER/hmmpfam.out +64 -0
  306. data/test/data/HMMER/hmmsearch.out +88 -0
  307. data/test/data/SOSUI/sample.report +11 -0
  308. data/test/data/TMHMM/sample.report +21 -0
  309. data/test/data/aaindex/DAYM780301 +30 -0
  310. data/test/data/aaindex/PRAM900102 +20 -0
  311. data/test/data/bl2seq/cd8a_cd8b_blastp.bl2seq +53 -0
  312. data/test/data/bl2seq/cd8a_p53_e-5blastp.bl2seq +37 -0
  313. data/test/data/blast/2.2.15.blastp.m7 +876 -0
  314. data/test/data/blast/b0002.faa +15 -0
  315. data/test/data/blast/b0002.faa.m0 +128 -0
  316. data/test/data/blast/b0002.faa.m7 +65 -0
  317. data/test/data/blast/b0002.faa.m8 +1 -0
  318. data/test/data/blast/blastp-multi.m7 +188 -0
  319. data/test/data/command/echoarg2.bat +1 -0
  320. data/test/data/embl/AB090716.embl +65 -0
  321. data/test/data/embl/AB090716.embl.rel89 +63 -0
  322. data/test/data/fasta/example1.txt +75 -0
  323. data/test/data/fasta/example2.txt +21 -0
  324. data/test/data/genscan/sample.report +63 -0
  325. data/test/data/iprscan/merged.raw +32 -0
  326. data/test/data/iprscan/merged.txt +74 -0
  327. data/test/data/paml/codeml/control_file.txt +30 -0
  328. data/test/data/paml/codeml/output.txt +78 -0
  329. data/test/data/paml/codeml/rates +217 -0
  330. data/test/data/prosite/prosite.dat +2233 -0
  331. data/test/data/refseq/nm_126355.entret +64 -0
  332. data/test/data/rpsblast/misc.rpsblast +193 -0
  333. data/test/data/soft/GDS100_partial.soft +92 -0
  334. data/test/data/soft/GSE3457_family_partial.soft +874 -0
  335. data/test/data/uniprot/p53_human.uniprot +1456 -0
  336. data/test/functional/bio/appl/test_pts1.rb +115 -0
  337. data/test/functional/bio/io/test_ensembl.rb +229 -0
  338. data/test/functional/bio/io/test_soapwsdl.rb +52 -0
  339. data/test/functional/bio/sequence/test_output_embl.rb +51 -0
  340. data/test/functional/bio/test_command.rb +301 -0
  341. data/test/runner.rb +23 -0
  342. data/test/unit/bio/appl/bl2seq/test_report.rb +134 -0
  343. data/test/unit/bio/appl/blast/test_ncbioptions.rb +112 -0
  344. data/test/unit/bio/appl/blast/test_report.rb +1135 -0
  345. data/test/unit/bio/appl/blast/test_rpsblast.rb +398 -0
  346. data/test/unit/bio/appl/genscan/test_report.rb +182 -0
  347. data/test/unit/bio/appl/hmmer/test_report.rb +342 -0
  348. data/test/unit/bio/appl/iprscan/test_report.rb +338 -0
  349. data/test/unit/bio/appl/mafft/test_report.rb +63 -0
  350. data/test/unit/bio/appl/paml/codeml/test_rates.rb +45 -0
  351. data/test/unit/bio/appl/paml/codeml/test_report.rb +45 -0
  352. data/test/unit/bio/appl/paml/test_codeml.rb +174 -0
  353. data/test/unit/bio/appl/sosui/test_report.rb +81 -0
  354. data/test/unit/bio/appl/targetp/test_report.rb +146 -0
  355. data/test/unit/bio/appl/test_blast.rb +277 -0
  356. data/test/unit/bio/appl/test_fasta.rb +130 -0
  357. data/test/unit/bio/appl/test_pts1.rb +77 -0
  358. data/test/unit/bio/appl/tmhmm/test_report.rb +126 -0
  359. data/test/unit/bio/data/test_aa.rb +90 -0
  360. data/test/unit/bio/data/test_codontable.rb +107 -0
  361. data/test/unit/bio/data/test_na.rb +80 -0
  362. data/test/unit/bio/db/embl/test_common.rb +117 -0
  363. data/test/unit/bio/db/embl/test_embl.rb +214 -0
  364. data/test/unit/bio/db/embl/test_embl_rel89.rb +219 -0
  365. data/test/unit/bio/db/embl/test_embl_to_bioseq.rb +203 -0
  366. data/test/unit/bio/db/embl/test_sptr.rb +1812 -0
  367. data/test/unit/bio/db/embl/test_uniprot.rb +31 -0
  368. data/test/unit/bio/db/kegg/test_genes.rb +45 -0
  369. data/test/unit/bio/db/pdb/test_pdb.rb +152 -0
  370. data/test/unit/bio/db/test_aaindex.rb +197 -0
  371. data/test/unit/bio/db/test_fasta.rb +250 -0
  372. data/test/unit/bio/db/test_gff.rb +1190 -0
  373. data/test/unit/bio/db/test_lasergene.rb +95 -0
  374. data/test/unit/bio/db/test_medline.rb +127 -0
  375. data/test/unit/bio/db/test_newick.rb +293 -0
  376. data/test/unit/bio/db/test_nexus.rb +364 -0
  377. data/test/unit/bio/db/test_prosite.rb +1437 -0
  378. data/test/unit/bio/db/test_rebase.rb +101 -0
  379. data/test/unit/bio/db/test_soft.rb +138 -0
  380. data/test/unit/bio/io/flatfile/test_autodetection.rb +375 -0
  381. data/test/unit/bio/io/flatfile/test_buffer.rb +251 -0
  382. data/test/unit/bio/io/flatfile/test_splitter.rb +369 -0
  383. data/test/unit/bio/io/test_ddbjxml.rb +80 -0
  384. data/test/unit/bio/io/test_ensembl.rb +109 -0
  385. data/test/unit/bio/io/test_fastacmd.rb +42 -0
  386. data/test/unit/bio/io/test_flatfile.rb +488 -0
  387. data/test/unit/bio/io/test_soapwsdl.rb +32 -0
  388. data/test/unit/bio/sequence/test_aa.rb +103 -0
  389. data/test/unit/bio/sequence/test_common.rb +373 -0
  390. data/test/unit/bio/sequence/test_compat.rb +69 -0
  391. data/test/unit/bio/sequence/test_dblink.rb +58 -0
  392. data/test/unit/bio/sequence/test_na.rb +330 -0
  393. data/test/unit/bio/shell/plugin/test_seq.rb +185 -0
  394. data/test/unit/bio/test_alignment.rb +1025 -0
  395. data/test/unit/bio/test_command.rb +349 -0
  396. data/test/unit/bio/test_db.rb +96 -0
  397. data/test/unit/bio/test_feature.rb +144 -0
  398. data/test/unit/bio/test_location.rb +599 -0
  399. data/test/unit/bio/test_map.rb +230 -0
  400. data/test/unit/bio/test_pathway.rb +499 -0
  401. data/test/unit/bio/test_reference.rb +252 -0
  402. data/test/unit/bio/test_sequence.rb +329 -0
  403. data/test/unit/bio/test_shell.rb +18 -0
  404. data/test/unit/bio/test_tree.rb +593 -0
  405. data/test/unit/bio/util/restriction_enzyme/analysis/test_calculated_cuts.rb +299 -0
  406. data/test/unit/bio/util/restriction_enzyme/analysis/test_cut_ranges.rb +103 -0
  407. data/test/unit/bio/util/restriction_enzyme/analysis/test_sequence_range.rb +240 -0
  408. data/test/unit/bio/util/restriction_enzyme/double_stranded/test_aligned_strands.rb +101 -0
  409. data/test/unit/bio/util/restriction_enzyme/double_stranded/test_cut_location_pair.rb +75 -0
  410. data/test/unit/bio/util/restriction_enzyme/double_stranded/test_cut_location_pair_in_enzyme_notation.rb +73 -0
  411. data/test/unit/bio/util/restriction_enzyme/double_stranded/test_cut_locations.rb +53 -0
  412. data/test/unit/bio/util/restriction_enzyme/double_stranded/test_cut_locations_in_enzyme_notation.rb +104 -0
  413. data/test/unit/bio/util/restriction_enzyme/single_strand/test_cut_locations_in_enzyme_notation.rb +83 -0
  414. data/test/unit/bio/util/restriction_enzyme/test_analysis.rb +246 -0
  415. data/test/unit/bio/util/restriction_enzyme/test_cut_symbol.rb +44 -0
  416. data/test/unit/bio/util/restriction_enzyme/test_double_stranded.rb +115 -0
  417. data/test/unit/bio/util/restriction_enzyme/test_single_strand.rb +147 -0
  418. data/test/unit/bio/util/restriction_enzyme/test_single_strand_complement.rb +147 -0
  419. data/test/unit/bio/util/restriction_enzyme/test_string_formatting.rb +60 -0
  420. data/test/unit/bio/util/test_color_scheme.rb +33 -0
  421. data/test/unit/bio/util/test_contingency_table.rb +94 -0
  422. data/test/unit/bio/util/test_restriction_enzyme.rb +42 -0
  423. data/test/unit/bio/util/test_sirna.rb +245 -0
  424. metadata +484 -0
@@ -0,0 +1,1283 @@
1
+ #
2
+ # = bio/db/embl/sptr.rb - UniProt/SwissProt and TrEMBL database class
3
+ #
4
+ # Copyright:: Copyright (C) 2001-2006 Mitsuteru C. Nakao <n@bioruby.org>
5
+ # License:: The Ruby License
6
+ #
7
+ # $Id:$
8
+ #
9
+ # == Description
10
+ #
11
+ # Shared methods for UniProtKB/SwissProt and TrEMBL classes.
12
+ #
13
+ # See the SWISS-PROT document file SPECLIST.TXT or UniProtKB/SwissProt
14
+ # user manual.
15
+ #
16
+ # == Examples
17
+ #
18
+ # str = File.read("p53_human.swiss")
19
+ # obj = Bio::SPTR.new(str)
20
+ # obj.entry_id #=> "P53_HUMAN"
21
+ #
22
+ # == References
23
+ #
24
+ # * Swiss-Prot Protein knowledgebase. TrEMBL Computer-annotated supplement
25
+ # to Swiss-Prot
26
+ # http://au.expasy.org/sprot/
27
+ #
28
+ # * UniProt
29
+ # http://uniprot.org/
30
+ #
31
+ # * The UniProtKB/SwissProt/TrEMBL User Manual
32
+ # http://www.expasy.org/sprot/userman.html
33
+ #
34
+
35
+
36
+ require 'bio/db'
37
+ require 'bio/db/embl/common'
38
+
39
+ module Bio
40
+
41
+ # Parser class for UniProtKB/SwissProt and TrEMBL database entry.
42
+ class SPTR < EMBLDB
43
+ include Bio::EMBLDB::Common
44
+
45
+ @@entry_regrexp = /[A-Z0-9]{1,4}_[A-Z0-9]{1,5}/
46
+ @@data_class = ["STANDARD", "PRELIMINARY"]
47
+
48
+ # returns a Hash of the ID line.
49
+ #
50
+ # returns a content (Int or String) of the ID line by a given key.
51
+ # Hash keys: ['ENTRY_NAME', 'DATA_CLASS', 'MODECULE_TYPE', 'SEQUENCE_LENGTH']
52
+ #
53
+ # === ID Line
54
+ # ID P53_HUMAN STANDARD; PRT; 393 AA.
55
+ # #"ID #{ENTRY_NAME} #{DATA_CLASS}; #{MOLECULE_TYPE}; #{SEQUENCE_LENGTH}."
56
+ #
57
+ # === Examples
58
+ # obj.id_line #=> {"ENTRY_NAME"=>"P53_HUMAN", "DATA_CLASS"=>"STANDARD",
59
+ # "SEQUENCE_LENGTH"=>393, "MOLECULE_TYPE"=>"PRT"}
60
+ #
61
+ # obj.id_line('ENTRY_NAME') #=> "P53_HUMAN"
62
+ #
63
+ def id_line(key = nil)
64
+ return id_line[key] if key
65
+ return @data['ID'] if @data['ID']
66
+
67
+ part = @orig['ID'].split(/ +/)
68
+ @data['ID'] = {
69
+ 'ENTRY_NAME' => part[1],
70
+ 'DATA_CLASS' => part[2].sub(/;/,''),
71
+ 'MOLECULE_TYPE' => part[3].sub(/;/,''),
72
+ 'SEQUENCE_LENGTH' => part[4].to_i
73
+ }
74
+ end
75
+
76
+
77
+ # returns a ENTRY_NAME in the ID line.
78
+ #
79
+ def entry_id
80
+ id_line('ENTRY_NAME')
81
+ end
82
+ alias entry_name entry_id
83
+ alias entry entry_id
84
+
85
+
86
+ # returns a MOLECULE_TYPE in the ID line.
87
+ #
88
+ # A short-cut for Bio::SPTR#id_line('MOLECULE_TYPE').
89
+ def molecule
90
+ id_line('MOLECULE_TYPE')
91
+ end
92
+ alias molecule_type molecule
93
+
94
+
95
+ # returns a SEQUENCE_LENGTH in the ID line.
96
+ #
97
+ # A short-cut for Bio::SPTR#id_line('SEQUENCE_LENGHT').
98
+ def sequence_length
99
+ id_line('SEQUENCE_LENGTH')
100
+ end
101
+ alias aalen sequence_length
102
+
103
+
104
+ # Bio::EMBLDB::Common#ac -> ary
105
+ # #accessions -> ary
106
+ # #accession -> String (accessions.first)
107
+ @@ac_regrexp = /[OPQ][0-9][A-Z0-9]{3}[0-9]/
108
+
109
+
110
+
111
+ # returns a Hash of information in the DT lines.
112
+ # hash keys:
113
+ # ['created', 'sequence', 'annotation']
114
+ # also Symbols acceptable (ASAP):
115
+ # [:created, :sequence, :annotation]
116
+ #
117
+ # returns a String of information in the DT lines by a given key..
118
+ #
119
+ # === DT Line; date (3/entry)
120
+ # DT DD-MMM-YYY (rel. NN, Created)
121
+ # DT DD-MMM-YYY (rel. NN, Last sequence update)
122
+ # DT DD-MMM-YYY (rel. NN, Last annotation update)
123
+ def dt(key = nil)
124
+ return dt[key] if key
125
+ return @data['DT'] if @data['DT']
126
+
127
+ part = self.get('DT').split(/\n/)
128
+ @data['DT'] = {
129
+ 'created' => part[0].sub(/\w{2} /,'').strip,
130
+ 'sequence' => part[1].sub(/\w{2} /,'').strip,
131
+ 'annotation' => part[2].sub(/\w{2} /,'').strip
132
+ }
133
+ end
134
+
135
+
136
+ # returns the proposed official name of the protein.
137
+ #
138
+ # === DE Line; description (>=1)
139
+ # "DE #{OFFICIAL_NAME} (#{SYNONYM})"
140
+ # "DE #{OFFICIAL_NAME} (#{SYNONYM}) [CONTEINS: #1; #2]."
141
+ # OFFICIAL_NAME 1/entry
142
+ # SYNONYM >=0
143
+ # CONTEINS >=0
144
+ def protein_name
145
+ name = ""
146
+ if de_line = fetch('DE') then
147
+ str = de_line[/^[^\[]*/] # everything preceding the first [ (the "contains" part)
148
+ name = str[/^[^(]*/].strip
149
+ name << ' (Fragment)' if str =~ /fragment/i
150
+ end
151
+ return name
152
+ end
153
+
154
+
155
+ # returns an array of synonyms (unofficial names).
156
+ #
157
+ # synonyms are each placed in () following the official name on the DE line.
158
+ def synonyms
159
+ ary = Array.new
160
+ if de_line = fetch('DE') then
161
+ line = de_line.sub(/\[.*\]/,'') # ignore stuff between [ and ]. That's the "contains" part
162
+ line.scan(/\([^)]+/) do |synonym|
163
+ unless synonym =~ /fragment/i then
164
+ ary << synonym[1..-1].strip # index to remove the leading (
165
+ end
166
+ end
167
+ end
168
+ return ary
169
+ end
170
+
171
+
172
+ # returns gene names in the GN line.
173
+ #
174
+ # New UniProt/SwissProt format:
175
+ # * Bio::SPTR#gn -> [ <gene record>* ]
176
+ # where <gene record> is:
177
+ # { :name => '...',
178
+ # :synonyms => [ 's1', 's2', ... ],
179
+ # :loci => [ 'l1', 'l2', ... ],
180
+ # :orfs => [ 'o1', 'o2', ... ]
181
+ # }
182
+ #
183
+ # Old format:
184
+ # * Bio::SPTR#gn -> Array # AND
185
+ # * Bio::SPTR#gn[0] -> Array # OR
186
+ #
187
+ # === GN Line: Gene name(s) (>=0, optional)
188
+ def gn
189
+ unless @data['GN']
190
+ case fetch('GN')
191
+ when /Name=/,/ORFNames=/
192
+ @data['GN'] = gn_uniprot_parser
193
+ else
194
+ @data['GN'] = gn_old_parser
195
+ end
196
+ end
197
+ @data['GN']
198
+ end
199
+
200
+
201
+ # returns contents in the old style GN line.
202
+ # === GN Line: Gene name(s) (>=0, optional)
203
+ # GN HNS OR DRDX OR OSMZ OR BGLY.
204
+ # GN CECA1 AND CECA2.
205
+ # GN CECA1 AND (HOGE OR FUGA).
206
+ #
207
+ # GN NAME1 [(AND|OR) NAME]+.
208
+ #
209
+ # Bio::SPTR#gn -> Array # AND
210
+ # #gn[0] -> Array # OR
211
+ # #gene_names -> Array
212
+ def gn_old_parser
213
+ names = Array.new
214
+ if get('GN').size > 0
215
+ names = fetch('GN').sub(/\.$/,'').split(/ AND /)
216
+ names.map! { |synonyms|
217
+ synonyms = synonyms.gsub(/\(|\)/,'').split(/ OR /).map { |e|
218
+ e.strip
219
+ }
220
+ }
221
+ end
222
+ @data['GN'] = names
223
+ end
224
+ private :gn_old_parser
225
+
226
+ # returns contents in the structured GN line.
227
+ # The new format of the GN line is:
228
+ # GN Name=; Synonyms=[, ...]; OrderedLocusNames=[, ...];
229
+ # GN ORFNames=[, ...];
230
+ #
231
+ # * Bio::SPTR#gn -> [ <gene record>* ]
232
+ # where <gene record> is:
233
+ # { :name => '...',
234
+ # :synonyms => [ 's1', 's2', ... ],
235
+ # :loci => [ 'l1', 'l2', ... ],
236
+ # :orfs => [ 'o1', 'o2', ... ]
237
+ # }
238
+ def gn_uniprot_parser
239
+ @data['GN'] = Array.new
240
+ gn_line = fetch('GN').strip
241
+ records = gn_line.split(/\s*and\s*/)
242
+ records.each do |record|
243
+ gene_hash = {:name => '', :synonyms => [], :loci => [], :orfs => []}
244
+ record.each_line(';') do |element|
245
+ case element
246
+ when /Name=/ then
247
+ gene_hash[:name] = $'[0..-2]
248
+ when /Synonyms=/ then
249
+ gene_hash[:synonyms] = $'[0..-2].split(/\s*,\s*/)
250
+ when /OrderedLocusNames=/ then
251
+ gene_hash[:loci] = $'[0..-2].split(/\s*,\s*/)
252
+ when /ORFNames=/ then
253
+ gene_hash[:orfs] = $'[0..-2].split(/\s*,\s*/)
254
+ end
255
+ end
256
+ @data['GN'] << gene_hash
257
+ end
258
+ return @data['GN']
259
+ end
260
+ private :gn_uniprot_parser
261
+
262
+
263
+ # returns a Array of gene names in the GN line.
264
+ def gene_names
265
+ gn # set @data['GN'] if it hasn't been already done
266
+ if @data['GN'].first.class == Hash then
267
+ @data['GN'].collect { |element| element[:name] }
268
+ else
269
+ @data['GN'].first
270
+ end
271
+ end
272
+
273
+
274
+ # returns a String of the first gene name in the GN line.
275
+ def gene_name
276
+ gene_names.first
277
+ end
278
+
279
+
280
+ # returns a Array of Hashs or a String of the OS line when a key given.
281
+ # * Bio::EMBLDB#os -> Array
282
+ # [{'name' => '(Human)', 'os' => 'Homo sapiens'},
283
+ # {'name' => '(Rat)', 'os' => 'Rattus norveticus'}]
284
+ # * Bio::EPTR#os[0] -> Hash
285
+ # {'name' => "(Human)", 'os' => 'Homo sapiens'}
286
+ # * Bio::SPTR#os[0]['name'] -> "(Human)"
287
+ # * Bio::EPTR#os(0) -> "Homo sapiens (Human)"
288
+ #
289
+ # === OS Line; organism species (>=1)
290
+ # OS Genus species (name).
291
+ # OS Genus species (name0) (name1).
292
+ # OS Genus species (name0) (name1).
293
+ # OS Genus species (name0), G s0 (name0), and G s (name0) (name1).
294
+ # OS Homo sapiens (Human), and Rarrus norveticus (Rat)
295
+ # OS Hippotis sp. Clark and Watts 825.
296
+ # OS unknown cyperaceous sp.
297
+ def os(num = nil)
298
+ unless @data['OS']
299
+ os = Array.new
300
+ fetch('OS').split(/, and|, /).each do |tmp|
301
+ if tmp =~ /(\w+ *[\w\d \:\'\+\-\.]+[\w\d\.])/
302
+ org = $1
303
+ tmp =~ /(\(.+\))/
304
+ os.push({'name' => $1, 'os' => org})
305
+ else
306
+ raise "Error: OS Line. #{$!}\n#{fetch('OS')}\n"
307
+ end
308
+ end
309
+ @data['OS'] = os
310
+ end
311
+
312
+ if num
313
+ # EX. "Trifolium repens (white clover)"
314
+ return "#{@data['OS'][num]['os']} #{@data['OS'][num]['name']}"
315
+ else
316
+ return @data['OS']
317
+ end
318
+ end
319
+
320
+
321
+ # Bio::EMBLDB::Common#og -> Array
322
+ # OG Line; organella (0 or 1/entry)
323
+ # ["MITOCHONDRION", "CHLOROPLAST", "Cyanelle", "Plasmid"]
324
+ # or a plasmid name (e.g. "Plasmid pBR322").
325
+
326
+
327
+ # Bio::EMBLDB::Common#oc -> Array
328
+ # OC Line; organism classification (>=1)
329
+ # "OC Eukaryota; Alveolata; Apicomplexa; Piroplasmida; Theileriidae;"
330
+ # "OC Theileria."
331
+
332
+
333
+
334
+ # returns a Hash of oraganism taxonomy cross-references.
335
+ # * Bio::SPTR#ox -> Hash
336
+ # {'NCBI_TaxID' => ['1234','2345','3456','4567'], ...}
337
+ #
338
+ # === OX Line; organism taxonomy cross-reference (>=1 per entry)
339
+ # OX NCBI_TaxID=1234;
340
+ # OX NCBI_TaxID=1234, 2345, 3456, 4567;
341
+ def ox
342
+ unless @data['OX']
343
+ tmp = fetch('OX').sub(/\.$/,'').split(/;/).map { |e| e.strip }
344
+ hsh = Hash.new
345
+ tmp.each do |e|
346
+ db,refs = e.split(/=/)
347
+ hsh[db] = refs.split(/, */)
348
+ end
349
+ @data['OX'] = hsh
350
+ end
351
+ return @data['OX']
352
+ end
353
+
354
+ # === The OH Line;
355
+ #
356
+ # OH NCBI_TaxID=TaxID; HostName.
357
+ # http://br.expasy.org/sprot/userman.html#OH_line
358
+ def oh
359
+ unless @data['OH']
360
+ @data['OH'] = fetch('OH').split("\. ").map {|x|
361
+ if x =~ /NCBI_TaxID=(\d+);/
362
+ taxid = $1
363
+ else
364
+ raise ArgumentError, ["Error: Invalid OH line format (#{self.entry_id}):",
365
+ $!, "\n", get('OH'), "\n"].join
366
+
367
+ end
368
+ if x =~ /NCBI_TaxID=\d+; (.+)/
369
+ host_name = $1
370
+ host_name.sub!(/\.$/, '')
371
+ else
372
+ host_name = nil
373
+ end
374
+ {'NCBI_TaxID' => taxid, 'HostName' => host_name}
375
+ }
376
+ end
377
+ @data['OH']
378
+ end
379
+
380
+
381
+
382
+ # Bio::EMBLDB::Common#ref -> Array
383
+ # R Lines
384
+ # RN RC RP RX RA RT RL
385
+
386
+ # returns contents in the R lines.
387
+ # * Bio::EMBLDB::Common#ref -> [ <refernece information Hash>* ]
388
+ # where <reference information Hash> is:
389
+ # {'RN' => '', 'RC' => '', 'RP' => '', 'RX' => '',
390
+ # 'RA' => '', 'RT' => '', 'RL' => '', 'RG' => ''}
391
+ #
392
+ # R Lines
393
+ # * RN RC RP RX RA RT RL RG
394
+ def ref
395
+ unless @data['R']
396
+ @data['R'] = [get('R').split(/\nRN /)].flatten.map { |str|
397
+ hash = {'RN' => '', 'RC' => '', 'RP' => '', 'RX' => '',
398
+ 'RA' => '', 'RT' => '', 'RL' => '', 'RG' => ''}
399
+ str = 'RN ' + str unless /^RN / =~ str
400
+
401
+ str.split("\n").each do |line|
402
+ if /^(R[NPXARLCTG]) (.+)/ =~ line
403
+ hash[$1] += $2 + ' '
404
+ else
405
+ raise "Invalid format in R lines, \n[#{line}]\n"
406
+ end
407
+ end
408
+
409
+ hash['RN'] = set_RN(hash['RN'])
410
+ hash['RC'] = set_RC(hash['RC'])
411
+ hash['RP'] = set_RP(hash['RP'])
412
+ hash['RX'] = set_RX(hash['RX'])
413
+ hash['RA'] = set_RA(hash['RA'])
414
+ hash['RT'] = set_RT(hash['RT'])
415
+ hash['RL'] = set_RL(hash['RL'])
416
+ hash['RG'] = set_RG(hash['RG'])
417
+
418
+ hash
419
+ }
420
+
421
+ end
422
+ @data['R']
423
+ end
424
+
425
+ def set_RN(data)
426
+ data.strip
427
+ end
428
+
429
+ def set_RC(data)
430
+ data.scan(/([STP]\w+)=(.+);/).map { |comment|
431
+ [comment[1].split(/, and |, /)].flatten.map { |text|
432
+ {'Token' => comment[0], 'Text' => text}
433
+ }
434
+ }.flatten
435
+ end
436
+ private :set_RC
437
+
438
+ def set_RP(data)
439
+ data = data.strip
440
+ data = data.sub(/\.$/, '')
441
+ data.split(/, AND |, /i).map {|x|
442
+ x = x.strip
443
+ x = x.gsub(' ', ' ')
444
+ }
445
+ end
446
+ private :set_RP
447
+
448
+ def set_RX(data)
449
+ rx = {'MEDLINE' => nil, 'PubMed' => nil, 'DOI' => nil}
450
+ if data =~ /MEDLINE=(.+?);/
451
+ rx['MEDLINE'] = $1
452
+ end
453
+ if data =~ /PubMed=(.+?);/
454
+ rx['PubMed'] = $1
455
+ end
456
+ if data =~ /DOI=(.+?);/
457
+ rx['DOI'] = $1
458
+ end
459
+ rx
460
+ end
461
+ private :set_RX
462
+
463
+ def set_RA(data)
464
+ data = data.sub(/; *$/, '')
465
+ end
466
+ private :set_RA
467
+
468
+ def set_RT(data)
469
+ data = data.sub(/; *$/, '')
470
+ data = data.gsub(/(^"|"$)/, '')
471
+ end
472
+ private :set_RT
473
+
474
+ def set_RL(data)
475
+ data = data.strip
476
+ end
477
+ private :set_RL
478
+
479
+ def set_RG(data)
480
+ data = data.split('; ')
481
+ end
482
+ private :set_RG
483
+
484
+
485
+
486
+ # returns Bio::Reference object from Bio::EMBLDB::Common#ref.
487
+ # * Bio::EMBLDB::Common#ref -> Bio::References
488
+ def references
489
+ unless @data['references']
490
+ ary = self.ref.map {|ent|
491
+ hash = Hash.new('')
492
+ ent.each {|key, value|
493
+ case key
494
+ when 'RA'
495
+ hash['authors'] = value.split(/, /)
496
+ when 'RT'
497
+ hash['title'] = value
498
+ when 'RL'
499
+ if value =~ /(.*) (\d+) \((\d+)\), (\d+-\d+) \((\d+)\)$/
500
+ hash['journal'] = $1
501
+ hash['volume'] = $2
502
+ hash['issue'] = $3
503
+ hash['pages'] = $4
504
+ hash['year'] = $5
505
+ else
506
+ hash['journal'] = value
507
+ end
508
+ when 'RX' # PUBMED, MEDLINE, DOI
509
+ value.each do |tag, xref|
510
+ hash[ tag.downcase ] = xref
511
+ end
512
+ end
513
+ }
514
+ Reference.new(hash)
515
+ }
516
+ @data['references'] = References.new(ary)
517
+ end
518
+ @data['references']
519
+ end
520
+
521
+
522
+
523
+
524
+
525
+
526
+ # === The HI line
527
+ # Bio::SPTR#hi #=> hash
528
+ def hi
529
+ unless @data['HI']
530
+ @data['HI'] = []
531
+ fetch('HI').split(/\. /).each do |hlist|
532
+ hash = {'Category' => '', 'Keywords' => [], 'Keyword' => ''}
533
+ hash['Category'], hash['Keywords'] = hlist.split(': ')
534
+ hash['Keywords'] = hash['Keywords'].split('; ')
535
+ hash['Keyword'] = hash['Keywords'].pop
536
+ hash['Keyword'].sub!(/\.$/, '')
537
+ @data['HI'] << hash
538
+ end
539
+ end
540
+ @data['HI']
541
+ end
542
+
543
+
544
+ @@cc_topics = ['PHARMACEUTICAL',
545
+ 'BIOTECHNOLOGY',
546
+ 'TOXIC DOSE',
547
+ 'ALLERGEN',
548
+ 'RNA EDITING',
549
+ 'POLYMORPHISM',
550
+ 'BIOPHYSICOCHEMICAL PROPERTIES',
551
+ 'MASS SPECTROMETRY',
552
+ 'WEB RESOURCE',
553
+ 'ENZYME REGULATION',
554
+ 'DISEASE',
555
+ 'INTERACTION',
556
+ 'DEVELOPMENTAL STAGE',
557
+ 'INDUCTION',
558
+ 'CAUTION',
559
+ 'ALTERNATIVE PRODUCTS',
560
+ 'DOMAIN',
561
+ 'PTM',
562
+ 'MISCELLANEOUS',
563
+ 'TISSUE SPECIFICITY',
564
+ 'COFACTOR',
565
+ 'PATHWAY',
566
+ 'SUBUNIT',
567
+ 'CATALYTIC ACTIVITY',
568
+ 'SUBCELLULAR LOCATION',
569
+ 'FUNCTION',
570
+ 'SIMILARITY']
571
+ # returns contents in the CC lines.
572
+ # * Bio::SPTR#cc -> Hash
573
+ #
574
+ # returns an object of contents in the TOPIC.
575
+ # * Bio::SPTR#cc(TOPIC) -> Array w/in Hash, Hash
576
+ #
577
+ # returns contents of the "ALTERNATIVE PRODUCTS".
578
+ # * Bio::SPTR#cc('ALTERNATIVE PRODUCTS') -> Hash
579
+ # {'Event' => str,
580
+ # 'Named isoforms' => int,
581
+ # 'Comment' => str,
582
+ # 'Variants'=>[{'Name' => str, 'Synonyms' => str, 'IsoId' => str, 'Sequence' => []}]}
583
+ #
584
+ # CC -!- ALTERNATIVE PRODUCTS:
585
+ # CC Event=Alternative splicing; Named isoforms=15;
586
+ # ...
587
+ # CC placentae isoforms. All tissues differentially splice exon 13;
588
+ # CC Name=A; Synonyms=no del;
589
+ # CC IsoId=P15529-1; Sequence=Displayed;
590
+ #
591
+ # returns contents of the "DATABASE".
592
+ # * Bio::SPTR#cc('DATABASE') -> Array
593
+ # [{'NAME'=>str,'NOTE'=>str, 'WWW'=>URI,'FTP'=>URI}, ...]
594
+ #
595
+ # CC -!- DATABASE: NAME=Text[; NOTE=Text][; WWW="Address"][; FTP="Address"].
596
+ #
597
+ # returns contents of the "MASS SPECTROMETRY".
598
+ # * Bio::SPTR#cc('MASS SPECTROMETRY') -> Array
599
+ # [{'MW"=>float,'MW_ERR'=>float, 'METHOD'=>str,'RANGE'=>str}, ...]
600
+ #
601
+ # CC -!- MASS SPECTROMETRY: MW=XXX[; MW_ERR=XX][; METHOD=XX][;RANGE=XX-XX].
602
+ #
603
+ # === CC lines (>=0, optional)
604
+ # CC -!- TISSUE SPECIFICITY: HIGHEST LEVELS FOUND IN TESTIS. ALSO PRESENT
605
+ # CC IN LIVER, KIDNEY, LUNG AND BRAIN.
606
+ #
607
+ # CC -!- TOPIC: FIRST LINE OF A COMMENT BLOCK;
608
+ # CC SECOND AND SUBSEQUENT LINES OF A COMMENT BLOCK.
609
+ #
610
+ # See also http://www.expasy.org/sprot/userman.html#CC_line
611
+ #
612
+ def cc(topic = nil)
613
+ unless @data['CC']
614
+ cc = Hash.new
615
+ comment_border= '-' * (77 - 4 + 1)
616
+ dlm = /-!- /
617
+
618
+ # 12KD_MYCSM has no CC lines.
619
+ return cc if get('CC').size == 0
620
+
621
+ cc_raw = fetch('CC')
622
+
623
+ # Removing the copyright statement.
624
+ cc_raw.sub!(/ *---.+---/m, '')
625
+
626
+ # Not any CC Lines without the copyright statement.
627
+ return cc if cc_raw == ''
628
+
629
+ begin
630
+ cc_raw, copyright = cc_raw.split(/#{comment_border}/)[0]
631
+ cc_raw = cc_raw.sub(dlm,'')
632
+ cc_raw.split(dlm).each do |tmp|
633
+ tmp = tmp.strip
634
+
635
+ if /(^[A-Z ]+[A-Z]): (.+)/ =~ tmp
636
+ key = $1
637
+ body = $2
638
+ body.gsub!(/- (?!AND)/,'-')
639
+ body.strip!
640
+ unless cc[key]
641
+ cc[key] = [body]
642
+ else
643
+ cc[key].push(body)
644
+ end
645
+ else
646
+ raise ["Error: [#{entry_id}]: CC Lines", '"', tmp, '"',
647
+ '', get('CC'),''].join("\n")
648
+ end
649
+ end
650
+ rescue NameError
651
+ if fetch('CC') == ''
652
+ return {}
653
+ else
654
+ raise ["Error: Invalid CC Lines: [#{entry_id}]: ",
655
+ "\n'#{self.get('CC')}'\n", "(#{$!})"].join
656
+ end
657
+ rescue NoMethodError
658
+ end
659
+
660
+ @data['CC'] = cc
661
+ end
662
+
663
+
664
+ case topic
665
+ when 'ALLERGEN'
666
+ return @data['CC'][topic]
667
+ when 'ALTERNATIVE PRODUCTS'
668
+ return cc_alternative_products(@data['CC'][topic])
669
+ when 'BIOPHYSICOCHEMICAL PROPERTIES'
670
+ return cc_biophysiochemical_properties(@data['CC'][topic])
671
+ when 'BIOTECHNOLOGY'
672
+ return @data['CC'][topic]
673
+ when 'CATALITIC ACTIVITY'
674
+ return cc_catalytic_activity(@data['CC'][topic])
675
+ when 'CAUTION'
676
+ return cc_caution(@data['CC'][topic])
677
+ when 'COFACTOR'
678
+ return @data['CC'][topic]
679
+ when 'DEVELOPMENTAL STAGE'
680
+ return @data['CC'][topic].join('')
681
+ when 'DISEASE'
682
+ return @data['CC'][topic].join('')
683
+ when 'DOMAIN'
684
+ return @data['CC'][topic]
685
+ when 'ENZYME REGULATION'
686
+ return @data['CC'][topic].join('')
687
+ when 'FUNCTION'
688
+ return @data['CC'][topic].join('')
689
+ when 'INDUCTION'
690
+ return @data['CC'][topic].join('')
691
+ when 'INTERACTION'
692
+ return cc_interaction(@data['CC'][topic])
693
+ when 'MASS SPECTROMETRY'
694
+ return cc_mass_spectrometry(@data['CC'][topic])
695
+ when 'MISCELLANEOUS'
696
+ return @data['CC'][topic]
697
+ when 'PATHWAY'
698
+ return cc_pathway(@data['CC'][topic])
699
+ when 'PHARMACEUTICAL'
700
+ return @data['CC'][topic]
701
+ when 'POLYMORPHISM'
702
+ return @data['CC'][topic]
703
+ when 'PTM'
704
+ return @data['CC'][topic]
705
+ when 'RNA EDITING'
706
+ return cc_rna_editing(@data['CC'][topic])
707
+ when 'SIMILARITY'
708
+ return @data['CC'][topic]
709
+ when 'SUBCELLULAR LOCATION'
710
+ return cc_subcellular_location(@data['CC'][topic])
711
+ when 'SUBUNIT'
712
+ return @data['CC'][topic]
713
+ when 'TISSUE SPECIFICITY'
714
+ return @data['CC'][topic]
715
+ when 'TOXIC DOSE'
716
+ return @data['CC'][topic]
717
+ when 'WEB RESOURCE'
718
+ return cc_web_resource(@data['CC'][topic])
719
+ when 'DATABASE'
720
+ # DATABASE: NAME=Text[; NOTE=Text][; WWW="Address"][; FTP="Address"].
721
+ tmp = Array.new
722
+ db = @data['CC']['DATABASE']
723
+ return db unless db
724
+
725
+ db.each do |e|
726
+ db = {'NAME' => nil, 'NOTE' => nil, 'WWW' => nil, 'FTP' => nil}
727
+ e.sub(/.$/,'').split(/;/).each do |line|
728
+ case line
729
+ when /NAME=(.+)/
730
+ db['NAME'] = $1
731
+ when /NOTE=(.+)/
732
+ db['NOTE'] = $1
733
+ when /WWW="(.+)"/
734
+ db['WWW'] = $1
735
+ when /FTP="(.+)"/
736
+ db['FTP'] = $1
737
+ end
738
+ end
739
+ tmp.push(db)
740
+ end
741
+ return tmp
742
+ when nil
743
+ return @data['CC']
744
+ else
745
+ return @data['CC'][topic]
746
+ end
747
+ end
748
+
749
+
750
+ def cc_alternative_products(data)
751
+ ap = data.join('')
752
+ return ap unless ap
753
+
754
+ # Event, Named isoforms, Comment, [Name, Synonyms, IsoId, Sequnce]+
755
+ tmp = {'Event' => "", 'Named isoforms' => "", 'Comment' => "",
756
+ 'Variants' => []}
757
+ if /Event=(.+?);/ =~ ap
758
+ tmp['Event'] = $1
759
+ tmp['Event'] = tmp['Event'].sub(/;/,'').split(/, /)
760
+ end
761
+ if /Named isoforms=(\S+?);/ =~ ap
762
+ tmp['Named isoforms'] = $1
763
+ end
764
+ if /Comment=(.+?);/m =~ ap
765
+ tmp['Comment'] = $1
766
+ end
767
+ ap.scan(/Name=.+?Sequence=.+?;/).each do |ent|
768
+ tmp['Variants'] << cc_alternative_products_variants(ent)
769
+ end
770
+ return tmp
771
+ end
772
+ private :cc_alternative_products
773
+
774
+ def cc_alternative_products_variants(data)
775
+ variant = {'Name' => '', 'Synonyms' => [], 'IsoId' => [], 'Sequence' => []}
776
+ data.split(/; /).map {|x| x.split(/=/) }.each do |e|
777
+ case e[0]
778
+ when 'Sequence', 'Synonyms', 'IsoId'
779
+ e[1] = e[1].sub(/;/,'').split(/, /)
780
+ end
781
+ variant[e[0]] = e[1]
782
+ end
783
+ variant
784
+ end
785
+ private :cc_alternative_products_variants
786
+
787
+
788
+ def cc_biophysiochemical_properties(data)
789
+ data = data[0]
790
+
791
+ hash = {'Absorption' => {},
792
+ 'Kinetic parameters' => {},
793
+ 'pH dependence' => "",
794
+ 'Redox potential' => "",
795
+ 'Temperature dependence' => ""}
796
+ if data =~ /Absorption: Abs\(max\)=(.+?);/
797
+ hash['Absorption']['Abs(max)'] = $1
798
+ end
799
+ if data =~ /Absorption: Abs\(max\)=.+; Note=(.+?);/
800
+ hash['Absorption']['Note'] = $1
801
+ end
802
+ if data =~ /Kinetic parameters: KM=(.+?); Vmax=(.+?);/
803
+ hash['Kinetic parameters']['KM'] = $1
804
+ hash['Kinetic parameters']['Vmax'] = $2
805
+ end
806
+ if data =~ /Kinetic parameters: KM=.+; Vmax=.+; Note=(.+?);/
807
+ hash['Kinetic parameters']['Note'] = $1
808
+ end
809
+ if data =~ /pH dependence: (.+?);/
810
+ hash['pH dependence'] = $1
811
+ end
812
+ if data =~ /Redox potential: (.+?);/
813
+ hash['Redox potential'] = $1
814
+ end
815
+ if data =~ /Temperature dependence: (.+?);/
816
+ hash['Temperature dependence'] = $1
817
+ end
818
+ hash
819
+ end
820
+ private :cc_biophysiochemical_properties
821
+
822
+
823
+ def cc_caution(data)
824
+ data.join('')
825
+ end
826
+ private :cc_caution
827
+
828
+
829
+ # returns conteins in a line of the CC INTERACTION section.
830
+ #
831
+ # CC P46527:CDKN1B; NbExp=1; IntAct=EBI-359815, EBI-519280;
832
+ def cc_interaction(data)
833
+ str = data.join('')
834
+ it = str.scan(/(.+?); NbExp=(.+?); IntAct=(.+?);/)
835
+ it.map {|ent|
836
+ ent.map! {|x| x.strip }
837
+ if ent[0] =~ /^(.+):(.+)/
838
+ spac = $1
839
+ spid = $2.split(' ')[0]
840
+ optid = nil
841
+ elsif ent[0] =~ /Self/
842
+ spac = self.entry_id
843
+ spid = self.entry_id
844
+ optid = nil
845
+ end
846
+ if ent[0] =~ /^.+:.+ (.+)/
847
+ optid = $1
848
+ end
849
+
850
+ {'SP_Ac' => spac,
851
+ 'identifier' => spid,
852
+ 'NbExp' => ent[1],
853
+ 'IntAct' => ent[2].split(', '),
854
+ 'optional_identifier' => optid}
855
+ }
856
+ end
857
+ private :cc_interaction
858
+
859
+
860
+ def cc_mass_spectrometry(data)
861
+ # MASS SPECTROMETRY: MW=XXX[; MW_ERR=XX][; METHOD=XX][;RANGE=XX-XX].
862
+ return data unless data
863
+
864
+ data.map { |m|
865
+ mass = {'MW' => nil, 'MW_ERR' => nil, 'METHOD' => nil, 'RANGE' => nil,
866
+ 'NOTE' => nil}
867
+ m.sub(/.$/,'').split(/;/).each do |line|
868
+ case line
869
+ when /MW=(.+)/
870
+ mass['MW'] = $1
871
+ when /MW_ERR=(.+)/
872
+ mass['MW_ERR'] = $1
873
+ when /METHOD=(.+)/
874
+ mass['METHOD'] = $1
875
+ when /RANGE=(\d+-\d+)/
876
+ mass['RANGE'] = $1 # RANGE class ?
877
+ when /NOTE=(.+)/
878
+ mass['NOTE'] = $1
879
+ end
880
+ end
881
+ mass
882
+ }
883
+ end
884
+ private :cc_mass_spectrometry
885
+
886
+
887
+ def cc_pathway(data)
888
+ data.map {|x| x.sub(/\.$/, '') }.map {|x|
889
+ x.split(/; | and |: /)
890
+ }[0]
891
+ end
892
+ private :cc_pathway
893
+
894
+
895
+ def cc_rna_editing(data)
896
+ data = data.join('')
897
+ entry = {'Modified_positions' => [], 'Note' => ""}
898
+ if data =~ /Modified_positions=(.+?)(\.|;)/
899
+ entry['Modified_positions'] = $1.sub(/\.$/, '').split(', ')
900
+ else
901
+ raise ArgumentError, "Invarid CC RNA Editing lines (#{self.entry_id}):#{$!}\n#{get('CC')}"
902
+ end
903
+ if data =~ /Note=(.+)/
904
+ entry['Note'] = $1
905
+ end
906
+ entry
907
+ end
908
+ private :cc_rna_editing
909
+
910
+
911
+ def cc_subcellular_location(data)
912
+ data.map {|x|
913
+ x.split('. ').map {|y|
914
+ y.split('; ').map {|z|
915
+ z.sub(/\.$/, '')
916
+ }
917
+ }
918
+ }[0]
919
+ end
920
+ private :cc_subcellular_location
921
+
922
+
923
+ # CC -!- WEB RESOURCE: NAME=ResourceName[; NOTE=FreeText][; URL=WWWAddress].
924
+ def cc_web_resource(data)
925
+ data.map {|x|
926
+ entry = {'NAME' => nil, 'NOTE' => nil, 'URL' => nil}
927
+ x.split(';').each do |y|
928
+ case y
929
+ when /NAME=(.+)/
930
+ entry['NAME'] = $1.strip
931
+ when /NOTE=(.+)/
932
+ entry['NOTE'] = $1.strip
933
+ when /URL="(.+)"/
934
+ entry['URL'] = $1.strip
935
+ end
936
+ end
937
+ entry
938
+ }
939
+ end
940
+
941
+
942
+ # returns databases cross-references in the DR lines.
943
+ # * Bio::SPTR#dr -> Hash w/in Array
944
+ #
945
+ # === DR Line; defabases cross-reference (>=0)
946
+ # DR database_identifier; primary_identifier; secondary_identifier.
947
+ # a cross_ref pre one line
948
+ @@dr_database_identifier = ['EMBL','CARBBANK','DICTYDB','ECO2DBASE',
949
+ 'ECOGENE',
950
+ 'FLYBASE','GCRDB','HIV','HSC-2DPAGE','HSSP','INTERPRO','MAIZEDB',
951
+ 'MAIZE-2DPAGE','MENDEL','MGD''MIM','PDB','PFAM','PIR','PRINTS',
952
+ 'PROSITE','REBASE','AARHUS/GHENT-2DPAGE','SGD','STYGENE','SUBTILIST',
953
+ 'SWISS-2DPAGE','TIGR','TRANSFAC','TUBERCULIST','WORMPEP','YEPD','ZFIN']
954
+
955
+ # Backup Bio::EMBLDB#dr as embl_dr
956
+ alias :embl_dr :dr
957
+
958
+ # Bio::SPTR#dr
959
+ def dr(key = nil)
960
+ unless key
961
+ embl_dr
962
+ else
963
+ (embl_dr[key] or []).map {|x|
964
+ {'Accession' => x[0],
965
+ 'Version' => x[1],
966
+ ' ' => x[2],
967
+ 'Molecular Type' => x[3]}
968
+ }
969
+ end
970
+ end
971
+
972
+
973
+ # Bio::EMBLDB::Common#kw - Array
974
+ # #keywords -> Array
975
+ #
976
+ # KW Line; keyword (>=1)
977
+ # KW [Keyword;]+
978
+
979
+
980
+ # returns contents in the feature table.
981
+ #
982
+ # == Examples
983
+ #
984
+ # sp = Bio::SPTR.new(entry)
985
+ # ft = sp.ft
986
+ # ft.class #=> Hash
987
+ # ft.keys.each do |feature_key|
988
+ # ft[feature_key].each do |feature|
989
+ # feature['From'] #=> '1'
990
+ # feature['To'] #=> '21'
991
+ # feature['Description'] #=> ''
992
+ # feature['FTId'] #=> ''
993
+ # feature['diff'] #=> []
994
+ # feature['original'] #=> [feature_key, '1', '21', '', '']
995
+ # end
996
+ # end
997
+ #
998
+ # * Bio::SPTR#ft -> Hash
999
+ # {FEATURE_KEY => [{'From' => int, 'To' => int,
1000
+ # 'Description' => aStr, 'FTId' => aStr,
1001
+ # 'diff' => [original_residues, changed_residues],
1002
+ # 'original' => aAry }],...}
1003
+ #
1004
+ # returns an Array of the information about the feature_name in the feature table.
1005
+ # * Bio::SPTR#ft(feature_name) -> Array of Hash
1006
+ # [{'From' => str, 'To' => str, 'Description' => str, 'FTId' => str},...]
1007
+ #
1008
+ # == FT Line; feature table data (>=0, optional)
1009
+ #
1010
+ # Col Data item
1011
+ # ----- -----------------
1012
+ # 1- 2 FT
1013
+ # 6-13 Feature name
1014
+ # 15-20 `FROM' endpoint
1015
+ # 22-27 `TO' endpoint
1016
+ # 35-75 Description (>=0 per key)
1017
+ # ----- -----------------
1018
+ #
1019
+ # Note: 'FROM' and 'TO' endopoints are allowed to use non-numerial charactors
1020
+ # including '<', '>' or '?'. (c.f. '<1', '?42')
1021
+ #
1022
+ # See also http://www.expasy.org/sprot/userman.html#FT_line
1023
+ #
1024
+ def ft(feature_key = nil)
1025
+ return ft[feature_key] if feature_key
1026
+ return @data['FT'] if @data['FT']
1027
+
1028
+ table = []
1029
+ begin
1030
+ get('FT').split("\n").each do |line|
1031
+ if line =~ /^FT \w/
1032
+ feature = line.chomp.ljust(74)
1033
+ table << [feature[ 5..12].strip, # Feature Name
1034
+ feature[14..19].strip, # From
1035
+ feature[21..26].strip, # To
1036
+ feature[34..74].strip ] # Description
1037
+ else
1038
+ table.last << line.chomp.sub!(/^FT +/, '')
1039
+ end
1040
+ end
1041
+
1042
+ # Joining Description lines
1043
+ table = table.map { |feature|
1044
+ ftid = feature.pop if feature.last =~ /FTId=/
1045
+ if feature.size > 4
1046
+ feature = [feature[0],
1047
+ feature[1],
1048
+ feature[2],
1049
+ feature[3, feature.size - 3].join(" ")]
1050
+ end
1051
+ feature << if ftid then ftid else '' end
1052
+ }
1053
+
1054
+ hash = {}
1055
+ table.each do |feature|
1056
+ hash[feature[0]] = [] unless hash[feature[0]]
1057
+ hash[feature[0]] << {
1058
+ # Removing '<', '>' or '?' in FROM/TO endopoint.
1059
+ 'From' => feature[1].sub(/\D/, '').to_i,
1060
+ 'To' => feature[2].sub(/\D/, '').to_i,
1061
+ 'Description' => feature[3],
1062
+ 'FTId' => feature[4].to_s.sub(/\/FTId=/, '').sub(/\.$/, ''),
1063
+ 'diff' => [],
1064
+ 'original' => feature
1065
+ }
1066
+
1067
+ case feature[0]
1068
+ when 'VARSPLIC', 'VARIANT', 'VAR_SEQ', 'CONFLICT'
1069
+ case hash[feature[0]].last['Description']
1070
+ when /(\w[\w ]*\w*) - ?> (\w[\w ]*\w*)/
1071
+ original_res = $1
1072
+ changed_res = $2
1073
+ original_res = original_res.gsub(/ /,'').strip
1074
+ chenged_res = changed_res.gsub(/ /,'').strip
1075
+ when /Missing/i
1076
+ original_res = seq.subseq(hash[feature[0]].last['From'],
1077
+ hash[feature[0]].last['To'])
1078
+ changed_res = ''
1079
+ end
1080
+ hash[feature[0]].last['diff'] = [original_res, chenged_res]
1081
+ end
1082
+ end
1083
+ rescue
1084
+ raise "Invalid FT Lines(#{$!}) in #{entry_id}:, \n'#{self.get('FT')}'\n"
1085
+ end
1086
+
1087
+ @data['FT'] = hash
1088
+ end
1089
+
1090
+
1091
+
1092
+ # returns a Hash of conteins in the SQ lines.
1093
+ # * Bio::SPTRL#sq -> hsh
1094
+ #
1095
+ # returns a value of a key given in the SQ lines.
1096
+ # * Bio::SPTRL#sq(key) -> int or str
1097
+ # * Keys: ['MW', 'mw', 'molecular', 'weight', 'aalen', 'len', 'length',
1098
+ # 'CRC64']
1099
+ #
1100
+ # === SQ Line; sequence header (1/entry)
1101
+ # SQ SEQUENCE 233 AA; 25630 MW; 146A1B48A1475C86 CRC64;
1102
+ # SQ SEQUENCE \d+ AA; \d+ MW; [0-9A-Z]+ CRC64;
1103
+ #
1104
+ # MW, Dalton unit.
1105
+ # CRC64 (64-bit Cyclic Redundancy Check, ISO 3309).
1106
+ def sq(key = nil)
1107
+ unless @data['SQ']
1108
+ if fetch('SQ') =~ /(\d+) AA\; (\d+) MW; (.+) CRC64;/
1109
+ @data['SQ'] = { 'aalen' => $1.to_i, 'MW' => $2.to_i, 'CRC64' => $3 }
1110
+ else
1111
+ raise "Invalid SQ Line: \n'#{fetch('SQ')}'"
1112
+ end
1113
+ end
1114
+
1115
+ if key
1116
+ case key
1117
+ when /mw/, /molecular/, /weight/
1118
+ @data['SQ']['MW']
1119
+ when /len/, /length/, /AA/
1120
+ @data['SQ']['aalen']
1121
+ else
1122
+ @data['SQ'][key]
1123
+ end
1124
+ else
1125
+ @data['SQ']
1126
+ end
1127
+ end
1128
+
1129
+
1130
+ # returns a Bio::Sequence::AA of the amino acid sequence.
1131
+ # * Bio::SPTR#seq -> Bio::Sequence::AA
1132
+ #
1133
+ # blank Line; sequence data (>=1)
1134
+ def seq
1135
+ unless @data['']
1136
+ @data[''] = Sequence::AA.new( fetch('').gsub(/ |\d+/,'') )
1137
+ end
1138
+ return @data['']
1139
+ end
1140
+ alias aaseq seq
1141
+
1142
+ end # class SPTR
1143
+
1144
+ end # module Bio
1145
+
1146
+
1147
+
1148
+ =begin
1149
+
1150
+ = Bio::SPTR < Bio::DB
1151
+
1152
+ Class for a entry in the SWISS-PROT/TrEMBL database.
1153
+
1154
+ * ((<URL:http://www.ebi.ac.uk/swissprot/>))
1155
+ * ((<URL:http://www.ebi.ac.uk/trembl/>))
1156
+ * ((<URL:http://www.ebi.ac.uk/sprot/userman.html>))
1157
+
1158
+
1159
+ --- Bio::SPTR.new(a_sp_entry)
1160
+
1161
+ === ID line (Identification)
1162
+
1163
+ --- Bio::SPTR#id_line -> {'ENTRY_NAME' => str, 'DATA_CLASS' => str,
1164
+ 'MOLECULE_TYPE' => str, 'SEQUENCE_LENGTH' => int }
1165
+ --- Bio::SPTR#id_line(key) -> str
1166
+
1167
+ key = (ENTRY_NAME|MOLECULE_TYPE|DATA_CLASS|SEQUENCE_LENGTH)
1168
+
1169
+ --- Bio::SPTR#entry_id -> str
1170
+ --- Bio::SPTR#molecule -> str
1171
+ --- Bio::SPTR#sequence_length -> int
1172
+
1173
+
1174
+ === AC lines (Accession number)
1175
+
1176
+ --- Bio::SPTR#ac -> ary
1177
+ --- Bio::SPTR#accessions -> ary
1178
+ --- Bio::SPTR#accession -> accessions.first
1179
+
1180
+
1181
+ === GN line (Gene name(s))
1182
+
1183
+ --- Bio::SPTR#gn -> [ary, ...] or [{:name => str, :synonyms => [], :loci => [], :orfs => []}]
1184
+ --- Bio::SPTR#gene_name -> str
1185
+ --- Bio::SPTR#gene_names -> [str] or [str]
1186
+
1187
+
1188
+ === DT lines (Date)
1189
+
1190
+ --- Bio::SPTR#dt -> {'created' => str, 'sequence' => str, 'annotation' => str}
1191
+ --- Bio::SPTR#dt(key) -> str
1192
+
1193
+ key := (created|annotation|sequence)
1194
+
1195
+
1196
+ === DE lines (Description)
1197
+
1198
+ --- Bio::SPTR#de -> str
1199
+ #definition -> str
1200
+
1201
+ --- Bio::SPTR#protein_name
1202
+
1203
+ Returns the proposed official name of the protein
1204
+
1205
+
1206
+ --- Bio::SPTR#synonyms
1207
+
1208
+ Returns an array of synonyms (unofficial names)
1209
+
1210
+ === KW lines (Keyword)
1211
+
1212
+ --- Bio::SPTR#kw -> ary
1213
+
1214
+ === OS lines (Organism species)
1215
+
1216
+ --- Bio::SPTR#os -> [{'name' => str, 'os' => str}, ...]
1217
+
1218
+ === OC lines (organism classification)
1219
+
1220
+ --- Bio::SPTR#oc -> ary
1221
+
1222
+ === OG line (Organella)
1223
+
1224
+ --- Bio::SPTR#og -> ary
1225
+
1226
+ === OX line (Organism taxonomy cross-reference)
1227
+
1228
+ --- Bio::SPTR#ox -> {'NCBI_TaxID' => [], ...}
1229
+
1230
+ === RN RC RP RX RA RT RL RG lines (Reference)
1231
+
1232
+ --- Bio::SPTR#ref -> [{'RN' => int, 'RP' => str, 'RC' => str, 'RX' => str, ''RT' => str, 'RL' => str, 'RA' => str, 'RC' => str, 'RG' => str},...]
1233
+
1234
+ === DR lines (Database cross-reference)
1235
+
1236
+ --- Bio::SPTR#dr -> {'EMBL' => ary, ...}
1237
+
1238
+ === FT lines (Feature table data)
1239
+
1240
+ --- Bio::SPTR#ft -> hsh
1241
+
1242
+ === SQ lines (Sequence header and data)
1243
+
1244
+ --- Bio::SPTR#sq -> {'CRC64' => str, 'MW' => int, 'aalen' => int}
1245
+ --- Bio::SPTR#sq(key) -> int or str
1246
+
1247
+ key := (aalen|MW|CRC64)
1248
+
1249
+ --- Bio::EMBL#seq -> Bio::Sequece::AA
1250
+ #aaseq -> Bio::Sequece::AA
1251
+
1252
+ =end
1253
+
1254
+ # Content Occurrence in an entry
1255
+ # ---- --------------------------- --------------------------------
1256
+ # ID - identification (begins each entry; 1 per entry)
1257
+ # AC - accession number(s) (>=1 per entry)
1258
+ # DT - date (3 per entry)
1259
+ # DE - description (>=1 per entry)
1260
+ # GN - gene name(s) (>=0 per entry; optional)
1261
+ # OS - organism species (>=1 per entry)
1262
+ # OG - organelle (0 or 1 per entry; optional)
1263
+ # OC - organism classification (>=1 per entry)
1264
+ # OX - organism taxonomy x-ref (>=1 per entry)
1265
+ # OH - Organism Host
1266
+ # RN - reference number (>=1 per entry)
1267
+ # RP - reference positions (>=1 per entry)
1268
+ # RC - reference comment(s) (>=0 per entry; optional)
1269
+ # RX - reference cross-reference(s) (>=0 per entry; optional)
1270
+ # RA - reference author(s) (>=1 per entry)
1271
+ # RT - reference title (>=0 per entry; optional)
1272
+ # RL - reference location (>=1 per entry)
1273
+ # RG - reference group(s)
1274
+ # CC - comments or notes (>=0 per entry; optional)
1275
+ # DR - database cross-references (>=0 per entry; optional)
1276
+ # KW - keywords (>=1 per entry)
1277
+ # FT - feature table data (>=0 per entry; optional)
1278
+ # SQ - sequence header (1 per entry)
1279
+ # - (blanks) The sequence data (>=1 per entry)
1280
+ # // - termination line (ends each entry; 1 per entry)
1281
+ # ---- --------------------------- --------------------------------
1282
+
1283
+