choderalab/msm-tis — pull request #20 by dwhswenson (2014-10-07 14:39:06+00:00)
Title: OrderParameter wrapper for mdtraj functions

This pull request includes three things:
1. `OP_Function`, a wrapper that turns a generic function of the configuration into an easily used order parameter
2. `tests/` directory, with tests of OP_Function and some duck-punching functions I've needed when writing tests.
3. Reasonable default behavior for `OrderParameter._eval_idx` (instead of no-op)

The last two are pretty self-explanatory, but I'll elaborate a bit on the first:

`OP_Function` allows us to take the various functions from mdtraj (or anything that we write on our own) and make them into simple callable order parameters. Example (used in the test): consider the psi dihedral in Ala dipeptide, defined by atom number 7,9,15, and 17 in my topology. We create an order parameter function with:

import mdtraj as md
psi_atoms = [7,9,15,17]
psi_orderparam = OP_Function("psi", md.compute_dihedrals, trajdatafmt="mdtraj", indices=[psi_atoms])

Then you can create an array of the order parameter for all frames in trajectory `traj` with:

psi_orderparam(traj)

We use mdtraj's `compute_dihedrals` function to do all the real work, and we can just as easily use many other functions that mdtraj provides.