3
$\begingroup$

I'm new to PyMol (and StackExchange!) and working on my first project. I have the structure of a protein as an object, called PolyA-M, and the idea is that the residues of it are shown as spheres of differing sizes based on a calcualted conservation value. I want to label each sphere with it's amino acid, but to have the label size corresponding to sphere size. Here is a sample of the code that might be used to label one amino acid.

alter ( resid 138 ), resn = "Q135"
alter ( name CB and resid 138 ), vdw = vdw * 0.8 * 0.679934640522875
set_color col138, [ 1.0, 0.181, 0.181 ]
show spheres, name CB and resi 138
show sticks, ( name CA or name CB ) and resid 138
set label_size, 14, PolyA-M
label PolyA-M and name CB and resid 138, "Q"
color col138, name CB and resi 138

In this case, residue 138 is medium sized sphere with a size 14 label Q that fits well. However, if later on in the code another residue is labelled as so:

alter ( resid 198 ), resn = "A208"
alter ( name CB and resid 198 ), vdw = vdw * 0.8 * 0.359803921568627
set_color col198, [ 1.0, 0.601, 0.601 ]
show spheres, name CB and resi 198
show sticks, ( name CA or name CB ) and resid 198
set label_size,  8, PolyA-M
label PolyA-M and name CB and resid 198, "A"
color col198, name CB and resi 198

This will label residue 198 with a small A to fit the small sphere. However, this will also change the earlier label to size 8 as well, making it too small for the sphere.

Is there any way for me to prevent this, such that each residue keeps its own label size?

I know that one way is to create multiple identical objects and keep all labels of the same size restricted to the same object (For example, PolyA-M_10 contains all residues with label size 10, polyA-M_14 all residues with label size 14) but I was wondeirng if there is a more efficient way?

Thank you for any help! This is my first Stack Exchange question so any feedback would be appreciated :)

$\endgroup$

2 Answers 2

2
$\begingroup$

'label_size' is a object-state-level setting, which means that you will have to rely on the 'create' command to create a new object for every different label size.

It can certainly be automated, and for this I'd recommend getting into Pyhton Scripting for PyMOL

$\endgroup$
1
  • $\begingroup$ Ah, I see what you mean! The way I've been doing it with multiple objects is to just create multiple copies in the directory (So PolyA-M_1 to PolyA-M_10) such that it reads those in too, and then writes labels of different sizes onto them. But if there isn't a command which is able to change label size at a residue level, then this definitely sounds more efficient than having loads of different files. It would also be good for me to learn more scripting in general. Thank you! $\endgroup$
    – A. King
    Commented Sep 20, 2019 at 10:32
1
$\begingroup$

I ended up fixing this by just putting this into the boilerplate code:

copy PolyA-MC_4, PolyA-MC
copy PolyA-MC_6, PolyA-MC
copy PolyA-MC_8, PolyA-MC
copy PolyA-MC_10, PolyA-MC
copy PolyA-MC_12, PolyA-MC
copy PolyA-MC_14, PolyA-MC
copy PolyA-MC_16, PolyA-MC
copy PolyA-MC_18, PolyA-MC
copy PolyA-MC_20, PolyA-MC

This copied my object such that I had one per size of label text, and then each label was placed on the object. As all labels on a given object are the same size, it worked! e.g. for one residue the labelling is now:

set label_size,  4, PolyA-MC_4

Effectively, it's the same as what I was already doing, but instead of having ten copy filies in the directory only one is needed. Much easier for sending to people, and more efficient!

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.