Skip to content

Commit

Permalink
Revert before blank node
Browse files Browse the repository at this point in the history
  • Loading branch information
mboudet committed Jul 11, 2022
1 parent d154265 commit 54c760c
Show file tree
Hide file tree
Showing 8 changed files with 18 additions and 34 deletions.
9 changes: 1 addition & 8 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

This changelog was started for release 4.2.0.

## [4.4.1] - Unreleased

### Changed

- Using blank node for categories values
- Changed documentation for blank nodes

## [4.4.0] - 2022-07-01
## Unreleased

### Fixed

Expand Down
9 changes: 3 additions & 6 deletions askomics/libaskomics/BedFile.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,11 +109,10 @@ def set_rdf_abstraction_domain_knowledge(self):
attribute_blanks[attribute["uri"]] = blank
# Domain Knowledge
if "values" in attribute.keys():
blank_category = attribute["range"]
for value in attribute["values"]:
self.graph_abstraction_dk.add((self.namespace_data[self.format_uri(value)], rdflib.RDF.type, self.namespace_data[self.format_uri("{}CategoryValue".format(attribute["label"]))]))
self.graph_abstraction_dk.add((self.namespace_data[self.format_uri(value)], rdflib.RDFS.label, rdflib.Literal(value)))
self.graph_abstraction_dk.add((blank_category, self.namespace_internal[self.format_uri("category")], self.namespace_data[self.format_uri(value)]))
self.graph_abstraction_dk.add((self.namespace_data[self.format_uri("{}Category".format(attribute["label"]))], self.namespace_internal[self.format_uri("category")], self.namespace_data[self.format_uri(value)]))

if attribute["label"] == rdflib.Literal("strand"):
self.graph_abstraction_dk.add((self.namespace_data[self.format_uri(value)], rdflib.RDF.type, self.get_faldo_strand(value)))
Expand Down Expand Up @@ -176,14 +175,13 @@ def generate_rdf_content(self):
self.graph_chunk.add((entity, relation, attribute))

if "reference" not in attribute_list:
blank_category = BNode()
attribute_list.append("reference")
self.attribute_abstraction.append({
"uri": self.namespace_data[self.format_uri("reference")],
"label": rdflib.Literal("reference"),
"type": [self.namespace_internal[self.format_uri("AskomicsCategory")], rdflib.OWL.ObjectProperty],
"domain": entity_type,
"range": blank_category,
"range": self.namespace_data[self.format_uri("{}Category".format("reference"))],
"values": [feature.chrom]
})
else:
Expand Down Expand Up @@ -259,14 +257,13 @@ def generate_rdf_content(self):

if strand:
if ("strand", strand_type) not in attribute_list:
blank_category = BNode()
attribute_list.append(("strand", strand_type))
self.attribute_abstraction.append({
"uri": self.namespace_data[self.format_uri("strand")],
"label": rdflib.Literal("strand"),
"type": [self.namespace_internal[self.format_uri("AskomicsCategory")], rdflib.OWL.ObjectProperty],
"domain": entity_type,
"range": blank_category,
"range": self.namespace_data[self.format_uri("{}Category".format("strand"))],
"values": [strand_type]
})

Expand Down
9 changes: 3 additions & 6 deletions askomics/libaskomics/CsvFile.py
Original file line number Diff line number Diff line change
Expand Up @@ -362,8 +362,8 @@ def set_rdf_abstraction_domain_knowledge(self):
def set_rdf_domain_knowledge(self):
"""Set the domain knowledge"""
for index, attribute in enumerate(self.header):
if self.columns_type[index] in ('category', 'reference', 'strand') and self.header[index] in self.category_values and self.header[index] in self.category_blank:
s = self.category_blank[self.header[index]]
if self.columns_type[index] in ('category', 'reference', 'strand') and self.header[index] in self.category_values:
s = self.namespace_data["{}Category".format(self.format_uri(attribute, remove_space=True))]
p = self.namespace_internal["category"]
for value in self.category_values[self.header[index]]:
o = self.rdfize(value)
Expand Down Expand Up @@ -400,7 +400,6 @@ def set_rdf_abstraction(self):
for ontology in OntologyManager(self.app, self.session).list_ontologies():
available_ontologies[ontology['short_name']] = ontology['uri']
attribute_blanks = {}
self.category_blank = {}

# Attributes and relations
for index, attribute_name in enumerate(self.header):
Expand Down Expand Up @@ -469,9 +468,7 @@ def set_rdf_abstraction(self):
elif self.columns_type[index] in ('category', 'reference', 'strand'):
attribute = self.rdfize(attribute_name)
label = rdflib.Literal(attribute_name)
category_blank = BNode()
self.category_blank[attribute_name] = category_blank
rdf_range = category_blank
rdf_range = self.namespace_data["{}Category".format(self.format_uri(attribute_name, remove_space=True))]
rdf_type = rdflib.OWL.ObjectProperty
self.graph_abstraction_dk.add((blank, rdflib.RDF.type, self.namespace_internal["AskomicsCategory"]))

