Re: [AMBER] [Amber] How to convert vector files (.pev) into coordinate files (.pdb)

From: Hai Nguyen <nhai.qn.gmail.com>
Date: Fri, 18 Nov 2016 20:09:35 -0500

Hi,

Please see the code below

import pytraj as pt
import numpy as np

pdb_traj = pt.load('nuc.pdb')
print(pdb_traj)

xyz = np.loadtxt('v00.dat', dtype='f8')

# reshape to make 3D array, shape=(1, n_atoms, 3) # 1 structure with its
coordinates
xyz =np.array([xyz.reshape(pdb_traj.top.n_atoms, 3)])


print(xyz.shape)
print(xyz.ndim)

pdb_traj.xyz = xyz
pdb_traj.save('vector.pdb', overwrite=True)

PS: numpy is very handy for array, so it's worth spending time on playing
with it.
https://docs.scipy.org/doc/numpy/reference/generated/numpy.loadtxt.html

cheers
Hai

On Fri, Nov 18, 2016 at 7:29 PM, The Cromicus Productions <
thecromicusproductions.gmail.com> wrote:

> Thanks Hai! I think I'm close to getting it, but I'm running into an error:
>
> raise ValueError("must have the same number of atoms")
> ValueError: must have the same number of atoms
> *********************************************************
> This is my python code:
> import pytraj as pt
> pdb_traj = pt.load('nuc.pdb')
>
> # xyz : 3D array
>
> import numpy as np
> f = open('v00.dat')
> content = f.readlines()
> xyz = np.reshape(content, (-1, 3))
>
> numrows=len(xyz) #These lines were to verify if my matrix was correct
> numcols=len(xyz[0])
> print("I have", numrows)
> print( "rows and also", numcols)
> print( "columns")
> print(xyz)
>
> pdb_traj.xyz = xyz
> pdb_traj.save('vector.pdb')
>
> ****************************************************
> My pdb file (nuc.pdb) has 632 atoms and my vector file (v00.dat) has
> 1896=632*3 lines,
> so I have no idea why this is giving me an error :(
>
>
>
>
>
>
> On Fri, Nov 18, 2016 at 4:06 PM, Hai Nguyen <nhai.qn.gmail.com> wrote:
>
> > On Fri, Nov 18, 2016 at 4:02 PM, The Cromicus Productions <
> > thecromicusproductions.gmail.com> wrote:
> >
> > > Thanks for the reply! Sorry for the ignorance, but what do you mean by
> "
> > > your_method_to_load_vector_values"?
> > > I have a vector.pev file which I get from using nma.nab, getting a file
> > > named "vecs" and renaming it to "vector.pev"
> > >
> >
> > I meant you need to write a small function to load vector.pev to 3D
> array.
> >
> > Hai
> >
> >
> > >
> > > On Fri, Nov 18, 2016 at 1:30 PM, Hai Nguyen <nhai.qn.gmail.com> wrote:
> > >
> > > > One simple way to do is to use pytraj (+ Python) ( :D )
> > > >
> > > > import pytraj as pt
> > > > pdb_traj = pt.load('your.pdb')
> > > >
> > > > # xyz : 3D array
> > > > xyz = your_method_to_load_vector_values(...)
> > > >
> > > > pdb_traj.xyz = xyz
> > > > pdb_traj.save('your_new.pdb')
> > > >
> > > > Hai
> > > >
> > > > On Fri, Nov 18, 2016 at 1:26 PM, The Cromicus Productions <
> > > > thecromicusproductions.gmail.com> wrote:
> > > >
> > > > > Hi all,
> > > > >
> > > > > I'm working with normal mode analysis and have been able
> > > > > to obtain vector files (.pev) using nma.nab and using the IED
> add-on
> > > > > (http://mccammon.ucsd.edu/ied/) along with the original pdb file
> > > > > with the coordinates I can watch the motion in vmd.
> > > > >
> > > > > Now, how can I obtain a .pdb file from these vectors? Is there a
> > simple
> > > > > way?
> > > > >
> > > > > Thanks a lot,
> > > > >
> > > > > Sebastian
> > > > > _______________________________________________
> > > > > AMBER mailing list
> > > > > AMBER.ambermd.org
> > > > > http://lists.ambermd.org/mailman/listinfo/amber
> > > > >
> > > > _______________________________________________
> > > > AMBER mailing list
> > > > AMBER.ambermd.org
> > > > http://lists.ambermd.org/mailman/listinfo/amber
> > > >
> > > _______________________________________________
> > > AMBER mailing list
> > > AMBER.ambermd.org
> > > http://lists.ambermd.org/mailman/listinfo/amber
> > >
> > _______________________________________________
> > AMBER mailing list
> > AMBER.ambermd.org
> > http://lists.ambermd.org/mailman/listinfo/amber
> >
>
> _______________________________________________
> AMBER mailing list
> AMBER.ambermd.org
> http://lists.ambermd.org/mailman/listinfo/amber
>
>
_______________________________________________
AMBER mailing list
AMBER.ambermd.org
http://lists.ambermd.org/mailman/listinfo/amber
Received on Fri Nov 18 2016 - 17:30:02 PST
Custom Search