Skip to content

Commit 6e69cb5

Browse files
committed
Lower default PyMOL surface quality
1 parent 393c934 commit 6e69cb5

File tree

5 files changed

+13
-0
lines changed

5 files changed

+13
-0
lines changed

csubst/csubst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -561,6 +561,8 @@ def _build_parser():
561561
help='default=%(default)s: Gray value for no-substitution sites. 0=black, 100=white')
562562
site.add_argument('--pymol_transparency', metavar='FLOAT', default=0.65, required=False, type=float,
563563
help='default=%(default)s: Surface transparency. 0=non-transparent, 1=completely transparent')
564+
site.add_argument('--pymol_surface_quality', metavar='INT', default=-1, required=False, type=int,
565+
help='default=%(default)s: PyMOL surface quality setting. Lower values speed up surface generation at the cost of smoothness.')
564566
site.add_argument('--pymol_img', metavar='yes|no', default='yes', type=strtobool,
565567
help='default=%(default)s: Whether to generate a rendered 6-view image file of protein structure.')
566568
site.add_argument('--pymol_max_num_chain', metavar='INT', default=20, required=False, type=int,

csubst/param.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -863,6 +863,8 @@ def get_global_parameters(args):
863863
)
864864
if (g['pymol_transparency'] < 0) or (g['pymol_transparency'] > 1):
865865
raise ValueError('--pymol_transparency should satisfy 0 <= value <= 1.')
866+
if 'pymol_surface_quality' in g.keys():
867+
g['pymol_surface_quality'] = int(g['pymol_surface_quality'])
866868
if 'pymol_max_num_chain' in g.keys():
867869
g['pymol_max_num_chain'] = int(g['pymol_max_num_chain'])
868870
if g['pymol_max_num_chain'] < 1:

csubst/parser_pymol.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -905,6 +905,7 @@ def set_substitution_colors(df, g, object_names, N_sub_cols):
905905
def write_pymol_session(df, g):
906906
df = df.reset_index(drop=True)
907907
_cmd_set('seq_view', 1)
908+
_cmd_set('surface_quality', int(g.get('pymol_surface_quality', -1)))
908909
if g['remove_solvent']:
909910
_cmd_remove('solvent')
910911
if g['remove_ligand']:

tests/test_param_backend.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -823,6 +823,7 @@ def test_get_global_parameters_validates_site_database_and_pymol_ranges():
823823
mafft_ep=0.2,
824824
pymol_gray=80,
825825
pymol_transparency=0.65,
826+
pymol_surface_quality=-1,
826827
pymol_max_num_chain=20,
827828
)
828829
)
@@ -832,6 +833,7 @@ def test_get_global_parameters_validates_site_database_and_pymol_ranges():
832833
assert g["mafft_ep"] == pytest.approx(0.2)
833834
assert g["pymol_gray"] == 80
834835
assert g["pymol_transparency"] == pytest.approx(0.65)
836+
assert g["pymol_surface_quality"] == -1
835837
assert g["pymol_max_num_chain"] == 20
836838

837839
with pytest.raises(ValueError, match="database_evalue_cutoff"):

tests/test_parser_pymol.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -740,14 +740,18 @@ def test_write_pymol_session_skips_ligand_preset_without_organic_atoms(tmp_path,
740740
"remove_ligand": "",
741741
"pymol_transparency": 0.1,
742742
"pymol_gray": 80,
743+
"pymol_surface_quality": -1,
743744
"mask_subunit": False,
744745
"session_file_path": str(tmp_path / "out.pse"),
745746
}
746747
parser_pymol.write_pymol_session(df=df, g=g)
747748
assert not any("preset.ligand_sites_trans_hq" in cmd for cmd in commands)
748749
assert not any("util.cbag organic" in cmd for cmd in commands)
750+
surface_quality_index = next(i for i, cmd in enumerate(commands) if "set surface_quality" in cmd)
749751
set_index = next(i for i, cmd in enumerate(commands) if "set transparency" in cmd)
750752
show_surface_index = next(i for i, cmd in enumerate(commands) if cmd == "show surface")
753+
assert "set surface_quality, -1" in commands[surface_quality_index]
754+
assert surface_quality_index < show_surface_index
751755
assert set_index < show_surface_index
752756

753757

@@ -770,9 +774,11 @@ def test_write_pymol_session_keeps_ligand_preset_with_organic_atoms(tmp_path, mo
770774
"remove_ligand": "",
771775
"pymol_transparency": 0.1,
772776
"pymol_gray": 80,
777+
"pymol_surface_quality": 0,
773778
"mask_subunit": False,
774779
"session_file_path": str(tmp_path / "out.pse"),
775780
}
776781
parser_pymol.write_pymol_session(df=df, g=g)
777782
assert any("preset.ligand_sites_trans_hq" in cmd for cmd in commands)
778783
assert any("util.cbag organic" in cmd for cmd in commands)
784+
assert any("set surface_quality, 0" in cmd for cmd in commands)

0 commit comments

Comments
 (0)