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

This commit is contained in:
Tanushree Tunstall 2021-09-29 18:24:06 +01:00
parent d443ecea6b
commit 93a91518e1

View file

@ -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 + <drug> + processing. Make sure it is somewhere with LOTS of storage as it writes all output!') #FIXME arg_parser.add_argument('-p', '--process_dir', help = 'Temp processing dir for running foldX. By default, it assmes homedir + <drug> + 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 <gene>_complex.pdb in input_dir') arg_parser.add_argument('-P', '--pdb_file', help = 'PDB File to process. By default, it assmumes a file called <gene>_complex.pdb in input_dir')
arg_parser.add_argument('-m', '--mutation_file', help = 'Mutation list. By default, assumes a file called <gene>_mcsm_snps.csv exists') arg_parser.add_argument('-m', '--mutation_file', help = 'Mutation list. By default, assumes a file called <gene>_mcsm_formatted_snps.csv exists')
# FIXME: Doesn't work with 2 chains yet! # FIXME: Doesn't work with 2 chains yet!
arg_parser.add_argument('-c1', '--chain1', help = 'Chain1 ID', default = 'A') # case sensitive 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 , '\noutput file:', outfile_foldx
, '\n=============================================================') , '\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 #### #### Delay for 10 seconds to check the params ####
print('Sleeping for 10 seconds to give you time to cancel') print('Sleeping for 10 seconds to give you time to cancel')
time.sleep(10) time.sleep(10)
@ -235,6 +245,13 @@ def main():
nmuts = len(mutlist) nmuts = len(mutlist)
print(nmuts) print(nmuts)
print(mutlist) 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') print('start')
# some common parameters for foldX # some common parameters for foldX
@ -242,61 +259,74 @@ def main():
print('\033[95mSTAGE: repair PDB (foldx subprocess) \033[0m') print('\033[95mSTAGE: repair PDB (foldx subprocess) \033[0m')
print('Running foldx RepairPDB for WT') print('Running foldx RepairPDB for WT')
subprocess.call(['foldx'
fold_RepairDB = ['foldx'
, '--command=RepairPDB' , '--command=RepairPDB'
, foldx_common , foldx_common
, '--pdb-dir=' + os.path.dirname(pdb_filename) # , '--pdb-dir=' + os.path.dirname(pdb_filename)
, '--pdb-dir=' + indir
, '--pdb=' + actual_pdb_filename , '--pdb=' + actual_pdb_filename
, 'outPDB=true' , '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('\033[95mCOMPLETED STAGE: repair PDB\033[0m')
print('\n==========================================================') print('\n==========================================================')
print('\033[95mSTAGE: Foldx commands BM, PN and SD (foldx subprocess) for WT\033[0m') print('\033[95mSTAGE: Foldx commands BM, PN and SD (foldx subprocess) for WT\033[0m')
print('Running foldx BuildModel for WT') print('Running foldx BuildModel for WT')
subprocess.call(['foldx'
foldx_BuildModel = ['foldx'
, '--command=BuildModel' , '--command=BuildModel'
, foldx_common , foldx_common
, '--pdb-dir=' + process_dir , '--pdb-dir=' + process_dir
, '--pdb=' + pdbname + '_Repair.pdb' , '--pdb=' + pdbname + '_Repair.pdb'
, '--mutant-file="individual_list_' + pdbname +'.txt"' , '--mutant-file=' + process_dir + '/' + 'individual_list_' + pdbname +'.txt'
, 'outPDB=true' , 'outPDB=true'
, '--numberOfRuns=1' , '--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') print('Running foldx PrintNetworks for WT')
subprocess.call(['foldx' foldx_PrintNetworks = ['foldx'
, '--command=PrintNetworks' , '--command=PrintNetworks'
, '--pdb-dir=' + process_dir , '--pdb-dir=' + process_dir
, '--pdb=' + pdbname + '_Repair.pdb' , '--pdb=' + pdbname + '_Repair.pdb'
, '--water=PREDICT' , '--water=PREDICT'
, '--vdwDesign=1' , '--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') print('Running foldx SequenceDetail for WT')
subprocess.call(['foldx' foldx_SequenceDetail = ['foldx'
, '--command=SequenceDetail' , '--command=SequenceDetail'
, '--pdb-dir=' + process_dir , '--pdb-dir=' + process_dir
, '--pdb=' + pdbname + '_Repair.pdb' , '--pdb=' + pdbname + '_Repair.pdb'
, '--water=PREDICT' , '--water=PREDICT'
, '--vdwDesign=1' , '--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('\033[95mCOMPLETED STAGE: Foldx commands BM, PN and SD\033[0m')
print('\n==========================================================') print('\n==========================================================')
print('\033[95mSTAGE: Print Networks (foldx subprocess) for MT\033[0m') print('\033[95mSTAGE: Print Networks (foldx subprocess) for MT\033[0m')
for n in range(1,nmuts+1): for n in range(1,nmuts+1):
print('\033[95mNETWORK:\033[0m', n) print('\033[95mNETWORK:\033[0m', n)
print('Running foldx PrintNetworks for mutation', n) print('Running foldx PrintNetworks for mutation', n)
subprocess.call(['foldx' foldx_PrintNetworksMT = ['foldx'
, '--command=PrintNetworks' , '--command=PrintNetworks'
, '--pdb-dir=' + process_dir , '--pdb-dir=' + process_dir
, '--pdb=' + pdbname + '_Repair_' + str(n) + '.pdb' , '--pdb=' + pdbname + '_Repair_' + str(n) + '.pdb'
, '--water=PREDICT' , '--water=PREDICT'
, '--vdwDesign=1' , '--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('\033[95mCOMPLETED STAGE: Print Networks (foldx subprocess) for MT\033[0m')
print('\n==========================================================') print('\n==========================================================')
@ -323,14 +353,16 @@ def main():
print('\033[95mSTAGE: Running foldx AnalyseComplex (foldx subprocess) for WT\033[0m') print('\033[95mSTAGE: Running foldx AnalyseComplex (foldx subprocess) for WT\033[0m')
chain1=chainA chain1=chainA
chain2=chainB chain2=chainB
subprocess.call(['foldx' foldx_AnalyseComplex = ['foldx'
, '--command=AnalyseComplex' , '--command=AnalyseComplex'
, '--pdb-dir=' + process_dir , '--pdb-dir=' + process_dir
, '--pdb=' + pdbname + '_Repair.pdb' , '--pdb=' + pdbname + '_Repair.pdb'
, '--analyseComplexChains=' + chain1 + ',' + chain2 , '--analyseComplexChains=' + chain1 + ',' + chain2
, '--water=PREDICT' , '--water=PREDICT'
, '--vdwDesign=1' , '--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 # FIXME why would we ever need to do this?!? Cargo-culted from runcomplex.sh
ac_source = process_dir + '/Summary_' + pdbname + '_Repair_AC.fxout' ac_source = process_dir + '/Summary_' + pdbname + '_Repair_AC.fxout'
@ -340,14 +372,16 @@ def main():
for n in range(1,nmuts+1): for n in range(1,nmuts+1):
print('\033[95mSTAGE: Running foldx AnalyseComplex (foldx subprocess) for mutation:\033[0m', n) print('\033[95mSTAGE: Running foldx AnalyseComplex (foldx subprocess) for mutation:\033[0m', n)
subprocess.call(['foldx' foldx_AnalyseComplex = ['foldx'
, '--command=AnalyseComplex' , '--command=AnalyseComplex'
, '--pdb-dir=' + process_dir , '--pdb-dir=' + process_dir
, '--pdb=' + pdbname + '_Repair_' + str(n) + '.pdb' , '--pdb=' + pdbname + '_Repair_' + str(n) + '.pdb'
, '--analyseComplexChains=' + chain1 + ',' + chain2 , '--analyseComplexChains=' + chain1 + ',' + chain2
, '--water=PREDICT' , '--water=PREDICT'
, '--vdwDesign=1' , '--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 # 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' ac_mut_source = process_dir + '/Summary_' + pdbname + '_Repair_' + str(n) +'_AC.fxout'