msmbuilder / msmbuilder-legacy

Legacy release of MSMBuilder
http://msmbuilder.org
GNU General Public License v2.0
25 stars 28 forks source link

Misshapen arrays in SaveStructures.py #188

Closed smileyujun closed 11 years ago

smileyujun commented 11 years ago

First,I provide my info about my project: 1, it is a protein 2, there are 134 amino acids and 2184 atoms in my PDB file

my problem is the following:

[root@localhost hil-21-2p2-2-MSM]# SaveStructures.py
--------------------------------------------------------------------------------
MSMBuilder version 2.6.0.dev-Unknown

See file AUTHORS for a list of MSMBuilder contributors.

--------------------------------------------------------------------------------
Copyright 2011 Stanford University.

MSMBuilder comes with ABSOLUTELY NO WARRANTY.

MSMBuilder is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.

--------------------------------------------------------------------------------
Please cite the following references:

GR Bowman, X Huang, and VS Pande. Methods 2009. Using generalized ensemble
simulations and Markov state models to identify conformational states.

KA Beauchamp, GR Bowman, TJ Lane, L Maibaum, IS Haque, VS Pande.  JCTC 2011.
MSMBuilder2: Modeling Conformational Dynamics
at the Picosecond to Millisecond Timescale

IS Haque, KA Beauchamp, VS Pande.  In preparation.
A Fast 3 x N Matrix Multiply Routine for Calculation of Protein RMSD.

--------------------------------------------------------------------------------{'assignments': 'Data/Assignments.Fixed.h5',
 'conformations_per_state': 5,
 'format': 'pdb',
 'output_dir': 'PDBs',
 'project': 'ProjectInfo.yaml',
 'quiet': False,
 'replacement': True,
 'states': [-1],
 'style': 'sep'}
09:31:35 - Yanking from all 63 states
09:32:18 - Creating directory PDBs
09:32:18 - Saving file: PDBs/State0-0.pdb
Traceback (most recent call last):
  File "/usr/local/bin/SaveStructures.py", line 5, in <module>
    pkg_resources.run_script('msmbuilder==2.6.0', 'SaveStructures.py')
  File "/usr/local/lib/python2.7/site-packages/distribute-0.6.36-py2.7.egg/pkg_resources.py", line 505, in run_script
    self.require(requires)[0].run_script(script_name, ns)
  File "/usr/local/lib/python2.7/site-packages/distribute-0.6.36-py2.7.egg/pkg_resources.py", line 1245, in run_script
    execfile(script_filename, namespace, namespace)
  File "/usr/local/lib/python2.7/site-packages/msmbuilder-2.6.0-py2.7-linux-i686.egg/EGG-INFO/scripts/SaveStructures.py", line 122, in <module>
    main()
  File "/usr/local/lib/python2.7/site-packages/msmbuilder-2.6.0-py2.7-linux-i686.egg/EGG-INFO/scripts/SaveStructures.py", line 119, in main
    format=args.format, outdir=args.output_dir)
  File "/usr/local/lib/python2.7/site-packages/msmbuilder-2.6.0-py2.7-linux-i686.egg/EGG-INFO/scripts/SaveStructures.py", line 25, in save
    trj[j].save(fn)
  File "/usr/local/lib/python2.7/site-packages/msmbuilder-2.6.0-py2.7-linux-i686.egg/msmbuilder/Trajectory.py", line 299, in save
    self.save_to_pdb(Filename)
  File "/usr/local/lib/python2.7/site-packages/msmbuilder-2.6.0-py2.7-linux-i686.egg/msmbuilder/Trajectory.py", line 250, in save_to_pdb
    PDB.WritePDBConformation(Filename, self["AtomID"], self["AtomNames"], self["ResidueNames"], self["ResidueID"], self["XYZList"][i], self["ChainID"])
  File "/usr/local/lib/python2.7/site-packages/msmbuilder-2.6.0-py2.7-linux-i686.egg/msmbuilder/PDB.py", line 2602, in WritePDBConformation
    x=10*XYZ[i][0]
