MCPcopy Create free account
hub / github.com/alibaba/GraphScope / load_ogbl_ddi

Function load_ogbl_ddi

python/graphscope/dataset/ogbl_ddi.py:26–85  ·  view source on GitHub ↗

Load ogbl_ddi graph. The ogbl-ddi dataset is a homogeneous, unweighted, undirected graph, representing the drug-drug interaction network [1]. Each node represents an FDA-approved or experimental drug. Edges represent interactions between drugs and can be interpreted as a phenomenon wh

(sess=None, prefix=None)

Source from the content-addressed store, hash-verified

24
25
26def load_ogbl_ddi(sess=None, prefix=None):
27 """Load ogbl_ddi graph.
28 The ogbl-ddi dataset is a homogeneous, unweighted, undirected graph, representing the drug-drug interaction
29 network [1]. Each node represents an FDA-approved or experimental drug. Edges represent interactions between drugs
30 and can be interpreted as a phenomenon where the joint effect of taking the two drugs together is considerably
31 different from the expected effect in which drugs act independently of each other.
32 See more details here:
33
34 https://ogb.stanford.edu/docs/linkprop/#ogbl-ddi
35
36 Args:
37 sess (:class:`graphscope.Session`): Load graph within the session.
38 Default session will be used when setting to None. Defaults to None.
39 prefix: `PathLike` object that represents a path.
40 With standalone mode, set prefix None will try to download from
41 source URL. Defaults to None.
42
43 Returns:
44 :class:`graphscope.framework.graph.GraphDAGNode`:
45 A Graph node which graph type is ArrowProperty, evaluated in eager mode.
46
47 Examples:
48 .. code:: python
49
50 >>> # lazy mode
51 >>> import graphscope
52 >>> from graphscope.dataset import load_ogbn_arsiv
53 >>> sess = graphscope.session(mode="lazy")
54 >>> g = load_ogbl_ddi(sess, "/path/to/dataset")
55 >>> g1 = sess.run(g)
56
57 >>> # eager mode
58 >>> import graphscope
59 >>> from graphscope.dataset import load_ogbl_ddi
60 >>> sess = graphscope.session(mode="eager")
61 >>> g = load_ogbl_ddi(sess, "/path/to/dataset")
62 """
63 if prefix is not None:
64 prefix = os.path.expandvars(prefix)
65 else:
66 fname = "ogbl_ddi.tar.gz"
67 origin = f"{DATA_SITE}/ogbl_ddi.tar.gz"
68 fpath = download_file(
69 fname,
70 origin=origin,
71 extract=True,
72 file_hash="2a66bf265a217fd6148ba1f0ed9c9a297e778bf539b2b7262edf4a0dc1f4c8b9",
73 )
74 # assumed dirname is ogbl_ddi after extracting from ogbl_ddi.tar.gz
75 prefix = fpath[0:-7]
76
77 if sess is None:
78 sess = get_default_session()
79
80 graph = sess.g()
81 graph = graph.add_vertices(os.path.join(prefix, "nodes.csv"), "drug").add_edges(
82 os.path.join(prefix, "edge.csv"), "effect"
83 )

Callers 1

test_download_datasetFunction · 0.85

Calls 6

download_fileFunction · 0.90
get_default_sessionFunction · 0.90
gMethod · 0.45
add_edgesMethod · 0.45
add_verticesMethod · 0.45
joinMethod · 0.45

Tested by 1

test_download_datasetFunction · 0.68