from mmtk import * ff = AmberForceField() block1 = Group('diamond111') oh = Group('hydroxyl') width = 39 height = 5 join = Joiner(block1) join.repeatGroup('hookeast', 'hookwest', width) join.repeatGroup('hooksouth', 'hooknorth', height) join.repeatGroup('hookup', 'hookdown', 2) result = join.getResult() base_name = result.name import gd im_out=gd.image((2*width,2*height)) red = im_out.colorAllocate((255,0,0)) green = im_out.colorAllocate((0,255,0)) blue = im_out.colorAllocate((0,0,255)) im_out.string(gd.gdFontSmall, (0,0), 'Hello, world!', blue) (maxx,maxy) = im_out.size() count = 0 join = Joiner(result) for y in range(maxy): for x in range(maxx): if im_out.getPixel((x,y)) > 0: (xd, xm) = divmod(x, 2) (yd, ym) = divmod(y, 2) block_index = xd + yd*width bond_index = ym + 2*xm import os pipe = os.popen("free") print 'Free:',pipe.read() print pipe.read() print pipe.read() print pipe.read() if bond_index == 3: h2 = Hook((result, [result.hookup_extra[block_index][0]])) else: h2 = Hook((result, [result.hookup[block_index][bond_index]])) join.joinGroups(h2, oh.hook1, 0) result = join.getIntermediateResult() count = count + 1 result.name = '%s_%d' % (base_name,count) result = join.getResult() result.setPositions(ff) result.hydrogenateDanglingBonds(ff) #save(result,'resulthello.mmtk') from ConfigIO import OutputFile fmt = OutputFile('PDB/result_hello1.pdb', 'pdb.connect') fmt.write(result) fmt.close() view(result)