Skip to content

Commit

Permalink
Query string indent
Browse files Browse the repository at this point in the history
  • Loading branch information
jmarinllao committed Oct 8, 2018
1 parent 61a6ed3 commit 8721836
Showing 1 changed file with 16 additions and 26 deletions.
42 changes: 16 additions & 26 deletions src/pathme/reactome/rdf_sparql.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@

import rdflib
import tqdm
from pybel import to_pickle
from rdflib import URIRef
from rdflib.namespace import Namespace, RDFS, RDF, DCTERMS, DC, OWL, XSD, SKOS

from pathme.constants import REACTOME_BEL
from pathme.reactome.convert_to_bel import convert_to_bel
from pathme.utils import query_result_to_dict, parse_rdf, get_pathway_statitics
from pybel import to_pickle

log = logging.getLogger(__name__)

Expand Down Expand Up @@ -52,7 +52,7 @@
{
?uri_id rdf:type biopax3:Pathway .
?uri_id biopax3:displayName ?name .
}
}
"""

#: SPARQL query string to get all components of a pathway (predicate biopax3:pathwayComponent).
Expand Down Expand Up @@ -81,30 +81,20 @@

#: SPARQL query to get all the possible metadate (optional statements) of an entity (Protein, Dna, Pathway...).
GET_ENTITY_METADATA = """
SELECT DISTINCT
(STRAFTER(STR(?entity), '#') AS ?identifier)
(STR(?entity) AS ?uri_reactome_id)
?uri_id
?name
?identifier
?cell_locat
?display_name
?complex_components
?comment
(STRAFTER(STR(?uri_type), str(biopax3:)) AS ?entity_type)
SELECT DISTINCT (STRAFTER(STR(?entity), '#') AS ?identifier) (STR(?entity) AS ?uri_reactome_id) ?uri_id ?name ?identifier ?cell_locat ?display_name ?complex_components ?comment (STRAFTER (STR(?uri_type), str(biopax3:)) AS ?entity_type)
WHERE
{
?entity rdf:type ?uri_type .
?entity biopax3:comment ?comment .
optional {?entity biopax3:entityReference ?uri_id .}
optional {?entity biopax3:name ?name .}
optional {?entity biopax3:displayName ?display_name .}
optional {?entity biopax3:cellularLocation ?cell_locat .}
optional {?entity biopax3:organism ?organism .}
optional {?entity biopax3:component ?complex_components .}
}
{
?entity rdf:type ?uri_type .
?entity biopax3:comment ?comment .
optional {?entity biopax3:entityReference ?uri_id .}
optional {?entity biopax3:name ?name .}
optional {?entity biopax3:displayName ?display_name .}
optional {?entity biopax3:cellularLocation ?cell_locat .}
optional {?entity biopax3:organism ?organism .}
optional {?entity biopax3:component ?complex_components .}
}
"""

"""Queries managers"""
Expand Down Expand Up @@ -208,7 +198,7 @@ def _get_reaction_participants(component_uri: str, component, rdf_graph: rdflib.
nodes[product_id] = product_metadata

if interaction.identifier not in interactions:
interactions[interaction.identifier] = {'metadata':component}
interactions[interaction.identifier] = {'metadata': component}

if 'participants' not in interactions[interaction.identifier]:
interactions[interaction.identifier]['participants'] = (reactant_id, product_id)
Expand Down

0 comments on commit 8721836

Please sign in to comment.