# -*- coding: utf-8 -*- # :noTabs=true: import sys, os, os.path, subprocess, shutil, commands import json args = json.load( file('.arguments.py') ) input_ = json.load( file('input.json') ) essential = [] # list of essential files for this jobs, rest of files will be deleted in ~30 days after the job finish. Files in this list SHOULD NOT include 'output/' prefix ignore = [] # list of files to ignore [do not store in DB]. Files in this list SHOULD NOT include 'output/' prefix print 'VIP analyze script, running with args:', json.dumps(args, sort_keys=True, indent=2) print 'input options:', json.dumps(input_, sort_keys=True, indent=2) def execute(message, commandline, return_=False): print message print commandline (res, output) = commands.getstatusoutput(commandline) print output if return_ == 'tuple': return(res, output) if res: print "\nEncounter error while executing: ", commandline if return_: return True, else: sys.exit(1) return False models = [] resfile = '' # Check if some of the files are too big to store and should be ignored... for dir_name, _, files in os.walk('output'): for f in files: fn = dir_name+ '/' + f if os.path.getsize(fn) > 1024*1024*100: # 100M limit for file storage ignore.append(fn[ len('output')+1 : ]) file(fn+'.is_too_large', 'w').close() if dir_name == 'output' and f.startswith('final_mutand') and f.endswith('.pdb'): models.append(f) if dir_name == 'output' and f.startswith('resfile_output'): resfile = f #print dir_name, f essential += models if resfile: essential.append(resfile) status = 0 if models and resfile else 'failed' output = dict(status=status, essential=essential, models=models, resfile=resfile, ignore=ignore) json.dump(output, file('output.json', 'w') )