From 2eab87da6243d07d31ebb69f11fd0191ec62d4c1 Mon Sep 17 00:00:00 2001 From: Tanushree Tunstall Date: Wed, 29 Sep 2021 18:24:06 +0100 Subject: [PATCH] fix runFoldx so that it looks for a missing rotabase.txt in the process_dir and also print the foldx command that will be run --- foldx/runFoldx.py | 70 +++++++++++++++++++++++++++++++++++------------ 1 file changed, 52 insertions(+), 18 deletions(-) diff --git a/foldx/runFoldx.py b/foldx/runFoldx.py index 8d9358b..12e00c9 100755 --- a/foldx/runFoldx.py +++ b/foldx/runFoldx.py @@ -41,7 +41,7 @@ arg_parser.add_argument('-o', '--output_dir', help = 'Output dir for results. By arg_parser.add_argument('-p', '--process_dir', help = 'Temp processing dir for running foldX. By default, it assmes homedir + + processing. Make sure it is somewhere with LOTS of storage as it writes all output!') #FIXME arg_parser.add_argument('-P', '--pdb_file', help = 'PDB File to process. By default, it assmumes a file called _complex.pdb in input_dir') -arg_parser.add_argument('-m', '--mutation_file', help = 'Mutation list. By default, assumes a file called _mcsm_snps.csv exists') +arg_parser.add_argument('-m', '--mutation_file', help = 'Mutation list. By default, assumes a file called _mcsm_formatted_snps.csv exists') # FIXME: Doesn't work with 2 chains yet! arg_parser.add_argument('-c1', '--chain1', help = 'Chain1 ID', default = 'A') # case sensitive @@ -148,6 +148,16 @@ print('Arguments being passed:' , '\noutput file:', outfile_foldx , '\n=============================================================') + +# make sure rotabase.txt exists in the process_dir +rotabase_file = process_dir + '/' + 'rotabase.txt' + +if Path(rotabase_file).is_file(): + print(f'rotabase file: {rotabase_file} exists') +else: + print(f'ERROR: rotabase file: {rotabase_file} does not exist. Please download it and put it in {process_dir}') + sys.exit() + #### Delay for 10 seconds to check the params #### print('Sleeping for 10 seconds to give you time to cancel') time.sleep(10) @@ -235,6 +245,13 @@ def main(): nmuts = len(mutlist) print(nmuts) print(mutlist) + print('start') + #subprocess.check_output(['bash','repairPDB.sh', pdbname, process_dir]) + print('\033[95mSTAGE: repair PDB\033[0m') + print('EXECUTING: repairPDB.sh %s %s %s' % (indir, actual_pdb_filename, process_dir)) + #subprocess.check_output(['bash','repairPDB.sh', indir, actual_pdb_filename, process_dir]) + # once you decide to use the function + # repairPDB(pdbname) print('start') # some common parameters for foldX @@ -242,61 +259,74 @@ def main(): print('\033[95mSTAGE: repair PDB (foldx subprocess) \033[0m') print('Running foldx RepairPDB for WT') - subprocess.call(['foldx' + + fold_RepairDB = ['foldx' , '--command=RepairPDB' , foldx_common - , '--pdb-dir=' + os.path.dirname(pdb_filename) +# , '--pdb-dir=' + os.path.dirname(pdb_filename) + , '--pdb-dir=' + indir , '--pdb=' + actual_pdb_filename , 'outPDB=true' - , '--output-dir=' + process_dir]) + , '--output-dir=' + process_dir] + print('CMD:', fold_RepairDB) + subprocess.call(fold_RepairDB) print('\033[95mCOMPLETED STAGE: repair PDB\033[0m') print('\n==========================================================') print('\033[95mSTAGE: Foldx commands BM, PN and SD (foldx subprocess) for WT\033[0m') print('Running foldx BuildModel for WT') - subprocess.call(['foldx' + + foldx_BuildModel = ['foldx' , '--command=BuildModel' , foldx_common , '--pdb-dir=' + process_dir , '--pdb=' + pdbname + '_Repair.pdb' - , '--mutant-file="individual_list_' + pdbname +'.txt"' + , '--mutant-file=' + process_dir + '/' + 'individual_list_' + pdbname +'.txt' , 'outPDB=true' , '--numberOfRuns=1' - , '--output-dir=' + process_dir], cwd=process_dir) + , '--output-dir=' + process_dir] + print('CMD:', foldx_BuildModel) + subprocess.call( foldx_BuildModel, cwd=process_dir) print('Running foldx PrintNetworks for WT') - subprocess.call(['foldx' + foldx_PrintNetworks = ['foldx' , '--command=PrintNetworks' , '--pdb-dir=' + process_dir , '--pdb=' + pdbname + '_Repair.pdb' , '--water=PREDICT' , '--vdwDesign=1' - , '--output-dir=' + process_dir], cwd=process_dir) + , '--output-dir=' + process_dir] + print('CMD:', foldx_PrintNetworks) + subprocess.call(foldx_PrintNetworks, cwd=process_dir) print('Running foldx SequenceDetail for WT') - subprocess.call(['foldx' + foldx_SequenceDetail = ['foldx' , '--command=SequenceDetail' , '--pdb-dir=' + process_dir , '--pdb=' + pdbname + '_Repair.pdb' , '--water=PREDICT' , '--vdwDesign=1' - , '--output-dir=' + process_dir], cwd=process_dir) + , '--output-dir=' + process_dir] + print('CMD:', foldx_SequenceDetail) + subprocess.call(foldx_SequenceDetail , cwd=process_dir) + print('\033[95mCOMPLETED STAGE: Foldx commands BM, PN and SD\033[0m') print('\n==========================================================') - print('\033[95mSTAGE: Print Networks (foldx subprocess) for MT\033[0m') for n in range(1,nmuts+1): print('\033[95mNETWORK:\033[0m', n) print('Running foldx PrintNetworks for mutation', n) - subprocess.call(['foldx' + foldx_PrintNetworksMT = ['foldx' , '--command=PrintNetworks' , '--pdb-dir=' + process_dir , '--pdb=' + pdbname + '_Repair_' + str(n) + '.pdb' , '--water=PREDICT' , '--vdwDesign=1' - , '--output-dir=' + process_dir], cwd=process_dir) + , '--output-dir=' + process_dir] + print('CMD:', foldx_PrintNetworksMT) + subprocess.call( foldx_PrintNetworksMT , cwd=process_dir) print('\033[95mCOMPLETED STAGE: Print Networks (foldx subprocess) for MT\033[0m') print('\n==========================================================') @@ -323,14 +353,16 @@ def main(): print('\033[95mSTAGE: Running foldx AnalyseComplex (foldx subprocess) for WT\033[0m') chain1=chainA chain2=chainB - subprocess.call(['foldx' + foldx_AnalyseComplex = ['foldx' , '--command=AnalyseComplex' , '--pdb-dir=' + process_dir , '--pdb=' + pdbname + '_Repair.pdb' , '--analyseComplexChains=' + chain1 + ',' + chain2 , '--water=PREDICT' , '--vdwDesign=1' - , '--output-dir=' + process_dir], cwd=process_dir) + , '--output-dir=' + process_dir] + print('CMD:',foldx_AnalyseComplex) + subprocess.call(foldx_AnalyseComplex, cwd=process_dir) # FIXME why would we ever need to do this?!? Cargo-culted from runcomplex.sh ac_source = process_dir + '/Summary_' + pdbname + '_Repair_AC.fxout' @@ -340,14 +372,16 @@ def main(): for n in range(1,nmuts+1): print('\033[95mSTAGE: Running foldx AnalyseComplex (foldx subprocess) for mutation:\033[0m', n) - subprocess.call(['foldx' + foldx_AnalyseComplex = ['foldx' , '--command=AnalyseComplex' , '--pdb-dir=' + process_dir , '--pdb=' + pdbname + '_Repair_' + str(n) + '.pdb' , '--analyseComplexChains=' + chain1 + ',' + chain2 , '--water=PREDICT' , '--vdwDesign=1' - , '--output-dir=' + process_dir], cwd=process_dir) + , '--output-dir=' + process_dir] + print('CMD:', foldx_AnalyseComplex) + subprocess.call( foldx_AnalyseComplex , cwd=process_dir) # FIXME why would we ever need to do this?!? Cargo-culted from runcomplex.sh ac_mut_source = process_dir + '/Summary_' + pdbname + '_Repair_' + str(n) +'_AC.fxout'