Ejemplo n.º 1
0
    def extract_docking_results(self, file_s, input_file_r, input_file_l):

        subprocess.check_output(license.wrap_command(
            "moebatch -exec \"db_ExportTriposMOL2 ['dock.mdb', 'lig.mol2', 'mol', []]\"",
            'moe'),
                                shell=True,
                                executable='/bin/bash')

        if os.path.exists('lig.mol2'):
            ligname = reader.open(input_file_l).ligname
            mol2.update_mol2file('lig.mol2',
                                 'lig-.mol2',
                                 ligname=ligname,
                                 multi=True)
            os.remove('lig.mol2')

            # get SDF to extract scores
            sdffile = 'lig.sdf'
            subprocess.check_output(license.wrap_command(
                "moebatch -exec \"db_ExportSD ['dock.mdb', '%s', ['mol','S'], []]\""
                % sdffile, 'moe'),
                                    shell=True,
                                    executable='/bin/bash')
            with open(sdffile, 'r') as sdff:
                with open(file_s, 'w') as sf:
                    for line in sdff:
                        if line.startswith("> <S>"):
                            print >> sf, sdff.next().strip()
            os.remove(sdffile)
        else:
            open(file_s, 'w').close()
Ejemplo n.º 2
0
    def write_rescoring_script(self, filename, file_r, files_l):
        """Rescore using Glide SP scoring function"""
        locals().update(self.options)

        files_l_joined = ' '.join(files_l)

        if self.use_prepwizard:
            # prepare protein cmd (the protein structure is already assumed to be minimized/protonated with prepwizard)
            prepwizard_cmd = license.wrap_command(
                "prepwizard -fix %(file_r)s target.mae" % locals(),
                'schrodinger')
        else:
            prepwizard_cmd = "structconvert -ipdb %(file_r)s -omae target.mae" % locals(
            )

        # prepare grid and scoring cmd
        glide_grid_cmd = license.wrap_command("glide grid.in",
                                              'schrodinger')  # grid prepare
        glide_dock_cmd = license.wrap_command("glide dock.in",
                                              'schrodinger')  # docking command
        tmpdirline = self.tmpdirline

        with open(filename, 'w') as file:
            script = """#!/bin/bash
%(tmpdirline)s
cat %(files_l_joined)s > lig.mol2

# (A) Prepare receptor
%(prepwizard_cmd)s

# (B) Prepare grid
echo "USECOMPMAE YES
INNERBOX %(innerbox)s
ACTXRANGE %(actxrange)s
ACTYRANGE %(actyrange)s
ACTZRANGE %(actzrange)s
GRID_CENTER %(grid_center)s
OUTERBOX %(outerbox)s
ENTRYTITLE target
GRIDFILE grid.zip
RECEP_FILE target.mae" > grid.in
%(glide_grid_cmd)s


# (C) convert ligand to maestro format
structconvert -imol2 lig.mol2 -omae lig.mae

# (D) perform rescoring
echo "WRITEREPT YES
USECOMPMAE YES
DOCKING_METHOD inplace
GRIDFILE $PWD/grid.zip
LIGANDFILE $PWD/lig.mae
PRECISION SP" > dock.in

%(glide_dock_cmd)s""" % locals()
            file.write(script)
