pytraj.c_action.actionlist.
ActionList
(commands=None, Topology top=None, DatasetList dslist=<???>, DataFileList dflist=<???>, crdinfo={})¶Bases: object
Attributes
data |
Store data (CpptrajDatasetList). |
is_setup |
is_setup: ‘bool’ |
n_frames |
n_frames: ‘unsigned int’ |
Methods
add (self[, action, command, top, check_status]) |
Add action to ActionList |
compute (self[, traj]) |
perform a series of Actions on Frame or Trajectory |
post_process (self) |
|
setup (self, Topology top[, crdinfo, n_frames_t]) |
perform Topology checking and some stuff |
add
(self, action='', command='', top=None, DatasetList dslist=<???>, DataFileList dflist=<???>, check_status=False)¶Add action to ActionList
Parameters: | action : str or Action object command : str or ArgList object top : str | Topology | TopologyList dslist : DatasetList dflist : DataFileList check_status : bool, default=False
|
---|
Examples
>>> actlist = ActionList()
>>> actlist.add('radgyr', '@CA', top=traj.top, dslist=dslist)
compute
(self, traj=<???>)¶perform a series of Actions on Frame or Trajectory
data
¶Store data (CpptrajDatasetList). This is for internal use.
is_setup
¶is_setup: ‘bool’
n_frames
¶n_frames: ‘unsigned int’
post_process
(self)¶setup
(self, Topology top, crdinfo={}, n_frames_t=0, bool exit_on_error=True)¶perform Topology checking and some stuff
pytraj.c_action.actionlist.
compute
(lines, traj, *args, **kwd)¶perorm a series of cpptraj’s actions on trajectory
Parameters: | lines : {str, list of string} traj : Trajectory-like process : {None, int}, default None
*args, **kwd : more arguments |
---|
Examples
>>> import pytraj as pt
>>> traj = pt.datafiles.load_tz2()
>>> # cpptraj command style
>>> data = pt.compute('''
... rms
... radgyr
... molsurf
... ''', traj)
>>> # a list of commands
>>> data = pt.compute([
... 'rms',
... 'radgyr',
... 'molsurf',], traj)
>>> # a list of commands with reference
>>> # need to explicitly add ``reference`` keyword and specify `ref=`
>>> # calculate rms and use traj[3] as reference
>>> data = pt.compute([
... 'rms myrms reference @CA',
... 'radgyr myrg @CA nomax',
... 'molsurf',], traj, ref=traj[3])
>>> data['myrms']
array([ 3.46476336, 3.4343108 , 2.94523273, ..., 4.21848857,
4.4566457 , 3.94477017])
>>> data['myrms'][3]
0.0
>>> # a list of commands with reference
>>> # can also specify 'refindex'
>>> # calculate rms and use traj[3] as reference
>>> data = pt.compute([
... 'rms myrms refindex 0 @CA',
... 'radgyr myrg @CA nomax',
... 'molsurf',], traj, ref=traj[3])
>>> data['myrms']
array([ 3.46476336, 3.4343108 , 2.94523273, ..., 4.21848857,
4.4566457 , 3.94477017])
>>> data['myrms'][3]
0.0
pytraj.c_action.actionlist.
pipe
(traj, commands, DatasetList dslist=<???>, frame_indices=None)¶create frame iterator from cpptraj’s commands.
This method is useful if you want cpptraj pre-processing your Trajectory before throwing it to your own method.
Parameters: | commands : a list of strings of cpptraj’s Action commands traj : Trajectory or any iterable that produces Frame dslist : CpptrajDatasetList, optional |
---|
Examples
>>> import pytraj as pt
>>> traj = pt.datafiles.load_tz2_ortho()
>>> for frame in pt.pipe(traj, ['autoimage', 'rms', 'center :1']): pass
Above example is similiar to cpptraj’s command:
cpptraj -i EOF<<
parm tz2.ortho.parm
trajin tz2.ortho.nc
autoimage
rms
center :1
EOF
You can design your own method:
def new_method(traj, ...):
for frame in traj:
do_some_thing_fun_with(frame)
fi = pt.pipe(traj, ['autoimage', 'rms', 'center :1'])
# perform action with pre-processed frames (already autoimaged, then rms fit to
# 1st frame, then center at box center.
data = new_method(fi, ...)