bio 1.2.1 → 1.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (259) hide show
  1. data/ChangeLog +3421 -0
  2. data/KNOWN_ISSUES.rdoc +88 -0
  3. data/README.rdoc +252 -0
  4. data/README_DEV.rdoc +285 -0
  5. data/Rakefile +143 -0
  6. data/bin/bioruby +0 -0
  7. data/bin/br_biofetch.rb +0 -0
  8. data/bin/br_bioflat.rb +12 -1
  9. data/bin/br_biogetseq.rb +0 -0
  10. data/bin/br_pmfetch.rb +4 -3
  11. data/bioruby.gemspec +477 -0
  12. data/bioruby.gemspec.erb +117 -0
  13. data/doc/Changes-0.7.rd +7 -0
  14. data/doc/Changes-1.3.rdoc +239 -0
  15. data/doc/Tutorial.rd +296 -184
  16. data/doc/Tutorial.rd.html +1031 -0
  17. data/doc/Tutorial.rd.ja +111 -45
  18. data/doc/Tutorial.rd.ja.html +2225 -0
  19. data/doc/bioruby.css +281 -0
  20. data/extconf.rb +2 -0
  21. data/lib/bio.rb +29 -4
  22. data/lib/bio/appl/blast.rb +306 -121
  23. data/lib/bio/appl/blast/ddbj.rb +142 -0
  24. data/lib/bio/appl/blast/format0.rb +35 -25
  25. data/lib/bio/appl/blast/format8.rb +2 -2
  26. data/lib/bio/appl/blast/genomenet.rb +263 -0
  27. data/lib/bio/appl/blast/ncbioptions.rb +220 -0
  28. data/lib/bio/appl/blast/remote.rb +106 -0
  29. data/lib/bio/appl/blast/report.rb +260 -9
  30. data/lib/bio/appl/blast/rexml.rb +12 -5
  31. data/lib/bio/appl/blast/rpsblast.rb +277 -0
  32. data/lib/bio/appl/blast/wublast.rb +133 -12
  33. data/lib/bio/appl/blast/xmlparser.rb +35 -18
  34. data/lib/bio/appl/blat/report.rb +46 -5
  35. data/lib/bio/appl/emboss.rb +62 -13
  36. data/lib/bio/appl/fasta.rb +9 -11
  37. data/lib/bio/appl/genscan/report.rb +3 -3
  38. data/lib/bio/appl/hmmer.rb +1 -1
  39. data/lib/bio/appl/hmmer/report.rb +10 -10
  40. data/lib/bio/appl/paml/baseml.rb +95 -0
  41. data/lib/bio/appl/paml/baseml/report.rb +32 -0
  42. data/lib/bio/appl/paml/codeml.rb +242 -0
  43. data/lib/bio/appl/paml/codeml/rates.rb +67 -0
  44. data/lib/bio/appl/paml/codeml/report.rb +67 -0
  45. data/lib/bio/appl/paml/common.rb +348 -0
  46. data/lib/bio/appl/paml/common_report.rb +38 -0
  47. data/lib/bio/appl/paml/yn00.rb +103 -0
  48. data/lib/bio/appl/paml/yn00/report.rb +32 -0
  49. data/lib/bio/appl/psort.rb +2 -2
  50. data/lib/bio/appl/pts1.rb +5 -5
  51. data/lib/bio/appl/tmhmm/report.rb +10 -1
  52. data/lib/bio/command.rb +297 -41
  53. data/lib/bio/compat/features.rb +157 -0
  54. data/lib/bio/compat/references.rb +128 -0
  55. data/lib/bio/db/biosql/biosql_to_biosequence.rb +67 -0
  56. data/lib/bio/db/biosql/sequence.rb +508 -0
  57. data/lib/bio/db/embl/common.rb +28 -12
  58. data/lib/bio/db/embl/embl.rb +107 -9
  59. data/lib/bio/db/embl/embl_to_biosequence.rb +85 -0
  60. data/lib/bio/db/embl/format_embl.rb +190 -0
  61. data/lib/bio/db/embl/sptr.rb +15 -16
  62. data/lib/bio/db/fantom.rb +6 -8
  63. data/lib/bio/db/fasta.rb +10 -507
  64. data/lib/bio/db/fasta/defline.rb +532 -0
  65. data/lib/bio/db/fasta/fasta_to_biosequence.rb +63 -0
  66. data/lib/bio/db/fasta/format_fasta.rb +97 -0
  67. data/lib/bio/db/genbank/common.rb +25 -8
  68. data/lib/bio/db/genbank/format_genbank.rb +187 -0
  69. data/lib/bio/db/genbank/genbank.rb +36 -1
  70. data/lib/bio/db/genbank/genbank_to_biosequence.rb +86 -0
  71. data/lib/bio/db/gff.rb +1791 -119
  72. data/lib/bio/db/kegg/glycan.rb +2 -6
  73. data/lib/bio/db/lasergene.rb +3 -3
  74. data/lib/bio/db/medline.rb +4 -1
  75. data/lib/bio/db/newick.rb +10 -10
  76. data/lib/bio/db/pdb/chain.rb +6 -2
  77. data/lib/bio/db/pdb/pdb.rb +12 -3
  78. data/lib/bio/db/rebase.rb +7 -8
  79. data/lib/bio/db/soft.rb +3 -3
  80. data/lib/bio/feature.rb +1 -88
  81. data/lib/bio/io/biosql/biodatabase.rb +64 -0
  82. data/lib/bio/io/biosql/bioentry.rb +29 -0
  83. data/lib/bio/io/biosql/bioentry_dbxref.rb +11 -0
  84. data/lib/bio/io/biosql/bioentry_path.rb +12 -0
  85. data/lib/bio/io/biosql/bioentry_qualifier_value.rb +10 -0
  86. data/lib/bio/io/biosql/bioentry_reference.rb +10 -0
  87. data/lib/bio/io/biosql/bioentry_relationship.rb +10 -0
  88. data/lib/bio/io/biosql/biosequence.rb +11 -0
  89. data/lib/bio/io/biosql/comment.rb +7 -0
  90. data/lib/bio/io/biosql/config/database.yml +20 -0
  91. data/lib/bio/io/biosql/dbxref.rb +13 -0
  92. data/lib/bio/io/biosql/dbxref_qualifier_value.rb +12 -0
  93. data/lib/bio/io/biosql/location.rb +32 -0
  94. data/lib/bio/io/biosql/location_qualifier_value.rb +11 -0
  95. data/lib/bio/io/biosql/ontology.rb +10 -0
  96. data/lib/bio/io/biosql/reference.rb +9 -0
  97. data/lib/bio/io/biosql/seqfeature.rb +32 -0
  98. data/lib/bio/io/biosql/seqfeature_dbxref.rb +11 -0
  99. data/lib/bio/io/biosql/seqfeature_path.rb +11 -0
  100. data/lib/bio/io/biosql/seqfeature_qualifier_value.rb +20 -0
  101. data/lib/bio/io/biosql/seqfeature_relationship.rb +11 -0
  102. data/lib/bio/io/biosql/taxon.rb +12 -0
  103. data/lib/bio/io/biosql/taxon_name.rb +9 -0
  104. data/lib/bio/io/biosql/term.rb +27 -0
  105. data/lib/bio/io/biosql/term_dbxref.rb +11 -0
  106. data/lib/bio/io/biosql/term_path.rb +12 -0
  107. data/lib/bio/io/biosql/term_relationship.rb +13 -0
  108. data/lib/bio/io/biosql/term_relationship_term.rb +11 -0
  109. data/lib/bio/io/biosql/term_synonym.rb +10 -0
  110. data/lib/bio/io/das.rb +7 -7
  111. data/lib/bio/io/ddbjxml.rb +57 -0
  112. data/lib/bio/io/ensembl.rb +2 -2
  113. data/lib/bio/io/fetch.rb +28 -14
  114. data/lib/bio/io/flatfile.rb +17 -853
  115. data/lib/bio/io/flatfile/autodetection.rb +545 -0
  116. data/lib/bio/io/flatfile/buffer.rb +237 -0
  117. data/lib/bio/io/flatfile/index.rb +17 -7
  118. data/lib/bio/io/flatfile/indexer.rb +30 -12
  119. data/lib/bio/io/flatfile/splitter.rb +297 -0
  120. data/lib/bio/io/hinv.rb +442 -0
  121. data/lib/bio/io/keggapi.rb +2 -2
  122. data/lib/bio/io/ncbirest.rb +733 -0
  123. data/lib/bio/io/pubmed.rb +34 -80
  124. data/lib/bio/io/registry.rb +2 -2
  125. data/lib/bio/io/sql.rb +178 -357
  126. data/lib/bio/io/togows.rb +458 -0
  127. data/lib/bio/location.rb +106 -11
  128. data/lib/bio/pathway.rb +120 -14
  129. data/lib/bio/reference.rb +115 -101
  130. data/lib/bio/sequence.rb +164 -183
  131. data/lib/bio/sequence/adapter.rb +108 -0
  132. data/lib/bio/sequence/common.rb +22 -45
  133. data/lib/bio/sequence/compat.rb +2 -2
  134. data/lib/bio/sequence/dblink.rb +54 -0
  135. data/lib/bio/sequence/format.rb +254 -77
  136. data/lib/bio/sequence/format_raw.rb +23 -0
  137. data/lib/bio/shell.rb +3 -1
  138. data/lib/bio/shell/core.rb +2 -2
  139. data/lib/bio/shell/plugin/entry.rb +33 -4
  140. data/lib/bio/shell/plugin/ncbirest.rb +64 -0
  141. data/lib/bio/shell/plugin/togows.rb +40 -0
  142. data/lib/bio/shell/rails/vendor/plugins/{generators → bioruby/generators}/bioruby/bioruby_generator.rb +0 -0
  143. data/lib/bio/shell/rails/vendor/plugins/{generators → bioruby/generators}/bioruby/templates/_classes.rhtml +0 -0
  144. data/lib/bio/shell/rails/vendor/plugins/{generators → bioruby/generators}/bioruby/templates/_log.rhtml +0 -0
  145. data/lib/bio/shell/rails/vendor/plugins/{generators → bioruby/generators}/bioruby/templates/_methods.rhtml +0 -0
  146. data/lib/bio/shell/rails/vendor/plugins/{generators → bioruby/generators}/bioruby/templates/_modules.rhtml +0 -0
  147. data/lib/bio/shell/rails/vendor/plugins/{generators → bioruby/generators}/bioruby/templates/_variables.rhtml +0 -0
  148. data/lib/bio/shell/rails/vendor/plugins/{generators → bioruby/generators}/bioruby/templates/bioruby-bg.gif +0 -0
  149. data/lib/bio/shell/rails/vendor/plugins/{generators → bioruby/generators}/bioruby/templates/bioruby-gem.png +0 -0
  150. data/lib/bio/shell/rails/vendor/plugins/{generators → bioruby/generators}/bioruby/templates/bioruby-link.gif +0 -0
  151. data/lib/bio/shell/rails/vendor/plugins/{generators → bioruby/generators}/bioruby/templates/bioruby.css +0 -0
  152. data/lib/bio/shell/rails/vendor/plugins/{generators → bioruby/generators}/bioruby/templates/bioruby.rhtml +0 -0
  153. data/lib/bio/shell/rails/vendor/plugins/{generators → bioruby/generators}/bioruby/templates/bioruby_controller.rb +0 -0
  154. data/lib/bio/shell/rails/vendor/plugins/{generators → bioruby/generators}/bioruby/templates/bioruby_helper.rb +0 -0
  155. data/lib/bio/shell/rails/vendor/plugins/{generators → bioruby/generators}/bioruby/templates/commands.rhtml +0 -0
  156. data/lib/bio/shell/rails/vendor/plugins/{generators → bioruby/generators}/bioruby/templates/history.rhtml +0 -0
  157. data/lib/bio/shell/rails/vendor/plugins/{generators → bioruby/generators}/bioruby/templates/index.rhtml +0 -0
  158. data/lib/bio/shell/rails/vendor/plugins/{generators → bioruby/generators}/bioruby/templates/spinner.gif +0 -0
  159. data/lib/bio/tree.rb +4 -2
  160. data/lib/bio/util/color_scheme.rb +2 -2
  161. data/lib/bio/util/contingency_table.rb +2 -2
  162. data/lib/bio/util/restriction_enzyme.rb +2 -2
  163. data/lib/bio/util/restriction_enzyme/single_strand.rb +6 -5
  164. data/lib/bio/version.rb +25 -0
  165. data/rdoc.zsh +8 -0
  166. data/sample/any2fasta.rb +0 -0
  167. data/sample/biofetch.rb +0 -0
  168. data/sample/dbget +0 -0
  169. data/sample/demo_sequence.rb +158 -0
  170. data/sample/enzymes.rb +0 -0
  171. data/sample/fasta2tab.rb +0 -0
  172. data/sample/fastagrep.rb +72 -0
  173. data/sample/fastasort.rb +54 -0
  174. data/sample/fsplit.rb +0 -0
  175. data/sample/gb2fasta.rb +2 -3
  176. data/sample/gb2tab.rb +0 -0
  177. data/sample/gbtab2mysql.rb +0 -0
  178. data/sample/genes2nuc.rb +0 -0
  179. data/sample/genes2pep.rb +0 -0
  180. data/sample/genes2tab.rb +0 -0
  181. data/sample/genome2rb.rb +0 -0
  182. data/sample/genome2tab.rb +0 -0
  183. data/sample/goslim.rb +0 -0
  184. data/sample/gt2fasta.rb +0 -0
  185. data/sample/na2aa.rb +34 -0
  186. data/sample/pmfetch.rb +0 -0
  187. data/sample/pmsearch.rb +0 -0
  188. data/sample/ssearch2tab.rb +0 -0
  189. data/sample/tfastx2tab.rb +0 -0
  190. data/sample/vs-genes.rb +0 -0
  191. data/setup.rb +1596 -0
  192. data/test/data/blast/blastp-multi.m7 +188 -0
  193. data/test/data/command/echoarg2.bat +1 -0
  194. data/test/data/paml/codeml/control_file.txt +30 -0
  195. data/test/data/paml/codeml/output.txt +78 -0
  196. data/test/data/paml/codeml/rates +217 -0
  197. data/test/data/rpsblast/misc.rpsblast +193 -0
  198. data/test/data/soft/GDS100_partial.soft +0 -0
  199. data/test/data/soft/GSE3457_family_partial.soft +0 -0
  200. data/test/functional/bio/appl/test_pts1.rb +115 -0
  201. data/test/functional/bio/io/test_ensembl.rb +123 -80
  202. data/test/functional/bio/io/test_togows.rb +267 -0
  203. data/test/functional/bio/sequence/test_output_embl.rb +51 -0
  204. data/test/functional/bio/test_command.rb +301 -0
  205. data/test/runner.rb +17 -1
  206. data/test/unit/bio/appl/blast/test_ncbioptions.rb +112 -0
  207. data/test/unit/bio/appl/blast/test_report.rb +753 -35
  208. data/test/unit/bio/appl/blast/test_rpsblast.rb +398 -0
  209. data/test/unit/bio/appl/paml/codeml/test_rates.rb +45 -0
  210. data/test/unit/bio/appl/paml/codeml/test_report.rb +45 -0
  211. data/test/unit/bio/appl/paml/test_codeml.rb +174 -0
  212. data/test/unit/bio/appl/test_blast.rb +135 -4
  213. data/test/unit/bio/appl/test_fasta.rb +2 -2
  214. data/test/unit/bio/appl/test_pts1.rb +1 -64
  215. data/test/unit/bio/db/embl/test_common.rb +15 -15
  216. data/test/unit/bio/db/embl/test_embl.rb +4 -4
  217. data/test/unit/bio/db/embl/test_embl_rel89.rb +5 -5
  218. data/test/unit/bio/db/embl/test_embl_to_bioseq.rb +203 -0
  219. data/test/unit/bio/db/embl/test_sptr.rb +38 -1
  220. data/test/unit/bio/db/pdb/test_pdb.rb +2 -2
  221. data/test/unit/bio/db/test_gff.rb +1151 -25
  222. data/test/unit/bio/db/test_medline.rb +127 -0
  223. data/test/unit/bio/db/test_nexus.rb +5 -1
  224. data/test/unit/bio/db/test_prosite.rb +4 -4
  225. data/test/unit/bio/io/flatfile/test_autodetection.rb +375 -0
  226. data/test/unit/bio/io/flatfile/test_buffer.rb +251 -0
  227. data/test/unit/bio/io/flatfile/test_splitter.rb +369 -0
  228. data/test/unit/bio/io/test_ddbjxml.rb +8 -3
  229. data/test/unit/bio/io/test_fastacmd.rb +5 -5
  230. data/test/unit/bio/io/test_flatfile.rb +357 -106
  231. data/test/unit/bio/io/test_soapwsdl.rb +2 -2
  232. data/test/unit/bio/io/test_togows.rb +161 -0
  233. data/test/unit/bio/sequence/test_common.rb +210 -11
  234. data/test/unit/bio/sequence/test_compat.rb +3 -3
  235. data/test/unit/bio/sequence/test_dblink.rb +58 -0
  236. data/test/unit/bio/sequence/test_na.rb +2 -2
  237. data/test/unit/bio/test_command.rb +111 -50
  238. data/test/unit/bio/test_feature.rb +29 -1
  239. data/test/unit/bio/test_location.rb +566 -6
  240. data/test/unit/bio/test_pathway.rb +91 -65
  241. data/test/unit/bio/test_reference.rb +67 -13
  242. data/test/unit/bio/util/restriction_enzyme/analysis/test_calculated_cuts.rb +3 -3
  243. data/test/unit/bio/util/restriction_enzyme/analysis/test_cut_ranges.rb +3 -3
  244. data/test/unit/bio/util/restriction_enzyme/analysis/test_sequence_range.rb +3 -3
  245. data/test/unit/bio/util/restriction_enzyme/double_stranded/test_aligned_strands.rb +4 -3
  246. data/test/unit/bio/util/restriction_enzyme/double_stranded/test_cut_location_pair.rb +3 -3
  247. data/test/unit/bio/util/restriction_enzyme/double_stranded/test_cut_location_pair_in_enzyme_notation.rb +3 -3
  248. data/test/unit/bio/util/restriction_enzyme/double_stranded/test_cut_locations.rb +3 -3
  249. data/test/unit/bio/util/restriction_enzyme/double_stranded/test_cut_locations_in_enzyme_notation.rb +3 -3
  250. data/test/unit/bio/util/restriction_enzyme/single_strand/test_cut_locations_in_enzyme_notation.rb +3 -3
  251. data/test/unit/bio/util/restriction_enzyme/test_analysis.rb +3 -3
  252. data/test/unit/bio/util/restriction_enzyme/test_cut_symbol.rb +4 -4
  253. data/test/unit/bio/util/restriction_enzyme/test_double_stranded.rb +3 -3
  254. data/test/unit/bio/util/restriction_enzyme/test_single_strand.rb +3 -3
  255. data/test/unit/bio/util/restriction_enzyme/test_single_strand_complement.rb +3 -3
  256. data/test/unit/bio/util/restriction_enzyme/test_string_formatting.rb +3 -3
  257. data/test/unit/bio/util/test_restriction_enzyme.rb +3 -3
  258. metadata +202 -167
  259. data/test/unit/bio/appl/blast/test_xmlparser.rb +0 -388