Ejemplo n.º 3
0
    def write_docking_script(self, filename, file_r, file_l):
        """ Write docking script for glide """
        locals().update(self.options)

        if self.use_prepwizard:
            # prepare protein cmd (the protein structure is already assumed to be minimized/protonated with prepwizard)
            prepwizard_cmd = license.wrap_command(
                "prepwizard -fix %(file_r)s target.mae" % locals(),
                'schrodinger')
        else:
            prepwizard_cmd = "structconvert -ipdb %(file_r)s -omae target.mae" % locals(
            )

        # prepare grid and docking cmd
        glide_grid_cmd = license.wrap_command("glide grid.in", 'schrodinger')
        glide_dock_cmd = license.wrap_command("glide dock.in", 'schrodinger')

        tmpdirline = self.tmpdirline

        # write glide script
        with open(filename, 'w') as file:
            script = """#!/bin/bash
%(tmpdirline)s

# (A) Prepare receptor
%(prepwizard_cmd)s

# (B) Prepare grid
echo "USECOMPMAE YES
INNERBOX %(innerbox)s
ACTXRANGE %(actxrange)s
ACTYRANGE %(actyrange)s
ACTZRANGE %(actzrange)s
GRID_CENTER %(grid_center)s
OUTERBOX %(outerbox)s
ENTRYTITLE target
GRIDFILE grid.zip
RECEP_FILE target.mae" > grid.in
%(glide_grid_cmd)s

# (C) convert ligand to maestro format
structconvert -imol2 %(file_l)s -omae lig.mae

# (D) perform docking
echo "WRITEREPT YES
USECOMPMAE YES
DOCKING_METHOD confgen
POSES_PER_LIG %(poses_per_lig)s
POSE_RMSD %(pose_rmsd)s
GRIDFILE $PWD/grid.zip
LIGANDFILE $PWD/lig.mae
PRECISION %(precision)s" > dock.in
%(glide_dock_cmd)s""" % locals()
            file.write(script)
Ejemplo n.º 4
0
def write_sitefinder_script(filename, file_r, args):

    write_moe_sitefinder_script('sitefinder.svl', file_r, args)
    sitefinder_cmd = license.wrap_command("moebatch -run sitefinder.svl",
                                          'moe')  # cmd for docking

    # write script
    with open(filename, 'w') as file:
        script = """#!/bin/bash
# run docking
%(sitefinder_cmd)s
""" % locals()
        file.write(script)
Ejemplo n.º 5
0
    def write_docking_script(self, filename, file_r, file_l):

        self.write_moe_docking_script('moe_dock.svl')

        convertmol2_cmd = license.wrap_command(
            "moebatch -exec \"mdb_key = db_Open ['ligand.mdb','create']; db_Close mdb_key;\
db_ImportMOL2 ['%(file_l)s','ligand.mdb', 'molecule']\"" % locals(),
            'moe')  # create mdb for ligand

        dock_cmd = license.wrap_command(
            "moebatch -run moe_dock.svl -rec %(file_r)s -lig ligand.mdb" %
            locals(), 'moe')  # cmd for docking

        # write script
        with open(filename, 'w') as ff:
            script = """#!/bin/bash
# convert .mol2 file to mdb
%(convertmol2_cmd)s

# run docking
%(dock_cmd)s\n""" % locals()
            ff.write(script)
Ejemplo n.º 6
0
    def extract_rescoring_results(self, file_s):

        locals().update(self.options)

        if self.options['rescoring'] == 'prolig':
            with open(file_s, 'a') as sf:
                if os.path.exists('moebatch.log'):
                    with open('moebatch.log', 'r') as logf:
                        is_interaction_energy = False
                        for line in logf:
                            if line.startswith("Interaction energy:"):
                                print >> sf, line.split()[-2]
                                is_interaction_energy = True
                                break
                        if not is_interaction_energy:
                            print >> sf, 'NaN'
                else:
                    print >> sf, 'NaN'
        else:
            # get SDF to extract scores
            sdffile = 'lig.sdf'
            subprocess.check_output(license.wrap_command(
                "moebatch -exec \"db_ExportSD ['dock.mdb', '%s', ['mol','S'], []]\""
                % sdffile, 'moe'),
                                    shell=True,
                                    executable='/bin/bash')
            with open(file_s, 'a') as sf:
                if os.path.exists(sdffile):
                    with open(sdffile, 'r') as sdff:
                        for line in sdff:
                            if line.startswith("> <S>"):
                                print >> sf, sdff.next().strip()
                                break
                        os.remove(sdffile)
                else:
                    print >> sf, 'NaN'
Ejemplo n.º 7
0
    def write_docking_script(self, filename, file_r, file_l):

        locals().update(self.options)

        dock_cmd = license.wrap_command("gold_auto gold.conf",
                                        'gold')  # cmd for docking

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

echo "  GOLD CONFIGURATION FILE

  AUTOMATIC SETTINGS
autoscale = 0.5

  POPULATION
