From: Viswanadham Sridhara (muta.mestri_at_gmail.com)
Date: Thu Nov 03 2005 - 16:11:54 CST

Hi everyone ,
John sent me this code few days back, and Its running absolutely well for me
to analyze some data.

set f [open "foo.dat" w]
 set sel [atomselect top "water and exwithin 3 of protein"]
set residlist [lsort -unique -integer [$sel get resid]]
foreach idx $residlist {
puts $f "$idx"
}
close $f

I have one quick question.

I want to write some text in the first line of this foo.dat file, before I
save the residue numbers....
e.g., my foo.dat now is a column having integers, I want to add a
line(characters like...
[A[expr $i]] before I store a column, I know its very simple question, but I
am just not familiar with these kind of languages.......Can anyone tell me
how to do it?

Thanks in advance ....

> On 9/8/05, John Stone <johns_at_ks.uiuc.edu> wrote:
> >
> >
> > Hi,
> > You can use something simple like this:
> >
> > set f [open "foo.dat" w]
> > set sel [atomselect top "water and exwithin 3 of protein"]
> > set residlist [lsort -unique -integer [$sel get resid]]
> > foreach idx $residlist {
> > puts $f "$idx"
> > }
> > close $f
> >
> >
> > On Thu, Sep 08, 2005 at 11:44:29AM -0400, Viswanadham Sridhara wrote:
> > > Hi John,
> > > Thanks for the quick reply.
> > > I understood the commands you gave.
> > > But my problem is I cannot write them to a file. If its the case of
> > pdb,
> > > writepdb command directly creates a .pdb file in the working
> > directory, but
> > > I am unable to find a simple way to write "array" into a file. I know
> > its a
> > > very simple question, but still I am having problems with this, as I
> > am new
> > > to Tcl Scripting.
> > > Thanks in advance.
> > > -Viswam
> > >
> > > On 9/8/05, John Stone <johns_at_ks.uiuc.edu> wrote:
> > > >
> > > >
> > > > Hi,
> > > > I'd suggest modifying the selection so that you're just selecting
> > > > the waters, and and then query the resids and sort unique. Something
> > > > like this:
> > > > set sel [atomselect top "water and exwithin 3 of protein"]
> > > > set residlist [lsort -unique [$sel get resid]]
> > > >
> > > > From there you can write the contents of $residlist to a file if you
> > wish.
> > > >
> > > > John Stone
> > > > vmd_at_ks.uiuc.edu
> > > >
> > > > On Thu, Sep 08, 2005 at 11:29:54AM -0400, VISWANADHA SRIDHARA wrote:
> > > > > Hi VMD users,
> > > > >
> > > > > I am trying to get the resid's of the molecules in a trajectory.
> > > > >
> > > > > The script I wrote I have seen in VMD tutorial is
> > > > >
> > > > > set number_frames [molinfo top get numframes]
> > > > > set selection [atomselect top "exwithin 3 of protein"]
> > > > > for {set i 0} {$i < $number_frames} {incr i} {
> > > > > $selection frame $i
> > > > > $selection update
> > > > > $selection writepdb water_$i.pdb
> > > > > }
> > > > >
> > > > > Now I want to find the residue ID's of the water molecules in
> > > > water_$i.pdb
> > > > > files.
> > > > > Is there any straight coding which can be incorporated in the
> > script to
> > > > > directly get residue ID's in a notepad/wordpad file.
> > > > > I can use gromacs or other tool to convert each water_$i.pdb file
> > to
> > > > > water_$i.ndx file, but can I use "$selection get index" and then
> > store
> > > > that
> > > > > in a file(ofcourse not pdb).
> > > > >
> > > > > Thanks in advance and Best Regards,
> > > > > Viswam.
> > > >
> > > > --
> > > > NIH Resource for Macromolecular Modeling and Bioinformatics
> > > > Beckman Institute for Advanced Science and Technology
> > > > University of Illinois, 405 N. Mathews Ave, Urbana, IL 61801
> > > > Email: johns_at_ks.uiuc.edu Phone: 217-244-3349
> > > > WWW: http://www.ks.uiuc.edu/~johns/>Fax: 217-244-6078
> > > >
> > >
> > >
> > >
> > > --
> > > Viswanadham Sridhara,
> > > Graduate Research Assistant,
> > > Old Dominion University, "VIRGINIA".
> >
> > --
> > NIH Resource for Macromolecular Modeling and Bioinformatics
> > Beckman Institute for Advanced Science and Technology
> > University of Illinois, 405 N. Mathews Ave, Urbana, IL 61801
> > Email:
johns_at_ks.uiuc.edu Phone: 217-244-3349
> > WWW: http://www.ks.uiuc.edu/~johns/ <http://www.ks.uiuc.edu/%7Ejohns/>Fax: 217-244-6078
> >
>
>
>
> --
> Viswanadham Sridhara,
> Graduate Research Assistant,
> Old Dominion University, "VIRGINIA".
>

--
Viswanadham Sridhara,
Graduate Research Assistant,
Old Dominion University, "VIRGINIA".