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 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241
|
from __future__ import print_function
from __future__ import absolute_import
from __future__ import division
import pymol
from pymol import cmd, testing, stored
# spectrum produces colors which are wrong in the second digit
get_color_tuple = lambda c, n=1: tuple([round(x, n) for x in cmd.get_color_tuple(c)])
class TestUtil(testing.PyMOLTestCase):
_color_by_area_cache = {}
@testing.foreach('molecular', 'solvent')
@testing.requires_version('1.9.0')
def test_color_by_area(self, mode):
cmd.fragment('tyr')
cmd.color('white')
pymol.util.color_by_area('*', mode, palette='blue_white_red')
stored.colors = set()
cmd.iterate('*', 'stored.colors.add(color)')
colors = [get_color_tuple(c) for c in sorted(stored.colors)]
self.assertTrue((1., 0., 0.) in colors)
self.assertTrue((0., 0., 1.) in colors)
# compare with other mode
self._color_by_area_cache[mode] = colors
colors_mode_other = self._color_by_area_cache.get(
'molecular' if mode == 'solvent' else 'solvent')
self.assertNotEqual(colors, colors_mode_other)
@testing.requires_version('1.7.2')
def test_find_surface_residues(self):
pymol.util.find_surface_residues
self.skipTest("TODO")
def test_find_surface_atoms(self):
pymol.util.find_surface_atoms
self.skipTest("TODO")
@testing.requires_version('1.7.2')
def test_get_area(self):
pymol.util.get_area
self.skipTest("TODO")
def test_get_sasa(self):
pymol.util.get_sasa
self.skipTest("TODO")
def test_mass_align(self):
pymol.util.mass_align
self.skipTest("TODO")
def test_sum_formal_charges(self):
pymol.util.sum_formal_charges
self.skipTest("TODO")
def test_sum_partial_charges(self):
pymol.util.sum_partial_charges
self.skipTest("TODO")
def test_compute_mass(self):
pymol.util.compute_mass
self.skipTest("TODO")
def test_protein_assign_charges_and_radii(self):
pymol.util.protein_assign_charges_and_radii
self.skipTest("TODO")
def test_protein_vacuum_esp(self):
pymol.util.protein_vacuum_esp
self.skipTest("TODO")
def test_color_carbon(self):
pymol.util.color_carbon
self.skipTest("TODO")
def test_cbss(self):
cmd.load(self.datafile('1oky-frag.pdb'))
c = [2, 13, 22] # blue orange forest
pymol.util.cbss('*', *c)
stored.colors = set()
cmd.iterate('*', 'stored.colors.add((ss or "L", color))')
self.assertEqual(stored.colors, set(zip('HSL', c)))
def _test_cba(self, fun, expected_color):
cmd.fragment('gly')
cmd.color('white')
fun('*')
stored.colors = set()
cmd.iterate('elem C', 'stored.colors.add(color)')
colors = [get_color_tuple(c, 3) for c in stored.colors]
self.assertEqual(colors, [expected_color])
def test_cbag(self):
self._test_cba(pymol.util.cbag, (0.2, 1.0, 0.2))
def test_cbac(self):
self._test_cba(pymol.util.cbac, (0.0, 1.0, 1.0))
def test_cbam(self):
self._test_cba(pymol.util.cbam, (1.0, 0.2, 0.8))
def test_cbay(self):
self._test_cba(pymol.util.cbay, (1.0, 1.0, 0.0))
def test_cbas(self):
self._test_cba(pymol.util.cbas, (1.0, 0.6, 0.6))
def test_cbaw(self):
self._test_cba(pymol.util.cbaw, (0.9, 0.9, 0.9))
def test_cbab(self):
self._test_cba(pymol.util.cbab, (0.5, 0.5, 1.0))
def test_cbao(self):
self._test_cba(pymol.util.cbao, (1.0, 0.7, 0.2))
def test_cbap(self):
self._test_cba(pymol.util.cbap, (0.75, 0.0, 0.75))
def test_cbak(self):
self._test_cba(pymol.util.cbak, (1.0, 0.65, 0.85))
def test_cnc(self):
pymol.util.cnc
self.skipTest("TODO")
def test_cba(self):
pymol.util.cba
self.skipTest("TODO")
def test_cbh(self):
pymol.util.cbh
self.skipTest("TODO")
def test_enable_all_shaders(self):
pymol.util.enable_all_shaders()
# result depends on whether shaders are available or not
def test_modernize_rendering(self):
pymol.util.modernize_rendering(1) # unused mode argument
def test_performance(self):
pymol.util.performance(0)
self.assertEqual(1, cmd.get_setting_int('surface_quality'))
self.assertEqual(1, cmd.get_setting_int('depth_cue'))
pymol.util.performance(33)
self.assertEqual(0, cmd.get_setting_int('surface_quality'))
self.assertEqual(1, cmd.get_setting_int('depth_cue'))
pymol.util.performance(66)
self.assertEqual(0, cmd.get_setting_int('surface_quality'))
self.assertEqual(0, cmd.get_setting_int('depth_cue'))
pymol.util.performance(100)
self.assertEqual(-1, cmd.get_setting_int('surface_quality'))
self.assertEqual(0, cmd.get_setting_int('depth_cue'))
def test_label_chains(self, mode='chain'):
cmd.load(self.datafile('4m4b-minimal-w-assembly.cif'))
if mode == 'chain':
pymol.util.label_chains()
else:
pymol.util.label_segments()
stored.labels = set()
cmd.iterate('*', 'stored.labels.add(label)')
self.assertEqual(stored.labels, set(['', mode + ' A', mode + ' B']))
@testing.requires_version('1.7.2')
def test_label_segments(self):
self.test_label_chains('segi')
def test_cbc(self):
pymol.util.cbc
self.skipTest("TODO")
def test_color_objs(self):
pymol.util.color_objs
self.skipTest("TODO")
def test_chainbow(self):
pymol.util.chainbow
self.skipTest("TODO")
def test_ray_shadows(self):
pymol.util.ray_shadows
self.skipTest("TODO")
def test_ff_copy(self):
pymol.util.ff_copy
self.skipTest("TODO")
def test_b2vdw(self):
pymol.util.b2vdw
self.skipTest("TODO")
def test_phipsi(self):
pymol.util.phipsi
self.skipTest("TODO")
def test_rainbow(self):
pymol.util.rainbow
self.skipTest("TODO")
def test_ss(self):
pymol.util.ss
self.skipTest("TODO")
def test_colors(self):
cmd.fragment('gly')
pymol.util.colors("jmol")
stored.colors = set()
cmd.iterate('elem C', 'stored.colors.add(color)')
colors = [get_color_tuple(c, 3) for c in stored.colors]
self.assertEqual(colors, [(0.567, 0.567, 0.567)])
@testing.requires_version('1.7.6')
def test_interchain_distances(self):
pymol.util.interchain_distances
self.skipTest("TODO")
@testing.requires_version('1.8.0')
def test_get_sasa_relative(self):
cmd.load(self.datafile('1oky-frag.pdb'))
r = cmd.get_sasa_relative()
self.assertAlmostEqual(r['1oky-frag', '', 'A', '86'], 0.708, delta=1e-3)
r = cmd.get_sasa_relative("resi 86")
self.assertAlmostEqual(r['1oky-frag', '', 'A', '86'], 0.708, delta=1e-3)
@testing.requires_version('2.6')
def test_get_sasa_relative_subsele(self):
cmd.load(self.datafile('1oky-frag.pdb'))
r = cmd.get_sasa_relative(subsele="sidechain")
self.assertAlmostEqual(r['1oky-frag', '', 'A', '86'], 0.812, delta=1e-3)
r = cmd.get_sasa_relative("resi 86", subsele="sidechain")
self.assertAlmostEqual(r['1oky-frag', '', 'A', '86'], 0.812, delta=1e-3)
@testing.requires_version('1.8.6')
def test_ligand_zoom(self):
pymol.util.ligand_zoom
self.skipTest("TODO")
|