def __init__(self, **keywords): """Create the atomslice object. The creation method can accept the following keyword arguments: cord= -- set where to get our coordinates. atoms= -- Should be a list of atoms to align by. If both of these keywords are given, the .init() method will be called for you. Both of these keywords are optional, if they are not given, you must use the .setcord() and .setatoms() methods to set this information. """ # Set cord with the normal method if it was passed. Set atoms if # atomlist was passed. init() if both were passed. mp3log.debug("Initilizing CordAtomSlice instance.") keywords.has_key("atomlist") or mp3log.warn( "Not initializing CordAtomSlice with an atomlist.") keywords.has_key("cord") or mp3log.warn( "Not initializing CordAtomSlice with an cord.") if keywords.has_key("cord"): self.setcord(keywords["cord"]) if keywords.has_key("atomlist"): self.setatomlist(keywords["atomlist"]) if keywords.has_key("cord") and keywords.has_key("atoms"): #self.init() pass
def setatomlist(self, atomlist): """Set which atoms to pass through. The argument to this function is a list of atoms which will be passed through the slicer. There is no default to use all atoms, since if that was likely, then this wrapper wouldn't be used, would it ? """ mp3log.debug("We have %s atoms passed through."%len(atomlist)) self.atomlist = atomlist self._natoms = len(atomlist)
#Use only a subset of atoms in a DCD object. # #This module defines a class that will extract a (constant) subset of #atoms from a DCD object, and only pass those atoms on. # import numpy import mp3.cord from mp3.log import mp3log mp3log.debug("loading cordatomslice.py") class CordAtomSlice(mp3.cord.Cord): """Use only a subset of atoms in a cord object. Example usage: (protein with solvent) -> (just the protein) >>> C = mp3.CordDCD("my.dcd") >>> C.nframes() 1000 >>> C.natoms() 100000 >>> C_sliced = mp3.CordAtomSlice(cord=C, atomlist=range(3000)) # the first 3000 atoms are the protein >>> C_sliced.nframes() 1000 >>> C_sliced.natoms() 3000