def get_conversions(self):
        """Extract Conversion INDRA Statements from BEL.


        The SPARQL query used to extract Conversions searches for
        a subject (controller) which is an AbundanceActivity
        which directlyIncreases a Reaction with a given list of
        Reactants and Products.

        Examples:

            catalyticActivity(proteinAbundance(HGNC:HMOX1))
            directlyIncreases
            reaction(reactants(abundance(CHEBI:heme)),
            products(abundance(SCHEM:Biliverdine),
            abundance(CHEBI:"carbon monoxide")))
        """
        query = prefixes + """
            SELECT DISTINCT ?controller ?controllerName ?controllerActivity
                ?product ?productName ?reactant ?reactantName ?stmt
            WHERE {
                ?stmt a belvoc:Statement .
                ?stmt belvoc:hasRelationship ?rel .
                ?stmt belvoc:hasSubject ?subject .
                ?stmt belvoc:hasObject ?rxn .
                ?subject a belvoc:AbundanceActivity .
                ?subject belvoc:hasActivityType ?controllerActivity .
                ?subject belvoc:hasChild ?controller .
                ?controller belvoc:hasConcept ?controllerName .
                ?rxn a belvoc:Reaction .
                ?rxn belvoc:hasChild ?reactants .
                ?reactants rdfs:label ?reactLabel .
                FILTER (regex(?reactLabel, "^reactants.*"))
                ?rxn belvoc:hasChild ?products .
                ?products rdfs:label ?prodLabel .
                FILTER (regex(?prodLabel, "^products.*"))
                ?reactants belvoc:hasChild ?reactant .
                ?products belvoc:hasChild ?product .
                ?reactant belvoc:hasConcept ?reactantName .
                ?product belvoc:hasConcept ?productName .
            }
            """
        res = self.g.query(query)
        # We need to collect all pieces of the same statement so that we can
        # collect multiple reactants and products
        stmt_map = collections.defaultdict(list)
        for stmt in res:
            stmt_map[stmt[-1]].append(stmt)
        for stmts in stmt_map.values():
            # First we get the shared part of the Statement
            stmt = stmts[0]
            subj = self._get_agent(stmt[1], stmt[0])
            evidence = self._get_evidence(stmt[-1])
            stmt_str = strip_statement(stmt[-1])
            # Now we collect the participants
            obj_from_map = {}
            obj_to_map = {}
            for stmt in stmts:
                reactant_name = stmt[6]
                product_name = stmt[4]
                if reactant_name not in obj_from_map:
                    obj_from_map[reactant_name] = \
                        self._get_agent(stmt[6], stmt[5])
                if product_name not in obj_to_map:
                    obj_to_map[product_name] = \
                        self._get_agent(stmt[4], stmt[3])
            obj_from = list(obj_from_map.values())
            obj_to = list(obj_to_map.values())
            st = Conversion(subj, obj_from, obj_to, evidence=evidence)
            # If we've matched a pattern, mark this as a converted statement
            self.statements.append(st)
            self.converted_direct_stmts.append(stmt_str)
def get_conversions ( self ) : query = prefixes + """
            SELECT DISTINCT ?controller ?controllerName ?controllerActivity
                ?product ?productName ?reactant ?reactantName ?stmt
            WHERE {
                ?stmt a belvoc:Statement .
                ?stmt belvoc:hasRelationship ?rel .
                ?stmt belvoc:hasSubject ?subject .
                ?stmt belvoc:hasObject ?rxn .
                ?subject a belvoc:AbundanceActivity .
                ?subject belvoc:hasActivityType ?controllerActivity .
                ?subject belvoc:hasChild ?controller .
                ?controller belvoc:hasConcept ?controllerName .
                ?rxn a belvoc:Reaction .
                ?rxn belvoc:hasChild ?reactants .
                ?reactants rdfs:label ?reactLabel .
                FILTER (regex(?reactLabel, "^reactants.*"))
                ?rxn belvoc:hasChild ?products .
                ?products rdfs:label ?prodLabel .
                FILTER (regex(?prodLabel, "^products.*"))
                ?reactants belvoc:hasChild ?reactant .
                ?products belvoc:hasChild ?product .
                ?reactant belvoc:hasConcept ?reactantName .
                ?product belvoc:hasConcept ?productName .
            }
            """ res = self . g . query ( query ) stmt_map = collections . defaultdict ( list ) for stmt in res : stmt_map [ stmt [ - 1 ] ] . append ( stmt ) for stmts in stmt_map . values ( ) : stmt = stmts [ 0 ] subj = self . _get_agent ( stmt [ 1 ] , stmt [ 0 ] ) evidence = self . _get_evidence ( stmt [ - 1 ] ) stmt_str = strip_statement ( stmt [ - 1 ] ) obj_from_map = { } obj_to_map = { } for stmt in stmts : reactant_name = stmt [ 6 ] product_name = stmt [ 4 ] if reactant_name not in obj_from_map : obj_from_map [ reactant_name ] = self . _get_agent ( stmt [ 6 ] , stmt [ 5 ] ) if product_name not in obj_to_map : obj_to_map [ product_name ] = self . _get_agent ( stmt [ 4 ] , stmt [ 3 ] ) obj_from = list ( obj_from_map . values ( ) ) obj_to = list ( obj_to_map . values ( ) ) st = Conversion ( subj , obj_from , obj_to , evidence = evidence ) self . statements . append ( st ) self . converted_direct_stmts . append ( stmt_str )
Extract Conversion INDRA Statements from BEL.


        The SPARQL query used to extract Conversions searches for
        a subject (controller) which is an AbundanceActivity
        which directlyIncreases a Reaction with a given list of
        Reactants and Products.

        Examples:

            catalyticActivity(proteinAbundance(HGNC:HMOX1))
            directlyIncreases
            reaction(reactants(abundance(CHEBI:heme)),
            products(abundance(SCHEM:Biliverdine),
            abundance(CHEBI:"carbon monoxide")))