bio 1.4.2 → 1.4.3
Sign up to get free protection for your applications and to get access to all the features.
- data/.travis.yml +66 -0
- data/ChangeLog +989 -4524
- data/KNOWN_ISSUES.rdoc +67 -2
- data/README.rdoc +89 -23
- data/README_DEV.rdoc +93 -2
- data/RELEASE_NOTES.rdoc +167 -95
- data/Rakefile +199 -7
- data/bioruby.gemspec +27 -12
- data/bioruby.gemspec.erb +6 -3
- data/doc/ChangeLog-before-1.4.2 +5013 -0
- data/doc/RELEASE_NOTES-1.4.2.rdoc +132 -0
- data/doc/Tutorial.rd +21 -3
- data/doc/Tutorial.rd.html +20 -12
- data/etc/bioinformatics/seqdatabase.ini +13 -196
- data/gemfiles/Gemfile.travis-jruby1.8 +7 -0
- data/gemfiles/Gemfile.travis-jruby1.9 +10 -0
- data/gemfiles/Gemfile.travis-ruby1.8 +7 -0
- data/gemfiles/Gemfile.travis-ruby1.9 +10 -0
- data/gemfiles/modify-Gemfile.rb +28 -0
- data/gemfiles/prepare-gemspec.rb +25 -0
- data/lib/bio/alignment.rb +1 -1
- data/lib/bio/appl/bl2seq/report.rb +3 -3
- data/lib/bio/appl/blast/ddbj.rb +0 -3
- data/lib/bio/appl/blast/format0.rb +4 -22
- data/lib/bio/appl/blast/genomenet.rb +33 -16
- data/lib/bio/appl/blast/ncbioptions.rb +8 -3
- data/lib/bio/appl/blast/remote.rb +6 -5
- data/lib/bio/appl/blast/report.rb +10 -6
- data/lib/bio/appl/blast/rpsblast.rb +3 -2
- data/lib/bio/appl/blast/wublast.rb +3 -3
- data/lib/bio/command.rb +118 -36
- data/lib/bio/data/na.rb +1 -1
- data/lib/bio/db/embl/embl.rb +74 -0
- data/lib/bio/db/embl/format_embl.rb +0 -4
- data/lib/bio/db/fasta.rb +57 -45
- data/lib/bio/db/fasta/defline.rb +1 -1
- data/lib/bio/db/fasta/format_fasta.rb +0 -4
- data/lib/bio/db/fasta/format_qual.rb +0 -5
- data/lib/bio/db/fastq/format_fastq.rb +0 -1
- data/lib/bio/db/genbank/format_genbank.rb +0 -4
- data/lib/bio/db/gff.rb +41 -12
- data/lib/bio/db/kegg/genes.rb +3 -3
- data/lib/bio/db/kegg/kgml.rb +465 -64
- data/lib/bio/db/newick.rb +0 -244
- data/lib/bio/db/pdb.rb +1 -4
- data/lib/bio/db/pdb/atom.rb +3 -2
- data/lib/bio/db/pdb/chain.rb +2 -3
- data/lib/bio/db/pdb/chemicalcomponent.rb +3 -2
- data/lib/bio/db/pdb/model.rb +2 -2
- data/lib/bio/db/pdb/pdb.rb +2 -1
- data/lib/bio/db/pdb/residue.rb +2 -2
- data/lib/bio/db/pdb/utils.rb +7 -4
- data/lib/bio/db/phyloxml/phyloxml_parser.rb +52 -5
- data/lib/bio/feature.rb +2 -3
- data/lib/bio/io/flatfile/autodetection.rb +1 -1
- data/lib/bio/io/flatfile/buffer.rb +84 -0
- data/lib/bio/sequence.rb +6 -4
- data/lib/bio/sequence/aa.rb +3 -5
- data/lib/bio/sequence/adapter.rb +6 -6
- data/lib/bio/sequence/common.rb +3 -3
- data/lib/bio/sequence/compat.rb +2 -7
- data/lib/bio/sequence/dblink.rb +6 -5
- data/lib/bio/sequence/format.rb +0 -6
- data/lib/bio/sequence/format_raw.rb +0 -4
- data/lib/bio/sequence/generic.rb +3 -4
- data/lib/bio/sequence/na.rb +4 -6
- data/lib/bio/sequence/quality_score.rb +2 -0
- data/lib/bio/sequence/sequence_masker.rb +3 -0
- data/lib/bio/shell/core.rb +1 -0
- data/lib/bio/tree.rb +1 -2
- data/lib/bio/tree/output.rb +264 -0
- data/lib/bio/util/restriction_enzyme.rb +1 -3
- data/lib/bio/util/restriction_enzyme/analysis.rb +8 -5
- data/lib/bio/util/restriction_enzyme/analysis_basic.rb +4 -3
- data/lib/bio/util/restriction_enzyme/cut_symbol.rb +3 -2
- data/lib/bio/util/restriction_enzyme/dense_int_array.rb +3 -0
- data/lib/bio/util/restriction_enzyme/double_stranded.rb +3 -4
- data/lib/bio/util/restriction_enzyme/double_stranded/aligned_strands.rb +3 -4
- data/lib/bio/util/restriction_enzyme/double_stranded/cut_location_pair.rb +3 -4
- data/lib/bio/util/restriction_enzyme/double_stranded/cut_location_pair_in_enzyme_notation.rb +3 -4
- data/lib/bio/util/restriction_enzyme/double_stranded/cut_locations.rb +3 -4
- data/lib/bio/util/restriction_enzyme/double_stranded/cut_locations_in_enzyme_notation.rb +3 -4
- data/lib/bio/util/restriction_enzyme/range/cut_range.rb +3 -4
- data/lib/bio/util/restriction_enzyme/range/cut_ranges.rb +3 -4
- data/lib/bio/util/restriction_enzyme/range/horizontal_cut_range.rb +3 -4
- data/lib/bio/util/restriction_enzyme/range/sequence_range.rb +3 -4
- data/lib/bio/util/restriction_enzyme/range/sequence_range/calculated_cuts.rb +3 -4
- data/lib/bio/util/restriction_enzyme/range/sequence_range/fragment.rb +3 -4
- data/lib/bio/util/restriction_enzyme/range/sequence_range/fragments.rb +3 -4
- data/lib/bio/util/restriction_enzyme/range/vertical_cut_range.rb +3 -4
- data/lib/bio/util/restriction_enzyme/single_strand.rb +3 -3
- data/lib/bio/util/restriction_enzyme/single_strand/cut_locations_in_enzyme_notation.rb +3 -4
- data/lib/bio/util/restriction_enzyme/single_strand_complement.rb +3 -4
- data/lib/bio/util/restriction_enzyme/sorted_num_array.rb +3 -0
- data/lib/bio/util/restriction_enzyme/string_formatting.rb +3 -4
- data/lib/bio/version.rb +11 -2
- data/sample/seqdatabase.ini +210 -0
- data/test/bioruby_test_helper.rb +37 -12
- data/test/data/KEGG/test.kgml +37 -0
- data/test/data/command/echoarg2.bat +0 -0
- data/test/data/command/echoarg2.sh +4 -0
- data/test/functional/bio/test_command.rb +58 -28
- data/test/{functional → network}/bio/appl/blast/test_remote.rb +0 -0
- data/test/{functional → network}/bio/appl/test_blast.rb +0 -0
- data/test/{functional → network}/bio/appl/test_pts1.rb +0 -0
- data/test/{functional → network}/bio/io/test_ddbjrest.rb +0 -0
- data/test/{functional → network}/bio/io/test_ensembl.rb +0 -0
- data/test/{functional → network}/bio/io/test_pubmed.rb +0 -0
- data/test/{functional → network}/bio/io/test_soapwsdl.rb +0 -0
- data/test/{functional → network}/bio/io/test_togows.rb +0 -0
- data/test/network/bio/test_command.rb +35 -0
- data/test/runner.rb +16 -6
- data/test/unit/bio/appl/blast/test_report.rb +119 -0
- data/test/unit/bio/appl/blast/test_rpsblast.rb +1 -0
- data/test/unit/bio/data/test_na.rb +1 -1
- data/test/unit/bio/db/embl/test_embl.rb +2 -7
- data/test/unit/bio/db/embl/test_embl_rel89.rb +2 -7
- data/test/unit/bio/db/fasta/test_defline.rb +1 -1
- data/test/unit/bio/db/genbank/test_genpept.rb +1 -1
- data/test/unit/bio/db/kegg/test_drug.rb +1 -1
- data/test/unit/bio/db/kegg/test_genome.rb +1 -1
- data/test/unit/bio/db/kegg/test_glycan.rb +1 -1
- data/test/unit/bio/db/kegg/test_kgml.rb +1022 -0
- data/test/unit/bio/db/sanger_chromatogram/test_abif.rb +2 -1
- data/test/unit/bio/db/sanger_chromatogram/test_scf.rb +4 -2
- data/test/unit/bio/db/test_newick.rb +2 -0
- data/test/unit/bio/db/test_phyloxml.rb +54 -2
- data/test/unit/bio/db/test_phyloxml_writer.rb +15 -9
- data/test/unit/bio/db/test_soft.rb +1 -1
- data/test/unit/bio/io/flatfile/test_autodetection.rb +6 -0
- data/test/unit/bio/io/flatfile/test_buffer.rb +141 -0
- data/test/unit/bio/sequence/test_common.rb +36 -4
- data/test/unit/bio/sequence/test_na.rb +1 -1
- data/test/unit/bio/test_command.rb +9 -4
- data/test/unit/bio/test_sequence.rb +2 -2
- data/test/unit/bio/test_tree.rb +11 -11
- data/test/unit/bio/util/test_restriction_enzyme.rb +1 -1
- metadata +1428 -655
- data/rdoc.zsh +0 -8
data/lib/bio/db/newick.rb
CHANGED
@@ -6,7 +6,6 @@
|
|
6
6
|
# Daniel Amelang <dan@amelang.net>
|
7
7
|
# License:: The Ruby License
|
8
8
|
#
|
9
|
-
# $Id:$
|
10
9
|
#
|
11
10
|
# == Description
|
12
11
|
#
|
@@ -22,249 +21,6 @@ require 'strscan'
|
|
22
21
|
require 'bio/tree'
|
23
22
|
|
24
23
|
module Bio
|
25
|
-
class Tree
|
26
|
-
|
27
|
-
#---
|
28
|
-
# newick output
|
29
|
-
#+++
|
30
|
-
|
31
|
-
# default options
|
32
|
-
DEFAULT_OPTIONS =
|
33
|
-
{ :indent => ' ' }
|
34
|
-
|
35
|
-
def __get_option(key, options)
|
36
|
-
if (r = options[key]) != nil then
|
37
|
-
r
|
38
|
-
elsif @options && (r = @options[key]) != nil then
|
39
|
-
r
|
40
|
-
else
|
41
|
-
DEFAULT_OPTIONS[key]
|
42
|
-
end
|
43
|
-
end
|
44
|
-
private :__get_option
|
45
|
-
|
46
|
-
|
47
|
-
# formats Newick label (unquoted_label or quoted_label)
|
48
|
-
def __to_newick_format_label(str, options)
|
49
|
-
if __get_option(:parser, options) == :naive then
|
50
|
-
return str.to_s
|
51
|
-
end
|
52
|
-
str = str.to_s
|
53
|
-
if /([\(\)\,\:\[\]\_\'\x00-\x1f\x7f])/ =~ str then
|
54
|
-
# quoted_label
|
55
|
-
return "\'" + str.gsub(/\'/, "\'\'") + "\'"
|
56
|
-
end
|
57
|
-
# unquoted_label
|
58
|
-
return str.gsub(/ /, '_')
|
59
|
-
end
|
60
|
-
private :__to_newick_format_label
|
61
|
-
|
62
|
-
# formats leaf
|
63
|
-
def __to_newick_format_leaf(node, edge, options)
|
64
|
-
|
65
|
-
label = __to_newick_format_label(get_node_name(node), options)
|
66
|
-
|
67
|
-
dist = get_edge_distance_string(edge)
|
68
|
-
|
69
|
-
bs = get_node_bootstrap_string(node)
|
70
|
-
|
71
|
-
if __get_option(:branch_length_style, options) == :disabled
|
72
|
-
dist = nil
|
73
|
-
end
|
74
|
-
|
75
|
-
case __get_option(:bootstrap_style, options)
|
76
|
-
when :disabled
|
77
|
-
label + (dist ? ":#{dist}" : '')
|
78
|
-
when :molphy
|
79
|
-
label + (dist ? ":#{dist}" : '') + (bs ? "[#{bs}]" : '')
|
80
|
-
when :traditional
|
81
|
-
label + (bs ? bs : '') + (dist ? ":#{dist}" : '')
|
82
|
-
else
|
83
|
-
# default: same as molphy style
|
84
|
-
label + (dist ? ":#{dist}" : '') + (bs ? "[#{bs}]" : '')
|
85
|
-
end
|
86
|
-
end
|
87
|
-
private :__to_newick_format_leaf
|
88
|
-
|
89
|
-
# formats leaf for NHX
|
90
|
-
def __to_newick_format_leaf_NHX(node, edge, options)
|
91
|
-
|
92
|
-
label = __to_newick_format_label(get_node_name(node), options)
|
93
|
-
|
94
|
-
dist = get_edge_distance_string(edge)
|
95
|
-
|
96
|
-
bs = get_node_bootstrap_string(node)
|
97
|
-
|
98
|
-
if __get_option(:branch_length_style, options) == :disabled
|
99
|
-
dist = nil
|
100
|
-
end
|
101
|
-
|
102
|
-
nhx = {}
|
103
|
-
|
104
|
-
# bootstrap
|
105
|
-
nhx[:B] = bs if bs and !(bs.empty?)
|
106
|
-
# EC number
|
107
|
-
nhx[:E] = node.ec_number if node.instance_eval {
|
108
|
-
defined?(@ec_number) && self.ec_number
|
109
|
-
}
|
110
|
-
# scientific name
|
111
|
-
nhx[:S] = node.scientific_name if node.instance_eval {
|
112
|
-
defined?(@scientific_name) && self.scientific_name
|
113
|
-
}
|
114
|
-
# taxonomy id
|
115
|
-
nhx[:T] = node.taxonomy_id if node.instance_eval {
|
116
|
-
defined?(@taxonomy_id) && self.taxonomy_id
|
117
|
-
}
|
118
|
-
|
119
|
-
# :D (gene duplication or speciation)
|
120
|
-
if node.instance_eval { defined?(@events) && !(self.events.empty?) } then
|
121
|
-
if node.events.include?(:gene_duplication)
|
122
|
-
nhx[:D] = 'Y'
|
123
|
-
elsif node.events.include?(:speciation)
|
124
|
-
nhx[:D] = 'N'
|
125
|
-
end
|
126
|
-
end
|
127
|
-
|
128
|
-
# log likelihood
|
129
|
-
nhx[:L] = edge.log_likelihood if edge.instance_eval {
|
130
|
-
defined?(@log_likelihood) && self.log_likelihood }
|
131
|
-
# width
|
132
|
-
nhx[:W] = edge.width if edge.instance_eval {
|
133
|
-
defined?(@width) && self.width }
|
134
|
-
|
135
|
-
# merges other parameters
|
136
|
-
flag = node.instance_eval { defined? @nhx_parameters }
|
137
|
-
nhx.merge!(node.nhx_parameters) if flag
|
138
|
-
flag = edge.instance_eval { defined? @nhx_parameters }
|
139
|
-
nhx.merge!(edge.nhx_parameters) if flag
|
140
|
-
|
141
|
-
nhx_string = nhx.keys.sort{ |a,b| a.to_s <=> b.to_s }.collect do |key|
|
142
|
-
"#{key.to_s}=#{nhx[key].to_s}"
|
143
|
-
end.join(':')
|
144
|
-
nhx_string = "[&&NHX:" + nhx_string + "]" unless nhx_string.empty?
|
145
|
-
|
146
|
-
label + (dist ? ":#{dist}" : '') + nhx_string
|
147
|
-
end
|
148
|
-
private :__to_newick_format_leaf_NHX
|
149
|
-
|
150
|
-
#
|
151
|
-
def __to_newick(parents, source, depth, format_leaf,
|
152
|
-
options, &block)
|
153
|
-
result = []
|
154
|
-
if indent_string = __get_option(:indent, options) then
|
155
|
-
indent0 = indent_string * depth
|
156
|
-
indent = indent_string * (depth + 1)
|
157
|
-
newline = "\n"
|
158
|
-
else
|
159
|
-
indent0 = indent = newline = ''
|
160
|
-
end
|
161
|
-
out_edges = self.out_edges(source)
|
162
|
-
if block_given? then
|
163
|
-
out_edges.sort! { |edge1, edge2| yield(edge1[1], edge2[1]) }
|
164
|
-
else
|
165
|
-
out_edges.sort! do |edge1, edge2|
|
166
|
-
o1 = edge1[1].order_number
|
167
|
-
o2 = edge2[1].order_number
|
168
|
-
if o1 and o2 then
|
169
|
-
o1 <=> o2
|
170
|
-
else
|
171
|
-
edge1[1].name.to_s <=> edge2[1].name.to_s
|
172
|
-
end
|
173
|
-
end
|
174
|
-
end
|
175
|
-
out_edges.each do |src, tgt, edge|
|
176
|
-
if parents.include?(tgt) then
|
177
|
-
;;
|
178
|
-
elsif self.out_degree(tgt) == 1 then
|
179
|
-
result << indent + __send__(format_leaf, tgt, edge, options)
|
180
|
-
else
|
181
|
-
result <<
|
182
|
-
__to_newick([ src ].concat(parents), tgt, depth + 1,
|
183
|
-
format_leaf, options) +
|
184
|
-
__send__(format_leaf, tgt, edge, options)
|
185
|
-
end
|
186
|
-
end
|
187
|
-
indent0 + "(" + newline + result.join(',' + newline) +
|
188
|
-
(result.size > 0 ? newline : '') + indent0 + ')'
|
189
|
-
end
|
190
|
-
private :__to_newick
|
191
|
-
|
192
|
-
# Returns a newick formatted string.
|
193
|
-
# If block is given, the order of the node is sorted
|
194
|
-
# (as the same manner as Enumerable#sort).
|
195
|
-
#
|
196
|
-
# Available options:
|
197
|
-
# <tt>:indent</tt>::
|
198
|
-
# indent string; set false to disable (default: ' ')
|
199
|
-
# <tt>:bootstrap_style</tt>::
|
200
|
-
# <tt>:disabled</tt> disables bootstrap representations.
|
201
|
-
# <tt>:traditional</tt> for traditional style.
|
202
|
-
# <tt>:molphy</tt> for Molphy style (default).
|
203
|
-
def output_newick(options = {}, &block) #:yields: node1, node2
|
204
|
-
root = @root
|
205
|
-
root ||= self.nodes.first
|
206
|
-
return '();' unless root
|
207
|
-
__to_newick([], root, 0, :__to_newick_format_leaf, options, &block) +
|
208
|
-
__to_newick_format_leaf(root, Edge.new, options) +
|
209
|
-
";\n"
|
210
|
-
end
|
211
|
-
|
212
|
-
alias newick output_newick
|
213
|
-
|
214
|
-
|
215
|
-
# Returns a NHX (New Hampshire eXtended) formatted string.
|
216
|
-
# If block is given, the order of the node is sorted
|
217
|
-
# (as the same manner as Enumerable#sort).
|
218
|
-
#
|
219
|
-
# Available options:
|
220
|
-
# <tt>:indent</tt>::
|
221
|
-
# indent string; set false to disable (default: ' ')
|
222
|
-
#
|
223
|
-
def output_nhx(options = {}, &block) #:yields: node1, node2
|
224
|
-
root = @root
|
225
|
-
root ||= self.nodes.first
|
226
|
-
return '();' unless root
|
227
|
-
__to_newick([], root, 0,
|
228
|
-
:__to_newick_format_leaf_NHX, options, &block) +
|
229
|
-
__to_newick_format_leaf_NHX(root, Edge.new, options) +
|
230
|
-
";\n"
|
231
|
-
end
|
232
|
-
|
233
|
-
# Returns formatted text (or something) of the tree
|
234
|
-
# Currently supported format is: :newick, :nhx
|
235
|
-
def output(format, *arg, &block)
|
236
|
-
case format
|
237
|
-
when :newick
|
238
|
-
output_newick(*arg, &block)
|
239
|
-
when :nhx
|
240
|
-
output_nhx(*arg, &block)
|
241
|
-
when :phylip_distance_matrix
|
242
|
-
output_phylip_distance_matrix(*arg, &block)
|
243
|
-
else
|
244
|
-
raise 'Unknown format'
|
245
|
-
end
|
246
|
-
end
|
247
|
-
|
248
|
-
#---
|
249
|
-
# This method isn't suitable to written in this file?
|
250
|
-
#+++
|
251
|
-
|
252
|
-
# Generates phylip-style distance matrix as a string.
|
253
|
-
# if nodes is not given, all leaves in the tree are used.
|
254
|
-
# If the names of some of the given (or default) nodes
|
255
|
-
# are not defined or are empty, the names are automatically generated.
|
256
|
-
def output_phylip_distance_matrix(nodes = nil, options = {})
|
257
|
-
nodes = self.leaves unless nodes
|
258
|
-
names = nodes.collect do |x|
|
259
|
-
y = get_node_name(x)
|
260
|
-
y = sprintf("%x", x.__id__.abs) if y.empty?
|
261
|
-
y
|
262
|
-
end
|
263
|
-
m = self.distance_matrix(nodes)
|
264
|
-
Bio::Phylip::DistanceMatrix.generate(m, names, options)
|
265
|
-
end
|
266
|
-
|
267
|
-
end #class Tree
|
268
24
|
|
269
25
|
#---
|
270
26
|
# newick parser
|
data/lib/bio/db/pdb.rb
CHANGED
@@ -5,14 +5,11 @@
|
|
5
5
|
# GOTO Naohisa <ngoto@gen-info.osaka-u.ac.jp>
|
6
6
|
# License:: The Ruby License
|
7
7
|
#
|
8
|
-
# $Id: pdb.rb,v 1.8 2007/04/05 23:35:40 trevor Exp $
|
9
8
|
#
|
10
9
|
|
11
|
-
require 'bio/db'
|
12
|
-
|
13
10
|
# definition of the PDB class
|
14
11
|
module Bio
|
15
|
-
class PDB
|
12
|
+
class PDB
|
16
13
|
|
17
14
|
autoload :ChemicalComponent, 'bio/db/pdb/chemicalcomponent'
|
18
15
|
|
data/lib/bio/db/pdb/atom.rb
CHANGED
@@ -6,7 +6,6 @@
|
|
6
6
|
# Naohisa Goto <ng@bioruby.org>
|
7
7
|
# License:: The Ruby License
|
8
8
|
#
|
9
|
-
# $Id: atom.rb,v 1.8 2007/04/05 23:35:41 trevor Exp $
|
10
9
|
#
|
11
10
|
# = Bio::PDB::Coordinate
|
12
11
|
#
|
@@ -19,9 +18,11 @@
|
|
19
18
|
#
|
20
19
|
|
21
20
|
require 'matrix'
|
22
|
-
require 'bio/db/pdb'
|
23
21
|
|
24
22
|
module Bio
|
23
|
+
|
24
|
+
require 'bio/db/pdb' unless const_defined?(:PDB)
|
25
|
+
|
25
26
|
class PDB
|
26
27
|
|
27
28
|
# Bio::PDB::Coordinate is a class to store a 3D coordinate.
|
data/lib/bio/db/pdb/chain.rb
CHANGED
@@ -6,17 +6,16 @@
|
|
6
6
|
# Naohisa Goto <ng@bioruby.org>
|
7
7
|
# License:: The Ruby License
|
8
8
|
#
|
9
|
-
# $Id: chain.rb,v 1.10 2008/04/01 10:36:44 ngoto Exp $
|
10
9
|
#
|
11
10
|
# = Bio::PDB::Chain
|
12
11
|
#
|
13
12
|
# Please refer Bio::PDB::Chain.
|
14
13
|
#
|
15
14
|
|
16
|
-
require 'bio/db/pdb'
|
17
|
-
|
18
15
|
module Bio
|
19
16
|
|
17
|
+
require 'bio/db/pdb' unless const_defined?(:PDB)
|
18
|
+
|
20
19
|
class PDB
|
21
20
|
|
22
21
|
# Bio::PDB::Chain is a class to store a chain.
|
@@ -5,7 +5,6 @@
|
|
5
5
|
# GOTO Naohisa <ngoto@gen-info.osaka-u.ac.jp>
|
6
6
|
# License:: The Ruby License
|
7
7
|
#
|
8
|
-
# $Id: chemicalcomponent.rb,v 1.3 2007/04/05 23:35:41 trevor Exp $
|
9
8
|
#
|
10
9
|
# = About Bio::PDB::ChemicalComponent
|
11
10
|
#
|
@@ -17,9 +16,11 @@
|
|
17
16
|
# * http://deposit.pdb.org/het_dictionary.txt
|
18
17
|
#
|
19
18
|
|
20
|
-
require 'bio/db/pdb/pdb'
|
21
19
|
|
22
20
|
module Bio
|
21
|
+
|
22
|
+
require 'bio/db/pdb' unless const_defined?(:PDB)
|
23
|
+
|
23
24
|
class PDB
|
24
25
|
|
25
26
|
# Bio::PDB::ChemicalComponet is a parser for a entry of
|
data/lib/bio/db/pdb/model.rb
CHANGED
@@ -6,17 +6,17 @@
|
|
6
6
|
# Naohisa Goto <ng@bioruby.org>
|
7
7
|
# License:: The Ruby License
|
8
8
|
#
|
9
|
-
# $Id: model.rb,v 1.10 2007/12/18 13:48:42 ngoto Exp $
|
10
9
|
#
|
11
10
|
# = Bio::PDB::Model
|
12
11
|
#
|
13
12
|
# Please refer Bio::PDB::Model.
|
14
13
|
#
|
15
14
|
|
16
|
-
require 'bio/db/pdb'
|
17
15
|
|
18
16
|
module Bio
|
19
17
|
|
18
|
+
require 'bio/db/pdb' unless const_defined?(:PDB)
|
19
|
+
|
20
20
|
class PDB
|
21
21
|
|
22
22
|
# Bio::PDB::Model is a class to store a model.
|
data/lib/bio/db/pdb/pdb.rb
CHANGED
@@ -22,11 +22,12 @@
|
|
22
22
|
# This is beta version. Specs shall be changed frequently.
|
23
23
|
#
|
24
24
|
|
25
|
-
require 'bio/db/pdb'
|
26
25
|
require 'bio/data/aa'
|
27
26
|
|
28
27
|
module Bio
|
29
28
|
|
29
|
+
require 'bio/db/pdb' unless const_defined?(:PDB)
|
30
|
+
|
30
31
|
# This is the main PDB class which takes care of parsing, annotations
|
31
32
|
# and is the entry way to the co-ordinate data held in models.
|
32
33
|
#
|
data/lib/bio/db/pdb/residue.rb
CHANGED
@@ -6,17 +6,17 @@
|
|
6
6
|
# Naohisa Goto <ng@bioruby.org>
|
7
7
|
# License:: The Ruby License
|
8
8
|
#
|
9
|
-
# $Id:$
|
10
9
|
#
|
11
10
|
# = Bio::PDB::Residue
|
12
11
|
#
|
13
12
|
# = Bio::PDB::Heterogen
|
14
13
|
#
|
15
14
|
|
16
|
-
require 'bio/db/pdb'
|
17
15
|
|
18
16
|
module Bio
|
19
17
|
|
18
|
+
require 'bio/db/pdb' unless const_defined?(:PDB)
|
19
|
+
|
20
20
|
class PDB
|
21
21
|
|
22
22
|
# Bio::PDB::Residue is a class to store a residue.
|
data/lib/bio/db/pdb/utils.rb
CHANGED
@@ -6,7 +6,6 @@
|
|
6
6
|
# Naohisa Goto <ng@bioruby.org>
|
7
7
|
# License:: The Ruby License
|
8
8
|
#
|
9
|
-
# $Id: utils.rb,v 1.7 2007/04/05 23:35:41 trevor Exp $
|
10
9
|
#
|
11
10
|
# = Bio::PDB::Utils
|
12
11
|
#
|
@@ -38,9 +37,12 @@
|
|
38
37
|
#
|
39
38
|
|
40
39
|
require 'matrix'
|
41
|
-
require 'bio/db/pdb'
|
42
40
|
|
43
|
-
module Bio
|
41
|
+
module Bio
|
42
|
+
|
43
|
+
require 'bio/db/pdb' unless const_defined?(:PDB)
|
44
|
+
|
45
|
+
class PDB
|
44
46
|
|
45
47
|
# Utility methods for PDB data.
|
46
48
|
# The methods in this mixin should be applicalbe to all PDB objects.
|
@@ -395,5 +397,6 @@ module Bio; class PDB
|
|
395
397
|
end
|
396
398
|
end #module HeterogenFinder
|
397
399
|
|
398
|
-
end
|
400
|
+
end #class PDB
|
401
|
+
end #module Bio
|
399
402
|
|
@@ -78,15 +78,27 @@ module PhyloXML
|
|
78
78
|
# Initializes LibXML::Reader and reads the file until it reaches the first
|
79
79
|
# phylogeny element.
|
80
80
|
#
|
81
|
-
# Create a new Bio::PhyloXML::Parser object.
|
81
|
+
# Example: Create a new Bio::PhyloXML::Parser object.
|
82
82
|
#
|
83
83
|
# p = Bio::PhyloXML::Parser.open("./phyloxml_examples.xml")
|
84
84
|
#
|
85
|
+
# If the optional code block is given, Bio::PhyloXML object is passed to
|
86
|
+
# the block as an argument. When the block terminates, the Bio::PhyloXML
|
87
|
+
# object is automatically closed, and the open method returns the value
|
88
|
+
# of the block.
|
89
|
+
#
|
90
|
+
# Example: Get the first tree in the file.
|
91
|
+
#
|
92
|
+
# tree = Bio::PhyloXML::Parser.open("example.xml") do |px|
|
93
|
+
# px.next_tree
|
94
|
+
# end
|
95
|
+
#
|
85
96
|
# ---
|
86
97
|
# *Arguments*:
|
87
98
|
# * (required) _filename_: Path to the file to parse.
|
88
99
|
# * (optional) _validate_: Whether to validate the file against schema or not. Default value is true.
|
89
|
-
# *Returns*:: Bio::PhyloXML::Parser object
|
100
|
+
# *Returns*:: (without block) Bio::PhyloXML::Parser object
|
101
|
+
# *Returns*:: (with block) the value of the block
|
90
102
|
def self.open(filename, validate=true)
|
91
103
|
obj = new(nil, validate)
|
92
104
|
obj.instance_eval {
|
@@ -98,7 +110,16 @@ module PhyloXML
|
|
98
110
|
LibXML::XML::Parser::Options::NONET })
|
99
111
|
_skip_leader
|
100
112
|
}
|
101
|
-
|
113
|
+
if block_given? then
|
114
|
+
begin
|
115
|
+
ret = yield obj
|
116
|
+
ensure
|
117
|
+
obj.close if obj and !obj.closed?
|
118
|
+
end
|
119
|
+
ret
|
120
|
+
else
|
121
|
+
obj
|
122
|
+
end
|
102
123
|
end
|
103
124
|
|
104
125
|
# Initializes LibXML::Reader and reads the file until it reaches the first
|
@@ -108,11 +129,17 @@ module PhyloXML
|
|
108
129
|
#
|
109
130
|
# p = Bio::PhyloXML::Parser.open_uri("http://www.phyloxml.org/examples/apaf.xml")
|
110
131
|
#
|
132
|
+
# If the optional code block is given, Bio::PhyloXML object is passed to
|
133
|
+
# the block as an argument. When the block terminates, the Bio::PhyloXML
|
134
|
+
# object is automatically closed, and the open_uri method returns the
|
135
|
+
# value of the block.
|
136
|
+
#
|
111
137
|
# ---
|
112
138
|
# *Arguments*:
|
113
139
|
# * (required) _uri_: (URI or String) URI to the data to parse
|
114
140
|
# * (optional) _validate_: For URI reader, the "validate" option is ignored and no validation is executed.
|
115
|
-
# *Returns*:: Bio::PhyloXML::Parser object
|
141
|
+
# *Returns*:: (without block) Bio::PhyloXML::Parser object
|
142
|
+
# *Returns*:: (with block) the value of the block
|
116
143
|
def self.open_uri(uri, validate=true)
|
117
144
|
case uri
|
118
145
|
when URI
|
@@ -129,7 +156,15 @@ module PhyloXML
|
|
129
156
|
@reader = XML::Reader.file(uri)
|
130
157
|
_skip_leader
|
131
158
|
}
|
132
|
-
|
159
|
+
if block_given? then
|
160
|
+
begin
|
161
|
+
ret = yield obj
|
162
|
+
ensure
|
163
|
+
obj.close if obj and !obj.closed?
|
164
|
+
end
|
165
|
+
else
|
166
|
+
obj
|
167
|
+
end
|
133
168
|
end
|
134
169
|
|
135
170
|
# Special class for closed PhyloXML::Parser object.
|
@@ -156,6 +191,18 @@ module PhyloXML
|
|
156
191
|
nil
|
157
192
|
end
|
158
193
|
|
194
|
+
# If the object is closed by using the close method or equivalent,
|
195
|
+
# returns true. Otherwise, returns false.
|
196
|
+
# ---
|
197
|
+
# *Returns*:: true or false
|
198
|
+
def closed?
|
199
|
+
if @reader.kind_of?(ClosedPhyloXMLParser) then
|
200
|
+
true
|
201
|
+
else
|
202
|
+
false
|
203
|
+
end
|
204
|
+
end
|
205
|
+
|
159
206
|
# Initializes LibXML::Reader and reads from the IO until it reaches
|
160
207
|
# the first phylogeny element.
|
161
208
|
#
|