Difference between revisions of "Alter"

From PyMOLWiki
Jump to navigation Jump to search
 
(redirect iterate)
 
(21 intermediate revisions by 6 users not shown)
Line 1: Line 1:
===DESCRIPTION===
+
#REDIRECT [[iterate]]
+
 
"alter" changes one or more atomic properties over a selection
+
'''alter''' changes one or more atomic properties over a selection using the python evaluator with a separate name space for each atom.  The symbols defined in the name space, which are are explained in [[Iterate]] are:
using the python evaluator with a separate name space for each
+
  name, resn, resi, chain, alt, elem, q, b, segi,
atom.  The symbols defined in the name space are:
+
type (ATOM,HETATM), partial_charge, formal_charge,
   
+
text_type, numeric_type, ID, vdw
  name, resn, resi, chain, alt, elem, q, b, segi,
+
 
  type (ATOM,HETATM), partial_charge, formal_charge,
+
All strings must be explicitly quoted.  This operation typically takes several seconds per thousand atoms altered.
  text_type, numeric_type, ID
+
 
+
'''WARNING''': You should always issue a '''sort''' command on an object
All strings must be explicitly quoted.  This operation typically
 
takes several seconds per thousand atoms altered.
 
 
WARNING: You should always issue a "sort" command on an object
 
 
after modifying any property which might affect canonical atom
 
after modifying any property which might affect canonical atom
 
ordering (names, chains, etc.).  Failure to do so will confound
 
ordering (names, chains, etc.).  Failure to do so will confound
 
subsequent "create" and "byres" operations.
 
subsequent "create" and "byres" operations.
+
 
 
===USAGE===
 
===USAGE===
 
  alter (selection),expression
 
  alter (selection),expression
+
 
 
===EXAMPLES===
 
===EXAMPLES===
  alter (chain A),chain='B'
+
 
  alter (all),resi=str(int(resi)+100)
+
====Change chain label and residue index====
  sort
+
<source lang="python">
   
+
alter (chain A),chain='B'
 +
alter (all),resi=str(int(resi)+100)
 +
sort
 +
</source>
 +
 
 +
====Change van der Waals radius of a given atom====
 +
<source lang="python">
 +
alter (name P), vdw=1.90
 +
</source>
 +
Note that is if dots, spheres, mesh or surface representation is used. You have to refresh the view with
 +
<source lang="python">
 +
rebuild
 +
</source>
 +
 
 +
====Renumber the amino acids in a protein, so that it starts from 0 instead of its offset as defined in the structure file====
 +
<source lang="python">
 +
# The first residue in the structure file for 1cll is 4. To change this to 0, maybe to match scripts
 +
# outputted from other programs, just remove the offset of 4 from each atom
 +
alter 1cll, resi=str(int(resi)-4)
 +
# refresh (turn on seq_view to see what this command does).
 +
sort
 +
</source>
 +
 
 +
====Change the b values of all atoms to the distance of the atoms to a reference point====
 +
<source lang="python">
 +
# reference point
 +
x0,y0,z0=[1,2,3] 
 +
# calculate distance values between the reference point and all the atoms
 +
alldist = []
 +
iterate_state 1, yourstruc, alldist.append(((x-x0)**2.0+(y-y0)**2.0+(z-z0)**2.0)**0.5)
 +
# assign distance values to b-factors
 +
di = iter(alldist)
 +
alter yourstruc, b=di.next()
 +
# visualize the distances
 +
spectrum b, rainbow, yourstruc
 +
</source>
 +
 
 +
====Copy (transfer) the color from one object to another====
 +
<source lang="python">
 +
stored.colors = {}
 +
iterate obj1, stored.colors[chain,resi,name] = color
 +
alter obj2, color = stored.colors.get((chain,resi,name), color)
 +
recolor
 +
</source>
 +
 
 +
=== PYMOL API ===
 +
 
 +
<source lang="python">
 +
cmd.alter(string selection, string expression, int quiet=1, dict space=None)
 +
</source>
 +
 
 +
As explained before, all strings must be explicitly quoted. For example to change all HETATM records to ATOM you should do:
 +
 
 +
<source lang="python">
 +
cmd.alter('all', 'type="ATOM"')
 +
</source>
 +
 
 
===SEE ALSO===
 
===SEE ALSO===
  [[Cmd alter_state]], [[Cmd iterate]], [[Cmd iterate_state]], [[Cmd sort ]]
+
[[Alter_State]], [[iterate]], [[Iterate_State]], [[sort]]
  
[[Category:Commands|alter]]
+
[[Category:Commands|Alter]]

Latest revision as of 17:01, 23 December 2015

Redirect to:

alter changes one or more atomic properties over a selection using the python evaluator with a separate name space for each atom. The symbols defined in the name space, which are are explained in Iterate are:

name, resn, resi, chain, alt, elem, q, b, segi,
type (ATOM,HETATM), partial_charge, formal_charge,
text_type, numeric_type, ID, vdw

All strings must be explicitly quoted. This operation typically takes several seconds per thousand atoms altered.

WARNING: You should always issue a sort command on an object after modifying any property which might affect canonical atom ordering (names, chains, etc.). Failure to do so will confound subsequent "create" and "byres" operations.

USAGE

alter (selection),expression

EXAMPLES

Change chain label and residue index

 alter (chain A),chain='B'
 alter (all),resi=str(int(resi)+100)
 sort

Change van der Waals radius of a given atom

alter (name P), vdw=1.90

Note that is if dots, spheres, mesh or surface representation is used. You have to refresh the view with

rebuild

Renumber the amino acids in a protein, so that it starts from 0 instead of its offset as defined in the structure file

# The first residue in the structure file for 1cll is 4.  To change this to 0, maybe to match scripts
# outputted from other programs, just remove the offset of 4 from each atom
alter 1cll, resi=str(int(resi)-4)
# refresh (turn on seq_view to see what this command does).
sort

Change the b values of all atoms to the distance of the atoms to a reference point

# reference point
x0,y0,z0=[1,2,3]  
# calculate distance values between the reference point and all the atoms
alldist = []
iterate_state 1, yourstruc, alldist.append(((x-x0)**2.0+(y-y0)**2.0+(z-z0)**2.0)**0.5)
# assign distance values to b-factors 
di = iter(alldist)
alter yourstruc, b=di.next()
# visualize the distances
spectrum b, rainbow, yourstruc

Copy (transfer) the color from one object to another

stored.colors = {}
iterate obj1, stored.colors[chain,resi,name] = color
alter obj2, color = stored.colors.get((chain,resi,name), color)
recolor

PYMOL API

cmd.alter(string selection, string expression, int quiet=1, dict space=None)

As explained before, all strings must be explicitly quoted. For example to change all HETATM records to ATOM you should do:

cmd.alter('all', 'type="ATOM"')

SEE ALSO

Alter_State, iterate, Iterate_State, sort