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

Function load_ppi

python/graphscope/dataset/ppi.py:26–88  ·  view source on GitHub ↗

Load protein-protein links datasets. In protein-protein links graph, every node represents a protein,and edges represent the links between them. See more details here: https://humgenomics.biomedcentral.com/articles/10.1186/1479-7364-3-3-291 Args: sess (:class:`graphsco

(sess=None, prefix=None, directed=False)

Source from the content-addressed store, hash-verified

24
25
26def load_ppi(sess=None, prefix=None, directed=False):
27 """Load protein-protein links datasets.
28
29 In protein-protein links graph, every node represents a protein,and edges represent
30 the links between them. See more details here:
31
32 https://humgenomics.biomedcentral.com/articles/10.1186/1479-7364-3-3-291
33
34 Args:
35 sess (:class:`graphscope.Session`): Load graph within the session.
36 Default session will be used when setting to None. Defaults to None.
37 prefix: `PathLike` object that represents a path.
38 With standalone mode, set prefix None will try to download from
39 source URL. Defaults to None.
40 directed (bool, optional): Determine to load a directed or undirected graph.
41 Defaults to True.
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_ppi
53 >>> sess = graphscope.session(mode="lazy")
54 >>> g = load_ppi(sess, "/path/to/dataset")
55 >>> g1 = sess.run(g)
56
57 >>> # eager mode
58 >>> import graphscope
59 >>> from graphscope.dataset import load_ppi
60 >>> sess = graphscope.session(mode="eager")
61 >>> g = load_ppi(sess, "/path/to/dataset")
62 """
63 if prefix is not None:
64 prefix = os.path.expandvars(prefix)
65 else:
66 fname = "ppi.tar.gz"
67 origin = f"{DATA_SITE}/ppi.tar.gz"
68 fpath = download_file(
69 fname,
70 origin=origin,
71 extract=True,
72 file_hash="2ffe7207626f5b177cb05871b65ee7c95fc9ebc45cc9f628d36efef8b5c0b642",
73 )
74 # assumed dirname is ppi after extracting from ppi.tar.gz
75 prefix = fpath[0:-7]
76
77 if sess is None:
78 sess = get_default_session()
79
80 graph = sess.g(directed=directed)
81 graph = graph.add_vertices(os.path.join(prefix, "node.csv"), "protein").add_edges(
82 os.path.join(prefix, "edge.csv"),
83 "link",

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