Return a set of relationships found in all subset GO Terms.
557596
def _init_relationships(self, relationships_arg):
        """"""
        if relationships_arg:
            relationships_all = self._get_all_relationships()
            if relationships_arg is True:
                return relationships_all
            else:
                return relationships_all.intersection(relationships_arg)
        return set()
275873
public List<ExtendedRelation> getRelationships() {
		List<ExtendedRelation> result = null;
		try {
			if (extendedRelationsDao.isTableExists()) {
				result = extendedRelationsDao.queryForAll();
			} else {
				result = new ArrayList<>();
			}
		} catch (SQLException e) {
			throw new GeoPackageException("Failed to query for relationships "
					+ "in " + EXTENSION_NAME, e);
		}
		return result;
	}
720874
public function getTermRelationships($terms) {
		static $table = 'term_relationships';
		if (!$terms) {
			return array();
		}
		$termIds = array_keys($terms);
		$termRelationships = $this->_query('SELECT * FROM '.$this->getTable($table).' WHERE term_taxonomy_id IN ('.implode(',', $termIds).')');
		$result = array();
		foreach ($termRelationships as $item) {
			$key = $item['object_id'];
			$value = $item['term_taxonomy_id'];
			if (!isset($result[$key])) {
				$result[$key] = array();
			}
			$result[$key][] = $value;
		}
		return $result;
	}
556409
def extract_subset(self, subset):
        
    
        # note subsets have an unusual encoding
        query = """
        prefix oboInOwl: <http://www.geneontology.org/formats/oboInOwl#>
        SELECT ?c WHERE {{
        GRAPH <{g}>  {{
        ?c oboInOwl:inSubset ?s
        FILTER regex(?s,'#{s}$','i')
        }}
        }}
        """.format(s=subset, g=self.graph_name)
        bindings = run_sparql(query)
        return [r['c']['value'] for r in bindings]
812378
def get_paths_goobjs(go_objs, go_top=None, go2obj=None):
    """"""
    go_paths = []  # Collect all paths for go_objs
    go_all = set() # Collect all GO terms in all paths
    pathobj = GoPaths()
    for go_obj in go_objs:
        #print "?FIND PATHS FOR {}?".format(go_obj.id)
        if go_obj.id not in go_all: # GO not yet seen in paths already found
            #print "!FIND PATHS FOR {}!".format(go_obj.id)
            paths_curr = pathobj.get_paths_from_to(go_obj, go_top, True)
            if paths_curr:
                for path_goobjs in paths_curr:
                    for path_goobj in path_goobjs:
                        goid = path_goobj.id
                        if goid not in go_all:
                            go_all.add(goid)
                            go2obj[goid] = path_goobj
                # go_all.update(GO.id for path in paths_curr for GO in path)
                go_paths.extend(path for path in paths_curr)
    return go_paths, go_all
757932
def get_relations_cnt(self):
        """"""
        return cx.Counter([e.relation for es in self.exts for e in es])
980435
def get_items(self, gos):
        """"""
        items = []
        for go_id in gos:
            items.extend(self.go2items.get(go_id, []))
        return set(items)
1319446
def infer_child_relations(graph, node: BaseEntity) -> List[str]:
    """"""
    return list(_infer_child_relations_iter(graph, node))
1312203
def connected_sets(C, mincount_connectivity=0, strong=True):
    
    import msmtools.estimation as msmest
    Cconn = C.copy()
    Cconn[np.where(C <= mincount_connectivity)] = 0
    # treat each connected set separately
    S = msmest.connected_sets(Cconn, directed=strong)
    return S
843970
def predicates(graph):
    
    seen = set()

    def _traverse(binding):
        if binding.path in seen:
            return
        seen.add(binding.path)

        if binding.is_object:
            for prop in binding.properties:
                yield (binding.path, prop.name, tuple(prop.types))
                for pred in _traverse(prop):
                    yield pred
        elif binding.is_array:
            for item in binding.items:
                for pred in _traverse(item):
                    yield pred

    schemas = graph.aliases.values()
    schemas.extend(graph.resolver.store)
    for schema_uri in graph.aliases.values():
        binding = graph.get_binding(schema_uri, None)
        for pred in _traverse(binding):
            if pred not in seen:
                yield pred
                seen.add(pred)
446178
def extract_subset(self, subset, contract=True):
        
        return [n for n in self.nodes() if subset in self.subsets(n, contract=contract)]
500619
def match(self, models, results, relation):
        
        return self.match_many(models, results, relation)
1168957
def relations(cls):
        
        return [c.key for c in cls.__mapper__.iterate_properties
                if isinstance(c, RelationshipProperty)]
220249
def rm_subsets(ctx, dataset, kwargs):
    ""

    kwargs = parse_kwargs(kwargs)
    data(dataset, **ctx.obj).rm_subsets(**kwargs)
1346636
private function getRelationships()
    {
        $relationships = [];

        // Loop through input, and check whether any key is a valid relationship
        foreach ($this->dataset as $model => $value)
        {
            // Skip anything which isn't a valid relationship
            if ( ! $this->isRelationship($model, $this->conditions)) continue;

            // Capture relationship and it's type
            $relationships[$model] = $this->getRelationshipType(Str::camel($model));
        }

        return $relationships;
    }
42247
def subsets(self):
        
    
        # note subsets have an unusual encoding
        query = """
        prefix oboInOwl: <http://www.geneontology.org/formats/oboInOwl#>
        SELECT DISTINCT ?s WHERE {{
        GRAPH <{g}>  {{
        ?c oboInOwl:inSubset ?s 
        }}
        }}
        """.format(g=self.graph_name)
        bindings = run_sparql(query)
        return [r['s']['value'] for r in bindings]
960948
def related(self):
        
        return [ch for ch in self.sentence.chunks 
                    if ch != self and intersects(unzip(0, ch.relations), unzip(0, self.relations))]