-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsynapseDownload.py
More file actions
60 lines (54 loc) · 1.51 KB
/
synapseDownload.py
File metadata and controls
60 lines (54 loc) · 1.51 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#!/usr/bin/env python3
"""
Downloads proximity files for given genes
Usage: python3 synapseDownload.py <list of genes> <optional credential file>
"""
import sys
import synapseclient # pip install synapseclient
import os
# Check argNum
if len(sys.argv)==3:
creds = sys.argv[2];
elif len(sys.argv) !=2:
sys.exit( __doc__);
else:
creds = False;
# Obtain creds
def login( creds ):
syn = synapseclient.Synapse()
user = ""
password = ""
if creds:
with open( creds , "r" ) as f:
credentials = []
for l in f:
l = l.strip()
credentials.append( l )
user = credentials[0]
password = credentials[1]
else:
user = input( 'Enter Synapse username: ' )
password = input( 'Enter Synapse password: ' )
syn.login( user , password )
return syn
syn = login(creds)
# By default get the latest version. Add version=N if needed
entity = syn.get("syn9704852", downloadLocation="/usr/local/hotspot3d/preprocess");
geneList = open(sys.argv[1]);
for gene in geneList:
IDfile = open("/usr/local/hotspot3d_synapse/gene_ID.txt");
for line in IDfile:
line = line.strip().split();
if gene.strip() == line[0]:
synID = line[2];
break;
else:
synID = "notFound";
if synID == "notFound":
print(gene.strip() + " was not found.");
continue;
IDfile.close();
entity = syn.get(synID, downloadLocation="/usr/local/hotspot3d/preprocess/prioritization");
# Unzip downloaded things
os.chdir("/usr/local/hotspot3d/preprocess/prioritization");
os.system("gzip -d *");