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,176 @@
1
+ #
2
+ # = bio/db/pdb/residue.rb - residue class for PDB
3
+ #
4
+ # Copyright:: Copyright (C) 2004, 2006
5
+ # Alex Gutteridge <alexg@ebi.ac.uk>
6
+ # Naohisa Goto <ng@bioruby.org>
7
+ # License:: The Ruby License
8
+ #
9
+ # $Id: residue.rb,v 1.14 2007/12/18 13:48:42 ngoto Exp $
10
+ #
11
+ # = Bio::PDB::Residue
12
+ #
13
+ # = Bio::PDB::Heterogen
14
+ #
15
+
16
+ require 'bio/db/pdb'
17
+
18
+ module Bio
19
+
20
+ class PDB
21
+
22
+ # Bio::PDB::Residue is a class to store a residue.
23
+ # The object would contain some atoms (Bio::PDB::Record::ATOM objects).
24
+ #
25
+ class Residue
26
+
27
+ include Utils
28
+ include AtomFinder
29
+
30
+ include Enumerable
31
+ include Comparable
32
+
33
+ # Creates residue id from an ATOM (or HETATM) object.
34
+ def self.get_residue_id_from_atom(atom)
35
+ "#{atom.resSeq}#{atom.iCode.strip}".strip
36
+ end
37
+
38
+ # Creates a new Residue object.
39
+ def initialize(resName = nil, resSeq = nil, iCode = nil,
40
+ chain = nil)
41
+
42
+ @resName = resName
43
+ @resSeq = resSeq
44
+ @iCode = iCode
45
+
46
+ @chain = chain
47
+ @atoms = []
48
+
49
+ update_residue_id
50
+ end
51
+
52
+ # atoms in this residue. (Array)
53
+ attr_reader :atoms
54
+
55
+ # the chain to which this residue belongs
56
+ attr_accessor :chain
57
+
58
+ # resName (residue name)
59
+ attr_accessor :resName
60
+
61
+ # residue id (String or nil).
62
+ # The id is a composite of resSeq and iCode.
63
+ attr_reader :residue_id
64
+
65
+ # Now, Residue#id is an alias of residue_id.
66
+ alias id residue_id
67
+
68
+ #Keyed access to atoms based on atom name e.g. ["CA"]
69
+ def [](key)
70
+ atom = @atoms.find{ |atom| key == atom.name }
71
+ end
72
+
73
+ # Updates residue id. This is a private method.
74
+ # Need to call this method to make sure id is correctly updated.
75
+ def update_residue_id
76
+ if !@resSeq and !@iCode
77
+ @residue_id = nil
78
+ else
79
+ @residue_id = "#{@resSeq}#{@iCode.to_s.strip}".strip
80
+ end
81
+ end
82
+ private :update_residue_id
83
+
84
+ # resSeq
85
+ attr_reader :resSeq
86
+
87
+ # resSeq=()
88
+ def resSeq=(resSeq)
89
+ @resSeq = resSeq.to_i
90
+ update_residue_id
91
+ @resSeq
92
+ end
93
+
94
+ # iCode
95
+ attr_reader :iCode
96
+
97
+ # iCode=()
98
+ def iCode=(iCode)
99
+ @iCode = iCode
100
+ update_residue_id
101
+ @iCode
102
+ end
103
+
104
+ # Adds an atom to this residue
105
+ def addAtom(atom)
106
+ raise "Expecting ATOM or HETATM" unless atom.is_a? Bio::PDB::Record::ATOM
107
+ @atoms.push(atom)
108
+ self
109
+ end
110
+
111
+ # Iterator over the atoms
112
+ def each
113
+ @atoms.each{ |atom| yield atom }
114
+ end
115
+ # Alias to override AtomFinder#each_atom
116
+ alias each_atom each
117
+
118
+ # Sorts based on resSeq and iCode if need be
119
+ def <=>(other)
120
+ if @resSeq != other.resSeq
121
+ return @resSeq <=> other.resSeq
122
+ else
123
+ return @iCode <=> other.iCode
124
+ end
125
+ end
126
+
127
+ # Stringifies each atom
128
+ def to_s
129
+ @atoms.join('')
130
+ end
131
+
132
+ # returns a string containing human-readable representation
133
+ # of this object.
134
+ def inspect
135
+ "#<#{self.class.to_s} resName=#{resName.inspect} id=#{residue_id.inspect} chain.id=#{(chain ? chain.id : nil).inspect} resSeq=#{resSeq.inspect} iCode=#{iCode.inspect} atoms.size=#{atoms.size}>"
136
+ end
137
+
138
+ # Always returns false.
139
+ #
140
+ # If the residue is HETATM, returns true.
141
+ # Otherwise, returns false.
142
+ def hetatm
143
+ false
144
+ end
145
+ end #class Residue
146
+
147
+ # Bio::PDB::Heterogen is a class to store a heterogen.
148
+ # It inherits Bio::PDB::Residue and most of the methods are the same.
149
+ #
150
+ # The object would contain some HETATMs
151
+ # (Bio::PDB::Record::HETATM objects).
152
+ class Heterogen < Residue
153
+
154
+ include HetatmFinder
155
+
156
+ # Always returns true.
157
+ #
158
+ # If the residue is HETATM, returns true.
159
+ # Otherwise, returns false.
160
+ def hetatm
161
+ true
162
+ end
163
+
164
+ # Alias to override HetatmFinder#each_hetatm
165
+ alias each_hetatm each
166
+
167
+ # Alias needed for HeterogenFinder.
168
+ alias hetatms atoms
169
+
170
+ # Alias to avoid confusion
171
+ alias heterogen_id residue_id
172
+ end #class Heterogen
173
+
174
+ end #class PDB
175
+
176
+ end #module Bio
@@ -0,0 +1,399 @@
1
+ #
2
+ # = bio/db/pdb/utils.rb - Utility modules for PDB
3
+ #
4
+ # Copyright:: Copyright (C) 2004, 2006
5
+ # Alex Gutteridge <alexg@ebi.ac.uk>
6
+ # Naohisa Goto <ng@bioruby.org>
7
+ # License:: The Ruby License
8
+ #
9
+ # $Id: utils.rb,v 1.7 2007/04/05 23:35:41 trevor Exp $
10
+ #
11
+ # = Bio::PDB::Utils
12
+ #
13
+ # Bio::PDB::Utils
14
+ #
15
+ # = Bio::PDB::ModelFinder
16
+ #
17
+ # Bio::PDB::ModelFinder
18
+ #
19
+ # = Bio::PDB::ChainFinder
20
+ #
21
+ # Bio::PDB::ChainFinder
22
+ #
23
+ # = Bio::PDB::ResidueFinder
24
+ #
25
+ # Bio::PDB::ResidueFinder
26
+ #
27
+ # = Bio::PDB::AtomFinder
28
+ #
29
+ # Bio::PDB::AtomFinder
30
+ #
31
+ # = Bio::PDB::HeterogenFinder
32
+ #
33
+ # Bio::PDB::HeterogenFinder
34
+ #
35
+ # = Bio::PDB::HetatmFinder
36
+ #
37
+ # Bio::PDB::HetatmFinder
38
+ #
39
+
40
+ require 'matrix'
41
+ require 'bio/db/pdb'
42
+
43
+ module Bio; class PDB
44
+
45
+ # Utility methods for PDB data.
46
+ # The methods in this mixin should be applicalbe to all PDB objects.
47
+ #
48
+ # Bio::PDB::Utils is included by Bio::PDB, Bio::PDB::Model,
49
+ # Bio::PDB::Chain, Bio::PDB::Residue, and Bio::PDB::Heterogen classes.
50
+ module Utils
51
+
52
+ # Returns the coordinates of the geometric centre (average co-ord)
53
+ # of any AtomFinder (or .atoms) implementing object
54
+ #
55
+ # If you want to get the geometric centre of hetatms,
56
+ # call geometricCentre(:each_hetatm).
57
+ def geometricCentre(method = :each_atom)
58
+ x = y = z = count = 0
59
+
60
+ self.__send__(method) do |atom|
61
+ x += atom.x
62
+ y += atom.y
63
+ z += atom.z
64
+ count += 1
65
+ end
66
+
67
+ x = (x / count)
68
+ y = (y / count)
69
+ z = (z / count)
70
+
71
+ Coordinate[x,y,z]
72
+ end
73
+
74
+ #Returns the coords of the centre of gravity for any
75
+ #AtomFinder implementing object
76
+ #Blleurgh! - working out what element it is from the atom name is
77
+ #tricky - this'll work in most cases but not metals etc...
78
+ #a proper element field is included in some PDB files but not all.
79
+ ElementMass = {
80
+ 'H' => 1,
81
+ 'C' => 12,
82
+ 'N' => 14,
83
+ 'O' => 16,
84
+ 'S' => 32,
85
+ 'P' => 31
86
+ }
87
+
88
+ # calculates centre of gravitiy
89
+ def centreOfGravity()
90
+ x = y = z = total = 0
91
+
92
+ self.each_atom{ |atom|
93
+ element = atom.element[0,1]
94
+ mass = ElementMass[element]
95
+ total += mass
96
+ x += atom.x * mass
97
+ y += atom.y * mass
98
+ z += atom.z * mass
99
+ }
100
+
101
+ x = x / total
102
+ y = y / total
103
+ z = z / total
104
+
105
+ Coordinate[x,y,z]
106
+ end
107
+
108
+ #--
109
+ #Perhaps distance and dihedral would be better off as class methods?
110
+ #(rather) than instance methods
111
+ #++
112
+
113
+ # Calculates distance between _coord1_ and _coord2_.
114
+ def distance(coord1, coord2)
115
+ coord1 = convert_to_xyz(coord1)
116
+ coord2 = convert_to_xyz(coord2)
117
+ (coord1 - coord2).r
118
+ end
119
+ module_function :distance
120
+
121
+ # Calculates dihedral angle.
122
+ def dihedral_angle(coord1, coord2, coord3, coord4)
123
+ (a1,b1,c1,d) = calculatePlane(coord1,coord2,coord3)
124
+ (a2,b2,c2) = calculatePlane(coord2,coord3,coord4)
125
+
126
+ torsion = acos((a1*a2 + b1*b2 + c1*c2)/(Math.sqrt(a1**2 + b1**2 + c1**2) * Math.sqrt(a2**2 + b2**2 + c2**2)))
127
+
128
+ if ((a1*coord4.x + b1*coord4.y + c1*coord4.z + d) < 0)
129
+ -torsion
130
+ else
131
+ torsion
132
+ end
133
+ end
134
+ module_function :dihedral_angle
135
+
136
+ # Implicit conversion into Vector or Bio::PDB::Coordinate
137
+ def convert_to_xyz(obj)
138
+ unless obj.is_a?(Vector)
139
+ begin
140
+ obj = obj.xyz
141
+ rescue NameError
142
+ obj = Vector.elements(obj.to_a)
143
+ end
144
+ end
145
+ obj
146
+ end
147
+ module_function :convert_to_xyz
148
+
149
+ # (Deprecated) alias of convert_to_xyz(obj)
150
+ def self.to_xyz(obj)
151
+ convert_to_xyz(obj)
152
+ end
153
+
154
+ #--
155
+ #Methods required for the dihedral angle calculations
156
+ #perhaps these should go in some separate Math module
157
+ #++
158
+
159
+ # radian to degree
160
+ def rad2deg(r)
161
+ (r/Math::PI)*180
162
+ end
163
+ module_function :rad2deg
164
+
165
+ # acos
166
+ def acos(x)
167
+ Math.atan2(Math.sqrt(1 - x**2),x)
168
+ end
169
+ module_function :acos
170
+
171
+ # calculates plane
172
+ def calculatePlane(coord1, coord2, coord3)
173
+ a = coord1.y * (coord2.z - coord3.z) +
174
+ coord2.y * (coord3.z - coord1.z) +
175
+ coord3.y * (coord1.z - coord2.z)
176
+ b = coord1.z * (coord2.x - coord3.x) +
177
+ coord2.z * (coord3.x - coord1.x) +
178
+ coord3.z * (coord1.x - coord2.x)
179
+ c = coord1.x * (coord2.y - coord3.y) +
180
+ coord2.x * (coord3.y - coord1.y) +
181
+ coord3.x * (coord1.y - coord2.y)
182
+ d = -1 *
183
+ (
184
+ (coord1.x * (coord2.y * coord3.z - coord3.y * coord2.z)) +
185
+ (coord2.x * (coord3.y * coord1.z - coord1.y * coord3.z)) +
186
+ (coord3.x * (coord1.y * coord2.z - coord2.y * coord1.z))
187
+ )
188
+
189
+ return [a,b,c,d]
190
+ end
191
+ module_function :calculatePlane
192
+
193
+ # Every class in the heirarchy implements finder, this takes
194
+ # a class which determines which type of object to find, the associated
195
+ # block is then run in classic .find style.
196
+ #
197
+ # The method might be deprecated.
198
+ # You'd better using find_XXX directly.
199
+ def finder(findtype, &block) #:yields: obj
200
+ if findtype == Bio::PDB::Atom
201
+ return self.find_atom(&block)
202
+ elsif findtype == Bio::PDB::Residue
203
+ return self.find_residue(&block)
204
+ elsif findtype == Bio::PDB::Chain
205
+ return self.find_chain(&block)
206
+ elsif findtype == Bio::PDB::Model
207
+ return self.find_model(&block)
208
+ else
209
+ raise TypeError, "You can't find a #{findtype}"
210
+ end
211
+ end
212
+ end #module Utils
213
+
214
+ #--
215
+ #The *Finder modules implement a find_* method which returns
216
+ #an array of anything for which the block evals true
217
+ #(suppose Enumerable#find_all method).
218
+ #The each_* style methods act as classic iterators.
219
+ #++
220
+
221
+ # methods to access models
222
+ #
223
+ # XXX#each_model must be defined.
224
+ #
225
+ # Bio::PDB::ModelFinder is included by Bio::PDB::PDB.
226
+ #
227
+ module ModelFinder
228
+ # returns an array containing all chains for which given block
229
+ # is not +false+ (similar to Enumerable#find_all).
230
+ def find_model
231
+ array = []
232
+ self.each_model do |model|
233
+ array.push(model) if yield(model)
234
+ end
235
+ return array
236
+ end
237
+ end #module ModelFinder
238
+
239
+ #--
240
+ #The heirarchical nature of the objects allow us to re-use the
241
+ #methods from the previous level - e.g. A PDB object can use the .models
242
+ #method defined in ModuleFinder to iterate through the models to find the
243
+ #chains
244
+ #++
245
+
246
+ # methods to access chains
247
+ #
248
+ # XXX#each_model must be defined.
249
+ #
250
+ # Bio::PDB::ChainFinder is included by Bio::PDB::PDB and Bio::PDB::Model.
251
+ #
252
+ module ChainFinder
253
+
254
+ # returns an array containing all chains for which given block
255
+ # is not +false+ (similar to Enumerable#find_all).
256
+ def find_chain
257
+ array = []
258
+ self.each_chain do |chain|
259
+ array.push(chain) if yield(chain)
260
+ end
261
+ return array
262
+ end
263
+
264
+ # iterates over each chain
265
+ def each_chain(&x) #:yields: chain
266
+ self.each_model { |model| model.each(&x) }
267
+ end
268
+
269
+ # returns all chains
270
+ def chains
271
+ array = []
272
+ self.each_model { |model| array.concat(model.chains) }
273
+ return array
274
+ end
275
+ end #module ChainFinder
276
+
277
+ # methods to access residues
278
+ #
279
+ # XXX#each_chain must be defined.
280
+ #
281
+ # Bio::PDB::ResidueFinder is included by Bio::PDB::PDB, Bio::PDB::Model,
282
+ # and Bio::PDB::Chain.
283
+ #
284
+ module ResidueFinder
285
+
286
+ # returns an array containing all residues for which given block
287
+ # is not +false+ (similar to Enumerable#find_all).
288
+ def find_residue
289
+ array = []
290
+ self.each_residue do |residue|
291
+ array.push(residue) if yield(residue)
292
+ end
293
+ return array
294
+ end
295
+
296
+ # iterates over each residue
297
+ def each_residue(&x) #:yields: residue
298
+ self.each_chain { |chain| chain.each(&x) }
299
+ end
300
+
301
+ # returns all residues
302
+ def residues
303
+ array = []
304
+ self.each_chain { |chain| array.concat(chain.residues) }
305
+ return array
306
+ end
307
+ end #module ResidueFinder
308
+
309
+ # methods to access atoms
310
+ #
311
+ # XXX#each_residue must be defined.
312
+ module AtomFinder
313
+ # returns an array containing all atoms for which given block
314
+ # is not +false+ (similar to Enumerable#find_all).
315
+ def find_atom
316
+ array = []
317
+ self.each_atom do |atom|
318
+ array.push(atom) if yield(atom)
319
+ end
320
+ return array
321
+ end
322
+
323
+ # iterates over each atom
324
+ def each_atom(&x) #:yields: atom
325
+ self.each_residue { |residue| residue.each(&x) }
326
+ end
327
+
328
+ # returns all atoms
329
+ def atoms
330
+ array = []
331
+ self.each_residue { |residue| array.concat(residue.atoms) }
332
+ return array
333
+ end
334
+ end #module AtomFinder
335
+
336
+ # methods to access HETATMs
337
+ #
338
+ # XXX#each_heterogen must be defined.
339
+ #
340
+ # Bio::PDB::HetatmFinder is included by Bio::PDB::PDB, Bio::PDB::Model,
341
+ # Bio::PDB::Chain, and Bio::PDB::Heterogen.
342
+ #
343
+ module HetatmFinder
344
+ # returns an array containing all HETATMs for which given block
345
+ # is not +false+ (similar to Enumerable#find_all).
346
+ def find_hetatm
347
+ array = []
348
+ self.each_hetatm do |hetatm|
349
+ array.push(hetatm) if yield(hetatm)
350
+ end
351
+ return array
352
+ end
353
+
354
+ # iterates over each HETATM
355
+ def each_hetatm(&x) #:yields: hetatm
356
+ self.each_heterogen { |heterogen| heterogen.each(&x) }
357
+ end
358
+
359
+ # returns all HETATMs
360
+ def hetatms
361
+ array = []
362
+ self.each_heterogen { |heterogen| array.concat(heterogen.hetatms) }
363
+ return array
364
+ end
365
+ end #module HetatmFinder
366
+
367
+ # methods to access heterogens (compounds or ligands)
368
+ #
369
+ # XXX#each_chain must be defined.
370
+ #
371
+ # Bio::PDB::HeterogenFinder is included by Bio::PDB::PDB, Bio::PDB::Model,
372
+ # and Bio::PDB::Chain.
373
+ #
374
+ module HeterogenFinder
375
+ # returns an array containing all heterogens for which given block
376
+ # is not +false+ (similar to Enumerable#find_all).
377
+ def find_heterogen
378
+ array = []
379
+ self.each_heterogen do |heterogen|
380
+ array.push(heterogen) if yield(heterogen)
381
+ end
382
+ return array
383
+ end
384
+
385
+ # iterates over each heterogens
386
+ def each_heterogen(&x) #:yields: heterogen
387
+ self.each_chain { |chain| chain.each_heterogen(&x) }
388
+ end
389
+
390
+ # returns all heterogens
391
+ def heterogens
392
+ array = []
393
+ self.each_chain { |chain| array.concat(chain.heterogens) }
394
+ return array
395
+ end
396
+ end #module HeterogenFinder
397
+
398
+ end; end #module Bio; class PDB
399
+