def test_dgraph_bulk_basics_path(dgraph_bundled_helper: DgraphBundledHelper): dg = dgraph_bundled_helper tmp_dir = tempfile.mkdtemp() r1 = pathlib.Path(tmp_dir, 'r1.rdf') with open(r1, 'a') as f: f.write('_:a <{n}> "ATCG" . \n_:b <{n}> "TCGG" . \n'.format( n=DEFAULT_NODE_TYPE)) f.write('_:a <{e}> _:e . \n_:e <{e}> _:b . \n'.format( e=DEFAULT_EDGE_PREDICATE)) f.write('_:e <type> "contig1" . \n') f.write('_:e <value> "0" . \n') try: dg.load(tmp_dir) connected, starting_edges = dg.g.connected('ATCG', 'TCGG') assert connected log.info("Connectivity check passed") assert len(starting_edges) == 1 log.info("Length of starting edges check passed") paths, _ = dg.g.path('ATCG', 'TCGG') assert len(paths) == 1 log.info("Length of paths check passed") path = paths[0] assert path[0].value == 'ATCG' assert path[1].value == 'TCGG' log.info("Path value checks passed") joined = concat_values(path) assert joined == 'ATCGG' log.info("Joined path check passed") except Exception as e: log.critical("Couldn't find one of the expected nodes") files = glob.glob('{}/**'.format(dg.g.out_dir), recursive=True) log.critical("Files is out_dir are:\n{}".format(files)) raise e
def test_lemongraph_connected_distant_path(prebuilt_graph: Graph): paths, _ = prebuilt_graph.path('ATACGACGCCA', 'CGTCCGGACGT') assert len(paths) == 1 path = paths[0] assert path[0].value == 'ATACGACGCCA' assert path[-1].value == 'CGTCCGGACGT' kmer = concat_values(path) assert kmer == 'ATACGACGCCAGCGAACGTCCGGACGT'
def test_lemongraph_connected_path(prebuilt_graph: Graph): paths, _ = prebuilt_graph.path('CCGGAAGAAAA', 'CGGAAGAAAAA') assert len(paths) == 1 path = paths[0] assert path[0].value == 'CCGGAAGAAAA' assert path[1].value == 'CGGAAGAAAAA' kmer = concat_values(path) assert kmer == 'CCGGAAGAAAAA'
def query(self, src: str, dst: str): log.info("Looking for all strings between {} and {} ...".format( src, dst)) paths, paths_meta = self.g.path(src, dst) list_hits = [] for i in range(len(paths)): path = paths[i] meta = paths_meta[i] string = concat_values(path) list_hits.append({'string': string, **meta}) ph = PrettyHits(list_hits) log.info("Found: {}".format(ph))
def test_graph_connected_path(g: Graph): _setup_connected(g) paths, _ = g.path("ABC", "BCD") # There should be 1 path in paths assert len(paths) == 1 path = paths[0] if path[0].value != "ABC" or path[1].value != "BCD": raise GraphException(g=g) else: assert True joined = concat_values(path) assert joined == "ABCD"
def test_graph_connected_distant_path(g: Graph): _setup_connected_distant(g) paths, _ = g.path('ABC', 'CDE') assert len(paths) == 1 path = paths[0] assert len(path) == 3 assert path[0].value == "ABC" assert path[1].value == "BCD" assert path[2].value == "CDE" joined = concat_values(path) assert joined == "ABCDE"