File: PYMOL-3209.py

package info (click to toggle)
pymol 3.1.0%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 74,084 kB
  • sloc: cpp: 482,660; python: 89,328; ansic: 29,512; javascript: 6,792; sh: 84; makefile: 25
file content (67 lines) | stat: -rw-r--r-- 2,059 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
import os
from pymol import cmd, testing

@testing.requires_version('2.4')
class TestMovieHiddenGroups(testing.PyMOLTestCase):

    def _load_example(self):
        # object in hidden group
        cmd.fragment('ile', 'm1')
        cmd.fragment('his', 'm2')
        cmd.group('g1', 'm1')
        cmd.disable('g1')

        # testable styling
        self.ambientOnly()
        cmd.orient()
        cmd.color('red', 'm1')
        cmd.color('blue', 'm2')
        cmd.show_as('spheres')

    def test_scenes(self):
        self._load_example()

        cmd.scene('s1', 'store')
        cmd.enable('g1')
        cmd.scene('s2', 'store')
        cmd.mset('1x4')
        cmd.mview('store', 1, scene='s2')
        cmd.mview('store', 4, scene='s1')

        with testing.mkdtemp() as tempdir:
            # export
            prefix = os.path.join(tempdir, 'frame')
            cmd.mpng(prefix, width=100, height=100)

            img = self.get_imagearray(prefix + '0002.png')
            self.assertImageHasColor('red', img)
            self.assertImageHasColor('blue', img)

            img = self.get_imagearray(prefix + '0003.png')
            self.assertImageHasNotColor('red', img)
            self.assertImageHasColor('blue', img)

    def test_mdo(self):
        self._load_example()

        cmd.mset('1x3')
        cmd.mdo(1, 'disable m1')
        cmd.mdo(2, 'enable m1')
        cmd.mdo(3, 'enable g1')

        with testing.mkdtemp() as tempdir:
            # export
            prefix = os.path.join(tempdir, 'frame')
            cmd.mpng(prefix, width=100, height=100)

            img = self.get_imagearray(prefix + '0001.png')
            self.assertImageHasNotColor('red', img)
            self.assertImageHasColor('blue', img)

            img = self.get_imagearray(prefix + '0002.png')
            self.assertImageHasNotColor('red', img)
            self.assertImageHasColor('blue', img)

            img = self.get_imagearray(prefix + '0003.png')
            self.assertImageHasColor('red', img)
            self.assertImageHasColor('blue', img)