RosettaCon2020 is virtual! Attend from anywhere!
4 years ago
Ruby, BioRuby, PhyloXML, Ubuntu
diana@diana-ubuntu:~/bioruby$ ruby-prof -p graph test/unit/bio/db/test_phyloxml_big.rb
Loaded suite /usr/bin/ruby-prof
Started
.
Finished in 1345.4039 seconds.
1 tests, 0 assertions, 0 failures, 0 errors
Thread ID: 3084157360
Total Time: 1257.6
[..]
-------------------------------------------------------------------------------
1257.56 0.60 0.00 1256.96 2/2 Bio::TestPhyloXMLBig#test_next_tree
100.00% 0.05% 1257.56 0.60 0.00 1256.96 2 Bio::PhyloXML#next_tree
0.08 0.03 0.00 0.05 8107/16210 Bio::PhyloXML#parse_attributes
0.00 0.00 0.00 0.00 1/243188 String#==
0.00 0.00 0.00 0.00 8104/24322 LibXML::XML::Reader#[]
6.18 0.97 0.00 5.21 48616/48616 Bio::PhyloXML#parse_clade_elements
0.14 0.14 0.00 0.00 48623/97244 LibXML::XML::Reader#read
0.27 0.17 0.00 0.10 48644/875134 Bio::PhyloXML#is_element?
0.11 0.04 0.00 0.07 16206/32442 Class#new
0.04 0.04 0.00 0.00 16206/116034 Kernel#==
0.00 0.00 0.00 0.00 4/72929 Bio::PhyloXML#parse_simple_elements
0.07 0.01 0.00 0.06 8102/8102 Bio::Tree#add_node
0.44 0.31 0.00 0.13 97243/137758 Bio::PhyloXML#is_end_element?
1249.05 0.02 0.00 1249.03 8102/8102 Bio::Tree#parent
0.58 0.07 0.00 0.51 8102/8102 Bio::Tree#add_edge
-----------------------------------------------------------------------------
1249.05 0.02 0.00 1249.03 8102/8102 Bio::PhyloXML#next_tree
99.32% 0.00% 1249.05 0.02 0.00 1249.03 8102 Bio::Tree#parent
1249.03 0.13 0.00 1248.90 8102/8102 Bio::Tree#path
0.00 0.00 0.00 0.00 8102/72975 Array#[]
--------------------------------------------------------------------------------
1249.03 0.13 0.00 1248.90 8102/8102 Bio::Tree#parent
99.32% 0.01% 1249.03 0.13 0.00 1248.90 8102 Bio::Tree#path
0.04 0.01 0.00 0.03 16204/164638052 Hash#[]
1248.82 0.27 0.00 1248.55 8102/8102 Bio::Pathway#bfs_shortest_path
0.03 0.03 0.00 0.00 24306/116034 Kernel#==
0.01 0.01 0.00 0.00 16204/72975 Array#[]
--------------------------------------------------------------------------------
1248.82 0.27 0.00 1248.55 8102/8102 Bio::Tree#path
99.30% 0.02% 1248.82 0.27 0.00 1248.55 8102 Bio::Pathway#bfs_shortest_path
0.26 0.19 0.00 0.07 142736/164638052 Hash#[]
0.07 0.07 0.00 0.00 75419/116034 Kernel#==
1248.18 115.50 0.00 1132.68 8102/8102 Bio::Pathway#breadth_first_search
0.04 0.04 0.00 0.00 67317/67330 Array#unshift
--------------------------------------------------------------------------------
1248.18 115.50 0.00 1132.68 8102/8102 Bio::Pathway#bfs_shortest_path
99.25% 9.18% 1248.18 115.50 0.00 1132.68 8102 Bio::Pathway#breadth_first_search
136.52 92.65 0.00 43.8765785140/164638052 Hash#[]
22.53 22.53 0.00 0.0032900672/32900681 Array#shift
973.59 324.56 0.00 649.0332892570/32892570 Hash#each_key
0.04 0.03 0.00 0.01 24306/98702064 Hash#[]=
[..]
1 def parse_events()
2 events = Events.new
3 @reader.read #go to next element
4 #read while have reached end of events
5 while not(is_end_element?('events')) do
6 if is_element?('type')
7 @reader.read
8 events.type = @reader.value
9 @reader.read
10 has_reached_end_tag?('type')
11 end
12 if is_element?('duplications')
13 @reader.read
14 events.duplications = @reader.value.to_i
15 @reader.read
16 has_reached_end_tag?('duplications')
17 end
18 if is_element?('speciations')
19 @reader.read
20 events.speciations = @reader.value.to_i
21 @reader.read
22 has_reached_end_tag?('speciations')
23 end
24 if is_element?('losses')
25 @reader.read
26 events.losses = @reader.value.to_i
27 @reader.read
28 has_reached_end_tag?('losses')
29 end
30 if is_element?('confidence')
31 events.confidence = parse_confidence
32 end
33 @reader.read
34 end
35 return events
36 end #parse_events
def parse_simple_element(object, name)
if is_element?(name)
@reader.read
object.send("#{name}=", @reader.value)
@reader.read
has_reached_end_tag?(name)
end
end
def parse_events()
events = Events.new
@reader.read #go to next element
while not(is_end_element?('events')) do
['type', 'duplications', 'speciations', 'losses'].each { |elmt|
parse_simple_element(events, elmt)
}
if is_element?('confidence')
events.confidence = parse_confidence
end
@reader.read
end
return events
end #parse_events