@@ -4,7 +4,7 @@
4
4
  # Copyright:: Copyright (C) 2004 Toshiaki Katayama <k@bioruby.org>
5
5
  # License:: The Ruby License
6
6
  #
7
- # $Id: glycan.rb,v 1.7 2007/12/14 16:20:38 k Exp $
7
+ # $Id:$
8
8
  #
9
9
 
10
10
  require 'bio/db'
@@ -46,11 +46,7 @@ class GLYCAN < KEGGDB
46
46
  # MASS
47
47
  def mass
48
48
  unless @data['MASS']
49
- hash = Hash.new
50
- fetch('MASS').scan(/(\S+)\s+\((\S+)\)/).each do |val, key|
51
- hash[key] = val.to_f
52
- end
53
- @data['MASS'] = hash
49
+ @data['MASS'] = field_fetch('MASS')[/[\d\.]+/].to_f
54
50
  end
55
51
  @data['MASS']
56
52
  end
@@ -5,10 +5,10 @@
5
5
  # Copyright:: Copyright (c) 2007 Center for Biomedical Research Informatics, University of Minnesota (http://cbri.umn.edu)
6
6
  # License:: The Ruby License
7
7
  #
8
- # $Id: lasergene.rb,v 1.3 2007/04/05 23:35:40 trevor Exp $
8
+ # $Id:$
9
9
  #
