def sculpt_relax(selection,
                 backbone=1,
                 neighbors=0,
                 model=None,
                 cycles=100,
                 state=0,
                 quiet=1):
    '''
DESCRIPTION

    Relax the given selection.

    SO FAR ONLY SUPPORTS SELECTIONS WITHIN THE SAME MODEL!

    Do 100 iterations, 75 of them with all terms but low VDW weights,
    and 25 with only local geometry terms. With default VDW weights and
    atom clashes, the structure gets distorted very easily!

USAGE

    sculpt_relax selection [, backbone [, neighbors [, model [, cycles ]]]]
    '''
    from pymol import selector

    backbone, neighbors = int(backbone), int(neighbors)
    cycles, state, quiet = int(cycles), int(state), int(quiet)

    sele = selector.process(selection)
    org = cmd.get_object_list(sele)[0]
    if model is None:
        model = org
    elif model != org:
        sele = sele.replace('(%s)' % org, '(%s)' % model)

    cmd.protect()
    cmd.deprotect(sele)
    if not backbone:
        cmd.protect('name CA+C+N+O+OXT')

    cmd.sculpt_activate(model, state)
    cmd.set('sculpt_vdw_weight', 0.25, model)  # Low VDW forces
    cmd.set('sculpt_field_mask', 0x1FF, model)  # Default

    if neighbors:
        cmd.sculpt_iterate(model, state, int(cycles * 0.25))
        cmd.deprotect('byres (%s within 6.0 of (%s))' % (model, sele))
        if not backbone:
            cmd.protect('name CA+C+N+O+OXT')
        cmd.sculpt_iterate(model, state, cycles=int(cycles * 0.50))
    else:
        cmd.sculpt_iterate(model, state, int(cycles * 0.75))

    cmd.set('sculpt_field_mask', 0x01F, model)  # Local Geometry Only
    cmd.sculpt_iterate(model, state, int(cycles * 0.25))

    cmd.unset('sculpt_vdw_weight', model)
    cmd.unset('sculpt_field_mask', model)
    cmd.sculpt_deactivate(model)
    cmd.deprotect()
def localSculpt(obj, site):
    res = str(site)
    cmd.protect('(not %s/) or name CA+C+N+O+OXT' % (res))
    print "Activating Sculpting."
    cmd.sculpt_activate(obj[:-4]) 
    cmd.sculpt_iterate(obj[:-4], cycles=5000) 
    cmd.sculpt_deactivate(obj[:-4])
    cmd.deprotect() 
Exemple #3
0
def sculpt_relax(selection, backbone=1, neighbors=0, model=None, cycles=100,
        state=0, quiet=1):
    '''
DESCRIPTION

    Relax the given selection.

    SO FAR ONLY SUPPORTS SELECTIONS WITHIN THE SAME MODEL!

    Do 100 iterations, 75 of them with all terms but low VDW weights,
    and 25 with only local geometry terms. With default VDW weights and
    atom clashes, the structure gets distorted very easily!

USAGE

    sculpt_relax selection [, backbone [, neighbors [, model [, cycles ]]]]
    '''
    from pymol import selector

    backbone, neighbors = int(backbone), int(neighbors)
    cycles, state, quiet = int(cycles), int(state), int(quiet)

    sele = selector.process(selection)
    org = cmd.get_object_list(sele)[0]
    if model is None:
        model = org
    elif model != org:
        sele = sele.replace('(%s)' % org, '(%s)' % model)

    cmd.protect()
    cmd.deprotect(sele)
    if not backbone:
        cmd.protect('name CA+C+N+O+OXT')

    cmd.sculpt_activate(model, state)
    cmd.set('sculpt_vdw_weight', 0.25, model) # Low VDW forces
    cmd.set('sculpt_field_mask', 0x1FF, model) # Default

    if neighbors:
        cmd.sculpt_iterate(model, state, int(cycles * 0.25))
        cmd.deprotect('byres (%s within 6.0 of (%s))' % (model, sele))
        if not backbone:
            cmd.protect('name CA+C+N+O+OXT')
        cmd.sculpt_iterate(model, state, cycles=int(cycles * 0.50))
    else:
        cmd.sculpt_iterate(model, state, int(cycles * 0.75))

    cmd.set('sculpt_field_mask', 0x01F, model) # Local Geometry Only
    cmd.sculpt_iterate(model, state, int(cycles * 0.25))

    cmd.unset('sculpt_vdw_weight', model)
    cmd.unset('sculpt_field_mask', model)
    cmd.sculpt_deactivate(model)
    cmd.deprotect()
