Anybody can help on this?

husam husam at macrozon.net
Wed Feb 20 08:10:59 EST 2002


Dear friends,
I hvae the following situation:
I have 10000 files that needs to be processed by a program called ProFit
( Biochemistry program).  What the program does is it reads one molecule
and then reads another one and performs calculations to see how much
these molecules are similar. Sinse I have 10000 molecules It would takes
me a month typing all these file names and the corresponding commands to
make the calculations.  Since I'm a newbie to python, I thought it must
be possible to automate this process. I wrote this little script which
does the job nicely:

listit=os.popen('ls *pdb')
pdbs=listit.readlines()
listit.close()
passit=os.popen('/home/chemistry/profit ','w')
passit.write('reference Complex_1g.pdb ')
for PDB in pdbs:
     passit.write('\n')
     passit.write(' mobile ')
     passit.write(PDB)
     passit.write(' fit ')
passit.close()

As you see the "reference" molecule is the molecule to which the
"mobile" one should be compared. This is the output of the program :

Reading reference structure...
   Reading mobile structure...
   Reading mobile structure...
   Fitting structures...
   RMS: 8.765
   Fitting structures...
   RMS: 9.588

The problem is how can I save the output to a file? the only way to do
this at the moment is to run the scrip like this:
earth>$ myscript.py > output
What I want to do is to incorporate a code into the script to save the
results to a file. I tried with "os.popen() with "r" option but it
doesn't work because I don't know where to put it in the code. What I
don't understand is the following:
I have a file object of "os.popen()" open to send some commands to. When
can I retrieve the output of each command?
and last but not least, how can I print some stuff to the lines of the
output of the program so that the output will be like this:

Fitting structures...
RMS:10.343 ===>> My stuff
Fitting structures...
RMS: 6.389====>> My stuff


any help will be very much appreciated.

PS: I run python 1.52 on redhat 7.2





More information about the Python-list mailing list