- atomsel(selection, molid = top, frame = now):
Creates a new atom selection object.
sel = atomsel('name CA') # Selects the alpha carbons of the top molecule at the current active frame.
- get(attribute):
Get an attribute from an existing atomsel object.
sel.get("beta") # Returns a list containing the beta value for the selected atoms.
- set(attribute, value):
Set an attribute for an existing atomsel object, using either a single value, or a sequence of values with a length equal to the number of atoms in the selection.
sel.set("beta", 1) # Set the beta for all atoms in the atomsel object to 1.
- frame:
Change or access the frame. Note that this does not update the selected atoms within this selection object.
>>> sel.frame = 0 # Set the frame references by the selection to the first frame.
>>> print sel.frame # Access the current frame referenced by the selection object.
- update():
Updates the selected atoms within the selection, such as in response to changing the frame.
>>> sel = atomsel("within 3 of resid 1")
>>> for f in range(molecule.numframes()):
>>> sel.frame = f
>>> sel.update()
>>> print sel.center()
- write(filetype, filename):
Writes the atoms selected to a file, using an explicit file type.
>>> sel.write("pdb", "correctpdb.pdb") # This will write a pdb.
>>> sel.write("namdbin", "notapdb.pdb") # This will write a namd binary
>>> #coordinate file, not a pdb like the extension might suggest.
>>> sel.write("psf", "correctpsf.psf") # You can also write a psf!
- bonds():
Get the bonds that are only within the selection, returned as a list of lists.
#Print all bonds within a selection.
idxs = sel.get("index")
bonds = sel.bonds()
for bidx in range(len(bonds)):
for b in bonds[bidx]:
# These are the atoms that are bonded together.
print idxs[bidx], b
- minmax():
Get bounding values for the selection.
mintup, maxtup = sel.minmax()
- center(weight=None):
Get center of the selection, optionally weighted by the given weight.
- centerperresidue(weight=None):
Return a list where each element has a 3-list corresponding to the center of each residue in the selection.
- rmsf(first=0, last=-1, step=1):
Get root mean square fluctuation over the loaded trajectory from the first to last frames, keeping every step'th frame.
- rmsfperresidue(weight=None):
Measures the RMSF along a trajectory per residue, returning a list with one element per residue in the selection.
- rmsd(ref, weight=None):
Measures the RMSD of a selection relative to a reference selection. Requires alignment with fit.
- rmsdQCP(ref, weight=None):
Measures the RMSD of a selection relative to a reference selection after optimal rotation. Does not require alignment.
- rmsdperresidue(ref, weight=None):
Measures the RMSD of a selection relative to a reference selection. Requires alignment with fit, and returns a list with one measurement per residue within the selection.
- fit(ref, weight=None):
Compute and return the transformation matrix for the RMS alignment
of the selection to sel. The format of the matrix is a 16-element
tuple suitable for passing to the move() method
(Column major/fortran ordering).
import numpy as np
ref = atomsel("name CA", frame=0)
sel = atomsel("name CA")
fitmatrix = np.asarray(sel.fit(ref), order='F')
fitmatrix.shape = (4,4)
#Only when the fitmatrix uses fortran ordering does it look correct.
print fitmatrix
#The QCP variant does not need prior alignment to correctly compute the RMSD.
print sel.rmsdQCP(ref)
print sel.rmsd(ref)
sel.move(sel.fit(ref))
#The typical RMSD calculation needs to be aligned first.
print sel.rmsd(ref)
- rgyr(weight=None):
Returns the radius of gyration of the selection.
rval = sel.rgyr()
- move(matrix):
Moves the selection by multiplying the coordinates by the 16-element transformation matrix provided.
- moveby(vec):
Moves the selection by the vector.
- contacts(sel, cutoff):
Return two lists, whose corresponding elements contain atom indices
in selection that are within cutoff of sel, but not directly bonded.
- hbond(cutoff, maxangle):
Return three lists, whose corresponding elements contain atom indices
in selection that form a hydrogen bond (acceptor, donor, and proton).
- sasa(srad, samples=500, points=None, restrict=None):
Returns solvent accessible surface area of the restrict selection if given.
Otherwise, returns the solvent accessible surface area of the whole selection.
- mdffsim(res=10, spacing=computed):
Computes a density map with a given resolution and spacing, analogous to the mdffsim command in Tcl.
This procedure returns a list with 4 elements.
1.) A 1-D list of the values at each point.
2.) 3 elements describing the x, y, z lengths.
3.) 3 elements describing the position of the origin.
4.) 9 elements describing the deltas for each axis (x, y, and z).
Example useage for export to numpy:
data, shape, origin, delta = asel.mdffsim(10,3)
data = np.array(data)
shape = np.array(shape)
data = data.reshape(shape, order='F')
delta = np.array(delta).reshape(3,3)
delta /= shape-1;
- mdffcc(volid, res=10, spacing=computed):
Computes the crosscorrelation coefficient between a given volumetric map (volid), and a synthetic map computed from the selection.
- len():
Returns the number of atoms in the selection.