Expand Down
9 changes: 3 additions & 6 deletions askomics/libaskomics/GffFile.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,11 +136,10 @@ def set_rdf_abstraction_domain_knowledge(self):
attribute_blanks[attribute["uri"]] = blank
# Domain Knowledge
if "values" in attribute.keys():
blank_category = attribute["range"]
for value in attribute["values"]:
self.graph_abstraction_dk.add((self.namespace_data[self.format_uri(value)], rdflib.RDF.type, self.namespace_data[self.format_uri("{}CategoryValue".format(attribute["label"]))]))
self.graph_abstraction_dk.add((self.namespace_data[self.format_uri(value)], rdflib.RDFS.label, rdflib.Literal(value)))
self.graph_abstraction_dk.add((blank_category, self.namespace_internal[self.format_uri("category")], self.namespace_data[self.format_uri(value)]))
self.graph_abstraction_dk.add((self.namespace_data[self.format_uri("{}Category".format(attribute["label"]))], self.namespace_internal[self.format_uri("category")], self.namespace_data[self.format_uri(value)]))

if attribute["label"] == rdflib.Literal("strand"):
self.graph_abstraction_dk.add((self.namespace_data[self.format_uri(value)], rdflib.RDF.type, self.get_faldo_strand(value)))
Expand Down Expand Up @@ -238,14 +237,13 @@ def generate_rdf_content(self):
# self.graph_chunk.add((entity, relation, attribute))

if (feature.type, "reference") not in attribute_list:
blank_category = BNode()
attribute_list.append((feature.type, "reference"))
self.attribute_abstraction.append({
"uri": self.namespace_data[self.format_uri("reference")],
"label": rdflib.Literal("reference"),
"type": [self.namespace_internal[self.format_uri("AskomicsCategory")], rdflib.OWL.ObjectProperty],
"domain": entity_type,
"range": blank_category,
"range": self.namespace_data[self.format_uri("{}Category".format("reference"))],
"values": [rec.id]
})
else:
Expand Down Expand Up @@ -314,14 +312,13 @@ def generate_rdf_content(self):
strand_type = "."

if (feature.type, "strand", strand_type) not in attribute_list:
blank_category = BNode()
attribute_list.append((feature.type, "strand", strand_type))
self.attribute_abstraction.append({
"uri": self.namespace_data[self.format_uri("strand")],
"label": rdflib.Literal("strand"),
"type": [self.namespace_internal[self.format_uri("AskomicsCategory")], rdflib.OWL.ObjectProperty],
"domain": entity_type,
"range": blank_category,
"range": self.namespace_data[self.format_uri("{}Category".format("strand"))],
"values": [strand_type]
})

Expand Down
10 changes: 5 additions & 5 deletions docs/abstraction.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,12 +82,12 @@ _:blank rdf:type owl:ObjectProperty .
_:blank rdf:type askomics:AskomicsCategory .
_:blank rdfs:label "category_attribute" .
_:blank rdfs:domain :EntityName .
_:blank rdfs:range _:blank2 .
_:blank rdfs:range :category_attributeCategory .
_:blank askomics:uri :category_attribute_uri
_:blank2 askomics:category :value_1 .
_:blank2 askomics:category :value_2 .
:category_attributeCategory askomics:category :value_1 .
:category_attributeCategory askomics:category :value_2 .
:value_1 rdf:type :category_attributeCategoryValue .
:value_1 rdfs:label "value_1" .
Expand Down Expand Up @@ -122,7 +122,7 @@ _:blank rdf:type askomics:AskomicsCategory .
_:blank rdf:type owl:ObjectProperty .
_:blank rdfs:label "reference_attribute" .
_:blank rdfs:domain :EntityName .
_:blank rdfs:range _:blank2.
_:blank rdfs:range :reference_attributeCategory.
_:blank askomics:uri :reference_attribute
```

Expand All @@ -136,7 +136,7 @@ _:blank rdf:type askomics:AskomicsCategory .
_:blank rdf:type owl:ObjectProperty .
_:blank rdfs:label "strand_attribute" .
_:blank rdfs:domain :EntityName .
_:blank rdfs:range _:blank2.
_:blank rdfs:range :strand_attributeCategory.
_:blank askomics:uri :strand_attribute
```

Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"ontology"
],
"name": "AskOmics",
"version": "4.4.1",
"version": "4.4.0",
"description": "Visual SPARQL query builder",
"author": "Xavier Garnier",
"license": "AGPL-3.0",
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

setup(
name='askomics',
version='4.4.1',
version='4.4.0',
description='''
AskOmics is a visual SPARQL query interface supporting both intuitive
data integration and querying while shielding the user from most of the
Expand Down

0 comments on commit 54c760c

Please sign in to comment.