Hej Sajeewa,
it is hard to test this without the data, however, I think what you may be
looking for is defining the "state". Either you can set it in your script
using cmd.set('state', x) or define it in the get_distance function. Since
you use state=0, it will always use the object's current one. In your loop
you could use i+1 or numarray[i] for this, depending on the order of the
states (I assume it starts with 1, i starts with 0).
from pymol import cmd # you won't need to write pymol.cmd. further down
f = open("twoD_dist_ang.txt", "w")
for i in range(0,len(numarray)): # I assume numarray is a defined list
containing numbers?
cmd.reinitialize() # I'm not sure you need to reinitialize PyMOL every
time, you could use cmd.delete('all') if you want to get rid of objects
cmd.load('amn%d_xd1.pdb' %(numarray[i]))
ang=cmd.get_angle(atom1="179/C",atom2="206/N",atom3="996/N",state=
numarray[i]) # skip the str() formatting for later
dis=cmd.get_distance(atom1="993/CG",atom2="996/N",state=numarray[i])
f.write('%.3f\t%.3f\t%d\n' %(ang, dis, numarray[i])) # format using %f
syntax, %.3f gives you 3 digits
f.close()
If you want to go through the states of the object you can use a loop:
for state in range(1, cmd.count_states('topo')+1):
cmd.set('state', state, 'topo')
# and so on
Hope this works out, you could manually control check if the script is
doing its job correctly.
Cheers,
Andreas
On Thu, Jul 17, 2014 at 7:47 PM, Sajeewa Pemasinghe <sajeew...@gmail.com>
wrote:
> Hi all,
>
> I have loaded a topology file by the name of "topo" into pymol and loaded
> the trajectory file on top of it. Now pymol says "amn1136_xd1.trj" appended
> into object "topo".
> CmdLoadTraj: 250 total states in the object.
>
> I want go through these states and write the distance between two atoms to
> a file.
>
> I already have a script that goes through and array of files and writes a
> distance and an angle to a file.
>
> f = open("twoD_dist_ang.txt", "w")
> for i in range(0,len(numarray)):
> pymol.cmd.reinitialize()
> pymol.cmd.load('amn%d_xd1.pdb' %(numarray[i]))
>
> ang=str(cmd.get_angle(atom1="179/C",atom2="206/N",atom3="996/N",state="0"))
> dis=str(cmd.get_distance(atom1="993/CG",atom2="996/N",state="0"))
> f.write (ang+'\t'+dis+'\t'+str(numarray[i])+'\n')
> f.close()
>
> I would really appreciate some advice on how to modify the above script to
> go through the states of the above topology object "topo".
>
> Best regards
>
> Sajeewa Dewage
>
>
> ------------------------------------------------------------------------------
> Want fast and easy access to all the code in your enterprise? Index and
> search up to 200,000 lines of code with a free copy of Black Duck
> Code Sight - the same software that powers the world's largest code
> search on Ohloh, the Black Duck Open Hub! Try it now.
> http://p.sf.net/sfu/bds
> _______________________________________________
> PyMOL-users mailing list (PyMOL-users@lists.sourceforge.net)
> Info Page: https://lists.sourceforge.net/lists/listinfo/pymol-users
> Archives: http://www.mail-archive.com/pymol-users@lists.sourceforge.net
>
------------------------------------------------------------------------------
Want fast and easy access to all the code in your enterprise? Index and
search up to 200,000 lines of code with a free copy of Black Duck
Code Sight - the same software that powers the world's largest code
search on Ohloh, the Black Duck Open Hub! Try it now.
http://p.sf.net/sfu/bds
_______________________________________________
PyMOL-users mailing list (PyMOL-users@lists.sourceforge.net)
Info Page: https://lists.sourceforge.net/lists/listinfo/pymol-users
Archives: http://www.mail-archive.com/pymol-users@lists.sourceforge.net