10
10
 
11
- module Bio #:nodoc:
11
+ module Bio
12
12
 
13
13
  #
14
14
  # bio/db/lasergene.rb - Interface for DNAStar Lasergene sequence file format
@@ -206,4 +206,4 @@ class Lasergene
206
206
  @sequence = Bio::Sequence.auto( lines[ (delimiter_2_indices[0] + 1) .. -1 ].join('') )
207
207
  end
208
208
  end # Lasergene
209
- end # Bio
209
+ end # Bio
@@ -153,7 +153,10 @@ class MEDLINE < NCBIDB
153
153
  au.split(/\n/).each do |author|
154
154
  if author =~ / /
155
155
  name = author.split(/\s+/)
156
- suffix = name[-2] =~ /^[A-Z]+$/ ? name.pop : nil # Jr etc.
156
+ suffix = nil
157
+ if name.length > 2 && name[-2] =~ /^[A-Z]+$/ # second to last are the initials
158
+ suffix = name.pop
159
+ end
157
160
  initial = name.pop.split(//).join('. ')
158
161
  author = "#{name.join(' ')}, #{initial}."
159
162
  end
@@ -6,7 +6,7 @@
6
6
  # Daniel Amelang <dan@amelang.net>
7
7
  # License:: The Ruby License
8
8
  #
9
- # $Id: newick.rb,v 1.8 2007/12/12 16:06:22 ngoto Exp $
9
+ # $Id:$
10
10
  #
11
11
  # == Description
12
12
  #
@@ -606,9 +606,9 @@ module Bio
606
606
  # If all of the internal node's names are numeric,
607
607
  # the names are regarded as bootstrap values.
608
608
  flag = false
609
- internal_nodes.each do |node|
610
- if node.name and !node.name.to_s.strip.empty? then
611
- if /\A[\+\-]?\d*\.?\d*\z/ =~ node.name
609
+ internal_nodes.each do |inode|
610
+ if inode.name and !inode.name.to_s.strip.empty? then
611
+ if /\A[\+\-]?\d*\.?\d*\z/ =~ inode.name
612
612
  flag = true
613
613
  else
614
614
  flag = false
@@ -619,17 +619,17 @@ module Bio
619
619
  if flag then
620
620
  @options[:bootstrap_style] = :traditional
621
621
  @options[:original_format] = :traditional
622
- internal_nodes.each do |node|
623
- if node.name then
624
- node.bootstrap_string = node.name
625
- node.name = nil
622
+ internal_nodes.each do |inode|
623
+ if inode.name then
624
+ inode.bootstrap_string = inode.name
625
+ inode.name = nil
626
626
  end
627
627
  end
628
628
  end
629
629
  end
630
630
  # Sets nodes order numbers
631
- nodes.each_with_index do |node, i|
632
- node.order_number = i
631
+ nodes.each_with_index do |xnode, i|
632
+ xnode.order_number = i
633
633
  end
634
634
  # If the root implicitly prepared by the program is a leaf and
635
635
  # there are no additional information for the edge from the root to
@@ -6,7 +6,7 @@
6
6
  # Naohisa Goto <ng@bioruby.org>
7
7
  # License:: The Ruby License
8
8
  #
9
- # $Id: chain.rb,v 1.9 2007/12/18 13:48:42 ngoto Exp $
9
+ # $Id: chain.rb,v 1.10 2008/04/01 10:36:44 ngoto Exp $
10
10
  #
11
11
  # = Bio::PDB::Chain
12
12
  #
@@ -189,7 +189,11 @@ module Bio
189
189
  x.times { string << 'X' }
190
190
  end
191
191
  tlc = residue.resName.capitalize
192
- olc = (Bio::AminoAcid.three2one(tlc) or 'X')
192
+ olc = (begin
193
+ Bio::AminoAcid.three2one(tlc)
194
+ rescue ArgumentError
195
+ nil
196
+ end || 'X')
193
197
  string << olc
194
198
  end
195
199
  @aaseq = Bio::Sequence::AA.new(string)
@@ -6,7 +6,7 @@
6
6
  # Alex Gutteridge <alexg@ebi.ac.uk>
7
7
  # License:: The Ruby License
8
8
  #
9
- # $Id: pdb.rb,v 1.27 2007/12/28 14:43:44 ngoto Exp $
9
+ # $Id: pdb.rb,v 1.28 2008/04/01 10:36:44 ngoto Exp $
10
10
  #
11
11
  # = About Bio::PDB
12
12
  #
@@ -1497,6 +1497,9 @@ module Bio
1497
1497
  cChain = newChain
1498
1498
  chain = newChain
1499
1499
  end
1500
+ # chain might be changed, clearing cResidue and cLigand
1501
+ cResidue = nil
1502
+ cLigand = nil
1500
1503
  end
1501
1504
  end
1502
1505
 
@@ -1550,6 +1553,8 @@ module Bio
1550
1553
  when 'MODEL'
1551
1554
  c_atom = nil
1552
1555
  cChain = nil
1556
+ cResidue = nil
1557
+ cLigand = nil
1553
1558
  if cModel.model_serial or cModel.chains.size > 0 then
1554
1559
  self.addModel(cModel)
1555
1560
  end
@@ -1809,13 +1814,17 @@ module Bio
1809
1814
  #aa is three letter code: i.e. ALA
1810
1815
  #need to look up with Ala
1811
1816
  aa = aa.capitalize
1812
- (Bio::AminoAcid.three2one(aa) or 'X')
1817
+ (begin
1818
+ Bio::AminoAcid.three2one(aa)
1819
+ rescue ArgumentError
1820
+ nil
1821
+ end || 'X')
1813
1822
  end
1814
1823
  seq = Bio::Sequence::AA.new(a.to_s)
1815
1824
  else
1816
1825
  # nucleic acid sequence
1817
1826
  a.collect! do |na|
1818
- na = na.strip
1827
+ na = na.delete('^a-zA-Z')
1819
1828
  na.size == 1 ? na : 'n'
1820
1829
  end
1821
1830
  seq = Bio::Sequence::NA.new(a.to_s)
@@ -5,14 +5,13 @@
5
5
  # Copyright:: Copyright (c) 2005-2007 Midwinter Laboratories, LLC (http://midwinterlabs.com)
6
6
  # License:: The Ruby License
7
7
  #
8
- # $Id: rebase.rb,v 1.8 2007/04/05 23:35:40 trevor Exp $
8
+ # $Id:$
9
9
  #
10
10
 
11
- autoload :YAML, 'yaml'
11
+ require 'yaml'
12
+ require 'bio/reference'
12
13
 
13
- module Bio #:nodoc:
14
-
15
- autoload :Reference, 'bio/reference'
14
+ module Bio
16
15
 
17
16
  #
18
17
  # bio/db/rebase.rb - Interface for EMBOSS formatted REBASE files
@@ -316,7 +315,7 @@ class REBASE
316
315
  def parse_enzymes( lines )
317
316
  data = {}
318
317
  return data if lines == nil
319
- lines.each do |line|
318
+ lines.each_line do |line|
320
319
  next if line[0].chr == '#'
321
320
  line.chomp!
322
321
 
@@ -347,7 +346,7 @@ class REBASE
347
346
  h = {}
348
347
  references_left = 0
349
348
 
350
- lines.each do |line|
349
+ lines.each_line do |line|
351
350
  next if line[0].chr == '#' # Comment
352
351
  next if line[0..1] == '//' # End of entry marker
353
352
  line.chomp!
@@ -389,7 +388,7 @@ class REBASE
389
388
  def parse_suppliers( lines )
390
389
  data = {}
391
390
  return data if lines == nil
392
- lines.each do |line|
391
+ lines.each_line do |line|
393
392
  next if line[0].chr == '#'
394
393
  data[$1] = $2 if line =~ %r{(.+?)\s(.+)}
395
394
  end
@@ -5,10 +5,10 @@
5
5
  # Copyright:: Copyright (c) 2007 Midwinter Laboratories, LLC (http://midwinterlabs.com)
6
6
  # License:: The Ruby License
7
7
  #
8
- # $Id: soft.rb,v 1.2 2007/04/05 23:35:40 trevor Exp $
8
+ # $Id:$
9
9
  #
10
10
 
11
- module Bio #:nodoc:
11
+ module Bio
12
12
 
13
13
  #
14
14
  # bio/db/soft.rb - Interface for SOFT formatted files
@@ -401,4 +401,4 @@ class SOFT
401
401
  end
402
402
 
403
403
  end # SOFT
404
- end # Bio
404
+ end # Bio
@@ -5,7 +5,7 @@
5
5
  # 2006 Jan Aerts <jan.aerts@bbsrc.ac.uk>
6
6
  # License:: The Ruby License
7
7
  #
8
- # $Id: feature.rb,v 1.13 2007/04/05 23:35:39 trevor Exp $
8
+ # $Id: feature.rb,v 1.13.2.1 2008/03/04 10:12:22 ngoto Exp $
9
9
 
10
10
  require 'bio/location'
11
11
 
@@ -135,92 +135,5 @@ class Feature
135
135
 
136
136
  end #Feature
137
137
 
138
-
139
- # = DESCRIPTION
140
- # Container for a list of Feature objects.
141
- #
142
- # = USAGE
143
- # # First, create some Bio::Feature objects
144
- # feature1 = Bio::Feature.new('intron','3627..4059')
145
- # feature2 = Bio::Feature.new('exon','4060..4236')
146
- # feature3 = Bio::Feature.new('intron','4237..4426')
147
- # feature4 = Bio::Feature.new('CDS','join(2538..3626,4060..4236)',
148
- # [ Bio::Feature::Qualifier.new('gene', 'CYP2D6'),
149
- # Bio::Feature::Qualifier.new('translation','MGXXTVMHLL...')
150
- # ])
151
- #
152
- # # And create a container for them
153
- # feature_container = Bio::Features.new([ feature1, feature2, feature3, feature4 ])
154
- #
155
- # # Iterate over all features and print
156
- # feature_container.each do |feature|
157
- # puts feature.feature + "\t" + feature.position
158
- # feature.each do |qualifier|
159
- # puts "- " + qualifier.qualifier + ": " + qualifier.value
160
- # end
161
- # end
162
- #
163
- # # Iterate only over CDS features and extract translated amino acid sequences
164
- # features.each("CDS") do |feature|
165
- # hash = feature.to_hash
166
- # name = hash["gene"] || hash["product"] || hash["note"]
167
- # aaseq = hash["translation"]
168
- # pos = feature.position
169
- # if name and seq
170
- # puts ">#{gene} #{feature.position}"
171
- # puts aaseq
172
- # end
173
- # end
174
- class Features
175
- # Create a new Bio::Features object.
176
- #
177
- # *Arguments*:
178
- # * (optional) _list of features_: list of Bio::Feature objects
179
- # *Returns*:: Bio::Features object
180
- def initialize(ary = [])
181
- @features = ary
182
- end
183
-
184
- # Returns an Array of Feature objects.
185
- attr_accessor :features
186
-
187
- # Appends a Feature object to Features.
188
- #
189
- # *Arguments*:
190
- # * (required) _feature_: Bio::Feature object
191
- # *Returns*:: Bio::Features object
192
- def append(a)
193
- @features.push(a) if a.is_a? Feature
194
- return self
195
- end
196
-
197
- # Iterates on each feature object.
198
- #
199
- # *Arguments*:
200
- # * (optional) _key_: if specified, only iterates over features with this key
201
- def each(arg = nil)
202
- @features.each do |x|
203
- next if arg and x.feature != arg
204
- yield x
205
- end
206
- end
207
-
208
- # Short cut for the Features#features[n]
209
- def [](*arg)
210
- @features[*arg]
211
- end
212
-
213
- # Short cut for the Features#features.first
214
- def first
215
- @features.first
216
- end
217
-
218
- # Short cut for the Features#features.last
219
- def last
220
- @features.last
221
- end
222
-
223
- end # Features
224
-
225
138
  end # Bio
226
139
 
@@ -0,0 +1,64 @@
1
+ module Bio
2
+ class SQL
3
+ class Biodatabase < DummyBase
4
+ has_many :bioentries, :class_name =>"Bioentry", :foreign_key => "biodatabase_id"
5
+ validates_uniqueness_of :name
6
+ end
7
+ end #SQL
8
+ end #Bio
9
+
10
+
11
+ if __FILE__ == $0
12
+ require 'rubygems'
13
+ require 'composite_primary_keys'
14
+ require 'bio'
15
+ require 'pp'
16
+
17
+ # pp connection = Bio::SQL.establish_connection('bio/io/biosql/config/database.yml','development')
18
+ pp connection = Bio::SQL.establish_connection({'test'=>{'database'=>"bio_test", 'adapter'=>"postgresql", 'username'=>"rails", 'password'=>nil}},'test')
19
+ #pp YAML::load(ERB.new(IO.read('bio/io/biosql/config/database.yml')).result)
20
+ if true
21
+ pp Bio::SQL.list_entries
22
+
23
+ puts "### GenBank"
24
+ if ARGV.size > 0
25
+ gb = Bio::GenBank.new(ARGF.read)
26
+ else
27
+ require 'bio/io/fetch'
28
+ gb = Bio::GenBank.new(Bio::Fetch.query('gb', 'AJ224122'))
29
+ end
30
+
31
+ biosequence = gb.to_biosequence
32
+ db=Bio::SQL::Biodatabase.new(:biodatabase_id=>3,:name=>"JEFF", :authority=>"ME", :description=>"YOU")
33
+ db.save!
34
+
35
+ #sqlseq = Bio::SQL::Sequence.new(:biosequence=>biosequence,:biodatabase_id=>db.id)
36
+
37
+ # bioseq = Bio::SQL.fetch_accession('AJ224122')
38
+ # pp bioseq
39
+ # pp bioseq.entry_id
40
+ #TODO create a test only for tables not sequence here
41
+ # pp bioseq.molecule_type
42
+ #pp bioseq.molecule_type.class
43
+ #bioseq.molecule_type_update('dna', 1)
44
+ pp Bio::SQL::Taxon.find(8121).taxon_names
45
+
46
+ #sqlseq.to_biosequence
47
+
48
+ #sqlseq.delete
49
+ end
50
+ #pp bioseq.molecule_type
51
+ #term = Bio::SQL::Term.find_by_name('mol_type')
52
+ #pp term
53
+ #pp bioseq.entry.bioentry_qualifier_values.create(:term=>term, :rank=>2, :value=>'pippo')
54
+ #pp bioseq.entry.bioentry_qualifier_values.inspect
55
+ #pp bioseq.entry.bioentry_qualifier_values.find_all_by_term_id(26)
56
+ #pp primo.class
57
+ # pp primo.value='dna'
58
+ # pp primo.save
59
+ #pp bioseq.molecule_type= 'prova'
60
+
61
+ #Bio::SQL::BioentryQualifierValue.delete(delete.bioentry_id,delete.term_id,delete.rank)
62
+
63
+
64
+ end
@@ -0,0 +1,29 @@
1
+ module Bio
2
+ class SQL
3
+ class Bioentry < DummyBase
4
+ belongs_to :biodatabase, :class_name => "Biodatabase"
5
+ belongs_to :taxon, :class_name => "Taxon"
6
+ has_one :biosequence
7
+ #, :class_name => "Biosequence", :foreign_key => "bioentry_id"
8
+ has_many :comments, :class_name =>"Comment", :order =>'rank'
9
+ has_many :seqfeatures, :class_name => "Seqfeature", :order=>'rank'
10
+ has_many :bioentry_references, :class_name=>"BioentryReference" #, :foreign_key => "bioentry_id"
11
+ has_many :bioentry_dbxrefs, :class_name => "BioentryDbxref"
12
+ has_many :object_bioentry_relationships, :class_name=>"BioentryRelationship", :foreign_key=>"object_bioentry_id" #non mi convince molto credo non funzioni nel modo corretto
13
+ has_many :subject_bioentry_relationships, :class_name=>"BioentryRelationship", :foreign_key=>"subject_bioentry_id" #non mi convince molto credo non funzioni nel modo corretto
14
+
15
+ has_many :cdsfeatures, :class_name=>"Seqfeature", :foreign_key =>"bioentry_id", :conditions=>["term.name='CDS'"], :include=>"type_term"
16
+
17
+ has_many :terms, :through=>:bioentry_qualifier_values, :class_name => "Term"
18
+ #NOTE: added order_by for multiple hit and manage ranks correctly
19
+ has_many :bioentry_qualifier_values, :order=>"bioentry_id,term_id,rank", :class_name => "BioentryQualifierValue"
20
+
21
+ #per la creazione richiesti:
22
+ #name, accession, version
23
+ # validates_uniqueness_of :accession, :scope=>[:biodatabase_id]
24
+ # validates_uniqueness_of :name, :scope=>[:biodatabase_id]
25
+ # validates_uniqueness_of :identifier, :scope=>[:biodatabase_id]
26
+
27
+ end
28
+ end #SQL
29
+ end #Bio
@@ -0,0 +1,11 @@
1
+ module Bio
2
+ class SQL
3
+ class BioentryDbxref < DummyBase
4
+ #delete set_sequence_name nil
5
+ set_primary_key nil #bioentry_id,dbxref_id
6
+ belongs_to :bioentry, :class_name => "Bioentry"
7
+ belongs_to :dbxref, :class_name => "Dbxref"
8
+ end
9
+ end #SQL
10
+ end #Bio
11
+
@@ -0,0 +1,12 @@
1
+ module Bio
2
+ class SQL
3
+ class BioentryPath < DummyBase
4
+ set_primary_key nil
5
+ #delete set_sequence_name nil
6
+ belongs_to :term, :class_name => "Term"
7
+ #da sistemare per poter procedere.
8
+ belongs_to :object_bioentry, :class_name=>"Bioentry"
9
+ belongs_to :subject_bioentry, :class_name=>"Bioentry"
10
+ end #BioentryPath
11
+ end #SQL
12
+ end #Bio