Sidechaincenters: Difference between revisions

From PyMOLWiki
Jump to navigation Jump to search
(created)
 
(2to3, psico)
 
(8 intermediate revisions by 3 users not shown)
Line 1: Line 1:
[[File:SidechaincentersExample.png|400px|thumb|right|sidechain centers]]
{{Infobox psico
|module    =  psico.creating
}}
Pseudo single-atom representation of sidechains. Usefull for [[AAindex|pair potential calculation]] for example.
Pseudo single-atom representation of sidechains. Usefull for [[AAindex|pair potential calculation]] for example.


Line 5: Line 11:
<source lang="python">
<source lang="python">
fetch 2x19
fetch 2x19
pseudo_sidechaincenters scc, 2x19
sidechaincenters scc, 2x19
</source>
</source>


Line 42: Line 48:
}
}


def pseudo_sidechaincenters(object='scc', selection='all', name='PS1', method='bahar1996'):
def sidechaincenters(object='scc', selection='all', name='PS1', method='bahar1996'):
     '''
     '''
DESCRIPTION
DESCRIPTION
Line 54: Line 60:
USAGE
USAGE


     pseudo_sidechaincenters object [, selection]
     sidechaincenters object [, selection]


ARGUMENTS
ARGUMENTS
Line 66: Line 72:
SEE ALSO
SEE ALSO


     pseudo_sidechaincentroids, pseudoatom
     sidechaincentroids, pseudoatom
     '''
     '''
     atmap = dict()
     atmap = dict()
Line 79: Line 85:
             atmap.setdefault((at.segi, at.chain, at.resn, at.resi), []).append(at)
             atmap.setdefault((at.segi, at.chain, at.resn, at.resi), []).append(at)
     else:
     else:
         print 'Error: unknown method'
         print('Error: unknown method:', method)
         return
         return


     model = models.Indexed()
     model = models.Indexed()
     for centeratoms in atmap.itervalues():
     for centeratoms in atmap.values():
         center = cpv.get_null()
         center = cpv.get_null()
         for at in centeratoms:
         for at in centeratoms:
Line 93: Line 99:
         atom.name = name
         atom.name = name
         for key in ['resn','chain','resi','resi_number','hetatm','ss','segi']:
         for key in ['resn','chain','resi','resi_number','hetatm','ss','segi']:
             atom.__dict__[key] = at.__dict__[key]
             setattr(atom, key, getattr(at, key))
         model.add_atom(atom)
         model.add_atom(atom)
     model.update_index()
     model.update_index()
Line 101: Line 107:
     return model
     return model


def pseudo_sidechaincentroids(object='scc', selection='all', name='PS1'):
def sidechaincentroids(object='scc', selection='all', name='PS1'):
     '''
     '''
DESCRIPTION
DESCRIPTION


     Sidechain centroids. Works like "pseudo_sidechaincenters", but the
     Sidechain centroids. Works like "sidechaincenters", but the
     pseudoatom is the centroid of all atoms except hydrogens and backbone atoms
     pseudoatom is the centroid of all atoms except hydrogens and backbone atoms
     (N, C and O).
     (N, C and O).
Line 114: Line 120:
     like in this example:
     like in this example:


     pseudo_sidechaincentroids newobject, all and (not name CA or resn GLY)
     sidechaincentroids newobject, all and (not name CA or resn GLY)


SEE ALSO
SEE ALSO


     pseudo_sidechaincenters
     sidechaincenters
     '''
     '''
     return pseudo_sidechaincenters(object, selection, name, method='centroids')
     return sidechaincenters(object, selection, name, method='centroid')


cmd.extend('pseudo_sidechaincenters', pseudo_sidechaincenters)
cmd.extend('sidechaincenters', sidechaincenters)
cmd.extend('pseudo_sidechaincentroids', pseudo_sidechaincentroids)
cmd.extend('sidechaincentroids', sidechaincentroids)
 
cmd.auto_arg[1].update({
    'sidechaincenters'    : [ cmd.selection_sc          , 'selection'      , ''  ],
    'sidechaincentroids'  : [ cmd.selection_sc          , 'selection'      , ''  ],
})


# vi: ts=4:sw=4:smarttab:expandtab
# vi: ts=4:sw=4:smarttab:expandtab
</script>
</source>
 
[[Category:Script_Library]]
[[Category:Structural_Biology_Scripts]]

Latest revision as of 16:17, 7 December 2021

sidechain centers

