Skip to content

Commit

Permalink
Merge pull request #61 from KULL-Centre/ligand-bug
Browse files Browse the repository at this point in the history
  • Loading branch information
j0kaso authored May 16, 2022
2 parents d21c53f + 2373740 commit 8b38320
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 19 deletions.
4 changes: 3 additions & 1 deletion software/rosetta_ddG_pipeline/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ To install the pipeline, get it from the GitHub page.
An installation file is not yet available.


The following links can be included in your bashrc, otherwise the default will be used:
The following links can be included in your bashrc, otherwise the default (found in rosetta_path.py) will be used:
```bash
export Rosetta_main_path= ‘{Newest Rosetta version}’
export Rosetta_tools_path='{path to Rosetta tools}’
Expand Down Expand Up @@ -79,6 +79,8 @@ General flags
--verbose increase verbose level
--gapped_output output pism and pdb file with shifted residue numbering according to input
--dump_pdb dumps all mutant pdbs
-nzip skip folder zipping (default off=false)
--do_checks does concistency checks after prepare and relax (default true)
```

Flags for membrane proteins:
Expand Down
14 changes: 9 additions & 5 deletions software/rosetta_ddG_pipeline/args_pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,10 +109,10 @@ def parse_args2():
help='Dumps all mutant pdbs, default False.'
)
parser.add_argument('--skip_zip', '-nzip',
default=True,
type=lambda s: s.lower() in ['false', 'f', 'no', '0'],
dest='ZIP_FILES',
help='Switch folder zipping off. default on'
default=False,
type=lambda s: s.lower() in ['true', 't', 'yes', '1'],
dest='NO_ZIP',
help='Skip folder zipping. default off'
)
parser.add_argument('--do_checks',
default=True,
Expand Down Expand Up @@ -348,8 +348,12 @@ def parse_args2():
args.MUT_MODE = 'mut_file'
if args.DUMP_PDB != 0:
args.DUMP_PDB = 1
if args.ZIP_FILES != True:
if args.NO_ZIP != False:
args.ZIP_FILES = False
else:
args.ZIP_FILES = True
if args.LIGAND != None:
args.LIGAND = True
if args.IS_MP == False:
args.MP_MULTISTRUC_PROTOCOL == 0
if args.IS_MP:
Expand Down
6 changes: 3 additions & 3 deletions software/rosetta_ddG_pipeline/relax_parse_results.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ def parse_relax_results(folder, pdb_id='', sc_name='score_bn15_calibrated', logg

# checking for consitency
if do_checking:
input_pdb = glob.glob(os.path.join(folder.input, '*.pdb'))[0]
input_pdb = glob.glob(os.path.join(folder.relax_input, '*.pdb'))[0]
output_pdb = os.path.join(folder.relax_run, f'{most_relaxed}.pdb')
chain = 'A'
with open(output_pdb, 'r') as fp:
Expand Down Expand Up @@ -246,10 +246,10 @@ def check_consitency(input_pdb, output_pdb, chain='A', is_MP=True, pdb_id='-'):
pdb_id = sys.argv[3]

if len(sys.argv) <= 9:
folder.update({'input': sys.argv[4], 'relax_run': sys.argv[5], 'relax_output': sys.argv[6],
folder.update({'relax_input': sys.argv[4], 'relax_run': sys.argv[5], 'relax_output': sys.argv[6],
'ddG_input': sys.argv[7]})
else:
folder.update({'input': sys.argv[4], 'relax_run': sys.argv[5], 'relax_output': sys.argv[6],
folder.update({'relax_input': sys.argv[4], 'relax_run': sys.argv[5], 'relax_output': sys.argv[6],
'ddG_input': [sys.argv[x] for x in range(7, len(sys.argv)-2)]})
print(sys.argv)
print(folder)
Expand Down
9 changes: 5 additions & 4 deletions software/rosetta_ddG_pipeline/run_pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ def predict_stability(args):

# Cleaning pdb and making fasta based on pdb or uniprot-id if provided
logger.info(f'Prepare the pdb and extract fasta file')
structure_instance.path_to_cleaned_pdb, struc_dic_cleaned = structure_instance.clean_up_and_isolate()
structure_instance.path_to_cleaned_pdb, struc_dic_cleaned = structure_instance.clean_up_and_isolate(ligand=args.LIGAND)
structure_instance.fasta_seq_full,structure_instance.fasta_seq = pdb_to_fasta_seq(
structure_instance.path_to_cleaned_pdb,chain_id)
if os.path.isfile(uniprot_accesion):
Expand Down Expand Up @@ -275,8 +275,8 @@ def predict_stability(args):
folder, partition=partition, output_gaps=args.GAPS_OUTPUT, zip_files=args.ZIP_FILES, sha_tag=SHA_TAG, is_MP=args.IS_MP, scale_factor=args.SCALE_FACTOR)
else:
path_to_parse_ddg_sbatch = mp_ddG.write_parse_rosetta_ddg_mp_pyrosetta_sbatch(
folder, chain_id=args.CHAIN, sys_name=name, output_name='ddG.out', add_output_name='ddG_additional.out', partition=partition,
output_gaps=args.GAPS_OUTPUT, mp_multistruc=args.MP_MULTISTRUC_PROTOCOL, zip_files=args.ZIP_FILES, sha_tag=SHA_TAG)
folder, chain_id=args.CHAIN, sys_name=name, output_name='ddG.out', add_output_name='ddG_additional.out', partition=partition,
output_gaps=args.GAPS_OUTPUT, mp_multistruc=args.MP_MULTISTRUC_PROTOCOL, zip_files=args.ZIP_FILES, sha_tag=SHA_TAG)
else:
# Parse sbatch relax file
relax_input_relaxfile = check_path(create_copy(
Expand All @@ -294,7 +294,8 @@ def predict_stability(args):
ddg_input_mutfile_dir = create_copy(
prepare_output_ddg_mutfile_dir, folder.ddG_input, name='mutfiles', directory=True)
path_to_ddg_calc_sbatch = structure_instance.write_rosetta_cartesian_ddg_sbatch(
folder, ddg_input_mutfile_dir, ddgfile=ddg_input_ddgfile, sys_name=name, partition=partition)
folder, ddg_input_mutfile_dir, ddgfile=ddg_input_ddgfile, sys_name=name,
partition=partition, dump_pdb=args.DUMP_PDB)
# Parse sbatch ddg parser
path_to_parse_ddg_sbatch = structure_instance.write_parse_cartesian_ddg_sbatch(
folder, partition=partition, output_gaps=args.GAPS_OUTPUT, zip_files=args.ZIP_FILES, sha_tag=SHA_TAG, is_MP=args.IS_MP, scale_factor=args.SCALE_FACTOR)
Expand Down
15 changes: 9 additions & 6 deletions software/rosetta_ddG_pipeline/structure_input.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,12 +77,13 @@ def clean_up_and_isolate(self, name='input',ligand=None):
#This cleans the protein but keeps the ligands
if ligand == True:
self.path_to_clean_pdb = rosetta_paths.path_to_clean_keep_ligand
self.tmp_prep_struc = create_copy(self.prep_struc, self.folder.prepare_cleaning, name='withHETATM.pdb')
#Runs shell script
shell_command = f'python2 {self.path_to_clean_pdb} {self.prep_struc} {self.chain_id} --keepzeroocc'
shell_command = f'python2 {self.path_to_clean_pdb} {self.tmp_prep_struc} {self.chain_id} --keepzeroocc'
self.logger.info('Running clean_pdb_keep_ligand.py script')
subprocess.call(shell_command, cwd=self.folder.prepare_cleaning, shell=True)
self.logger.info('end of output from clean_pdb_keep_ligand.py')
path_to_cleaned_pdb = os.path.join(self.folder.prepare_cleaning, f'{name}.pdb{self.chain_id}.pdb')
path_to_cleaned_pdb = f'{self.tmp_prep_struc}{self.chain_id}.pdb'
#Creates struc.json from cleaned pdb file
struc_dic_cleaned= get_structure_parameters(
self.folder.prepare_cleaning, path_to_cleaned_pdb,printing=False)
Expand Down Expand Up @@ -422,17 +423,18 @@ def parse_relax_sbatch(self, folder, sys_name='', partition='sbinlab', sc_name='
# launching parsing script
''')
if mp_multistruc == 0:
fp.write(f'python {path_to_parse_relax_script} {do_checking} {is_MP} {ref_pdb} {folder.input} {folder.relax_run} {folder.relax_output} {folder.ddG_input} {sc_name}')
fp.write(f'python {path_to_parse_relax_script} {do_checking} {is_MP} {ref_pdb} {folder.relax_input} {folder.relax_run} {folder.relax_output} {folder.ddG_input} {sc_name}')
else:
fp.write(f'python {path_to_parse_relax_script} {do_checking} {is_MP} {ref_pdb} {folder.input} {folder.relax_run} {folder.relax_output}' )
fp.write(f'python {path_to_parse_relax_script} {do_checking} {is_MP} {ref_pdb} {folder.relax_input} {folder.relax_run} {folder.relax_output}' )
for ddg_subfolder in folder.ddG_input:
fp.write(f' {ddg_subfolder}')
fp.write(f' {sc_name} {mp_multistruc}')
self.logger.info(path_to_sbatch)
return path_to_sbatch


def write_rosetta_cartesian_ddg_sbatch(self, folder, input_mutfiles='', ddgfile='', sys_name='', partition='sbinlab'):
def write_rosetta_cartesian_ddg_sbatch(self, folder, input_mutfiles='', ddgfile='', sys_name='',
partition='sbinlab', dump_pdb=0):
"""This script creates the rosetta_dddg.sbatch script"""

path_to_sbatch = os.path.join(self.folder.ddG_input, 'rosetta_ddg.sbatch')
Expand Down Expand Up @@ -466,7 +468,8 @@ def write_rosetta_cartesian_ddg_sbatch(self, folder, input_mutfiles='', ddgfile=
''')
fp.write((f'{os.path.join(rosetta_paths.path_to_rosetta, f"bin/cartesian_ddg.{rosetta_paths.Rosetta_extension}")} '
f'-s {structure_path} -ddg:mut_file ${{LST[$INDEX]}} '
f' -out:prefix ddg-$SLURM_ARRAY_JOB_ID-$SLURM_ARRAY_TASK_ID @{path_to_ddgflags}'))
f' -out:prefix ddg-$SLURM_ARRAY_JOB_ID-$SLURM_ARRAY_TASK_ID @{path_to_ddgflags}'
f' -ddg::dump_pdbs {dump_pdb} '))
self.logger.info(path_to_sbatch)
return path_to_sbatch

Expand Down

0 comments on commit 8b38320

Please sign in to comment.