Class: BEL::Resource::NamespaceValue
- Inherits:
-
Object
- Object
- BEL::Resource::NamespaceValue
show all
- Includes:
- Concept
- Defined in:
- lib/bel/resource/namespace_value.rb
Overview
NamespaceValue represents a NamespaceConcept RDF Resource and associated properties.
Constant Summary
collapse
- DC =
RDF::Vocab::DC
- SKOS =
RDF::Vocab::SKOS
- BELV =
RDF::Vocabulary.new('http://www.openbel.org/vocabulary/')
Instance Attribute Summary collapse
Instance Method Summary
collapse
Methods included from Concept
#alt_label, #from_species, #identifier, #pref_label, #title, #type
Constructor Details
#initialize(rdf_repository, uri) ⇒ NamespaceValue
Returns a new instance of NamespaceValue.
20
21
22
23
24
25
26
27
28
29
30
31
32
|
# File 'lib/bel/resource/namespace_value.rb', line 20
def initialize(rdf_repository, uri)
@rdf_repository = rdf_repository
@uri = RDF::URI(uri.to_s)
@uri_hash = @uri.hash
@eq_query = [
:subject => @uri,
:predicate => SKOS.exactMatch
]
@ortho_query = [
:subject => @uri,
:predicate => BELV.orthologousMatch
]
end
|
Instance Attribute Details
#uri ⇒ Object
Returns the value of attribute uri.
14
15
16
|
# File 'lib/bel/resource/namespace_value.rb', line 14
def uri
@uri
end
|
Instance Method Details
#==(other) ⇒ Object
Also known as:
eql?
105
106
107
108
|
# File 'lib/bel/resource/namespace_value.rb', line 105
def ==(other)
return false if other == nil
@uri == other.uri
end
|
#equivalents(target_namespaces = :all) ⇒ Object
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
|
# File 'lib/bel/resource/namespace_value.rb', line 51
def equivalents(target_namespaces = :all)
return to_enum(:equivalents, target_namespaces) unless block_given?
if target_namespaces == :all
@rdf_repository.
query(@eq_query) { |solution|
yield NamespaceValue.new(@rdf_repository, solution.object)
}
else
target_namespaces = Namespaces.new(@rdf_repository).
find([target_namespaces].flatten).to_a
target_namespaces.compact!
target_namespaces.map! { |ns| ns.uri }
@rdf_repository.
query(@eq_query).map { |solution|
NamespaceValue.new(@rdf_repository, solution.object)
}.select { |value|
scheme_uri = value.in_scheme
target_namespaces.include?(scheme_uri)
}.each { |value|
yield value
}
end
end
|
#hash ⇒ Object
101
102
103
|
# File 'lib/bel/resource/namespace_value.rb', line 101
def hash
@uri_hash
end
|
#in_scheme ⇒ Object
40
41
42
43
44
45
46
47
48
49
|
# File 'lib/bel/resource/namespace_value.rb', line 40
def in_scheme
@rdf_repository
.query([:subject => @uri, :predicate => SKOS.inScheme])
.select { |solution|
scheme_uri = solution.object
@rdf_repository.has_statement?(
RDF::Statement(scheme_uri, RDF.type, BELV.NamespaceConceptScheme)
)
}.map { |solution| solution.object.to_s }
end
|
#namespace ⇒ Object
34
35
36
37
38
|
# File 'lib/bel/resource/namespace_value.rb', line 34
def namespace
schemes = in_scheme
return nil if schemes.empty?
Namespace.new(@rdf_repository, schemes.first)
end
|
#orthologs(target_namespaces = :all) ⇒ Object
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
|
# File 'lib/bel/resource/namespace_value.rb', line 76
def orthologs(target_namespaces = :all)
return to_enum(:orthologs, target_namespaces) unless block_given?
if target_namespaces == :all
@rdf_repository.
query(@ortho_query) { |solution|
yield NamespaceValue.new(@rdf_repository, solution.object)
}
else
target_namespaces = Namespaces.new(@rdf_repository).
find([target_namespaces].flatten).to_a
target_namespaces.compact!
target_namespaces.map! { |ns| ns.uri }
@rdf_repository.
query(@ortho_query).map { |solution|
NamespaceValue.new(@rdf_repository, solution.object)
}.select { |value|
scheme_uri = value.in_scheme
target_namespaces.include?(scheme_uri)
}.each { |value|
yield value
}
end
end
|