Mercurial > repos > melissacline > ucsc_xena_platform
comparison xenaGetDataset.py @ 0:8bb037f88ed2
Uploaded
author | melissacline |
---|---|
date | Tue, 13 Jan 2015 23:37:23 -0500 |
parents | |
children | 02b0824c7d60 |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:8bb037f88ed2 |
---|---|
1 #!/usr/bin/env python | |
2 | |
3 import argparse | |
4 import re | |
5 import urllib2 | |
6 | |
7 | |
8 def main(): | |
9 parser = argparse.ArgumentParser() | |
10 parser.add_argument("dataHub", type=str) | |
11 parser.add_argument("datasetId", type=str) | |
12 parser.add_argument("metadatafile", type=str) | |
13 parser.add_argument("datafile", type=str) | |
14 args = parser.parse_args() | |
15 | |
16 datasetUrlHost = re.sub("/proj/", "/download/", args.dataHub) | |
17 datasetIdTokens = re.split("/", args.datasetId) | |
18 datasetUrl = datasetUrlHost + "/" + "/".join(datasetIdTokens[1:]) | |
19 print datasetUrl | |
20 metadataUrl = datasetUrl + ".json" | |
21 mm = urllib2.urlopen(metadataUrl) | |
22 with open(args.metadatafile, "w") as metadata: | |
23 metadata.write(mm.read()) | |
24 mm.close() | |
25 dd = urllib2.urlopen(datasetUrl) | |
26 with open(args.datafile, "w") as data: | |
27 data.write(dd.read()) | |
28 dd.close() | |
29 | |
30 | |
31 if __name__ == "__main__": | |
32 main() | |
33 |