From: Jason V. <jas...@sc...> - 2010-08-26 15:24:23
|
Hi Martin, I can think of two ways to achieve this. You can attempt to be tricky and add from pymol import stored stored.outFile = open("/my/myHbons.txt", 'w') to your script and then inside the iterate commands instead of 'print "%1s/%3s`%s/%-4s " % (chain, resn, resi, name),') put 'stored.outFile.write("%1s/%3s`%s/%-4s " % (chain, resn, resi, name)') Or, second, you could just use "stored" to make a few lists to save your data and then write those lists to disk: from pymol import stored stored.listA = [] > for pairs in hb: > cmd.iterate("%s and index %s" % (pairs[0][0], pairs[0][1]), > 'stored.listA.append( "%1s/%3s`%s/%-4s " % (chain, resn, resi, name)') ... then after all your lists are created, outFile = open("/tmp/myHbonds.txt", 'w') for curLine in stored.listA: outFile.write(curLine + "\n") outFile.close() which should write to the file /tmp/myHbonds.txt with your data. Cheers, -- Jason On Thu, Aug 26, 2010 at 11:07 AM, Martin Hediger <ma...@bl...> wrote: > Dear all > I am using the script of Robert Campell to collect hydrogen bonds and > the essential part looks like this: > > [collect pairs in hb by cmd.find_pairs] > for pairs in hb: > cmd.iterate("%s and index %s" % (pairs[0][0], pairs[0][1]), > 'print "%1s/%3s`%s/%-4s " % (chain, resn, resi, name),') > > > cmd.iterate("%s and index %s" % (pairs[1][0],pairs[1][1]), > 'print "%1s/%3s`%s/%-4s " % (chain, resn, resi, name),') > > > print "%.2f" % cmd.distance(hb_list_name, "%s and index %s" % > (pairs[0][0], pairs[0][1]), "%s and index %s" % > (pairs[1][0], > pairs[1][1])) > > This nicely lists three columns, where the interacting pairs are shown > together with the length of the hydrogen bond. > I have now started various unsuccessfull attempts to direct the output > of 'cmd.iterate(...)' to a file which I would like to process further > (sorting for largest change for two different configurations, etc.). > > How do I direct the output from iterate to a file? > > Suggestions would be appreciated. > Martin > > ------------------------------------------------------------------------------ > Sell apps to millions through the Intel(R) Atom(Tm) Developer Program > Be part of this innovative community and reach millions of netbook users > worldwide. Take advantage of special opportunities to increase revenue and > speed time-to-market. Join now, and jumpstart your future. > http://p.sf.net/sfu/intel-atom-d2d > _______________________________________________ > PyMOL-users mailing list (PyM...@li...) > Info Page: https://lists.sourceforge.net/lists/listinfo/pymol-users > Archives: http://www.mail-archive.com/pym...@li... > -- Jason Vertrees, PhD PyMOL Product Manager Schrodinger, LLC (e) Jas...@sc... (o) +1 (603) 374-7120 |