ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/freemol/trunk/smi23d/src/mengine/mengine.py
Revision: 14
Committed: Thu Jun 19 00:21:04 2008 UTC (13 years, 7 months ago) by tjod
File size: 539 byte(s)
Log Message:
Sample python code showing how mengine can be called using popen2

Line User Rev File contents
1 tjod 14 import os
2    
3     molblock_in = file("drugs.sdf").read()
4     cmd = os.curdir + os.sep + "mengine"
5     # mengine will read multi-molblock sdf files,
6     # but calling through popen2 with some (large?) files hangs on windows,
7     # even though the same file runs fine at command line.
8     # So, split into separate files.
9     for molblock_in in (file("drugs.sdf").read()).split('$$$$\n'):
10     if len(molblock_in) > 0:
11     mengine_in, mengine_out = os.popen2(cmd)
12     mengine_in.write(molblock_in)
13     mengine_in.close()
14     molblock_out = mengine_out.read()
15     print molblock_out,