Mercurial > repos > melissacline > ucsc_xena_platform
annotate xena_delete.py @ 2:6eeb3ca663fb
Fixed dataset delete bugs (the full pathname was needed) plus changed xena_import to give a checkbox for turning on column normalization
author | melissacline |
---|---|
date | Wed, 14 Jan 2015 15:21:09 -0800 |
parents | 8bb037f88ed2 |
children | 98b498545a52 |
rev | line source |
---|---|
0 | 1 #!/usr/bin/env python |
2 | |
3 """ | |
4 xena_delete.py: delete a dataset from Xena | |
5 | |
6 Given the name of a Xena dataset, delete it from the local Xena database. | |
7 """ | |
8 | |
9 import argparse | |
10 import json | |
11 import os | |
12 import re | |
13 import shutil | |
14 import subprocess | |
15 import sys | |
16 import traceback | |
17 import xena_utils as xena | |
18 | |
19 def main(): | |
20 parser = argparse.ArgumentParser() | |
21 parser.add_argument("datasetName", type=str) | |
22 parser.add_argument("outfile", type=str) | |
23 args = parser.parse_args() | |
24 | |
25 fp2 = open(args.outfile, "w") | |
26 xenaFileDir = xena.fileDir() | |
27 | |
28 # Set up the xena delete comamnd and try to execute it. If an exception | |
29 # is generated, output a traceback and exit with nonzero status. If | |
30 # no exception was generated, indicate a successful import and exit | |
31 # with zero status. | |
2
6eeb3ca663fb
Fixed dataset delete bugs (the full pathname was needed) plus changed xena_import to give a checkbox for turning on column normalization
melissacline
parents:
0
diff
changeset
|
32 xenaDeleteCmd = "java -jar %s --delete %s/%s -p %s" % (xena.jarPath(), |
6eeb3ca663fb
Fixed dataset delete bugs (the full pathname was needed) plus changed xena_import to give a checkbox for turning on column normalization
melissacline
parents:
0
diff
changeset
|
33 xenaFileDir, |
6eeb3ca663fb
Fixed dataset delete bugs (the full pathname was needed) plus changed xena_import to give a checkbox for turning on column normalization
melissacline
parents:
0
diff
changeset
|
34 args.datasetName, |
6eeb3ca663fb
Fixed dataset delete bugs (the full pathname was needed) plus changed xena_import to give a checkbox for turning on column normalization
melissacline
parents:
0
diff
changeset
|
35 xena.port()) |
6eeb3ca663fb
Fixed dataset delete bugs (the full pathname was needed) plus changed xena_import to give a checkbox for turning on column normalization
melissacline
parents:
0
diff
changeset
|
36 print "Issuing command", xenaDeleteCmd |
0 | 37 try: |
38 subprocess.call(xenaDeleteCmd, shell=True) | |
39 except: | |
40 exc_type, exc_value, exc_traceback = sys.exc_info() | |
41 lines = traceback.format_exception(exc_type, exc_value, exc_traceback) | |
42 allLines = ''.join('!! ' + line for line in lines) | |
43 fp2.write("Unsuccessful: error %s\n" % allLines) | |
44 fp2.close() | |
45 sys.exit(-1) | |
46 else: | |
47 fp2.write( "Dataset %s deleted\n" % args.datasetName) | |
48 fp2.close() | |
49 sys.exit(0) | |
50 | |
51 | |
52 if __name__ == "__main__": | |
53 main() |