IndexError: index 22 is out of bounds for axis 0 with size 22
[root@localhost hil-21-2p2-2-MSM]#

I dont know where my fault is, and how do i know how many atoms in the trajectories? which file i need look at for it?

kyleabeauchamp commented 11 years ago

So I'm not sure what's going on here. I think the first step towards debugging is opening up a trajectory in an interactive python session. Run ipython --pylab and then enter the following:

>>> from msmbuilder import Trajectory
>>> traj = Trajectory.load_from_lhdf("./Trajectories/trj0.lh5")
>>> traj["XYZList"].shape

>>> traj["XYZList"] = traj["XYZList"][0:5]
>>> traj.save_to_pdb("./test_output.pdb")

This will load a trajectory from your project, check its shape (tell us the shape that you see), grab the first five frames, and save to a PDB. I just want to make sure your trajectories are OK.

smileyujun commented 11 years ago

Thank you very much for your reply.

Then ,how can i open up a trajectory in an interactive python session?What command i need to type in an interactive python session? I'm sorry that i am a beginner ,but i'm interested in it.Hope get your reply,thanks.

yours sincerely

yujun

At 2013-05-07 02:54:08,kyleabeauchamp notifications@github.com wrote:

So I'm not sure what's going on here. I think the first step towards debugging is opening up a trajectory in an interactive python session. Run ipython --pylab and then enter the following:

from msmbuilder import Trajectory traj = Trajectory.load_from_lhdf("./Trajectories/trj0.lh5") traj["XYZList"].shape

traj["XYZList"] = traj["XYZList"][0:5] traj.save_to_pdb("./test_output.pdb")

This will load a trajectory from your project, check its shape (tell us the shape that you see), grab the first five frames, and save to a PDB. I just want to make sure your trajectories are OK.

— Reply to this email directly or view it on GitHub.

rmcgibbo commented 11 years ago
  1. If you don't already have it, download and install ipython
    • On ubuntu/debian, this can be done with sudo apt-get install ipython
    • If you'd prefer to download and install from source, use the instructions here http://ipython.org/install.html
  2. On the command line, run ipython --pylab
  3. Enter the commands that @kyleabeauchamp typed above.

good luck!

smileyujun commented 11 years ago

This is the outcome:

[root@localhost 2oqp4-msm]# ipython --pylab
Python 2.7.3 (default, Mar 27 2013, 10:49:52)
Type "copyright", "credits" or "license" for more information.

IPython 0.13.1 -- An enhanced Interactive Python.
?         -> Introduction and overview of IPython's features.
%quickref -> Quick reference.
help      -> Python's own help system.
object?   -> Details about 'object', use 'object??' for extra details.
Welcome to pylab, a matplotlib-based Python environment [backend: TkAgg].For more information, type 'help(pylab)'.

In [1]: from msmbuilder import Trajectory

In [2]: traj = Trajectory.load_from_lhdf("./Trajectories/trj0.lh5")

In [3]: traj["XYZList"].shape
Out[3]: (501, 22, 3)

In [4]: traj["XYZList"] = traj["XYZList"][0:5]

In [5]: traj.save_to_pdb("./test_output.pdb")
---------------------------------------------------------------------------IndexError                                Traceback (most recent call last)<ipython-input-5-8ac5f186f0ac> in <module>()
----> 1 traj.save_to_pdb("./test_output.pdb")

/usr/local/lib/python2.7/site-packages/msmbuilder-2.6.0-py2.7-linux-i686.egg/msmbuilder/Trajectory.pyc in save_to_pdb(self, Filename)
    248
    249         for i in range(len(self["XYZList"])):
--> 250             PDB.WritePDBConformation(Filename, self["AtomID"], self["AtomNames"], self["ResidueNames"], self["ResidueID"], self["XYZList"][i], self["ChainID"])
    251
    252     def save_to_xyz(self, Filename):

