Amber-MD / cpptraj

Biomolecular simulation trajectory/data analysis.
Other
137 stars 64 forks source link

wrapping Trajin or DataSet_Coord_TRJ #12

Closed hainm closed 9 years ago

hainm commented 9 years ago

Dan,

pytraj used Trajin class in cpptraj for its TrajectoryIterator. Now I have time to look closer at DataSet_Coord_TRJ and find it more interesting.

traj = DataSet_Coords_TRJ()
traj.top = io.load("./myparm.top)
traj.load(a_list_of_file_names)

What do you think about using DataSet_Coord_TRJ for TrajectoryIterator? any technical issue I should expect if I implement?

Hai

hainm commented 9 years ago

one of the things I am concerning is I don't know how DataSet_Coords_TRJ control opening/closing file.

Looking at GetFrame code here https://github.com/hainm/cpptraj/blob/master/src/DataSet_Coords_TRJ.cpp#L87, it's likely that file is opened and closed every time the method is called?

Hai

hainm commented 9 years ago

by the way, the more I am reading cpptraj's code, the more I find it interesting and convenient. There are many features the end-users don't need to care about but would be great help for pytraj.

for example with DataSet_Coords_TRJ, I can create a single TrajectoryIterator from a list of many trajectory file names. https://github.com/hainm/pytraj/blob/dataset_trj/tests/test_DataSet_Coords_TRJ.py#L69

and if I need to load all frames into memory, just do this

from pytraj import Trajectory # in-memory Trajectory
traj = Trajectory(traj_iterator) # load from `DataSet_Coords_TRJ`
drroe commented 9 years ago

Hi,

No, a trajectory is only opened as needed, i.e. when the frame you are asking for does not fall within that trajectory's range. For example, if the first trajectory is 10 frames and I ask for frames 2, 5, 7, and 11, the first traj is opened on 2 (but not 5 and 7), then closed and the second traj is opened for 11. Make sense?

On Fri, Jun 5, 2015 at 10:41 AM, Hai Nguyen notifications@github.com wrote:

one of the things I am concerning is I don't know how DataSet_Coords_TRJ control opening/closing file.

Looking at GetFrame code here https://github.com/hainm/cpptraj/blob/master/src/DataSet_Coords_TRJ.cpp#L87, it's likely that file is opened and closed every time the method is called?

Hai

— Reply to this email directly or view it on GitHub https://github.com/mojyt/cpptraj/issues/12#issuecomment-109357842.


Daniel R. Roe, PhD Department of Medicinal Chemistry University of Utah 30 South 2000 East, Room 307 Salt Lake City, UT 84112-5820 http://home.chpc.utah.edu/~cheatham/ (801) 587-9652 (801) 585-6208 (Fax)

drroe commented 9 years ago

Yeah, this is why I need to be a bit more diligent about creating tutorials, which in my opinion are probably the best way to inform users about new features...(why the hell do we bother with manuals...)

On Fri, Jun 5, 2015 at 11:48 AM, Hai Nguyen notifications@github.com wrote:

by the way, the more I am reading cpptraj's code, the more I find it interesting and convenient. There are many features the end-users don't need to care about but would be great help for pytraj.

for example with DataSet_Coords_TRJ, I can create a single TrajectoryIterator from a list of many trajectory file names. https://github.com/hainm/pytraj/blob/1657e78e58332251107a4eecf352d9d718393b4b/tests/test_DataSet_Coords_TRJ.py#L69

— Reply to this email directly or view it on GitHub https://github.com/mojyt/cpptraj/issues/12#issuecomment-109377516.


Daniel R. Roe, PhD Department of Medicinal Chemistry University of Utah 30 South 2000 East, Room 307 Salt Lake City, UT 84112-5820 http://home.chpc.utah.edu/~cheatham/ (801) 587-9652 (801) 585-6208 (Fax)

hainm commented 9 years ago

Great. Make sense to me. I asked this because pytraj currently wraps Trajin_Single for TraectoryIterator. Whenever getting a Frame, pytraj need to explicitly open (call BeginTraj or something like that). With Dataset TRJ, it seems that cpptraj takes care of this. If you dont have plan to retire this dataset TRJ, i will go ahead to use it instead of using Train_single.

What do think?

Hai

On Jun 5, 2015, at 4:13 PM, Daniel R. Roe notifications@github.com wrote:

Hi,

No, a trajectory is only opened as needed, i.e. when the frame you are asking for does not fall within that trajectory's range. For example, if the first trajectory is 10 frames and I ask for frames 2, 5, 7, and 11, the first traj is opened on 2 (but not 5 and 7), then closed and the second traj is opened for 11. Make sense?

On Fri, Jun 5, 2015 at 10:41 AM, Hai Nguyen notifications@github.com wrote:

one of the things I am concerning is I don't know how DataSet_Coords_TRJ control opening/closing file.

Looking at GetFrame code here https://github.com/hainm/cpptraj/blob/master/src/DataSet_Coords_TRJ.cpp#L87, it's likely that file is opened and closed every time the method is called?

Hai

— Reply to this email directly or view it on GitHub https://github.com/mojyt/cpptraj/issues/12#issuecomment-109357842.


Daniel R. Roe, PhD Department of Medicinal Chemistry University of Utah 30 South 2000 East, Room 307 Salt Lake City, UT 84112-5820 http://home.chpc.utah.edu/~cheatham/ (801) 587-9652 (801) 585-6208 (Fax) — Reply to this email directly or view it on GitHub.

hainm commented 9 years ago

I strongly agree focusing on tutorials and examples. Manual is just manual, which is incredible hard to follow.

It's great that user can copy and paste and reproduce expected output.

PS: like in Amber mailinglist, not so many pp know about multidihedral, which is super cool.

Hai

On Jun 5, 2015, at 4:14 PM, Daniel R. Roe notifications@github.com wrote:

Yeah, this is why I need to be a bit more diligent about creating tutorials, which in my opinion are probably the best way to inform users about new features...(why the hell do we bother with manuals...)

On Fri, Jun 5, 2015 at 11:48 AM, Hai Nguyen notifications@github.com wrote:

by the way, the more I am reading cpptraj's code, the more I find it interesting and convenient. There are many features the end-users don't need to care about but would be great help for pytraj.

for example with DataSet_Coords_TRJ, I can create a single TrajectoryIterator from a list of many trajectory file names. https://github.com/hainm/pytraj/blob/1657e78e58332251107a4eecf352d9d718393b4b/tests/test_DataSet_Coords_TRJ.py#L69

— Reply to this email directly or view it on GitHub https://github.com/mojyt/cpptraj/issues/12#issuecomment-109377516.


Daniel R. Roe, PhD Department of Medicinal Chemistry University of Utah 30 South 2000 East, Room 307 Salt Lake City, UT 84112-5820 http://home.chpc.utah.edu/~cheatham/ (801) 587-9652 (801) 585-6208 (Fax) — Reply to this email directly or view it on GitHub.