Get all degenerate BEL statements.

        Stores the results of the query in self.degenerate_stmts.
171275
def get_degenerate_statements(self):
        
        logger.info("Checking for 'degenerate' statements...\n")
        # Get rules of type protein X -> activity Y
        q_stmts = prefixes + """
            SELECT ?stmt
            WHERE {
                ?stmt a belvoc:Statement .
                ?stmt belvoc:hasSubject ?subj .
                ?stmt belvoc:hasObject ?obj .
                {
                  { ?stmt belvoc:hasRelationship belvoc:DirectlyIncreases . }
                  UNION
                  { ?stmt belvoc:hasRelationship belvoc:DirectlyDecreases . }
                }
                {
                  { ?subj a belvoc:ProteinAbundance . }
                  UNION
                  { ?subj a belvoc:ModifiedProteinAbundance . }
                }
                ?subj belvoc:hasConcept ?xName .
                {
                  {
                    ?obj a belvoc:ProteinAbundance .
                    ?obj belvoc:hasConcept ?yName .
                  }
                  UNION
                  {
                    ?obj a belvoc:ModifiedProteinAbundance .
                    ?obj belvoc:hasChild ?proteinY .
                    ?proteinY belvoc:hasConcept ?yName .
                  }
                  UNION
                  {
                    ?obj a belvoc:AbundanceActivity .
                    ?obj belvoc:hasChild ?objChild .
                    ?objChild a belvoc:ProteinAbundance .
                    ?objChild belvoc:hasConcept ?yName .
                  }
                }
                FILTER (?xName != ?yName)
            }
        """
        res_stmts = self.g.query(q_stmts)

        logger.info("Protein -> Protein/Activity statements:")
        logger.info("---------------------------------------")
        for stmt in res_stmts:
            stmt_str = strip_statement(stmt[0])
            logger.info(stmt_str)
            self.degenerate_stmts.append(stmt_str)
789977
def all(self):
    " "
    query,inputs = self._toedn()
    return self.db.q(query,
      inputs  = inputs,
      limit   = self._limit,
      offset  = self._offset,
      history = self._history)
475141
public List<Statement> getAllStatements() {
        List<Statement> ret = new ArrayList<Statement>();

        // Statements within this group
        if (statements != null) {
            ret.addAll(statements);
        }

        // Statements within nested statement groups
        if (statementGroups != null) {
            for (final StatementGroup sg : statementGroups)
                ret.addAll(sg.getAllStatements());
        }

        return ret;
    }
378514
def declallvars(self):
        """"""
        for f in self.body:
            if (hasattr(f, '_ctype')
                    and not isinstance(f._ctype, FuncType)):
                yield f
1231591
def _entity_list_as_bel(entities: Iterable[BaseEntity]) -> str:
    """"""
    return ', '.join(
        e.as_bel()
        for e in entities
    )
964269
def find_deref_completions(ast_rootpath, root_env=gcl.default_env):
  """"""
  with util.LogTime('find_deref_completions'):
    tup = inflate_context_tuple(ast_rootpath, root_env)
    path = path_until(ast_rootpath, is_deref_node)
    if not path:
      return {}
    deref = path[-1]
    haystack = deref.haystack(tup.env(tup))
    if not hasattr(haystack, 'keys'):
      return {}
    return {n: get_completion(haystack, n) for n in haystack.keys()}
102982
def get_all_if_deleted(self):
        

        with self._lock:
            results = {}
            for add, fut in self._state.items():
                if self._contains_and_deleted(add):
                    results[add] = fut.result()
            return results
473234
def all(pred: Callable, xs: Iterable):
    
    for x in xs:
        if not pred(x):
            return False

    return True