popsiz = auto
select_pressure = auto
n_islands = auto
maxops = auto
niche_siz = auto

  GENETIC OPERATORS
pt_crosswt = auto
allele_mutatewt = auto
migratewt = auto

  FLOOD FILL
radius = %(radius)s
origin = %(origin)s
do_cavity = 1
floodfill_atom_no = 0
cavity_file = 
floodfill_center = point

  DATA FILES
ligand_data_file %(file_l)s %(nposes)s
param_file = DEFAULT
set_ligand_atom_types = 1
set_protein_atom_types = 0
directory = .
tordist_file = DEFAULT
make_subdirs = 0
save_lone_pairs = 1
fit_points_file = f it_pts.mol2
read_fitpts = 0

  FLAGS
internal_ligand_h_bonds = 0
flip_free_corners = 0
match_ring_templates = 0
flip_amide_bonds = 0
flip_planar_n = 1 flip_ring_NRR flip_ring_NHR
flip_pyramidal_n = 0
rotate_carboxylic_oh = flip
use_tordist = 1
postprocess_bonds = 1
rotatable_bond_override_file = DEFAULT
solvate_all = 1

  TERMINATION
early_termination = 1
n_top_solutions = 3
rms_tolerance = 1.5

  CONSTRAINTS
force_constraints = 0

  COVALENT BONDING
covalent = 0

  SAVE OPTIONS
save_score_in_file = 1
save_protein_torsions = 1

  FITNESS FUNCTION SETTINGS
initial_virtual_pt_match_max = 3
relative_ligand_energy = 1
gold_fitfunc_path = goldscore
start_vdw_linear_cutoff = 6
score_param_file = DEFAULT

  PROTEIN DATA
protein_datafile = %(file_r)s" > gold.conf

%(dock_cmd)s""" % locals()
            file.write(script)
Ejemplo n.º 8
0
    def write_rescoring_script(self, filename, file_r, file_l):

        locals().update(self.options)

        if self.options['rescoring'] == 'prolig':
            rescoring_cmd = license.wrap_command(
                "moebatch -run moe_rescoring.svl -rec %(file_r)s -lig %(file_l)s"
                % locals(), 'moe')  # cmd for docking

            with open(filename, 'w') as file:
                script = """#!/bin/bash
echo "#svl
function prolig_Calculate;

global argv;
function ArgvPull;

local function main[]

    ArgvReset ArgvExpand argv;
    local [recmdb, ligmdb, outf] = ArgvPull [
        ['-rec','-lig','-o'],
        1
    ];
    local lk = ReadTriposMOL2 [ligmdb, []];

    // Load pdb
    local rk = ReadAuto [recmdb, []];

    local itypes = ['hbond', 'metal', 'ionic', 'covalent', 'arene', 'distance'];
    local iract = prolig_Calculate [itypes, lk, rk, []];
    //local iract_v = Formulate2DInteractions [lk, rk, []];

    local idx;
    local interaction_energy = 0.;
    for idx = 1, length iract(1) loop
        if iract(1)(idx) == 'distance' then
            break;
        else
            interaction_energy = interaction_energy + iract(4)(idx);
        endif
    endloop

    write ['Interaction energy: {f.2} kCal/mol \\n', interaction_energy];

endfunction;" > moe_rescoring.svl