Exemple #4
0
def local_sculpt(obj, variant_three, site):
    # Original version of local side chain optimization
    #res = str(site)
    #cmd.protect('(not %s/) or name CA+C+N+O+OXT' % (res))
    #print "Activating Sculpting."
    #cmd.sculpt_activate(obj[:-4]) 
    #cmd.sculpt_iterate(obj[:-4], cycles=50) 
    #cmd.sculpt_deactivate(obj[:-4])
    #cmd.deprotect() 

    # New version of local side chain optimization.
    #cmd.select("%s%s_exp" % (variant_one, site), "(byres (\"%s/\" expand 1.8))" % site)
    #cmd.select("%s%s_exp_sc" % (variant_one, site), "%s%s and (not name C+CA+N+O+HA+HT)" % (variant_one, site))
    #cmd.protect("not %s%s_exp_sc" % (variant_one, site))
    variant_one = get_one(variant_three)
    cmd.select("%s%s" % (variant_one, site), "%s/" % site)
    cmd.select("bb", "name C+CA+N+O+H+HA+HT")
    cmd.select("%s%s_sc" % (variant_one, site), "%s%s and not bb" % (variant_one, site))
    cmd.protect("not %s%s_sc" % (variant_one, site))
    cmd.sculpt_activate(obj[:-4])
    cmd.sculpt_iterate(obj[:-4], cycles=3000)
    cmd.sculpt_deactivate(obj[:-4])
    cmd.deprotect()
 def build(self):
     """Build the peptide"""
     name = self.targetObjectNameLineEdit.text()
     if name in cmd.get_object_list():
         if QtWidgets.QMessageBox.question(
                 self, 'Overwrite existing model?',
                 'Model {} already exists. Do you want to overwrite it?'.
                 format(name),
                 QtWidgets.QMessageBox.Yes | QtWidgets.QMessageBox.No,
                 QtWidgets.QMessageBox.No) == QtWidgets.QMessageBox.NoRole:
             # "No" was selected by the user, return without building
             return
         cmd.delete('model {}'.format(name))
     residues = self.model.residues()
     try:
         betafab2(name, *residues)
     except Exception as exc:
         QtWidgets.QMessageBox.critical(
             self, 'Error while building peptide',
             'Error while building peptide:\n{}'.format(exc.args[0]))
     if self.cleanupCheckBox.isChecked():
         # try to energy minimize the structure
         select_bbb('_bbone_of_{}'.format(name), 'model {}'.format(name))
         cmd.flag('fix', '_bbone_of_{}'.format(name), 'set')
         try:
             import freemol.mengine
             cmd.clean('model {}'.format(name))
         except:
             warnings.warn(
                 'Cannot run clean(): This PyMOL build appears not to include full modeling capabilities '
                 '(could not import the freemol.mengine module). Using the inferior sculpting facility.'
             )
             cmd.sculpt_activate(name)
             cmd.sculpt_iterate(name, cycles=1000)
             cmd.sculpt_deactivate(name)
         cmd.flag('fix', '_bbone_of_{}'.format(name), 'clear')
         cmd.delete('_bbone_of_{}'.format(name))
