Class: FishTank::Taxon
- Inherits:
-
Object
show all
- Defined in:
- lib/fishtank/taxon.rb
Defined Under Namespace
Classes: Arm, Fish, Tetrapod
Instance Attribute Summary collapse
Instance Method Summary
collapse
Constructor Details
#initialize(taxon_id: nil) ⇒ Taxon
Returns a new instance of Taxon.
9
10
11
12
13
14
|
# File 'lib/fishtank/taxon.rb', line 9
def initialize(taxon_id: nil)
@label = taxon_id
@stats = {}
get_metadata
crunch_stats
end
|
Instance Attribute Details
#label ⇒ Object
6
7
8
|
# File 'lib/fishtank/taxon.rb', line 6
def label
@label
end
|
#stats ⇒ Object
Returns the value of attribute stats.
7
8
9
|
# File 'lib/fishtank/taxon.rb', line 7
def stats
@stats
end
|
Instance Method Details
#attributes ⇒ Object
81
82
|
# File 'lib/fishtank/taxon.rb', line 81
def attributes
end
|
#base_for(id) ⇒ Object
77
78
79
|
# File 'lib/fishtank/taxon.rb', line 77
def base_for(id)
BASE + id
end
|
#crunch_stats ⇒ Object
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
|
# File 'lib/fishtank/taxon.rb', line 49
def crunch_stats
totals = {}
stats.keys.each do |entity|
stats[entity][:raw].each do |k, count|
totals[k] ||= 0
totals[k] += count
end
end
description.each do |entity, v|
stats[entity][:crunched] ||= {}
totals.keys.each do |t|
v = totals[t] == 0 ? 0.to_f : stats[entity][:raw][t].to_f / totals[t].to_f
stats[entity][:crunched][t] = v
end
end
true
end
|
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
|
# File 'lib/fishtank/taxon.rb', line 32
def get_metadata
@stats ||= {}
description.each do |k, v|
@stats[k] ||= {}
@stats[k][:raw] ||= {}
xml = get_nexml(k)
o = SimpleNexml.new(doc: xml, taxon: label)
@stats[k][:raw] = o.stats[:count]
FishTank::QUALITIES.each do |q|
@stats[k][:raw][q] = get_phenotype_total(k, q)
end
end
true
end
|
#get_nexml(entity) ⇒ XML
17
18
19
|
# File 'lib/fishtank/taxon.rb', line 17
def get_nexml(entity)
Phenoscape::Ontotrace.ontotrace(taxon: iri_for(label), entity: some_iri(entity), ret: 'noko')
end
|
#get_phenotype_total(entity, quality) ⇒ Integer
22
23
24
25
26
27
28
29
30
|
# File 'lib/fishtank/taxon.rb', line 22
def get_phenotype_total(entity, quality)
Phenoscape::Taxa.annotations(
in_taxon: base_for(label),
entity: base_for(entity),
quality: base_for(quality),
total: true,
parts: true
)['total']
end
|
#iri_for(id) ⇒ Object
73
74
75
|
# File 'lib/fishtank/taxon.rb', line 73
def iri_for(id)
'<' + base_for(id) + '>'
end
|
#pic_height ⇒ Integer
94
95
96
|
# File 'lib/fishtank/taxon.rb', line 94
def pic_height
100
end
|
#pic_width ⇒ Integer
89
90
91
|
# File 'lib/fishtank/taxon.rb', line 89
def pic_width
60
end
|
#some_iri(entity) ⇒ Object
69
70
71
|
# File 'lib/fishtank/taxon.rb', line 69
def some_iri(entity)
iri_for('BFO_0000050') + ' some ' + iri_for(entity)
end
|
#symmetry ⇒ Object
84
85
86
|
# File 'lib/fishtank/taxon.rb', line 84
def symmetry
return {}
end
|