biointerchange 0.1.0 → 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.travis.yml +3 -3
- data/Gemfile +2 -1
- data/README.md +192 -7
- data/Rakefile +1 -1
- data/VERSION +1 -1
- data/examples/vocabulary.rb +23 -0
- data/generators/javaify.rb +131 -0
- data/generators/pythonify.rb +67 -0
- data/generators/rdfxml.rb +152 -44
- data/lib/biointerchange/core.rb +2 -1
- data/lib/biointerchange/exceptions.rb +27 -0
- data/lib/biointerchange/genomics/gff3_rdf_ntriples.rb +21 -18
- data/lib/biointerchange/gff3o.rb +495 -0
- data/lib/biointerchange/gvf1o.rb +730 -0
- data/lib/biointerchange/registry.rb +2 -2
- data/lib/biointerchange/sio.rb +10951 -5845
- data/lib/biointerchange/sofa.rb +2171 -1300
- data/spec/exceptions_spec.rb +6 -0
- data/spec/gff3_rdfwriter_spec.rb +7 -1
- data/spec/text_mining_pdfx_xml_reader_spec.rb +6 -0
- data/spec/text_mining_pubannos_json_reader_spec.rb +6 -0
- data/spec/text_mining_rdfwriter_spec.rb +6 -0
- data/supplemental/java/biointerchange/pom.xml +45 -0
- data/supplemental/java/biointerchange/src/main/java/org/biointerchange/App.java +58 -0
- data/supplemental/java/biointerchange/src/main/java/org/biointerchange/AppSIO.java +49 -0
- data/supplemental/java/biointerchange/src/main/java/org/biointerchange/vocabulary/GFF3O.java +647 -0
- data/supplemental/java/biointerchange/src/main/java/org/biointerchange/vocabulary/GVF1O.java +946 -0
- data/supplemental/java/biointerchange/src/main/java/org/biointerchange/vocabulary/SIO.java +15390 -0
- data/supplemental/java/biointerchange/src/main/java/org/biointerchange/vocabulary/SOFA.java +2968 -0
- data/supplemental/java/biointerchange/src/test/java/org/biointerchange/AppTest.java +38 -0
- data/supplemental/python/biointerchange/__init__.py +4 -0
- data/supplemental/python/biointerchange/gff3o.py +581 -0
- data/supplemental/python/biointerchange/gvf1o.py +864 -0
- data/supplemental/python/biointerchange/sio.py +11772 -0
- data/supplemental/python/biointerchange/sofa.py +2422 -0
- data/supplemental/python/example.py +19 -0
- data/supplemental/python/setup.py +13 -0
- data/web/about.html +3 -0
- data/web/api.html +219 -0
- data/web/index.html +4 -3
- data/web/ontologies.html +109 -0
- data/web/webservices.html +1 -0
- metadata +144 -117
- data/docs/exceptions_readme.txt +0 -13
- data/lib/biointerchange/gff3.rb +0 -135
@@ -0,0 +1,67 @@
|
|
1
|
+
#!/usr/bin/ruby
|
2
|
+
|
3
|
+
private_scope = false
|
4
|
+
python_class = nil
|
5
|
+
namespace = nil
|
6
|
+
comment = nil
|
7
|
+
|
8
|
+
cls = ''
|
9
|
+
|
10
|
+
puts 'import rdflib'
|
11
|
+
puts ''
|
12
|
+
puts 'from rdflib import Namespace'
|
13
|
+
puts ''
|
14
|
+
|
15
|
+
STDIN.each { |line|
|
16
|
+
line.chomp!
|
17
|
+
|
18
|
+
if line.match('http://') then
|
19
|
+
namespace = line.scan(/http:\/\/[^']+/)[0].sub(/(\/[^\/#]+)'$/, '').sub(/(#).*$/, '\1') unless namespace
|
20
|
+
line.gsub!(namespace, '')
|
21
|
+
end
|
22
|
+
|
23
|
+
if line.start_with?('class') then
|
24
|
+
python_class = line.sub(/^.* /, '')
|
25
|
+
transduction = "#{line}:"
|
26
|
+
elsif line.strip.start_with?('def ') then
|
27
|
+
leading_spaces = line.gsub(/[^ ].*$/, '')
|
28
|
+
transduction = "#{leading_spaces}@classmethod\n"
|
29
|
+
leading_spaces << ' '
|
30
|
+
if comment then
|
31
|
+
transduction << "#{line.sub('?', '').sub(/self\./, '')}:\n#{('"""' + comment).gsub(/^/, "#{leading_spaces}")}\n#{leading_spaces}\"\"\""
|
32
|
+
comment = nil
|
33
|
+
else
|
34
|
+
transduction << "#{line.sub('?', '').sub(/self\./, '')}:"
|
35
|
+
end
|
36
|
+
transduction.sub!('(', '(cls, ')
|
37
|
+
transduction.sub!(':', '(cls):') unless line.match(/\(/)
|
38
|
+
elsif line.strip.start_with?('#') then
|
39
|
+
unless comment then
|
40
|
+
comment = line.strip.sub(/^# ?/, '')
|
41
|
+
else
|
42
|
+
comment << "\n#{line.strip.gsub(/^# ?/, '').gsub(/\+([^+]+)\+::/, '\1 --')}"
|
43
|
+
end
|
44
|
+
transduction = nil
|
45
|
+
elsif line.strip.start_with?('end') then
|
46
|
+
transduction = nil
|
47
|
+
elsif line.strip.start_with?('if ') or line.strip.start_with?('elsif') then
|
48
|
+
transduction = "#{line.sub(/ then$/, '').sub('elsif', 'elif').gsub('@@', 'cls.__').gsub(/RDF::URI\.new\(([^)]+)\)/, "_namespace_#{python_class}(\\1)").gsub(/(\w)\?\(/, '\1(')}:"
|
49
|
+
elsif line.strip.start_with?('private') then
|
50
|
+
private_scope = true
|
51
|
+
transduction = nil
|
52
|
+
puts "__namespace_#{python_class} = Namespace('#{namespace}')"
|
53
|
+
puts ''
|
54
|
+
puts "def _namespace_#{python_class}(accession):"
|
55
|
+
puts " return __namespace_#{python_class}[accession]"
|
56
|
+
puts ''
|
57
|
+
else
|
58
|
+
transduction = line.gsub('@@', '__').gsub('=>', ':').gsub(/RDF::URI\.new\(([^)]+)\)/, "_namespace_#{python_class}(\\1)").gsub('true', 'True').gsub('false', 'False').gsub(/(\w+)\.select ?\{ ?\|(\w+)\| ?(.*[^ ]) ?\}/, 'filter(lambda \2: \3, \1)').gsub(/(\w)\?\(/, '\1(').gsub('has_parent(', 'cls.has_parent(')
|
59
|
+
transduction.gsub!('__', 'cls.__') unless line.strip.start_with?('@@')
|
60
|
+
end
|
61
|
+
|
62
|
+
cls << "#{transduction.gsub(/^( +)/, '\1\1')}\n" if transduction
|
63
|
+
|
64
|
+
}
|
65
|
+
|
66
|
+
puts cls
|
67
|
+
|
data/generators/rdfxml.rb
CHANGED
@@ -10,9 +10,16 @@ if ARGV.length != 2 then
|
|
10
10
|
exit 1
|
11
11
|
end
|
12
12
|
|
13
|
-
# Will later be used for extracting comments from SOFA
|
13
|
+
# Will later be used for extracting comments from SOFA:
|
14
14
|
OBO_DEF = RDF::URI.new('http://purl.obolibrary.org/obo/def')
|
15
15
|
|
16
|
+
# For handling synonyms in SIO:
|
17
|
+
SIO_SYN = RDF::URI.new('http://semanticscience.org/resource/synonym')
|
18
|
+
|
19
|
+
def makeLabel(label)
|
20
|
+
label.gsub(/[ '-.<>]/, '_').gsub(/\([^\)]*?\)/, '').sub(/^(\d+)/, "a_#{$1}").gsub(/^_+|_+$/, '').gsub(/_+/, '_')
|
21
|
+
end
|
22
|
+
|
16
23
|
reader = RDF::RDFXML::Reader.open(ARGV[0])
|
17
24
|
|
18
25
|
model = {}
|
@@ -35,69 +42,170 @@ named_individuals = {}
|
|
35
42
|
puts "class #{ARGV[1]}"
|
36
43
|
puts ''
|
37
44
|
|
45
|
+
parent_properties = {}
|
46
|
+
combined_uris = {}
|
47
|
+
generated_labels = {}
|
48
|
+
comments = {}
|
38
49
|
model.keys.each { |key|
|
39
50
|
entry = model[key]
|
40
51
|
type = entry[RDF.type]
|
41
52
|
|
42
53
|
# TODO Check whether label present
|
43
54
|
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
55
|
+
next unless type
|
56
|
+
|
57
|
+
label = entry[RDF::RDFS.label].to_s
|
58
|
+
next if makeLabel(label).empty?
|
59
|
+
uri = key.to_s
|
60
|
+
|
61
|
+
# Only deal with URI sub-classes/sub-properties, whilst ignoring restrictions, etc.
|
62
|
+
if entry[RDF::RDFS.subClassOf] then
|
63
|
+
parent_properties[uri] = entry[RDF::RDFS.subClassOf] unless entry[RDF::RDFS.subClassOf].kind_of?(RDF::Node)
|
64
|
+
elsif entry[RDF::RDFS.subPropertyOf] then
|
65
|
+
parent_properties[uri] = entry[RDF::RDFS.subPropertyOf] unless entry[RDF::RDFS.subPropertyOf].kind_of?(RDF::Node)
|
66
|
+
end
|
67
|
+
|
68
|
+
[ label, entry[SIO_SYN] ].compact.each { |label_or_synonym|
|
69
|
+
label_or_synonym = label_or_synonym.to_s
|
49
70
|
|
50
|
-
|
71
|
+
set = comments[label_or_synonym]
|
72
|
+
set = [] unless set
|
73
|
+
comment = nil
|
74
|
+
# Try to gather some comment for RDoc. The comment identification depends on the ontology used:
|
51
75
|
if entry[RDF::DC.description] then
|
52
|
-
|
76
|
+
comment = [ uri, " # #{entry[RDF::DC.description].to_s.gsub(/\n|\r\n/, "\n # ")}\n" ]
|
53
77
|
elsif entry[OBO_DEF] then
|
54
|
-
|
78
|
+
comment = [ uri, " # #{entry[OBO_DEF].to_s.sub(/^"(.*)" \[(.*)\]$/, '\1 (\2)').gsub(/\n|\r\n/, "\n # ")}\n" ]
|
79
|
+
elsif entry[RDF::RDFS.comment] then
|
80
|
+
comment = [ uri, " # #{entry[RDF::RDFS.comment].to_s.gsub(/\n|\r\n/, "\n # ")}\n" ]
|
81
|
+
end
|
82
|
+
comments[label_or_synonym] = set | [ comment ] if comment
|
83
|
+
|
84
|
+
set = combined_uris[label_or_synonym]
|
85
|
+
set = [] unless set
|
86
|
+
combined_uris[label_or_synonym] = set | [ uri ]
|
87
|
+
generated_labels[label_or_synonym] = makeLabel(label_or_synonym)
|
88
|
+
}
|
89
|
+
|
90
|
+
object_properties[uri] = true if type == RDF::OWL.ObjectProperty
|
91
|
+
datatype_properties[uri] = true if type == RDF::OWL.DatatypeProperty
|
92
|
+
classes[uri] = true if type == RDF::OWL.Class
|
93
|
+
named_individuals[uri] = true if type == RDF::OWL.NamedIndividual
|
94
|
+
}
|
95
|
+
|
96
|
+
seen_labels = {}
|
97
|
+
|
98
|
+
model.keys.each { |key|
|
99
|
+
entry = model[key]
|
100
|
+
type = entry[RDF.type]
|
101
|
+
|
102
|
+
label = entry[RDF::RDFS.label].to_s
|
103
|
+
|
104
|
+
[ label, entry[SIO_SYN] ].compact.each { |label_or_synonym|
|
105
|
+
label_or_synonym = label_or_synonym.to_s
|
106
|
+
|
107
|
+
next unless type and combined_uris.has_key?(label_or_synonym)
|
108
|
+
|
109
|
+
generated_label = generated_labels[label_or_synonym]
|
110
|
+
|
111
|
+
next if seen_labels[generated_label]
|
112
|
+
seen_labels[generated_label] = true
|
113
|
+
|
114
|
+
uris = combined_uris[label_or_synonym]
|
115
|
+
|
116
|
+
if comments[label_or_synonym] then
|
117
|
+
if comments[label_or_synonym].length == 1 then
|
118
|
+
comment = "#{comments[label_or_synonym][0][1]} # (#{comments[label_or_synonym][0][0]})\n"
|
119
|
+
else
|
120
|
+
comment = ''
|
121
|
+
introduction = true
|
122
|
+
comments[label_or_synonym].each { |linked_comment|
|
123
|
+
if introduction then
|
124
|
+
introduction = false
|
125
|
+
comment << " # Either:\n"
|
126
|
+
else
|
127
|
+
comment << " # Or:\n"
|
128
|
+
end
|
129
|
+
comment << "#{linked_comment[1].sub(/# /, '# ')} # (#{linked_comment[0]})\n"
|
130
|
+
}
|
131
|
+
end
|
132
|
+
puts comment
|
133
|
+
else
|
134
|
+
puts ' # Ambiguous label.' if combined_uris[label_or_synonym].length > 1
|
55
135
|
end
|
56
|
-
puts "
|
57
|
-
|
58
|
-
|
136
|
+
puts " def self.#{generated_label}"
|
137
|
+
if combined_uris[label_or_synonym].length == 1 then
|
138
|
+
puts " return RDF::URI.new('#{combined_uris[label_or_synonym][0]}')"
|
139
|
+
else
|
140
|
+
puts " return [ #{combined_uris[label_or_synonym].map { |uri| "RDF::URI.new('#{uri}')" }.join(', ')} ]"
|
141
|
+
end
|
142
|
+
puts ' end'
|
59
143
|
puts ''
|
60
|
-
|
61
|
-
datatype_properties[uri] = true if type == RDF::OWL.DatatypeProperty
|
62
|
-
classes[uri] = true if type == RDF::OWL.Class
|
63
|
-
named_individuals[uri] = true if type == RDF::OWL.NamedIndividual
|
64
|
-
end
|
144
|
+
}
|
65
145
|
}
|
66
146
|
|
67
|
-
puts '
|
68
|
-
puts '
|
69
|
-
puts '
|
70
|
-
puts '
|
71
|
-
object_properties.keys.each { |uri| puts "
|
72
|
-
puts '
|
73
|
-
puts '
|
147
|
+
puts ' # Determines whether the given URI is an object property.'
|
148
|
+
puts ' #'
|
149
|
+
puts ' # +uri+:: URI that is tested for being an object property'
|
150
|
+
puts ' def self.is_object_property?(uri)'
|
151
|
+
object_properties.keys.each { |uri| puts " if uri == RDF::URI.new('#{uri}') then\n return true\n end" }
|
152
|
+
puts ' return false'
|
153
|
+
puts ' end'
|
74
154
|
puts ''
|
75
155
|
|
76
|
-
puts '
|
77
|
-
puts '
|
78
|
-
puts '
|
79
|
-
puts '
|
80
|
-
datatype_properties.keys.each { |uri| puts "
|
81
|
-
puts '
|
82
|
-
puts '
|
156
|
+
puts ' # Determines whether the given URI is a datatype property.'
|
157
|
+
puts ' #'
|
158
|
+
puts ' # +uri+:: URI that is tested for being a datatype property'
|
159
|
+
puts ' def self.is_datatype_property?(uri)'
|
160
|
+
datatype_properties.keys.each { |uri| puts " if uri == RDF::URI.new('#{uri}') then\n return true\n end" }
|
161
|
+
puts ' return false'
|
162
|
+
puts ' end'
|
83
163
|
puts ''
|
84
164
|
|
85
|
-
puts '
|
86
|
-
puts '
|
87
|
-
puts '
|
88
|
-
puts '
|
89
|
-
classes.keys.each { |uri| puts "
|
90
|
-
puts '
|
91
|
-
puts '
|
165
|
+
puts ' # Determines whether the given URI is a class.'
|
166
|
+
puts ' #'
|
167
|
+
puts ' # +uri+:: URI that is tested for being a class'
|
168
|
+
puts ' def self.is_class?(uri)'
|
169
|
+
classes.keys.each { |uri| puts " if uri == RDF::URI.new('#{uri}') then\n return true\n end" }
|
170
|
+
puts ' return false'
|
171
|
+
puts ' end'
|
92
172
|
puts ''
|
93
173
|
|
94
|
-
puts '
|
95
|
-
puts '
|
96
|
-
puts '
|
97
|
-
puts '
|
98
|
-
named_individuals.keys.each { |uri| puts "
|
99
|
-
puts '
|
174
|
+
puts ' # Determines whether the given URI is a named individual.'
|
175
|
+
puts ' #'
|
176
|
+
puts ' # +uri+:: URI that is tested for being a named individual'
|
177
|
+
puts ' def self.is_named_individual?(uri)'
|
178
|
+
named_individuals.keys.each { |uri| puts " if uri == RDF::URI.new('#{uri}') then\n return true\n end" }
|
179
|
+
puts ' return false'
|
180
|
+
puts ' end'
|
181
|
+
puts ''
|
182
|
+
|
183
|
+
puts ' # Returns only those URIs that fall under a designated parent URI.'
|
184
|
+
puts ' #'
|
185
|
+
puts ' # +uris+:: Set of URIs that are tested whether they have the given parent URI.'
|
186
|
+
puts ' # +parent+:: Parent URI.'
|
187
|
+
puts ' def self.with_parent(uris, parent)'
|
188
|
+
puts ' return uris.select { |uri| has_parent?(uri, parent) }'
|
189
|
+
puts ' end'
|
190
|
+
puts ''
|
191
|
+
|
192
|
+
puts ' # Recursively tries to determine the parent for a given URI.'
|
193
|
+
puts ' #'
|
194
|
+
puts ' # +uri+:: URI that is tested for whether it has the given parent URI.'
|
195
|
+
puts ' # +parent+:: Parent URI.'
|
196
|
+
puts ' def self.has_parent?(uri, parent)'
|
197
|
+
puts ' if @@parent_properties.has_key?(uri) then'
|
198
|
+
puts ' if @@parent_properties[uri] == parent then'
|
199
|
+
puts ' return true'
|
200
|
+
puts ' end'
|
201
|
+
puts ' return has_parent?(@@parent_properties[uri], parent)'
|
100
202
|
puts ' end'
|
203
|
+
puts ' return false'
|
204
|
+
puts ' end'
|
205
|
+
puts ''
|
206
|
+
|
207
|
+
puts 'private'
|
208
|
+
puts " @@parent_properties = {#{ parent_properties.keys.map { |uri| " RDF::URI.new('#{uri}') => RDF::URI.new('#{parent_properties[uri]}')" }.join(' ,') } }"
|
101
209
|
puts ''
|
102
210
|
|
103
211
|
puts 'end'
|
data/lib/biointerchange/core.rb
CHANGED
@@ -4,7 +4,8 @@ module BioInterchange
|
|
4
4
|
require 'biointerchange/exceptions'
|
5
5
|
|
6
6
|
# Ontologies (besides the ones from the 'rdf' gem)
|
7
|
-
require 'biointerchange/
|
7
|
+
require 'biointerchange/gff3o'
|
8
|
+
require 'biointerchange/gvf1o'
|
8
9
|
require 'biointerchange/sio'
|
9
10
|
require 'biointerchange/sofa'
|
10
11
|
|
@@ -1,3 +1,30 @@
|
|
1
|
+
# BioInterchange Exception and Error handling.
|
2
|
+
#
|
3
|
+
# All BioInterchange errors come under two main categories:
|
4
|
+
# 1. InputFormatError
|
5
|
+
# 2. ImplementationError
|
6
|
+
#
|
7
|
+
# Each of these classes is handled differently within the BioInterchange framework.
|
8
|
+
#
|
9
|
+
# InputFormatErrors are those that could be raised at any time (during runtime), and
|
10
|
+
# that the user could then be exposed to. Examples include errors relating to missing
|
11
|
+
# files, or incorrect file formats. These Errors are rescued at the highest level in
|
12
|
+
# our program, and adjusted such that a user friendly error message is displayed without
|
13
|
+
# a stacktrace (backtrace). This helps to keep our system more user-friendly. However,
|
14
|
+
# this means that we strongly advise that when such an error is raised, that it comes
|
15
|
+
# with a user friendly error message, and is as specific as possible.
|
16
|
+
#
|
17
|
+
# ImplementationErrors are those that could only be thrown during program implementation
|
18
|
+
# and extension. For example, a method is passed something it is not expecting or cannot
|
19
|
+
# handle (e.g., a writer is passed an invalid model). These errors are not caught by the
|
20
|
+
# main program, instead left to execute in the normal fashion including stacktrace to
|
21
|
+
# enable program debugging by a developer.
|
22
|
+
#
|
23
|
+
# ImplementationErrors have three sub-categories. They are split into errors being raised
|
24
|
+
# from either the Reader (ImplementationReaderError), the Model (ImplementationModelError),
|
25
|
+
# or the Writer (ImplementationWriterError). Please use the ImplementationError sub-class
|
26
|
+
# consistent with where the error is being raised. This helps provide an easy way to see
|
27
|
+
# which stage in program execution an error has occurred.
|
1
28
|
module BioInterchange::Exceptions
|
2
29
|
|
3
30
|
# Top level Error class for all framework errors.
|
@@ -34,7 +34,7 @@ private
|
|
34
34
|
def serialize_model(model)
|
35
35
|
graph = RDF::Graph.new
|
36
36
|
set_uri = RDF::URI.new(model.uri)
|
37
|
-
graph.insert(RDF::Statement.new(set_uri, RDF.type, BioInterchange::
|
37
|
+
graph.insert(RDF::Statement.new(set_uri, RDF.type, BioInterchange::GFF3O.Set))
|
38
38
|
model.contents.each { |feature|
|
39
39
|
serialize_feature(graph, set_uri, feature)
|
40
40
|
}
|
@@ -50,27 +50,30 @@ private
|
|
50
50
|
# TODO Make sure there is only one value in the 'ID' list.
|
51
51
|
feature_uri = RDF::URI.new("#{set_uri.to_s}/feature/#{feature.sequence_id},#{feature.source},#{feature.type.to_s.sub(/^[^:]+:\/\//, '')},#{feature.start_coordinate},#{feature.end_coordinate},#{feature.strand},#{feature.phase}") unless feature.attributes.has_key?('ID')
|
52
52
|
feature_uri = RDF::URI.new("#{set_uri.to_s}/feature/#{feature.attributes['ID'][0]}") if feature.attributes.has_key?('ID')
|
53
|
-
|
54
|
-
graph.insert(RDF::Statement.new(
|
55
|
-
graph.insert(RDF::Statement.new(feature_uri,
|
56
|
-
graph.insert(RDF::Statement.new(feature_uri, BioInterchange::
|
57
|
-
graph.insert(RDF::Statement.new(feature_uri, BioInterchange::
|
58
|
-
graph.insert(RDF::Statement.new(feature_uri, BioInterchange::
|
59
|
-
graph.insert(RDF::Statement.new(feature_uri, BioInterchange::
|
60
|
-
graph.insert(RDF::Statement.new(feature_uri, BioInterchange::
|
53
|
+
feature_properties = BioInterchange::GFF3O.feature_properties.select { |uri| BioInterchange::GFF3O.is_datatype_property?(uri) }[0]
|
54
|
+
graph.insert(RDF::Statement.new(set_uri, BioInterchange::GFF3O.contains, feature_uri))
|
55
|
+
graph.insert(RDF::Statement.new(feature_uri, RDF.type, BioInterchange::GFF3O.Feature))
|
56
|
+
graph.insert(RDF::Statement.new(feature_uri, BioInterchange::GFF3O.seqid, RDF::Literal.new(feature.sequence_id)))
|
57
|
+
graph.insert(RDF::Statement.new(feature_uri, BioInterchange::GFF3O.source, RDF::Literal.new(feature.source)))
|
58
|
+
graph.insert(RDF::Statement.new(feature_uri, BioInterchange::GFF3O.type, RDF::Literal.new(feature.type)))
|
59
|
+
graph.insert(RDF::Statement.new(feature_uri, BioInterchange::GFF3O.with_parent(BioInterchange::GFF3O.start, feature_properties)[0], RDF::Literal.new(feature.start_coordinate)))
|
60
|
+
graph.insert(RDF::Statement.new(feature_uri, BioInterchange::GFF3O.with_parent(BioInterchange::GFF3O.end, feature_properties)[0], RDF::Literal.new(feature.end_coordinate)))
|
61
|
+
graph.insert(RDF::Statement.new(feature_uri, BioInterchange::GFF3O.score, RDF::Literal.new(feature.score))) if feature.score
|
62
|
+
feature_properties = BioInterchange::GFF3O.feature_properties.select { |uri| BioInterchange::GFF3O.is_object_property?(uri) }[0]
|
63
|
+
strand_uri = BioInterchange::GFF3O.with_parent(BioInterchange::GFF3O.strand, feature_properties)[0]
|
61
64
|
case feature.strand
|
62
65
|
when BioInterchange::Genomics::GFF3Feature::NOT_STRANDED
|
63
|
-
graph.insert(RDF::Statement.new(feature_uri,
|
66
|
+
graph.insert(RDF::Statement.new(feature_uri, strand_uri, BioInterchange::GFF3O.NotStranded))
|
64
67
|
when BioInterchange::Genomics::GFF3Feature::UNKNOWN
|
65
|
-
graph.insert(RDF::Statement.new(feature_uri,
|
68
|
+
graph.insert(RDF::Statement.new(feature_uri, strand_uri, BioInterchange::GFF3O.UnknownStrand))
|
66
69
|
when BioInterchange::Genomics::GFF3Feature::POSITIVE
|
67
|
-
graph.insert(RDF::Statement.new(feature_uri,
|
70
|
+
graph.insert(RDF::Statement.new(feature_uri, strand_uri, BioInterchange::GFF3O.Positive))
|
68
71
|
when BioInterchange::Genomics::GFF3Feature::NEGATIVE
|
69
|
-
graph.insert(RDF::Statement.new(feature_uri,
|
72
|
+
graph.insert(RDF::Statement.new(feature_uri, strand_uri, BioInterchange::GFF3O.Negative))
|
70
73
|
else
|
71
74
|
raise ArgumentException, 'Strand of feature is set to an unknown constant.'
|
72
75
|
end
|
73
|
-
graph.insert(RDF::Statement.new(feature_uri, BioInterchange::
|
76
|
+
graph.insert(RDF::Statement.new(feature_uri, BioInterchange::GFF3O.phase, RDF::Literal.new(feature.phase))) if feature.phase
|
74
77
|
|
75
78
|
serialize_attributes(graph, set_uri, feature_uri, feature.attributes) unless feature.attributes.keys.empty?
|
76
79
|
end
|
@@ -85,16 +88,16 @@ private
|
|
85
88
|
attributes.each_pair { |tag, list|
|
86
89
|
if tag == 'Parent' then
|
87
90
|
list.each { |parent_id|
|
88
|
-
graph.insert(RDF::Statement.new(feature_uri, BioInterchange::
|
91
|
+
graph.insert(RDF::Statement.new(feature_uri, BioInterchange::GFF3O.parent, RDF::URI.new("#{set_uri.to_s}/feature/#{parent_id}")))
|
89
92
|
}
|
90
93
|
else
|
91
94
|
list.each_index { |index|
|
92
95
|
value = list[index]
|
93
96
|
attribute_uri = RDF::URI.new("#{feature_uri.to_s}/attribute/#{tag}") if list.size == 1
|
94
97
|
attribute_uri = RDF::URI.new("#{feature_uri.to_s}/attribute/#{tag}-#{index + 1}") unless list.size == 1
|
95
|
-
graph.insert(RDF::Statement.new(feature_uri, BioInterchange::
|
96
|
-
graph.insert(RDF::Statement.new(attribute_uri, RDF.type, BioInterchange::
|
97
|
-
graph.insert(RDF::Statement.new(attribute_uri, BioInterchange::
|
98
|
+
graph.insert(RDF::Statement.new(feature_uri, BioInterchange::GFF3O.attributes, attribute_uri))
|
99
|
+
graph.insert(RDF::Statement.new(attribute_uri, RDF.type, BioInterchange::GFF3O.Attribute))
|
100
|
+
graph.insert(RDF::Statement.new(attribute_uri, BioInterchange::GFF3O.tag, RDF::Literal.new("#{tag}")))
|
98
101
|
graph.insert(RDF::Statement.new(attribute_uri, RDF.value, RDF::Literal.new(value)))
|
99
102
|
}
|
100
103
|
end
|
@@ -0,0 +1,495 @@
|
|
1
|
+
require 'rdf'
|
2
|
+
module BioInterchange
|
3
|
+
|
4
|
+
class GFF3O
|
5
|
+
|
6
|
+
# Either:
|
7
|
+
# Strand of the feature.
|
8
|
+
# (http://www.biointerchange.org/gff3o#GFF3_0010)
|
9
|
+
# Or:
|
10
|
+
# Strand of a target -- if applicable.
|
11
|
+
# (http://www.biointerchange.org/gff3o#GFF3_0045)
|
12
|
+
def self.strand
|
13
|
+
return [ RDF::URI.new('http://www.biointerchange.org/gff3o#GFF3_0010'), RDF::URI.new('http://www.biointerchange.org/gff3o#GFF3_0045') ]
|
14
|
+
end
|
15
|
+
|
16
|
+
# Tag name/value pair attributes of a feature that are not covered by object-/data-properties of the ontology. Tags that are represented as object-/data-properties are: ID, Name, Alias, Parent, Target, Gap, Derives_from, Dbxref, Ontology_term, Ontology_term, or Is_circular
|
17
|
+
# (http://www.biointerchange.org/gff3o#GFF3_0012)
|
18
|
+
def self.attributes
|
19
|
+
return RDF::URI.new('http://www.biointerchange.org/gff3o#GFF3_0012')
|
20
|
+
end
|
21
|
+
|
22
|
+
# Link out to the parent feature.
|
23
|
+
# (http://www.biointerchange.org/gff3o#GFF3_0014)
|
24
|
+
def self.parent
|
25
|
+
return RDF::URI.new('http://www.biointerchange.org/gff3o#GFF3_0014')
|
26
|
+
end
|
27
|
+
|
28
|
+
# Relationship that describes which features belong to a feature set.
|
29
|
+
# (http://www.biointerchange.org/gff3o#GFF3_0015)
|
30
|
+
def self.contains
|
31
|
+
return RDF::URI.new('http://www.biointerchange.org/gff3o#GFF3_0015')
|
32
|
+
end
|
33
|
+
|
34
|
+
# Either:
|
35
|
+
# FALDO "Region" instance replacement for a feature's start, stop, strand properties.
|
36
|
+
# (http://www.biointerchange.org/gff3o#GFF3_0021)
|
37
|
+
# Or:
|
38
|
+
# FALDO "Region" instance replacement for a target's start, stop, strand properties.
|
39
|
+
# (http://www.biointerchange.org/gff3o#GFF3_0050)
|
40
|
+
def self.region
|
41
|
+
return [ RDF::URI.new('http://www.biointerchange.org/gff3o#GFF3_0021'), RDF::URI.new('http://www.biointerchange.org/gff3o#GFF3_0050') ]
|
42
|
+
end
|
43
|
+
|
44
|
+
# NCBI Taxonomy Ontology "NCBITaxon_1" (or sub-classes) instance that denotes the species for a feature set.
|
45
|
+
# (http://www.biointerchange.org/gff3o#GFF3_0023)
|
46
|
+
def self.species
|
47
|
+
return RDF::URI.new('http://www.biointerchange.org/gff3o#GFF3_0023')
|
48
|
+
end
|
49
|
+
|
50
|
+
# Either:
|
51
|
+
# Properties that are directly associated with Set class instances.
|
52
|
+
# (http://www.biointerchange.org/gff3o#GFF3_0025)
|
53
|
+
# Or:
|
54
|
+
# Properties that are directly associated with Set class instances.
|
55
|
+
# (http://www.biointerchange.org/gff3o#GFF3_0027)
|
56
|
+
def self.set_properties
|
57
|
+
return [ RDF::URI.new('http://www.biointerchange.org/gff3o#GFF3_0025'), RDF::URI.new('http://www.biointerchange.org/gff3o#GFF3_0027') ]
|
58
|
+
end
|
59
|
+
|
60
|
+
# Either:
|
61
|
+
# Properties that are directly associated with Feature class instances.
|
62
|
+
# (http://www.biointerchange.org/gff3o#GFF3_0026)
|
63
|
+
# Or:
|
64
|
+
# Properties that are directly associated with Feature class instances.
|
65
|
+
# (http://www.biointerchange.org/gff3o#GFF3_0028)
|
66
|
+
def self.feature_properties
|
67
|
+
return [ RDF::URI.new('http://www.biointerchange.org/gff3o#GFF3_0026'), RDF::URI.new('http://www.biointerchange.org/gff3o#GFF3_0028') ]
|
68
|
+
end
|
69
|
+
|
70
|
+
# A database cross-reference to associate a sequence alteration to its representation in another database.
|
71
|
+
# (http://www.biointerchange.org/gff3o#GFF3_0034)
|
72
|
+
def self.dbxref
|
73
|
+
return RDF::URI.new('http://www.biointerchange.org/gff3o#GFF3_0034')
|
74
|
+
end
|
75
|
+
|
76
|
+
# A cross-reference to an ontology term that is associated with a feature.
|
77
|
+
# (http://www.biointerchange.org/gff3o#GFF3_0035)
|
78
|
+
def self.ontology_term
|
79
|
+
return RDF::URI.new('http://www.biointerchange.org/gff3o#GFF3_0035')
|
80
|
+
end
|
81
|
+
|
82
|
+
# Identifies the target that the features aligns to.
|
83
|
+
# (http://www.biointerchange.org/gff3o#GFF3_0039)
|
84
|
+
def self.target
|
85
|
+
return RDF::URI.new('http://www.biointerchange.org/gff3o#GFF3_0039')
|
86
|
+
end
|
87
|
+
|
88
|
+
# Either:
|
89
|
+
# Properties that are directly associated with Target class instances.
|
90
|
+
# (http://www.biointerchange.org/gff3o#GFF3_0044)
|
91
|
+
# Or:
|
92
|
+
# Properties that are directly associated with Target class instances.
|
93
|
+
# (http://www.biointerchange.org/gff3o#GFF3_0040)
|
94
|
+
def self.target_properties
|
95
|
+
return [ RDF::URI.new('http://www.biointerchange.org/gff3o#GFF3_0044'), RDF::URI.new('http://www.biointerchange.org/gff3o#GFF3_0040') ]
|
96
|
+
end
|
97
|
+
|
98
|
+
# Describes a temporal relationship between two features, where the object denotes the subjects origin.
|
99
|
+
# (http://www.biointerchange.org/gff3o#GFF3_0047)
|
100
|
+
def self.derives_from
|
101
|
+
return RDF::URI.new('http://www.biointerchange.org/gff3o#GFF3_0047')
|
102
|
+
end
|
103
|
+
|
104
|
+
# ID of the landmark that establishes the coordinate system for the current feature.
|
105
|
+
# (http://www.biointerchange.org/gff3o#GFF3_0004)
|
106
|
+
def self.seqid
|
107
|
+
return RDF::URI.new('http://www.biointerchange.org/gff3o#GFF3_0004')
|
108
|
+
end
|
109
|
+
|
110
|
+
# A free text qualifier that describes the algorithm or operating procedure that generated this feature. For example, the name of the software that generated this feature or a database name.
|
111
|
+
# (http://www.biointerchange.org/gff3o#GFF3_0005)
|
112
|
+
def self.source
|
113
|
+
return RDF::URI.new('http://www.biointerchange.org/gff3o#GFF3_0005')
|
114
|
+
end
|
115
|
+
|
116
|
+
# Type of the feature, which is either a term from the "lite" version of the Sequence Ontology (SOFA), a term from the full Sequence Ontology (SO) that is a child of sequence_feature (SO:0000110), or a SOFA or SO accession number.
|
117
|
+
# (http://www.biointerchange.org/gff3o#GFF3_0006)
|
118
|
+
def self.type
|
119
|
+
return RDF::URI.new('http://www.biointerchange.org/gff3o#GFF3_0006')
|
120
|
+
end
|
121
|
+
|
122
|
+
# Either:
|
123
|
+
# Start coordinate of the feature on the seqid landmark.
|
124
|
+
# (http://www.biointerchange.org/gff3o#GFF3_0007)
|
125
|
+
# Or:
|
126
|
+
# Start coordinate of the target.
|
127
|
+
# (http://www.biointerchange.org/gff3o#GFF3_0042)
|
128
|
+
def self.start
|
129
|
+
return [ RDF::URI.new('http://www.biointerchange.org/gff3o#GFF3_0007'), RDF::URI.new('http://www.biointerchange.org/gff3o#GFF3_0042') ]
|
130
|
+
end
|
131
|
+
|
132
|
+
# Either:
|
133
|
+
# End coordinate of the feature on the seqid landmark.
|
134
|
+
# (http://www.biointerchange.org/gff3o#GFF3_0008)
|
135
|
+
# Or:
|
136
|
+
# End coordinate of the target.
|
137
|
+
# (http://www.biointerchange.org/gff3o#GFF3_0043)
|
138
|
+
def self.end
|
139
|
+
return [ RDF::URI.new('http://www.biointerchange.org/gff3o#GFF3_0008'), RDF::URI.new('http://www.biointerchange.org/gff3o#GFF3_0043') ]
|
140
|
+
end
|
141
|
+
|
142
|
+
# Score of the feature. For example, an E-value for sequence similarity features or a P-value for ab initio gene prediction features.
|
143
|
+
# (http://www.biointerchange.org/gff3o#GFF3_0009)
|
144
|
+
def self.score
|
145
|
+
return RDF::URI.new('http://www.biointerchange.org/gff3o#GFF3_0009')
|
146
|
+
end
|
147
|
+
|
148
|
+
# Phase for "CDS" features. It indicates where the feature begins with reference to the reading frame. For forward strand features, phase is counted from the start field, whilst for reverse strand features, phase is counted from the end field.
|
149
|
+
# (http://www.biointerchange.org/gff3o#GFF3_0011)
|
150
|
+
def self.phase
|
151
|
+
return RDF::URI.new('http://www.biointerchange.org/gff3o#GFF3_0011')
|
152
|
+
end
|
153
|
+
|
154
|
+
# Tag name of a feature attribute.
|
155
|
+
# (http://www.biointerchange.org/gff3o#GFF3_0013)
|
156
|
+
def self.tag
|
157
|
+
return RDF::URI.new('http://www.biointerchange.org/gff3o#GFF3_0013')
|
158
|
+
end
|
159
|
+
|
160
|
+
# Version of the GFF3 specification that defines the feature set contents.
|
161
|
+
# (http://www.biointerchange.org/gff3o#GFF3_0022)
|
162
|
+
def self.version
|
163
|
+
return RDF::URI.new('http://www.biointerchange.org/gff3o#GFF3_0022')
|
164
|
+
end
|
165
|
+
|
166
|
+
# Name of a genome assembly build that denotes the provenance of features in a feature set. For example, 'NCBI 36' or 'FlyBase r4.1'.
|
167
|
+
# (http://www.biointerchange.org/gff3o#GFF3_0024)
|
168
|
+
def self.build
|
169
|
+
return RDF::URI.new('http://www.biointerchange.org/gff3o#GFF3_0024')
|
170
|
+
end
|
171
|
+
|
172
|
+
# Properties that are directly associated with Attribute class instances.
|
173
|
+
# (http://www.biointerchange.org/gff3o#GFF3_0029)
|
174
|
+
def self.attribute_properties
|
175
|
+
return RDF::URI.new('http://www.biointerchange.org/gff3o#GFF3_0029')
|
176
|
+
end
|
177
|
+
|
178
|
+
# Properties that are directly associated with DBXRef class instances.
|
179
|
+
# (http://www.biointerchange.org/gff3o#GFF3_0031)
|
180
|
+
def self.dbxref_properties
|
181
|
+
return RDF::URI.new('http://www.biointerchange.org/gff3o#GFF3_0031')
|
182
|
+
end
|
183
|
+
|
184
|
+
# Either:
|
185
|
+
# Name of an external database. For example, "dbSNP" or "OMIM".
|
186
|
+
# (http://www.biointerchange.org/gff3o#GFF3_0032)
|
187
|
+
# Or:
|
188
|
+
# Name of a feature, which can be used for display purposes. The name is not a unique property among features.
|
189
|
+
# (http://www.biointerchange.org/gff3o#GFF3_0036)
|
190
|
+
def self.name
|
191
|
+
return [ RDF::URI.new('http://www.biointerchange.org/gff3o#GFF3_0032'), RDF::URI.new('http://www.biointerchange.org/gff3o#GFF3_0036') ]
|
192
|
+
end
|
193
|
+
|
194
|
+
# External database identifier. For example, for dbSNP, this identifier could be "rs3131969".
|
195
|
+
# (http://www.biointerchange.org/gff3o#GFF3_0033)
|
196
|
+
def self.xref
|
197
|
+
return RDF::URI.new('http://www.biointerchange.org/gff3o#GFF3_0033')
|
198
|
+
end
|
199
|
+
|
200
|
+
# An alternative name for a feature. This can be another descriptive name of a feature, such as a locus name or accession number.
|
201
|
+
# (http://www.biointerchange.org/gff3o#GFF3_0037)
|
202
|
+
def self.alias
|
203
|
+
return RDF::URI.new('http://www.biointerchange.org/gff3o#GFF3_0037')
|
204
|
+
end
|
205
|
+
|
206
|
+
# ID or accession of the target alignment.
|
207
|
+
# (http://www.biointerchange.org/gff3o#GFF3_0041)
|
208
|
+
def self.target_id
|
209
|
+
return RDF::URI.new('http://www.biointerchange.org/gff3o#GFF3_0041')
|
210
|
+
end
|
211
|
+
|
212
|
+
# Gap describing the feature/target alignment if the sequences are not collinear. The formal description of this property has been lost due to a dead link in the GFF3 specification.
|
213
|
+
# (http://www.biointerchange.org/gff3o#GFF3_0046)
|
214
|
+
def self.gap
|
215
|
+
return RDF::URI.new('http://www.biointerchange.org/gff3o#GFF3_0046')
|
216
|
+
end
|
217
|
+
|
218
|
+
# A free text note.
|
219
|
+
# (http://www.biointerchange.org/gff3o#GFF3_0048)
|
220
|
+
def self.note
|
221
|
+
return RDF::URI.new('http://www.biointerchange.org/gff3o#GFF3_0048')
|
222
|
+
end
|
223
|
+
|
224
|
+
# Describes whether a feature is circular or not.
|
225
|
+
# (http://www.biointerchange.org/gff3o#GFF3_0049)
|
226
|
+
def self.is_circular
|
227
|
+
return RDF::URI.new('http://www.biointerchange.org/gff3o#GFF3_0049')
|
228
|
+
end
|
229
|
+
|
230
|
+
# Set of genomic sequence features, whose identifiers are unique within the set.
|
231
|
+
# (http://www.biointerchange.org/gff3o#GFF3_0001)
|
232
|
+
def self.Set
|
233
|
+
return RDF::URI.new('http://www.biointerchange.org/gff3o#GFF3_0001')
|
234
|
+
end
|
235
|
+
|
236
|
+
# A genomic sequence feature.
|
237
|
+
# (http://www.biointerchange.org/gff3o#GFF3_0002)
|
238
|
+
def self.Feature
|
239
|
+
return RDF::URI.new('http://www.biointerchange.org/gff3o#GFF3_0002')
|
240
|
+
end
|
241
|
+
|
242
|
+
# Describes additional feature attributes besides ID, Name, Alias, Parent, Target, Gap, Derives_from, Dbxref, Ontology_term, Ontology_term, or Is_circular.
|
243
|
+
# (http://www.biointerchange.org/gff3o#GFF3_0003)
|
244
|
+
def self.Attribute
|
245
|
+
return RDF::URI.new('http://www.biointerchange.org/gff3o#GFF3_0003')
|
246
|
+
end
|
247
|
+
|
248
|
+
# Class describing a genomic strand. Instances of the class (individuals) are used to denote forward-/reverse-strands, etc.
|
249
|
+
# (http://www.biointerchange.org/gff3o#GFF3_0016)
|
250
|
+
def self.Strand
|
251
|
+
return RDF::URI.new('http://www.biointerchange.org/gff3o#GFF3_0016')
|
252
|
+
end
|
253
|
+
|
254
|
+
# A class describing relationships between features and external databases.
|
255
|
+
# (http://www.biointerchange.org/gff3o#GFF3_0030)
|
256
|
+
def self.DBXRef
|
257
|
+
return RDF::URI.new('http://www.biointerchange.org/gff3o#GFF3_0030')
|
258
|
+
end
|
259
|
+
|
260
|
+
# Indicates a feature's "target" of a nucleotide-to-nucleotide or protein-to-nucleotide alignment.
|
261
|
+
# (http://www.biointerchange.org/gff3o#GFF3_0038)
|
262
|
+
def self.Target
|
263
|
+
return RDF::URI.new('http://www.biointerchange.org/gff3o#GFF3_0038')
|
264
|
+
end
|
265
|
+
|
266
|
+
# Location on the positive (forward) strand.
|
267
|
+
# (http://www.biointerchange.org/gff3o#GFF3_0017)
|
268
|
+
def self.Positive
|
269
|
+
return RDF::URI.new('http://www.biointerchange.org/gff3o#GFF3_0017')
|
270
|
+
end
|
271
|
+
|
272
|
+
# Location on the negative (reverse) strand.
|
273
|
+
# (http://www.biointerchange.org/gff3o#GFF3_0018)
|
274
|
+
def self.Negative
|
275
|
+
return RDF::URI.new('http://www.biointerchange.org/gff3o#GFF3_0018')
|
276
|
+
end
|
277
|
+
|
278
|
+
# Strand was not determined, which leaves it open whether the location is on the positive (forward) or negative (reverse) strand.
|
279
|
+
# (http://www.biointerchange.org/gff3o#GFF3_0019)
|
280
|
+
def self.UnknownStrand
|
281
|
+
return RDF::URI.new('http://www.biointerchange.org/gff3o#GFF3_0019')
|
282
|
+
end
|
283
|
+
|
284
|
+
# Strand is not applicable.
|
285
|
+
# (http://www.biointerchange.org/gff3o#GFF3_0020)
|
286
|
+
def self.NotStranded
|
287
|
+
return RDF::URI.new('http://www.biointerchange.org/gff3o#GFF3_0020')
|
288
|
+
end
|
289
|
+
|
290
|
+
# Determines whether the given URI is an object property.
|
291
|
+
#
|
292
|
+
# +uri+:: URI that is tested for being an object property
|
293
|
+
def self.is_object_property?(uri)
|
294
|
+
if uri == RDF::URI.new('http://www.biointerchange.org/gff3o#GFF3_0010') then
|
295
|
+
return true
|
296
|
+
end
|
297
|
+
if uri == RDF::URI.new('http://www.biointerchange.org/gff3o#GFF3_0012') then
|
298
|
+
return true
|
299
|
+
end
|
300
|
+
if uri == RDF::URI.new('http://www.biointerchange.org/gff3o#GFF3_0014') then
|
301
|
+
return true
|
302
|
+
end
|
303
|
+
if uri == RDF::URI.new('http://www.biointerchange.org/gff3o#GFF3_0015') then
|
304
|
+
return true
|
305
|
+
end
|
306
|
+
if uri == RDF::URI.new('http://www.biointerchange.org/gff3o#GFF3_0021') then
|
307
|
+
return true
|
308
|
+
end
|
309
|
+
if uri == RDF::URI.new('http://www.biointerchange.org/gff3o#GFF3_0023') then
|
310
|
+
return true
|
311
|
+
end
|
312
|
+
if uri == RDF::URI.new('http://www.biointerchange.org/gff3o#GFF3_0025') then
|
313
|
+
return true
|
314
|
+
end
|
315
|
+
if uri == RDF::URI.new('http://www.biointerchange.org/gff3o#GFF3_0026') then
|
316
|
+
return true
|
317
|
+
end
|
318
|
+
if uri == RDF::URI.new('http://www.biointerchange.org/gff3o#GFF3_0034') then
|
319
|
+
return true
|
320
|
+
end
|
321
|
+
if uri == RDF::URI.new('http://www.biointerchange.org/gff3o#GFF3_0035') then
|
322
|
+
return true
|
323
|
+
end
|
324
|
+
if uri == RDF::URI.new('http://www.biointerchange.org/gff3o#GFF3_0039') then
|
325
|
+
return true
|
326
|
+
end
|
327
|
+
if uri == RDF::URI.new('http://www.biointerchange.org/gff3o#GFF3_0044') then
|
328
|
+
return true
|
329
|
+
end
|
330
|
+
if uri == RDF::URI.new('http://www.biointerchange.org/gff3o#GFF3_0045') then
|
331
|
+
return true
|
332
|
+
end
|
333
|
+
if uri == RDF::URI.new('http://www.biointerchange.org/gff3o#GFF3_0047') then
|
334
|
+
return true
|
335
|
+
end
|
336
|
+
if uri == RDF::URI.new('http://www.biointerchange.org/gff3o#GFF3_0050') then
|
337
|
+
return true
|
338
|
+
end
|
339
|
+
return false
|
340
|
+
end
|
341
|
+
|
342
|
+
# Determines whether the given URI is a datatype property.
|
343
|
+
#
|
344
|
+
# +uri+:: URI that is tested for being a datatype property
|
345
|
+
def self.is_datatype_property?(uri)
|
346
|
+
if uri == RDF::URI.new('http://www.biointerchange.org/gff3o#GFF3_0004') then
|
347
|
+
return true
|
348
|
+
end
|
349
|
+
if uri == RDF::URI.new('http://www.biointerchange.org/gff3o#GFF3_0005') then
|
350
|
+
return true
|
351
|
+
end
|
352
|
+
if uri == RDF::URI.new('http://www.biointerchange.org/gff3o#GFF3_0006') then
|
353
|
+
return true
|
354
|
+
end
|
355
|
+
if uri == RDF::URI.new('http://www.biointerchange.org/gff3o#GFF3_0007') then
|
356
|
+
return true
|
357
|
+
end
|
358
|
+
if uri == RDF::URI.new('http://www.biointerchange.org/gff3o#GFF3_0008') then
|
359
|
+
return true
|
360
|
+
end
|
361
|
+
if uri == RDF::URI.new('http://www.biointerchange.org/gff3o#GFF3_0009') then
|
362
|
+
return true
|
363
|
+
end
|
364
|
+
if uri == RDF::URI.new('http://www.biointerchange.org/gff3o#GFF3_0011') then
|
365
|
+
return true
|
366
|
+
end
|
367
|
+
if uri == RDF::URI.new('http://www.biointerchange.org/gff3o#GFF3_0013') then
|
368
|
+
return true
|
369
|
+
end
|
370
|
+
if uri == RDF::URI.new('http://www.biointerchange.org/gff3o#GFF3_0022') then
|
371
|
+
return true
|
372
|
+
end
|
373
|
+
if uri == RDF::URI.new('http://www.biointerchange.org/gff3o#GFF3_0024') then
|
374
|
+
return true
|
375
|
+
end
|
376
|
+
if uri == RDF::URI.new('http://www.biointerchange.org/gff3o#GFF3_0027') then
|
377
|
+
return true
|
378
|
+
end
|
379
|
+
if uri == RDF::URI.new('http://www.biointerchange.org/gff3o#GFF3_0028') then
|
380
|
+
return true
|
381
|
+
end
|
382
|
+
if uri == RDF::URI.new('http://www.biointerchange.org/gff3o#GFF3_0029') then
|
383
|
+
return true
|
384
|
+
end
|
385
|
+
if uri == RDF::URI.new('http://www.biointerchange.org/gff3o#GFF3_0031') then
|
386
|
+
return true
|
387
|
+
end
|
388
|
+
if uri == RDF::URI.new('http://www.biointerchange.org/gff3o#GFF3_0032') then
|
389
|
+
return true
|
390
|
+
end
|
391
|
+
if uri == RDF::URI.new('http://www.biointerchange.org/gff3o#GFF3_0033') then
|
392
|
+
return true
|
393
|
+
end
|
394
|
+
if uri == RDF::URI.new('http://www.biointerchange.org/gff3o#GFF3_0036') then
|
395
|
+
return true
|
396
|
+
end
|
397
|
+
if uri == RDF::URI.new('http://www.biointerchange.org/gff3o#GFF3_0037') then
|
398
|
+
return true
|
399
|
+
end
|
400
|
+
if uri == RDF::URI.new('http://www.biointerchange.org/gff3o#GFF3_0040') then
|
401
|
+
return true
|
402
|
+
end
|
403
|
+
if uri == RDF::URI.new('http://www.biointerchange.org/gff3o#GFF3_0041') then
|
404
|
+
return true
|
405
|
+
end
|
406
|
+
if uri == RDF::URI.new('http://www.biointerchange.org/gff3o#GFF3_0042') then
|
407
|
+
return true
|
408
|
+
end
|
409
|
+
if uri == RDF::URI.new('http://www.biointerchange.org/gff3o#GFF3_0043') then
|
410
|
+
return true
|
411
|
+
end
|
412
|
+
if uri == RDF::URI.new('http://www.biointerchange.org/gff3o#GFF3_0046') then
|
413
|
+
return true
|
414
|
+
end
|
415
|
+
if uri == RDF::URI.new('http://www.biointerchange.org/gff3o#GFF3_0048') then
|
416
|
+
return true
|
417
|
+
end
|
418
|
+
if uri == RDF::URI.new('http://www.biointerchange.org/gff3o#GFF3_0049') then
|
419
|
+
return true
|
420
|
+
end
|
421
|
+
return false
|
422
|
+
end
|
423
|
+
|
424
|
+
# Determines whether the given URI is a class.
|
425
|
+
#
|
426
|
+
# +uri+:: URI that is tested for being a class
|
427
|
+
def self.is_class?(uri)
|
428
|
+
if uri == RDF::URI.new('http://www.biointerchange.org/gff3o#GFF3_0001') then
|
429
|
+
return true
|
430
|
+
end
|
431
|
+
if uri == RDF::URI.new('http://www.biointerchange.org/gff3o#GFF3_0002') then
|
432
|
+
return true
|
433
|
+
end
|
434
|
+
if uri == RDF::URI.new('http://www.biointerchange.org/gff3o#GFF3_0003') then
|
435
|
+
return true
|
436
|
+
end
|
437
|
+
if uri == RDF::URI.new('http://www.biointerchange.org/gff3o#GFF3_0016') then
|
438
|
+
return true
|
439
|
+
end
|
440
|
+
if uri == RDF::URI.new('http://www.biointerchange.org/gff3o#GFF3_0030') then
|
441
|
+
return true
|
442
|
+
end
|
443
|
+
if uri == RDF::URI.new('http://www.biointerchange.org/gff3o#GFF3_0038') then
|
444
|
+
return true
|
445
|
+
end
|
446
|
+
return false
|
447
|
+
end
|
448
|
+
|
449
|
+
# Determines whether the given URI is a named individual.
|
450
|
+
#
|
451
|
+
# +uri+:: URI that is tested for being a named individual
|
452
|
+
def self.is_named_individual?(uri)
|
453
|
+
if uri == RDF::URI.new('http://www.biointerchange.org/gff3o#GFF3_0017') then
|
454
|
+
return true
|
455
|
+
end
|
456
|
+
if uri == RDF::URI.new('http://www.biointerchange.org/gff3o#GFF3_0018') then
|
457
|
+
return true
|
458
|
+
end
|
459
|
+
if uri == RDF::URI.new('http://www.biointerchange.org/gff3o#GFF3_0019') then
|
460
|
+
return true
|
461
|
+
end
|
462
|
+
if uri == RDF::URI.new('http://www.biointerchange.org/gff3o#GFF3_0020') then
|
463
|
+
return true
|
464
|
+
end
|
465
|
+
return false
|
466
|
+
end
|
467
|
+
|
468
|
+
# Returns only those URIs that fall under a designated parent URI.
|
469
|
+
#
|
470
|
+
# +uris+:: Set of URIs that are tested whether they have the given parent URI.
|
471
|
+
# +parent+:: Parent URI.
|
472
|
+
def self.with_parent(uris, parent)
|
473
|
+
return uris.select { |uri| has_parent?(uri, parent) }
|
474
|
+
end
|
475
|
+
|
476
|
+
# Recursively tries to determine the parent for a given URI.
|
477
|
+
#
|
478
|
+
# +uri+:: URI that is tested for whether it has the given parent URI.
|
479
|
+
# +parent+:: Parent URI.
|
480
|
+
def self.has_parent?(uri, parent)
|
481
|
+
if @@parent_properties.has_key?(uri) then
|
482
|
+
if @@parent_properties[uri] == parent then
|
483
|
+
return true
|
484
|
+
end
|
485
|
+
return has_parent?(@@parent_properties[uri], parent)
|
486
|
+
end
|
487
|
+
return false
|
488
|
+
end
|
489
|
+
|
490
|
+
private
|
491
|
+
@@parent_properties = { RDF::URI.new('http://www.biointerchange.org/gff3o#GFF3_0010') => RDF::URI.new('http://www.biointerchange.org/gff3o#GFF3_0026') , RDF::URI.new('http://www.biointerchange.org/gff3o#GFF3_0012') => RDF::URI.new('http://www.biointerchange.org/gff3o#GFF3_0026') , RDF::URI.new('http://www.biointerchange.org/gff3o#GFF3_0014') => RDF::URI.new('http://www.biointerchange.org/gff3o#GFF3_0026') , RDF::URI.new('http://www.biointerchange.org/gff3o#GFF3_0015') => RDF::URI.new('http://www.biointerchange.org/gff3o#GFF3_0025') , RDF::URI.new('http://www.biointerchange.org/gff3o#GFF3_0021') => RDF::URI.new('http://www.biointerchange.org/gff3o#GFF3_0025') , RDF::URI.new('http://www.biointerchange.org/gff3o#GFF3_0023') => RDF::URI.new('http://www.biointerchange.org/gff3o#GFF3_0025') , RDF::URI.new('http://www.biointerchange.org/gff3o#GFF3_0034') => RDF::URI.new('http://www.biointerchange.org/gff3o#GFF3_0026') , RDF::URI.new('http://www.biointerchange.org/gff3o#GFF3_0035') => RDF::URI.new('http://www.biointerchange.org/gff3o#GFF3_0026') , RDF::URI.new('http://www.biointerchange.org/gff3o#GFF3_0039') => RDF::URI.new('http://www.biointerchange.org/gff3o#GFF3_0026') , RDF::URI.new('http://www.biointerchange.org/gff3o#GFF3_0045') => RDF::URI.new('http://www.biointerchange.org/gff3o#GFF3_0044') , RDF::URI.new('http://www.biointerchange.org/gff3o#GFF3_0047') => RDF::URI.new('http://www.biointerchange.org/gff3o#GFF3_0026') , RDF::URI.new('http://www.biointerchange.org/gff3o#GFF3_0050') => RDF::URI.new('http://www.biointerchange.org/gff3o#GFF3_0044') , RDF::URI.new('http://www.biointerchange.org/gff3o#GFF3_0004') => RDF::URI.new('http://www.biointerchange.org/gff3o#GFF3_0028') , RDF::URI.new('http://www.biointerchange.org/gff3o#GFF3_0005') => RDF::URI.new('http://www.biointerchange.org/gff3o#GFF3_0028') , RDF::URI.new('http://www.biointerchange.org/gff3o#GFF3_0006') => RDF::URI.new('http://www.biointerchange.org/gff3o#GFF3_0028') , RDF::URI.new('http://www.biointerchange.org/gff3o#GFF3_0007') => RDF::URI.new('http://www.biointerchange.org/gff3o#GFF3_0028') , RDF::URI.new('http://www.biointerchange.org/gff3o#GFF3_0008') => RDF::URI.new('http://www.biointerchange.org/gff3o#GFF3_0028') , RDF::URI.new('http://www.biointerchange.org/gff3o#GFF3_0009') => RDF::URI.new('http://www.biointerchange.org/gff3o#GFF3_0028') , RDF::URI.new('http://www.biointerchange.org/gff3o#GFF3_0011') => RDF::URI.new('http://www.biointerchange.org/gff3o#GFF3_0028') , RDF::URI.new('http://www.biointerchange.org/gff3o#GFF3_0013') => RDF::URI.new('http://www.biointerchange.org/gff3o#GFF3_0029') , RDF::URI.new('http://www.biointerchange.org/gff3o#GFF3_0022') => RDF::URI.new('http://www.biointerchange.org/gff3o#GFF3_0027') , RDF::URI.new('http://www.biointerchange.org/gff3o#GFF3_0024') => RDF::URI.new('http://www.biointerchange.org/gff3o#GFF3_0027') , RDF::URI.new('http://www.biointerchange.org/gff3o#GFF3_0032') => RDF::URI.new('http://www.biointerchange.org/gff3o#GFF3_0031') , RDF::URI.new('http://www.biointerchange.org/gff3o#GFF3_0033') => RDF::URI.new('http://www.biointerchange.org/gff3o#GFF3_0031') , RDF::URI.new('http://www.biointerchange.org/gff3o#GFF3_0036') => RDF::URI.new('http://www.biointerchange.org/gff3o#GFF3_0028') , RDF::URI.new('http://www.biointerchange.org/gff3o#GFF3_0037') => RDF::URI.new('http://www.biointerchange.org/gff3o#GFF3_0028') , RDF::URI.new('http://www.biointerchange.org/gff3o#GFF3_0041') => RDF::URI.new('http://www.biointerchange.org/gff3o#GFF3_0040') , RDF::URI.new('http://www.biointerchange.org/gff3o#GFF3_0042') => RDF::URI.new('http://www.biointerchange.org/gff3o#GFF3_0040') , RDF::URI.new('http://www.biointerchange.org/gff3o#GFF3_0043') => RDF::URI.new('http://www.biointerchange.org/gff3o#GFF3_0040') , RDF::URI.new('http://www.biointerchange.org/gff3o#GFF3_0046') => RDF::URI.new('http://www.biointerchange.org/gff3o#GFF3_0028') , RDF::URI.new('http://www.biointerchange.org/gff3o#GFF3_0048') => RDF::URI.new('http://www.biointerchange.org/gff3o#GFF3_0028') , RDF::URI.new('http://www.biointerchange.org/gff3o#GFF3_0049') => RDF::URI.new('http://www.biointerchange.org/gff3o#GFF3_0028') }
|
492
|
+
|
493
|
+
end
|
494
|
+
|
495
|
+
end
|