Пример #1
0
    def write_docking_script(self, filename, file_r, file_l):
        """Dock using DOCK6 flexible docking with grid scoring as primary score"""

        locals().update(self.options)
        self.write_script_ligand_prep()

        if self.options['charge_method']:
            amber_version = utils.check_amber_version()
            ambertools.run_antechamber(file_l,
                                       'lig_ref.mol2',
                                       at='sybyl',
                                       c=self.options['charge_method'],
                                       version=amber_version)
        else:
            shutil.copyfile(file_l, 'lig_ref.mol2')

        if self.options['grid_dir'] is None:
            # write autodock script
            with open(filename, 'w') as file:
                script = """#!/bin/bash
set -e

# remove hydrogens from target
echo "delete element.H
write format pdb #0 target_noH.pdb" > removeH.cmd
chimera --nogui %(file_r)s removeH.cmd
rm -rf removeH.cmd

# prepare receptor (add missing h, add partial charges,...)
echo "import chimera
from DockPrep import prep

models = chimera.openModels.list(modelTypes=[chimera.Molecule])
prep(models)

from WriteMol2 import writeMol2
writeMol2(models, 'target.mol2')" > dockprep.py
chimera --nogui %(file_r)s dockprep.py

# generating receptor surface
dms target_noH.pdb -n -w %(probe_radius)s -v -o target_noH.ms

# generating spheres
echo "target_noH.ms
R
X
0.0
%(maximum_sphere_radius)s
%(minimum_sphere_radius)s
target_noH_site.sph" > INSPH
sphgen_cpp

# shift ligand coordintates
python prepare_ligand_dock.py lig_ref.mol2 lig.mol2 %(center)s

# selecting spheres within a user-defined radius (sphgen_radius)
sphere_selector target_noH_site.sph lig.mol2 %(sphgen_radius)s

# create box - the second argument in the file showbox.in
# is the extra margin to also be enclosed to the box (angstroms)
echo "Y
%(extra_margin)s
selected_spheres.sph
1
target_noH_box.pdb" > showbox.in
showbox < showbox.in

dock6path=`which dock6`
vdwfile=`python -c "print '/'.join('$dock6path'.split('/')[:-2]) + '/parameters/vdw_AMBER_parm99.defn'"`
flexfile=`python -c "print '/'.join('$dock6path'.split('/')[:-2]) + '/parameters/flex.defn'"`
flexdfile=`python -c "print '/'.join('$dock6path'.split('/')[:-2]) + '/parameters/flex_drive.tbl'"`

# create grid
echo "compute_grids yes
grid_spacing %(grid_spacing)s
output_molecule no
contact_score yes
energy_score yes
energy_cutoff_distance 9999
atom_model a
attractive_exponent %(attractive_exponent)s
repulsive_exponent %(repulsive_exponent)s
distance_dielectric yes
dielectric_factor 4
bump_filter yes
bump_overlap 0.75
receptor_file target.mol2
box_file target_noH_box.pdb
vdw_definition_file $vdwfile
score_grid_prefix grid
contact_cutoff_distance 4.5" > grid.in
grid -i grid.in

# flexible docking using grid score as primary score and no secondary score
echo "ligand_atom_file lig.mol2
limit_max_ligands no
skip_molecule no
read_mol_solvation no
calculate_rmsd no
use_database_filter no
orient_ligand yes
automated_matching yes
receptor_site_file selected_spheres.sph
max_orientations %(max_orientations)s
critical_points no
chemical_matching no
use_ligand_spheres no
use_internal_energy yes
internal_energy_rep_exp 12
flexible_ligand yes
user_specified_anchor no
limit_max_anchors no
min_anchor_size 5
pruning_use_clustering yes
pruning_max_orients 1000
pruning_clustering_cutoff 100
pruning_conformer_score_cutoff 100
use_clash_overlap yes
clash_overlap 0.5
write_growth_tree no
bump_filter yes
bump_grid_prefix grid
max_bumps_anchor 12
max_bumps_growth 12
score_molecules yes
contact_score_primary no
contact_score_secondary no
grid_score_primary yes
grid_score_secondary no
grid_score_rep_rad_scale 1
grid_score_vdw_scale 1
grid_score_es_scale 1
grid_score_grid_prefix grid
multigrid_score_secondary no
dock3.5_score_secondary no
continuous_score_secondary no
descriptor_score_secondary no
gbsa_zou_score_secondary no
gbsa_hawkins_score_secondary no
SASA_descriptor_score_secondary no
pbsa_score_secondary no
amber_score_secondary no
minimize_ligand yes
minimize_anchor yes
minimize_flexible_growth yes
use_advanced_simplex_parameters no
simplex_max_cycles 1
simplex_score_converge 0.1
simplex_cycle_converge 1.0
simplex_trans_step 1.0
simplex_rot_step 0.1
simplex_tors_step 10.0
simplex_anchor_max_iterations 1000
simplex_grow_max_iterations 1000
simplex_grow_tors_premin_iterations 0
simplex_random_seed 0
simplex_restraint_min no
atom_model all
vdw_defn_file $vdwfile
flex_defn_file $flexfile
flex_drive_file $flexdfile
ligand_outfile_prefix lig_out
write_orientations no
num_scored_conformers %(num_scored_conformers)s
write_conformations no
cluster_conformations yes
cluster_rmsd_threshold %(rmsd)s
rank_ligands no" > dock6.in

dock6 -i dock6.in""" % locals()
                file.write(script)

        else:
            grid_prefix = self.options['grid_dir'] + '/' + self.options[
                'dockdir'] + '/grid'
            # check if grid file exists
            if not os.path.isfile(grid_prefix + '.in'):
                raise IOError(
                    'No grid file detected in specified location %s' %
                    self.options['grid_dir'])

            sphfile = self.options['grid_dir'] + '/' + self.options[
                'dockdir'] + '/selected_spheres.sph'
            # check if grid file exists
            if not os.path.isfile(sphfile):
                raise IOError(
                    'No selected_spheres.sph file detected in specified location %s'
                    % self.options['grid_dir'])

            with open(filename, 'w') as file:
                script = """#!/bin/bash

# shift ligand coordintates
python prepare_ligand_dock.py lig_ref.mol2 lig.mol2 %(center)s

dock6path=`which dock6`
vdwfile=`python -c "print '/'.join('$dock6path'.split('/')[:-2]) + '/parameters/vdw_AMBER_parm99.defn'"`
flexfile=`python -c "print '/'.join('$dock6path'.split('/')[:-2]) + '/parameters/flex.defn'"`
flexdfile=`python -c "print '/'.join('$dock6path'.split('/')[:-2]) + '/parameters/flex_drive.tbl'"`

# flexible docking using grid score as primary score and no secondary score
echo "ligand_atom_file lig.mol2
limit_max_ligands no
skip_molecule no
read_mol_solvation no
calculate_rmsd no
use_database_filter no
orient_ligand yes
automated_matching yes
receptor_site_file %(sphfile)s
max_orientations %(max_orientations)s
critical_points no
chemical_matching no
use_ligand_spheres no
use_internal_energy yes
internal_energy_rep_exp 12
flexible_ligand yes
user_specified_anchor no
limit_max_anchors no
min_anchor_size 5
pruning_use_clustering yes
pruning_max_orients 1000
pruning_clustering_cutoff 100
pruning_conformer_score_cutoff 100
use_clash_overlap yes
clash_overlap 0.5
write_growth_tree no
bump_filter yes
bump_grid_prefix %(grid_prefix)s
max_bumps_anchor 12
max_bumps_growth 12
score_molecules yes
contact_score_primary no
contact_score_secondary no
grid_score_primary yes
grid_score_secondary no
grid_score_rep_rad_scale 1
grid_score_vdw_scale 1
grid_score_es_scale 1
grid_score_grid_prefix %(grid_prefix)s
multigrid_score_secondary no
dock3.5_score_secondary no
continuous_score_secondary no
descriptor_score_secondary no
gbsa_zou_score_secondary no
gbsa_hawkins_score_secondary no
SASA_descriptor_score_secondary no
pbsa_score_secondary no
amber_score_secondary no
minimize_ligand yes
minimize_anchor yes
minimize_flexible_growth yes
use_advanced_simplex_parameters no
simplex_max_cycles 1
simplex_score_converge 0.1
simplex_cycle_converge 1.0
simplex_trans_step 1.0
simplex_rot_step 0.1
simplex_tors_step 10.0
simplex_anchor_max_iterations 1000
simplex_grow_max_iterations 1000
simplex_grow_tors_premin_iterations 0
simplex_random_seed 0
simplex_restraint_min no
atom_model all
vdw_defn_file $vdwfile
flex_defn_file $flexfile
flex_drive_file $flexdfile
ligand_outfile_prefix lig_out
write_orientations no
num_scored_conformers %(num_scored_conformers)s
write_conformations no
cluster_conformations yes
cluster_rmsd_threshold %(rmsd)s
rank_ligands no" > dock6.in

dock6 -i dock6.in""" % locals()
                file.write(script)
