Skip to content

Commit

Permalink
Merge pull request #1 from xgaia/release_1.1.0_federated
Browse files Browse the repository at this point in the history
Release 1.1.0
  • Loading branch information
xgaia authored Oct 8, 2019
2 parents 5d2b2f0 + ff1b8da commit 3a659f1
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 14 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ First, clone the git repo

```bash
# clone
git clone https://github.com/xgaia/abstractor.git
git clone https://github.com/askomics/abstractor.git
# cd
cd abstractor
```
Expand Down Expand Up @@ -70,4 +70,4 @@ abstractor -e <endpoint_url> -p <entity_prefix> -o <output_file>
abstractor -e "https://sparql.nextprot.org" -p "http://nextprot.org/rdf#" -o "abstraction.ttl"
```

Obtained TTL file can be used with [AskOmics](https://github.com/xgaia/flaskomics)
Obtained TTL file can be used with [AskOmics](https://github.com/askomics/flaskomics)
20 changes: 11 additions & 9 deletions abstractor
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ class Abstractor(object):
parser = argparse.ArgumentParser(description="Generate AskOmics abstraction from a SPARQL endpoint")

parser.add_argument("-e", "--endpoint", type=str, help="SPARQL enpoint url", required=True)
parser.add_argument("-p", "--prefix", type=str, help="SPARQL prefix uri for :", required=True)
parser.add_argument("-p", "--endpoint-prefix", type=str, help="Endpoint prefix", required=True)
parser.add_argument("--askomics-prefix", type=str, help="AskOmics prefix", default="http://www.semanticweb.org/user/ontologies/2018/1#")
parser.add_argument("-o", "--output", type=str, help="Output ttl file", default="abstraction.ttl")

self.args = parser.parse_args()
Expand All @@ -29,7 +30,7 @@ class Abstractor(object):
list, list
header and results
"""
sparql = SparqlQuery(self.args.endpoint, self.args.prefix)
sparql = SparqlQuery(self.args.endpoint, self.args.askomics_prefix)

query = textwrap.dedent('''
SELECT DISTINCT ?entity ?rel ?valueType
Expand All @@ -55,7 +56,7 @@ class Abstractor(object):
list, list
header and results
"""
sparql = SparqlQuery(self.args.endpoint, self.args.prefix)
sparql = SparqlQuery(self.args.endpoint, self.args.askomics_prefix)

query = textwrap.dedent('''
SELECT DISTINCT ?entity ?attr
Expand All @@ -79,7 +80,7 @@ class Abstractor(object):
list, list
header and results
"""
sparql = SparqlQuery(self.args.endpoint, self.args.prefix)
sparql = SparqlQuery(self.args.endpoint, self.args.askomics_prefix)

query = textwrap.dedent('''
SELECT DISTINCT ?entity ?attr
Expand All @@ -98,7 +99,7 @@ class Abstractor(object):

def main(self):
"""main"""
sparql = SparqlQuery(self.args.endpoint, self.args.prefix)
sparql = SparqlQuery(self.args.endpoint, self.args.askomics_prefix)

with open(self.args.output, "w") as file:

Expand All @@ -119,7 +120,7 @@ class Abstractor(object):
relation = result["rel"] if "rel" in result else None
relation_range = result["valueType"] if "valueType" in result else None

if not entity.startswith(self.args.prefix):
if not entity.startswith(self.args.endpoint_prefix):
continue

# Write ttl for entities
Expand All @@ -129,6 +130,7 @@ class Abstractor(object):
<{}> a :entity ,
:startPoint ,
owl:Class ;
:instancesHaveNoLabels true ;
rdfs:label "{}" .
'''.format(
entity,
Expand All @@ -137,7 +139,7 @@ class Abstractor(object):

file.write(ttl)

if not relation.startswith(self.args.prefix):
if not relation.startswith(self.args.endpoint_prefix):
continue

# write ttl for relations
Expand Down Expand Up @@ -168,7 +170,7 @@ class Abstractor(object):
entity = result["entity"]
attribute = result["attr"] if "attr" in result else None

if not entity.startswith(self.args.prefix) and attribute.startswith(self.args.prefix):
if not entity.startswith(self.args.endpoint_prefix) and attribute.startswith(self.args.endpoint_prefix):
continue

if attribute:
Expand All @@ -195,7 +197,7 @@ class Abstractor(object):
entity = result["entity"]
attribute = result["attr"] if "attr" in result else None

if not entity.startswith(self.args.prefix) and attribute.startswith(self.args.prefix):
if not entity.startswith(self.args.endpoint_prefix) and attribute.startswith(self.args.endpoint_prefix):
continue

if attribute:
Expand Down
6 changes: 3 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@

setup(
name='abstractor',
version='1.0.5',
version='1.1.0',
description='Abstraction generator for AskOmics, from a distant SPARQL endpoint',
author='Xavier Garnier',
author_email='[email protected]',
url='https://github.com/xgaia/abstractor',
download_url='https://github.com/xgaia/abstractor/archive/1.0.5.tar.gz',
url='https://github.com/askomics/abstractor',
download_url='https://github.com/askomics/abstractor/archive/1.1.0.tar.gz',
install_requires=['SPARQLWrapper'],
packages=find_packages(),
license='AGPL',
Expand Down

0 comments on commit 3a659f1

Please sign in to comment.