Included in psico
This command or function is available from psico, which is a PyMOL extension.

Module psico.creating

Pseudo single-atom representation of sidechains. Usefull for pair potential calculation for example.

Example

fetch 2x19
sidechaincenters scc, 2x19

The Script

'''
(c) 2010 Thomas Holder
'''

from pymol import cmd
from chempy import Atom, cpv, models

sidechaincenteratoms = {
    'GLY': ('CA',),
    'ALA': ('CB',),
    'VAL': ('CG1', 'CG2'),
    'ILE': ('CD1',),
    'LEU': ('CD1', 'CD2'),
    'SER': ('OG',),
    'THR': ('OG1', 'CG2'),
    'ASP': ('OD1', 'OD2'),
    'ASN': ('OD1', 'ND2'),
    'GLU': ('OE1', 'OE2'),
    'GLN': ('OE1', 'NE2'),
    'LYS': ('NZ',),
    'ARG': ('NE', 'NH1', 'NH2'),
    'CYS': ('SG',),
    'MET': ('SD',),
    'MSE': ('SE',),
    'PHE': ('CG', 'CD1', 'CD2', 'CE1', 'CE2', 'CZ'),
    'TYR': ('CG', 'CD1', 'CD2', 'CE1', 'CE2', 'CZ', 'OH'),
    'TRP': ('CG', 'CD1', 'CD2', 'NE1', 'CE2', 'CE3', 'CZ2', 'CZ3'),
    'HIS': ('CG', 'ND1', 'CD2', 'CE1', 'NE2'),
    'PRO': ('CB', 'CG', 'CD'),
}

def sidechaincenters(object='scc', selection='all', name='PS1', method='bahar1996'):
    '''
DESCRIPTION

    Creates an object with sidechain representing pseudoatoms for each residue
    in selection.

    Sidechain interaction centers as defined by Bahar and Jernigan 1996
    http://www.ncbi.nlm.nih.gov/pubmed/9080182

USAGE

    sidechaincenters object [, selection]

ARGUMENTS

    object = string: name of object to create

    selection = string: atoms to consider {default: (all)}

    name = string: atom name of pseudoatoms {default: PS1}

SEE ALSO

    sidechaincentroids, pseudoatom
    '''
    atmap = dict()
    if method == 'bahar1996':
        modelAll = cmd.get_model('(%s) and resn %s' % (selection, '+'.join(sidechaincenteratoms)))
        for at in modelAll.atom:
            if at.name in sidechaincenteratoms[at.resn]:
                atmap.setdefault((at.segi, at.chain, at.resn, at.resi), []).append(at)
    elif method == 'centroid':
        modelAll = cmd.get_model('(%s) and not (hydro or name C+N+O)' % selection)
        for at in modelAll.atom:
            atmap.setdefault((at.segi, at.chain, at.resn, at.resi), []).append(at)
    else:
        print('Error: unknown method:', method)
        return

    model = models.Indexed()
    for centeratoms in atmap.values():
        center = cpv.get_null()
        for at in centeratoms:
            center = cpv.add(center, at.coord)
        center = cpv.scale(center, 1./len(centeratoms))
        atom = Atom()
        atom.coord = center
        atom.index = model.nAtom + 1
        atom.name = name
        for key in ['resn','chain','resi','resi_number','hetatm','ss','segi']:
            setattr(atom, key, getattr(at, key))
        model.add_atom(atom)
    model.update_index()
    if object in cmd.get_object_list():
        cmd.delete(object)
    cmd.load_model(model, object)
    return model

def sidechaincentroids(object='scc', selection='all', name='PS1'):
    '''
DESCRIPTION

    Sidechain centroids. Works like "sidechaincenters", but the
    pseudoatom is the centroid of all atoms except hydrogens and backbone atoms
    (N, C and O).

NOTE

    If you want to exclude C-alpha atoms from sidechains, modify the selection
    like in this example:

    sidechaincentroids newobject, all and (not name CA or resn GLY)

SEE ALSO

    sidechaincenters
    '''
    return sidechaincenters(object, selection, name, method='centroid')

cmd.extend('sidechaincenters', sidechaincenters)
cmd.extend('sidechaincentroids', sidechaincentroids)

cmd.auto_arg[1].update({
    'sidechaincenters'     : [ cmd.selection_sc           , 'selection'       , ''   ],
    'sidechaincentroids'   : [ cmd.selection_sc           , 'selection'       , ''   ],
})

# vi: ts=4:sw=4:smarttab:expandtab