Пример #2
0
    def write_rescoring_script(self, filename, file_r, files_l):
        """Rescore using DOCK6 grid scoring function"""

        locals().update(self.options)
        self.write_script_ligand_prep()

        # cat mol2 files in a single mol2
        file_l_all = 'lig_all.mol2'

        if self.options['charge_method']:
            amber_version = utils.check_amber_version()
            ambertools.run_antechamber(files_l[0],
                                       'lig-1.mol2',
                                       at='sybyl',
                                       c=self.options['charge_method'],
                                       version=amber_version)
        else:
            shutil.copyfile(files_l[0], 'lig-1.mol2')

        for idx, file_l in enumerate(files_l):
            if idx > 0:
                if self.options['charge_method']:
                    # if not first one, do not regenerate the charges, copy charges generated the first time
                    coords_l = mol2.get_coordinates(file_l)
                    struct = mol2.Reader('lig-1.mol2').next()
                    struct = mol2.replace_coordinates(struct, coords_l)
                    mol2.Writer().write('lig-%i.mol2' % (idx + 1), struct)
                else:
                    shutil.copyfile(file_l, 'lig-%i.mol2' % (idx + 1))
            subprocess.check_output("cat lig-%i.mol2 >> %s" %
                                    (idx + 1, file_l_all),
                                    shell=True)

        if self.options['grid_dir'] is None:
            with open(filename, 'w') as file:
                script = """#!/bin/bash
set -e

# remove hydrogens from target
echo "delete element.H
write format pdb #0 target_noH.pdb" > removeH.cmd
chimera --nogui %(file_r)s removeH.cmd
rm -rf removeH.cmd

# prepare receptor (add missing h, add partial charges,...)
echo "import chimera
from DockPrep import prep

models = chimera.openModels.list(modelTypes=[chimera.Molecule])
prep(models)

from WriteMol2 import writeMol2
writeMol2(models, 'target.mol2')" > dockprep.py
chimera --nogui %(file_r)s dockprep.py

# generating receptor surface
dms target_noH.pdb -n -w %(probe_radius)s -v -o target_noH.ms

# generating spheres
echo "target_noH.ms
R
X
0.0
%(maximum_sphere_radius)s
%(minimum_sphere_radius)s
target_noH_site.sph" > INSPH
sphgen_cpp

# shift ligand coordintates
python prepare_ligand_dock.py lig-1.mol2 lig.mol2 %(center)s

# selecting spheres within a user-defined radius (sphgen_radius)
sphere_selector target_noH_site.sph lig.mol2 %(sphgen_radius)s

# create box - the second argument in the file showbox.in
# is the extra margin to also be enclosed to the box (angstroms)
echo "Y
%(extra_margin)s
selected_spheres.sph
1
target_noH_box.pdb" > showbox.in
showbox < showbox.in

dock6path=`which dock6`
vdwfile=`python -c "print '/'.join('$dock6path'.split('/')[:-2]) + '/parameters/vdw_AMBER_parm99.defn'"`
flexfile=`python -c "print '/'.join('$dock6path'.split('/')[:-2]) + '/parameters/flex.defn'"`
flexdfile=`python -c "print '/'.join('$dock6path'.split('/')[:-2]) + '/parameters/flex_drive.tbl'"`

# create grid
echo "compute_grids yes
grid_spacing %(grid_spacing)s
output_molecule no
contact_score yes
energy_score yes
energy_cutoff_distance 9999
atom_model a
attractive_exponent %(attractive_exponent)s
repulsive_exponent %(repulsive_exponent)s
distance_dielectric yes
dielectric_factor 4
bump_filter yes
bump_overlap 0.75
receptor_file target.mol2
box_file target_noH_box.pdb
vdw_definition_file $vdwfile
score_grid_prefix grid
contact_cutoff_distance 4.5" > grid.in
grid -i grid.in

echo "ligand_atom_file %(file_l_all)s
limit_max_ligands no
skip_molecule no
read_mol_solvation no
calculate_rmsd no
use_database_filter no
orient_ligand no
use_internal_energy yes
internal_energy_rep_exp 12
flexible_ligand no
bump_filter no
score_molecules yes
contact_score_primary no
contact_score_secondary no
grid_score_primary yes
grid_score_secondary no
grid_score_rep_rad_scale 1
grid_score_vdw_scale 1
grid_score_es_scale 1
grid_score_grid_prefix grid
multigrid_score_secondary no
dock3.5_score_secondary no
continuous_score_secondary no
descriptor_score_secondary no
gbsa_zou_score_secondary no
gbsa_hawkins_score_secondary no
SASA_descriptor_score_secondary no
amber_score_secondary no
minimize_ligand no
atom_model all
vdw_defn_file $vdwfile
flex_defn_file $flexfile
flex_drive_file $flexdfile
ligand_outfile_prefix lig_out
write_orientations no
num_scored_conformers 1
rank_ligands no" > dock6.in

dock6 -i dock6.in > dock.out""" % locals()
                file.write(script)
        else:
            grid_prefix = self.options['grid_dir'] + '/' + self.options[
                'dockdir'] + '/grid'
            # check if grid file exists
            if not os.path.isfile(grid_prefix + '.in'):
                raise IOError(
                    'No grid file detected in specified location %s' %
                    self.options['grid_dir'])

            with open(filename, 'w') as file:
                script = """#!/bin/bash

# shift ligand coordintates
python prepare_ligand_dock.py lig-1.mol2 lig.mol2 %(center)s

dock6path=`which dock6`
vdwfile=`python -c "print '/'.join('$dock6path'.split('/')[:-2]) + '/parameters/vdw_AMBER_parm99.defn'"`
flexfile=`python -c "print '/'.join('$dock6path'.split('/')[:-2]) + '/parameters/flex.defn'"`
flexdfile=`python -c "print '/'.join('$dock6path'.split('/')[:-2]) + '/parameters/flex_drive.tbl'"`

echo "ligand_atom_file %(file_l_all)s
limit_max_ligands no
skip_molecule no
read_mol_solvation no
calculate_rmsd no
use_database_filter no
orient_ligand no
use_internal_energy yes
internal_energy_rep_exp 12
flexible_ligand no
bump_filter no
score_molecules yes
contact_score_primary no
contact_score_secondary no
grid_score_primary yes
grid_score_secondary no
grid_score_rep_rad_scale 1
grid_score_vdw_scale 1
grid_score_es_scale 1
grid_score_grid_prefix %(grid_prefix)s
multigrid_score_secondary no
dock3.5_score_secondary no
continuous_score_secondary no
descriptor_score_secondary no
gbsa_zou_score_secondary no
gbsa_hawkins_score_secondary no
SASA_descriptor_score_secondary no
amber_score_secondary no
minimize_ligand no
atom_model all
vdw_defn_file $vdwfile
flex_defn_file $flexfile
flex_drive_file $flexdfile
ligand_outfile_prefix lig_out
write_orientations no
num_scored_conformers 1
rank_ligands no" > dock6.in

dock6 -i dock6.in > dock.out""" % locals()
                file.write(script)
Пример #3
0
if args.cut is None:
    if args.solvent == 'explicit':
        args.cut = 10.0
    else:
        args.cut = 999.0

if args.ncpus is None:
    if args.partition == 'gpu':
        args.ncpus = 16
    else:
        args.ncpus = 8

locals().update(args.__dict__)

# get amber version
amber_version = utils.check_amber_version()

# check electric field option
if not amber_version in ['16', '17'] and efz is not None:
    sys.exit('Electric field option only supported for Amber 16 or 17')
elif efz:
    ef_lines = "\nefz=%s,"%efz
    if efn == 1:
        ef_lines += " efn=1,"
else:
    ef_lines = "" 

# set aMD options
if amd is not None:
    options_amd = amd.split(',')
    noptions_amd = len(options_amd)/2