Mercurial > repos > melissacline > ucsc_xena_platform
annotate xena_delete.py @ 29:fc6f93710384
Fixing a merge issue
author | melissacline |
---|---|
date | Mon, 13 Jul 2015 14:35:34 -0700 |
parents | 98b498545a52 |
children |
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()) |
0 | 36 try: |
37 subprocess.call(xenaDeleteCmd, shell=True) | |
38 except: | |
39 exc_type, exc_value, exc_traceback = sys.exc_info() | |
40 lines = traceback.format_exception(exc_type, exc_value, exc_traceback) | |
41 allLines = ''.join('!! ' + line for line in lines) | |
42 fp2.write("Unsuccessful: error %s\n" % allLines) | |
43 fp2.close() | |
44 sys.exit(-1) | |
45 else: | |
46 fp2.write( "Dataset %s deleted\n" % args.datasetName) | |
3
98b498545a52
Fixed xena_delete to delete the files from the Xena files directory as well as from the database
melissacline
parents:
2
diff
changeset
|
47 dataPathname = xenaFileDir + "/" + args.datasetName |
98b498545a52
Fixed xena_delete to delete the files from the Xena files directory as well as from the database
melissacline
parents:
2
diff
changeset
|
48 if os.path.exists(dataPathname): |
98b498545a52
Fixed xena_delete to delete the files from the Xena files directory as well as from the database
melissacline
parents:
2
diff
changeset
|
49 os.unlink(dataPathname) |
98b498545a52
Fixed xena_delete to delete the files from the Xena files directory as well as from the database
melissacline
parents:
2
diff
changeset
|
50 metadataPathname = dataPathname + ".json" |
98b498545a52
Fixed xena_delete to delete the files from the Xena files directory as well as from the database
melissacline
parents:
2
diff
changeset
|
51 if os.path.exists(metadataPathname): |
98b498545a52
Fixed xena_delete to delete the files from the Xena files directory as well as from the database
melissacline
parents:
2
diff
changeset
|
52 os.unlink(metadataPathname) |
0 | 53 fp2.close() |
54 sys.exit(0) | |
55 | |
56 | |
57 if __name__ == "__main__": | |
58 main() |