/usr/local/lib/python2.7/site-packages/msmbuilder-2.6.0-py2.7-linux-i686.egg/msmbuilder/PDB.pyc in WritePDBConformation(Filename, ATOMNUMS, ATOMS, RESNAMES, RESNUMS, XYZ, CHAIN)
   2600         line[22:26]=array(list(str(RESNUMS[i]).rjust(4)))
   2601
-> 2602         x=10*XYZ[i][0]
   2603         y=10*XYZ[i][1]
   2604         z=10*XYZ[i][2]

IndexError: index 22 is out of bounds for axis 0 with size 22

In [6]:

The next,how can i solve the problem?

rmcgibbo commented 11 years ago

You realize that you are dealing with the tutorial data, not your own protein, right? This line:

In [3]: traj["XYZList"].shape
Out[3]: (501, 22, 3)

Indicates that the trajectory contains 501 frames and 22 atoms, which means that it's alanine dipeptide. Regardless, there is still some kind of issue going on. We are looking into it.

rmcgibbo commented 11 years ago

Also, not that this is really relevant to the question at hand, but why are you logged in as root? That seems like a curious choice.

schwancr commented 11 years ago

It might be that your trajectory was not created correctly.

How did you create that trajectory file?

Can you do this in ipython and paste the output here:

    print traj['AtomID'].shape
smileyujun commented 11 years ago

Yes,you are right. i use my own protein, but when i run the first command: ConvertDataToHDF.py -s my.pdb -i XTC, in this command, XTC comes from the msmbuilder2.6 tutorial.So i may be wrong here.

Then, if i run my own protein,where do i obtain XTC from?

(I know the frist command:ConvertDataToHDF.py -s my.pdb -i XTC is very important,because it generates the following files:projectInfo.h5 , Trajectories/ , Data/)

kyleabeauchamp commented 11 years ago

The XTC input directory should point to wherever you stored your MD simulations, run using Gromacs.

rmcgibbo commented 11 years ago

If you're not familiar with running gromacs, there are some nice tutorials at http://www.gromacs.org/Documentation/Tutorials, but in general, proper setup and running the MD simulations is beyond the scope of msmbuilder.

smileyujun commented 11 years ago

Does it mean that i must install Gromacs,soon after let Gromacs generate XTC?

schwancr commented 11 years ago

'XTC' is just a folder that contains the results of an MD simulation. Have you done an MD simulation for the protein you are interested in studying? MSMBuilder cannot generate this data for you; it is a way to analyze the results.

rmcgibbo commented 11 years ago

MSMBuilder is a tool to analyze molecular dynamics ("MD") simulations -- it requires, as input, one or more MD trajectories. Gromacs is one of the many software packages available for running MD simulations. So yes, to run an MD simulation you must install gromacs, or one of the other MD packages such as CHARMM, AMBER, OpenMM or others.

smileyujun commented 11 years ago

Thanks very much, i see,and i will try. Please forgive me that i'm a learner in the first stage,so i don't know much about it.

Thank all of you again for giving me these directions.

rmcgibbo commented 11 years ago

Okay. I'm going to close this issue now. It seems like it's been resolved.

smileyujun commented 11 years ago

It haves only one xtc file, that is .xtc(generated by Gromacs), then can i run MSMBuilder?For example,run ConvertDataToHDF.py -s my.pdb -i XTC

At 2013-05-07 10:49:00,"Robert McGibbon" notifications@github.com wrote:

You realize that you are dealing with the tutorial data, not your own protein, right? This line:

In [3]: traj["XYZList"].shape Out[3]: (501, 22, 3)

Indicates that the trajectory contains 501 frames and 22 atoms, which means that it's alanine dipeptide. Regardless, there is still some kind of issue going on. We are looking into it.

— Reply to this email directly or view it on GitHub.