24646
def _get_stmt_by_group(self, stmt_type, stmts_this_type, eh):
        """"""
        # Dict of stmt group key tuples, indexed by their first Agent
        stmt_by_first = collections.defaultdict(lambda: [])
        # Dict of stmt group key tuples, indexed by their second Agent
        stmt_by_second = collections.defaultdict(lambda: [])
        # Dict of statements with None first, with second Agent as keys
        none_first = collections.defaultdict(lambda: [])
        # Dict of statements with None second, with first Agent as keys
        none_second = collections.defaultdict(lambda: [])
        # The dict of all statement groups, with tuples of components
        # or entity_matches_keys as keys
        stmt_by_group = collections.defaultdict(lambda: [])
        # Here we group Statements according to the hierarchy graph
        # components that their agents are part of
        for stmt_tuple in stmts_this_type:
            _, stmt = stmt_tuple
            entities = self._get_entities(stmt, stmt_type, eh)
            # At this point we have an entity list
            # If we're dealing with Complexes, sort the entities and use
            # as dict key
            if stmt_type == Complex:
                # There shouldn't be any statements of the type
                # e.g., Complex([Foo, None, Bar])
                assert None not in entities
                assert len(entities) > 0
                entities.sort()
                key = tuple(entities)
                if stmt_tuple not in stmt_by_group[key]:
                    stmt_by_group[key].append(stmt_tuple)
            elif stmt_type == Conversion:
                assert len(entities) > 0
                key = (entities[0],
                       tuple(sorted(entities[1:len(stmt.obj_from)+1])),
                       tuple(sorted(entities[-len(stmt.obj_to):])))
                if stmt_tuple not in stmt_by_group[key]:
                    stmt_by_group[key].append(stmt_tuple)
            # Now look at all other statement types
            # All other statements will have one or two entities
            elif len(entities) == 1:
                # If only one entity, we only need the one key
                # It should not be None!
                assert None not in entities
                key = tuple(entities)
                if stmt_tuple not in stmt_by_group[key]:
                    stmt_by_group[key].append(stmt_tuple)
            else:
                # Make sure we only have two entities, and they are not both
                # None
                key = tuple(entities)
                assert len(key) == 2
                assert key != (None, None)
                # First agent is None; add in the statements, indexed by
                # 2nd
                if key[0] is None and stmt_tuple not in none_first[key[1]]:
                    none_first[key[1]].append(stmt_tuple)
                # Second agent is None; add in the statements, indexed by
                # 1st
                elif key[1] is None and stmt_tuple not in none_second[key[0]]:
                    none_second[key[0]].append(stmt_tuple)
                # Neither entity is None!
                elif None not in key:
                    if stmt_tuple not in stmt_by_group[key]:
                        stmt_by_group[key].append(stmt_tuple)
                    if key not in stmt_by_first[key[0]]:
                        stmt_by_first[key[0]].append(key)
                    if key not in stmt_by_second[key[1]]:
                        stmt_by_second[key[1]].append(key)

        # When we've gotten here, we should have stmt_by_group entries, and
        # we may or may not have stmt_by_first/second dicts filled out
        # (depending on the statement type).
        if none_first:
            # Get the keys associated with stmts having a None first
            # argument
            for second_arg, stmts in none_first.items():
                # Look for any statements with this second arg
                second_arg_keys = stmt_by_second[second_arg]
                # If there are no more specific statements matching this
                # set of statements with a None first arg, then the
                # statements with the None first arg deserve to be in
                # their own group.
                if not second_arg_keys:
                    stmt_by_group[(None, second_arg)] = stmts
                # On the other hand, if there are statements with a matching
                # second arg component, we need to add the None first
                # statements to all groups with the matching second arg
                for second_arg_key in second_arg_keys:
                    stmt_by_group[second_arg_key] += stmts
        # Now do the corresponding steps for the statements with None as the
        # second argument:
        if none_second:
            for first_arg, stmts in none_second.items():
                # Look for any statements with this first arg
                first_arg_keys = stmt_by_first[first_arg]
                # If there are no more specific statements matching this
                # set of statements with a None second arg, then the
                # statements with the None second arg deserve to be in
                # their own group.
                if not first_arg_keys:
                    stmt_by_group[(first_arg, None)] = stmts
                # On the other hand, if there are statements with a matching
                # first arg component, we need to add the None second
                # statements to all groups with the matching first arg
                for first_arg_key in first_arg_keys:
                    stmt_by_group[first_arg_key] += stmts
        return stmt_by_group
288467
def debug_query_result(rows: Sequence[Any]) -> None:
    """"""
    log.info("Retrieved {} rows", len(rows))
    for i in range(len(rows)):
        log.info("Row {}: {}", i, rows[i])
572982
def get_bool(strings: Sequence[str],
             prefix: str,
             ignoreleadingcolon: bool = False,
             precedingline: str = "") -> Optional[bool]:
    
    return get_bool_raw(get_string(strings, prefix,
                                   ignoreleadingcolon=ignoreleadingcolon,
                                   precedingline=precedingline))
561699
def _GetPredicate(self, pred_str, test_attr=False):
        
        predicate, args, func_type = self.predicates.LookupWithType(pred_str)
        if predicate:
            pred = predicate, args, func_type
        else:
            # Nicer syntax, {.debug?} is shorthand for {.if test debug}.
            # Currently there is not if/elif chain; just use
            # {.if test debug} {.or test release} {.or} {.end}
            if test_attr:
                assert pred_str.endswith('?')
                # func, args, func_type
                pred = (_TestAttribute, (pred_str[:-1],), ENHANCED_FUNC)
            else:
                raise BadPredicate('%r is not a valid predicate' % pred_str)
        return pred
407288
def get_statements(self):
        """"""
        for k, v in self.reader_output.items():
            for interaction in v['interactions']:
                self._process_interaction(k, interaction, v['text'], self.pmid,
                                          self.extra_annotations)
1162556
def preprocess_bel_stmt(stmt: str) -> str:
    

    stmt = stmt.strip()  # remove newline at end of stmt
    stmt = re.sub(r",+", ",", stmt)  # remove multiple commas
    stmt = re.sub(r",", ", ", stmt)  # add space after each comma
    stmt = re.sub(r" +", " ", stmt)  # remove multiple spaces

    return stmt
385033
def _get_filtered_stmts(self, lookup_node, node, stmts, mystmt):
        """"""
        if self is mystmt:
            if isinstance(lookup_node, (Const, Name)):
                return [lookup_node], True

        elif self.statement() is mystmt:
            # original node's statement is the assignment, only keeps
            # current node (gen exp, list comp)

            return [node], True

        return stmts, False
1032054
def _infer_stmts(stmts, context, frame=None):
    """"""
    inferred = False
    if context is not None:
        name = context.lookupname
        context = context.clone()
    else:
        name = None
        context = contextmod.InferenceContext()

    for stmt in stmts:
        if stmt is util.Uninferable:
            yield stmt
            inferred = True
            continue
        context.lookupname = stmt._infer_name(frame, name)
        try:
            for inferred in stmt.infer(context=context):
                yield inferred
                inferred = True
        except exceptions.NameInferenceError:
            continue
        except exceptions.InferenceError:
            yield util.Uninferable
            inferred = True
    if not inferred:
        raise exceptions.InferenceError(
            "Inference failed for all members of {stmts!r}.",
            stmts=stmts,
            frame=frame,
            context=context,
        )
1116900
def get_statements(self):
        """"""
        statements = []
        for statement in self._parsed:
            if statement:
                sql = str(statement).strip(' \n;\t')
                if sql:
                    statements.append(sql)
        return statements