Example #1
0
def merge(inputs, output):
    """
    Loads a series of knowledge graphs and merges cliques using `same_as` edges
    as well as `same_as` node properties. The resulting graph will not have any
    `same_as` edges, and the remaining clique leader nodes will have all
    equivalent identifiers in their `same_as` property.
    """
    transformers = []
    output_transformer = get_transformer(get_type(output))()
    graph = None
    for path in inputs:
        construct = get_transformer(get_type(path))
        if construct is None:
            raise Exception('No transformer for {}'.format(path))
        transformers.append(construct())
    for transformer, path in zip(transformers, inputs):
        if graph is None:
            graph = transformer.graph
        else:
            transformer.graph = graph
        transformer.parse(path)
    output_transformer.graph = graph
    output_transformer.graph = clique_merge(output_transformer.graph)
    output_transformer.save(output)
Example #2
0
from kgx import JsonTransformer, clique_merge

t = JsonTransformer()
t.parse('results/hp.owl')
t.parse('results/mondo.json')
t.parse('results/hgnc.json')
t.parse('results/clinvar.json')
t.parse('results/omim.json')
t.parse('results/hpoa.json')
t.parse('results/orphanet.json')

#t = PandasTransformer(t.graph)
#t.parse('data/semmeddb_edges.csv')
#t.parse('data/semmeddb_nodes.csv')

t.graph = clique_merge(t.graph)
t.save('results/clique_merged.json')