%(rescoring_cmd)s
""" % locals()
                file.write(script)

        else:
            convertmol2_cmd = license.wrap_command(
                "moebatch -exec \"mdb_key = db_Open ['lig.mdb','create']; db_Close mdb_key;\
db_ImportMOL2 ['%(file_l)s','lig.mdb', 'molecule']\"" % locals(),
                'moe')  # create mdb for ligand
            rescoring_cmd = license.wrap_command(
                "moebatch -run moe_rescoring.svl -rec %(file_r)s -lig lig.mdb"
                % locals(), 'moe')  # cmd for docking

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

%(convertmol2_cmd)s

echo "#svl
function DockAtoms, DockFile;
function DockMDBwAtoms, DockMDBwFile;

global argv;
function ArgvPull;

local function main []

    // Set potential and setup parameters
    pot_Load '$MOE/lib/Amber10EHT.ff';

    pot_Setup [
        strEnable: 1,
        angEnable: 1,
        stbEnable: 1,
        oopEnable: 1,
        torEnable: 1,
        vdwEnable: 1,
        eleEnable: 1,
        solEnable: 0,
        resEnable: 1,
        strWeight: 1,
        angWeight: 1,
        stbWeight: 1,
        oopWeight: 1,
        torWeight: 1,
        vdwWeight: 1,
        eleWeight: 1,
        solWeight: 1,
        resWeight: 1,
        cutoffEnable: 1,
        cutoffOn: 8,
        cutoffOff: 10,
        eleDist: 2,
        vdwScale14: 0.5,
        vdwBuffer1: 0,
        vdwBuffer2: 0,
        eleScale14: 0.833333,
        eleDielectric: 1,
        eleBuffer: 0,
        solDielectric: 80,
        solDielectricOffset: 0,
        state0: 1,
        state1: 0,
        state2: 1,
        threadCount: 0
    ];

ArgvReset ArgvExpand argv;
    local [recmdb, ligmdb, ph4file, outf] = ArgvPull [
        ['-rec','-lig','-ph4','-o'],
        1
    ];

    // If no receptor given as argument use default rec.moe
    if isnull recmdb then
        recmdb = 'rec.moe';
    endif

    local basename = fbase recmdb;
    local extension = fext recmdb;

    // output docking database file
    outf = 'dock.mdb';

    // Receptor file or database
    // Assume that the file is a moe or pdb file extract chains atoms

    local chains = ReadAuto [recmdb, []];
    local rec = cat cAtoms chains; // extract atom info from atom

    local alpha_sites = run['sitefind.svl', [rec, []], 'AlphaSites'];

    // Take first/highest scoring pocket alpha_sites(1)
    // Take fpos data alpha_sites(1)(1)
    // Take only coords of fpos data alpha_sites(1)(1)(2)
    local a_sites = apt cat alpha_sites(1)(1)(2); // x, y, z coords

    // Make dummy He atoms for alpha site
    local dummy, x, y, z;
    for x = 1, length a_sites loop
        dummy(x) = sm_Build ['[He]'];
        aSetPos [dummy(x), a_sites(x)];
    endloop

    // Make a collection of site atoms to send to docking
    // from the alpha site
    oSetCollection ['Site', dummy];
    local site = oGetCollection 'Site';

    // Ligand database
    local lmdb = _db_Open [ligmdb, 'read'];
    if lmdb == 0 then
        exit twrite ['Cannot read ligand mdb file {}', ligmdb];
    endif

    local ent = 0; // must have this set to zero
    while ent = db_NextEntry[lmdb, ent] loop; //loop through ligand database
        local ligdata = db_Read[lmdb, ent]; //read data for each entry
        local ligmoldata = ligdata.mol; // extract into moldata
        local ligchains = mol_Create ligmoldata; //create molecule in window
        local lig = cat cAtoms ligchains; // extract atom info from atom
    endloop

    // Set options for docking and refinement
    // maxpose is set to accept 50 poses, change as required
    local opt = [
                outrmsd: 1,
                sel_ent_only_rec: 0,
                sel_ent_only: 0,
                wall: [ '', 0, [ 0, 0, 0 ], [ 1000000, 1000000, 1000000 ], 0 ],
                csearch: 1,
                placement: 'None',
                scoring: 'None',
                dup_placement: 1,
                rescoring: '%(rescoring)s',
                rescoring_opt: [ train : 0 ],
                dup_refine: 1,
                remaxpose: 1,
                descexpr: '',
                receptor_mfield: '',
                ligand_mfield: '',
                tplate: [  ],
                tplateSel: [  ],
                ligmdbname: ligmdb,
                recmdbname: recmdb
    ];

    //Perform the docking
    DockFile [rec, site, ligmdb, outf, opt];

    oDestroy ligchains;
    db_Close lmdb;
    write ['Docking finished at {}.\\n', asctime []];

endfunction;" > moe_rescoring.svl

%(rescoring_cmd)s""" % locals()
                file.write(script)