comparison metfrag.py @ 5:c53ed894d736 draft

planemo upload for repository https://github.com/computational-metabolomics/metfrag-galaxy commit 826659b9105b635cf240474428122f5a269f5c88
author tomnl
date Fri, 02 Aug 2019 11:38:06 -0400
parents eb581a101672
children 0b3816a7a14b
comparison
equal deleted inserted replaced
4:eb581a101672 5:c53ed894d736
59 59
60 args = parser.parse_args() 60 args = parser.parse_args()
61 print(args) 61 print(args)
62 62
63 if os.stat(args.input_pth).st_size == 0: 63 if os.stat(args.input_pth).st_size == 0:
64 exit('Input file empty') 64 print('Input file empty')
65 exit()
65 66
66 67
67 # Create temporary working directory 68 # Create temporary working directory
68 if args.temp_dir: 69 if args.temp_dir:
69 wd = args.temp_dir 70 wd = args.temp_dir
381 ###################################################################### 382 ######################################################################
382 # outputs might have different headers. Need to get a list of all the headers before we start merging the files 383 # outputs might have different headers. Need to get a list of all the headers before we start merging the files
383 # outfiles = [os.path.join(wd, f) for f in glob.glob(os.path.join(wd, "*_metfrag_result.csv"))] 384 # outfiles = [os.path.join(wd, f) for f in glob.glob(os.path.join(wd, "*_metfrag_result.csv"))]
384 outfiles = glob.glob(os.path.join(wd, "*_metfrag_result.csv")) 385 outfiles = glob.glob(os.path.join(wd, "*_metfrag_result.csv"))
385 386
387 if len(outfiles) == 0:
388 print('No results')
389 sys.exit()
390
386 headers = [] 391 headers = []
387 c = 0 392 c = 0
388 for fn in outfiles: 393 for fn in outfiles:
389 with open(fn, 'r') as infile: 394 with open(fn, 'r') as infile:
390 reader = csv.reader(infile) 395 reader = csv.reader(infile)
398 if i == 1: 403 if i == 1:
399 break 404 break
400 405
401 # if no data rows (e.g. matches) then do not save an output and leave the program 406 # if no data rows (e.g. matches) then do not save an output and leave the program
402 if c == 0: 407 if c == 0:
408 print('No results')
403 sys.exit() 409 sys.exit()
404 410
405 additional_detail_headers = ['sample_name'] 411 additional_detail_headers = ['sample_name']
406 for k, paramd in six.iteritems(paramds): 412 for k, paramd in six.iteritems(paramds):
407 additional_detail_headers = list(set(additional_detail_headers + list(paramd['additional_details'].keys()))) 413 additional_detail_headers = list(set(additional_detail_headers + list(paramd['additional_details'].keys())))