def peptide_rebuild(name, selection='all', cycles=1000, state=1, quiet=1):
    '''
DESCRIPTION

    Rebuild the peptide from selection. All atoms which are present in
    selection will be kept fixed, while atoms missing in selection are
    placed by sculpting.

USAGE

    peptide_rebuild name [, selection [, cycles [, state ]]]

SEE ALSO

    stub2ala, add_missing_atoms, peptide_rebuild_modeller
    '''
    from chempy import fragments, feedback, models

    cycles, state, quiet = int(cycles), int(state), int(quiet)

    # suppress feedback for model merging
    feedback['actions'] = False

    # work with named selection
    namedsele = cmd.get_unused_name('_')
    cmd.select(namedsele, selection, 0)

    identifiers = []
    cmd.iterate(namedsele + ' and polymer and guide and alt +A',
            'identifiers.append([segi,chain,resi,resv,resn])', space=locals())

    model = models.Indexed()
    for (segi,chain,resi,resv,resn) in identifiers:
        try:
            fname = resn.lower() if resn != 'MSE' else 'met'
            frag = fragments.get(fname)
        except IOError:
            print(' Warning: unknown residue: ' + resn)
            continue

        for a in frag.atom:
            a.segi = segi
            a.chain = chain
            a.resi = resi
            a.resi_number = resv
            a.resn = resn

        model.merge(frag)

    if not quiet:
        print(' Loading model...')

    cmd.load_model(model, name, 1, zoom=0)
    if cmd.get_setting_boolean('auto_remove_hydrogens'):
        cmd.remove(name + ' and hydro')

    cmd.protect(name + ' in ' + namedsele)
    cmd.sculpt_activate(name)
    cmd.update(name, namedsele, 1, state)
    cmd.delete(namedsele)

    if not quiet:
        print(' Sculpting...')

    cmd.set('sculpt_field_mask', 0x003, name) # bonds and angles only
    cmd.sculpt_iterate(name, 1, int(cycles / 4))

    cmd.set('sculpt_field_mask', 0x09F, name) # local + torsions
    cmd.sculpt_iterate(name, 1, int(cycles / 4))

    cmd.set('sculpt_field_mask', 0x0FF, name) # ... + vdw
    cmd.sculpt_iterate(name, 1, int(cycles / 2))

    cmd.sculpt_deactivate(name)
    cmd.deprotect(name)
    cmd.unset('sculpt_field_mask', name)

    if not quiet:
        print(' Connecting peptide...')

    pairs = cmd.find_pairs(name + ' and name C', name + ' and name N', 1, 1, 2.0)
    for pair in pairs:
        cmd.bond(*pair)
    cmd.h_fix(name)

    if not quiet:
        print(' peptide_rebuild: done')
Exemple #7
0
def peptide_rebuild(name, selection='all', cycles=1000, state=1, quiet=1):
    '''
DESCRIPTION

    Rebuild the peptide from selection. All atoms which are present in
    selection will be kept fixed, while atoms missing in selection are
    placed by sculpting.

USAGE

    peptide_rebuild name [, selection [, cycles [, state ]]]

SEE ALSO

    stub2ala, add_missing_atoms, peptide_rebuild_modeller
    '''
    from chempy import fragments, feedback, models

    cycles, state, quiet = int(cycles), int(state), int(quiet)

    # suppress feedback for model merging
    feedback['actions'] = False

    # work with named selection
    namedsele = cmd.get_unused_name('_')
    cmd.select(namedsele, selection, 0)

    identifiers = []
    cmd.iterate(namedsele + ' and polymer and guide and alt +A',
            'identifiers.append([segi,chain,resi,resv,resn])', space=locals())

    model = models.Indexed()
    for (segi,chain,resi,resv,resn) in identifiers:
        try:
            fname = resn.lower() if resn != 'MSE' else 'met'
            frag = fragments.get(fname)
        except IOError:
            print(' Warning: unknown residue:', resn)
            continue

        for a in frag.atom:
            a.segi = segi
            a.chain = chain
            a.resi = resi
            a.resi_number = resv
            a.resn = resn

        model.merge(frag)

    if not quiet:
        print(' Loading model...')

    cmd.load_model(model, name, 1, zoom=0)
    if cmd.get_setting_boolean('auto_remove_hydrogens'):
        cmd.remove(name + ' and hydro')

    cmd.protect(name + ' in ' + namedsele)
    cmd.sculpt_activate(name)
    cmd.update(name, namedsele, 1, state)
    cmd.delete(namedsele)

    if not quiet:
        print(' Sculpting...')

    cmd.set('sculpt_field_mask', 0x003, name) # bonds and angles only
    cmd.sculpt_iterate(name, 1, int(cycles / 4))

    cmd.set('sculpt_field_mask', 0x09F, name) # local + torsions
    cmd.sculpt_iterate(name, 1, int(cycles / 4))

    cmd.set('sculpt_field_mask', 0x0FF, name) # ... + vdw
    cmd.sculpt_iterate(name, 1, int(cycles / 2))

    cmd.sculpt_deactivate(name)
    cmd.deprotect(name)
    cmd.unset('sculpt_field_mask', name)

    if not quiet:
        print(' Connecting peptide...')

    pairs = cmd.find_pairs(name + ' and name C', name + ' and name N', 1, 1, 2.0)
    for pair in pairs:
        cmd.bond(*pair)
    cmd.h_fix(name)

    if not quiet:
        print(' peptide_rebuild: done')
