Пример #1
0
 def png(self, filename, *args, **kwargs):
     '''
     Save image to filename, with antialias=0.
     '''
     cmd.unset('antialias')
     cmd.png(filename, *args, **kwargs)
     cmd.draw()
Пример #2
0
    def test(self):
        cmd.set('suspend_updates')
        cmd.set('depth_cue', 0)
        cmd.set('ambient', 1)
        cmd.set('specular', 0)
        cmd.set('stereo_angle', 10)
        cmd.pseudoatom()
        cmd.show_as('sphere')
        cmd.zoom()
        cmd.stereo('anaglyph')
        cmd.set('suspend_updates', 0)

        wh = (40, 40)
        cmd.draw(*wh, antialias=0)
        cmd.sync()

        img = self.get_imagearray(prior=1)
        self.assertEqual(wh, img.shape[:2])

        # ray tracing and shaders in PyMOL 1.7.6+:
        # 0xe50000
        # 0x00e5e5
        # -> delta=26 (0x1a)

        self.assertImageHasColor('0xff0000', img, delta=0x1a)
        self.assertImageHasColor('0x00ffff', img, delta=0x1a)
Пример #3
0
    def testDirtyDelete(self):
        cmd.pseudoatom('m1')
        cmd.pseudoatom('m2')
        cmd.group('g1', 'm1 m2')
        cmd.set_wizard(MockWizard())

        cmd.draw()

        v = cmd.get_object_list('(g1)')
        self.assertEqual(v, ['m1', 'm2'])
Пример #4
0
    def testPngExists(self):
        '''
        Save a PNG image with width/height specified and
        check if the file exists.
        '''
        cmd.pseudoatom('m1')
        cmd.show('spheres')

        with testing.mktemp('.png') as filename:
            cmd.png(filename, width=100, height=100, ray=0)
            cmd.draw()
            self.assertTrue(os.path.exists(filename), 'png file not written')
Пример #5
0
    def test(self, ribbon_as_cylinders):
        cmd.set('ribbon_as_cylinders', ribbon_as_cylinders)
        cmd.set('ribbon_width', 8)
        cmd.fab('AG')
        cmd.color('red', 'resn ALA')
        cmd.color('blue', 'resn GLY')
        cmd.show_as('ribbon')
        cmd.orient()

        self.ambientOnly()
        cmd.viewport(100, 100)
        cmd.draw(100, 100)
        img = self.get_imagearray()
        self.assertImageHasColor('red', img)
        self.assertImageHasColor('blue', img)
Пример #6
0
def render_false_color_image(width, height, filename=''):
    global tmpdir

    tmpFile = get_temporary_file(filename)

    # draw with antialiasing disabled
    cmd.draw(width, height, 0)
    cmd.png(tmpFile)
    while not os.path.exists(tmpFile):
        time.sleep(1)

    if DEBUG:
        print "created temporary file %s" % tmpFile

    return tmpFile
Пример #7
0
    def test(self, ribbon_as_cylinders):
        cmd.set('ribbon_as_cylinders', ribbon_as_cylinders)
        cmd.set('ribbon_width', 8)
        cmd.fab('AG')
        cmd.color('red', 'resn ALA')
        cmd.color('blue', 'resn GLY')
        cmd.show_as('ribbon')
        cmd.orient()

        self.ambientOnly()
        cmd.viewport(100, 100)
        cmd.draw(100, 100)
        img = self.get_imagearray()
        self.assertImageHasColor('red', img)
        self.assertImageHasColor('blue', img)
Пример #8
0
    def testAsyncBuilds(self, rep, async_builds):
        target = "1aon"
        if async_builds:
            msg = '%s cpus' % max_threads
        else:
            msg = '1 cpu'
        cmd.set("async_builds", async_builds)
    
        cmd.load(self.datafile('1aon.pdb.gz'), target)
        for x in cmd.get_chains():
            cmd.create("Chain_%s" % x, target + " & c. " + x)
        cmd.delete(target)

        with self.timing('%s' % msg):
            cmd.show_as(rep)
            cmd.draw()
Пример #9
0
# NLS
for r in range(680, 742):
    cmd.color('firebrick', 'resi {0} and S009'.format(r))




###### SETVIEW

cmd.set_view ('\
     0.636402488,    0.699312985,   -0.325504273,\
    -0.565354168,    0.135798618,   -0.813591778,\
    -0.524754405,    0.701796234,    0.481783271,\
     0.000000000,    0.000000000, -429.757751465,\
   -69.421409607,    7.238445282,   72.295677185,\
   338.824279785,  520.691223145,  -20.000000000 ')


###### POSTAMBLE

cmd.select(None)
cmd.set('specular', "off")
cmd.draw(width=1000, height=1000)
cmd.png('{0}_{1}.png'.format(structure, metric), ray=1)
cmd.rotate('y', angle=180)
cmd.draw(width=1000, height=1000)
cmd.png('{0}_{1}_y.png'.format(structure, metric), ray=1)
cmd.rotate('y', angle=180)
cmd.rotate('x', angle=90)
cmd.draw(width=1000, height=1000)
cmd.png('{0}_{1}_x.png'.format(structure, metric), ray=1)
Пример #10
0
 def _pngExistsAsync(self, filename, sync_in_thread):
     cmd.png(filename, width=100, height=100, ray=0)
     cmd.draw()
     if sync_in_thread:
         cmd.sync()
Пример #11
0
 def test2668(self):
     cmd.pseudoatom('m1', pos=(-.4, 0, 0))
     cmd.pseudoatom('m2', pos=(.4, 0, 0))
     cmd.distance('d0', 'm1', 'm2')
     cmd.draw()
Пример #12
0
 def _pngExistsAsync(self, filename, sync_in_thread):
     cmd.png(filename, width=100, height=100, ray=0)
     cmd.draw()
     if sync_in_thread:
         cmd.sync()
assert (len(min_rmsd_key) == 1)

max_id1 = max_rmsd_key[0][0]
max_id2 = max_rmsd_key[0][1]
print('The maximum rmsd arose from a comparison of ' + max_id1 + ' and ' +
      max_id2 + ' with a rmsd value of: ' + str(round(max_rmsd, 2)))

min_id1 = min_rmsd_key[0][0]
min_id2 = min_rmsd_key[0][1]
print('The maximum rmsd arose from a comparison of ' + min_id1 + ' and ' +
      min_id2 + ' with a rmsd value of: ' + str(round(min_rmsd, 2)))

## set your best and worst protein structures up to take an image, and capture this to your working directory
print 'Build best.pdb from {} and {}'.format(max_id1, max_id2)
sys.stdout.flush()
pdb_merge(max_id1, max_id2, 'best.pdb')

print 'Build worst.pdb from {} and {}'.format(min_id1, min_id2)
sys.stdout.flush()
pdb_merge(min_id1, min_id2, 'worst.pdb')

cmd.load('best.pdb')
cmd.cartoon('putty', 'best')
cmd.draw()
cmd.save('best.png')

cmd.load('worst.pdb')
cmd.cartoon('putty', 'worst')
cmd.draw()
cmd.save('worst.png')