Exemple #8
0
    cmd.unpick()

    # Set dihedral angles fo new residues to alpha-helix
    for res0 in range(32, 35):
        atom1 = "/MyProtein//" + chn + "/" + str(res0 - 1) + "/C"
        atom2 = "/MyProtein//" + chn + "/" + str(res0) + "/N"
        atom3 = "/MyProtein//" + chn + "/" + str(res0) + "/CA"
        atom4 = "/MyProtein//" + chn + "/" + str(res0) + "/C"
        atom5 = "/MyProtein//" + chn + "/" + str(res0 + 1) + "/N"
        # 	# Set (Phi,Psi) dihedral angles per residue, respectively
        cmd.set_dihedral(atom1, atom2, atom3, atom4, -60)
        cmd.set_dihedral(atom2, atom3, atom4, atom5, -45)

# Remove steric clashes between sidechains
## Select only sidechain of THR-32 to ASN-35
# cmd.select("sidechains", "resi 32:35 and ! bb.")
cmd.select("backbone_range", "resi 32:35 and bb.")

## Protect rest of the protein from modifications by sculpting
# cmd.protect('(not sidechains)')
cmd.protect('(backbone_range)')

## Carry out Sculpting for 7000 cycles
cmd.sculpt_activate('MyProtein')
cmd.sculpt_iterate('MyProtein', cycles=7000)
cmd.sculpt_deactivate('MyProtein')
cmd.deprotect()

# Save sculpted structure into output file
cmd.save(out_protein, "MyProtein")
#target = 'with_seq_final_opt_cwza_L.pdb'
#target = 'bb_cwza_opt.pdb'

cmd.load(mobile, 'MyProtein')
cmd.load(target, 'MyModelBB')

Chains = cmd.get_chains('MyProtein')
for chain in Chains:
    cmd.create('MyChain' + chain, '/MyProtein//' + chain)
    mobile_bb = 'MyChain' + chain
    target_bb = '/MyModelBB//' + chain
    cmd.align(mobile_bb, target_bb)

cmd.delete('MyProtein')
cmd.delete('MyModelBB')
cmd.orient()

cmd.create('MyModel', 'all')

cmd.select('sidechains', 'MyModel')
## Protect rest of the protein from modifications by sculpting
cmd.protect('(not sidechains)')

## Carry out Sculpting for 5000 cycles
cmd.sculpt_activate('MyModel')
cmd.sculpt_iterate('MyModel', cycles=500)
cmd.sculpt_deactivate('MyModel')
cmd.deprotect()

cmd.save(out_pdb, "MyModel")