3dmol / 3Dmol.js

WebGL accelerated JavaScript molecular graphics library
https://3dmol.org/
Other
804 stars 194 forks source link

Consider modified amino acid residues as protein atoms (hetflag: false) #810

Closed JavierSanchez-Utges closed 1 month ago

JavierSanchez-Utges commented 1 month ago

Hi, I have been dealing with some structures, for example PDB: 1SVH, which have phosphorylated residues. I use hetflag: false to select all my protein atoms. This usually works perfectly, but for examples like these ones, that present 1 TPO (phosphothreonine) and 1 SEP (phosphoserine), these two residues are not in the selection and therefore the cartoon will be incomplete.

ChimreaX, for example, recognises these residues and other modified amino acid as standard amino acids, and not other ligands. I was wondering if there is a way around this. I think in general, you would want these modified residues to behave as any other standard amino acid and be selected with the hetflag: false as they are part of the petide chain.

Screenshot 2024-09-10 at 14 48 31

Many thanks for your help!

dkoes commented 1 month ago

These are marked as hetatoms in the pdb file:

HETATM 1502  N   TPO A 197      40.591   5.296  18.772  1.00 41.91           N  

The 3Dmol behavior is correct. You could create your own list of standard/nonstandard residue names and select using that (or do an or selection between hetflag: false and nonstandard residues names).

JavierSanchez-Utges commented 1 month ago

Hmm, yeah, I thought that was gonna be the case. Yes, I will create a list of all resn of modified amino acids and combine with hetflag: false with the or as you suggested. Thanks!

JavierSanchez-Utges commented 1 month ago

Right, I see. But then, since these modified amino acids are hetatm, they can't have a cartoon representation, can they?

dkoes commented 1 month ago

If they have the normal atom names for the backbone atoms it should work. Does it not?

dkoes commented 1 month ago

Seems to work for me: https://3dmol.org/viewer.html?pdb=1svh&select=all&style=cartoon&select=resn:TPO&style=stick;cartoon

JavierSanchez-Utges commented 1 month ago

True, I had my selection wrong. I have now created my own selections to use instead of hetflag:

const canAas = ['CYS', 'MET', 'HIS', 'GLU', 'ASP', 'LYS', 'ARG', 'SER', 'THR', 'ASN', 'GLN', 'TRP', 'TYR', 'PHE', 'ILE', 'LEU', 'VAL', 'ALA', 'PRO', 'GLY'];
const modAas = ['TPO', 'SEP', 'PTR', 'PYL', 'MLY', 'MSE', 'CSO', 'CME', 'CSD', 'CSW', 'CSX', 'CSS', 'CSH', 'CSL', 'CSZ', 'CSK', 'CSM', 'CSR', 'CSS', 'CSU'];
const allAas = canAas.concat(modAas);
const aasSel = allAas.map(function(residue) {
    return { resn: residue };
})
const protAtoms = {or: aasSel}; // all protein atoms, including 20 canonical AAs and 20 modified AAs
const hetAtoms = {not: protAtoms}; // all non-protein atoms
const hetAtomsNotHoh = {and: [hetAtoms, {not: {resn: 'HOH'}}]}; // all non-protein atoms except water
const hohAtoms = {resn: 'HOH'}; // all water atoms

However, now I am having issues with complex selections combining and, not, and or operators. This links to issue #804. For example: {and:[{model: protAtomsModel}, {resi: PDBResNums}, {chain: repPdbChainId}, protAtoms]}, applies to all the models that are open.

According to my understanding, this selection should include: the atoms of all residues within those 40 AAs in chain 'A' of model modelID for 1svh_A that are in {resi: PDBResNums}. However, this selection seems to include atoms of all models.

Screenshot 2024-09-11 at 13 19 00

Is my selection or understanding of them wrong? Perhaps I am not understanding properly the combination of the different operators.

Attaching example models here: models_example.zip

Thanks so much!

JavierSanchez-Utges commented 1 month ago

I think there might be an issue with the implementation of the and operator when one of the selectionSpec is {model:}. See how there is no difference between yellow and cyan, i.e., atoms from other models that are not protAtomsModel are not being removed.

Screenshot 2024-09-11 at 14 34 44

More examples here:

Screenshot 2024-09-11 at 14 48 38

All the sidechains on the bottom right of the viewer correspond to SEP residues of multiple different models, except protAtomsModel, so when passing the {model: protAtomsModel} they should not appear, right?

Hope this helps!

JavierSanchez-Utges commented 1 month ago

Another example here. Should these two ways not result in the same selection?

viewer.setStyle({and:[{model: protAtomsModel}, {resn: "TPO"}]}, {cartoon: {hidden: false, color: "red"}, stick:{color:"red", hidden: false}, sphere:{color:"red", hidden: false, radius: 0.25}});

Screenshot 2024-09-11 at 15 29 19

viewer.setStyle({model: protAtomsModel, resn: "TPO"}, {cartoon: {hidden: false, color: "green"}, stick:{color:"green", hidden: false}, sphere:{color:"green", hidden: false, radius: 0.25}});

Screenshot 2024-09-11 at 15 32 21

Thanks!

JavierSanchez-Utges commented 1 month ago

I have found a temporary solution that avoids using and operators altogether. It might not work for very complex solutions, but is doing the trick at the moment. I am doing so by extending my current existing selection objects.

Instead of {and:[{model: protAtomsModel}, {resi: PDBResNums}, {chain: repPdbChainId}, protAtoms]},

using:

{...protAtoms, model: protAtomsModel, not: {resi: PDBResNums}, chain: repPdbChainId}

dkoes commented 1 month ago

resn: ["ARG","LYS"] should work - you don't need and/or to specify multiple residue names or ids. Issue #804 is definitely a problem (selections are applied to models individually so the logical operators don't work properly with model specifiers). I will get around to fixing it, but I think you can do everything you want as long as you keep the model specifier at the top level.

JavierSanchez-Utges commented 1 month ago

Ah, I See. I will try the resn: array. OK, that is good to know, I thought I was going mad with the selections. By top level, do you mean on the main AtomSelectionSpec, without and and or? There is an and operator working within this top level of the AtomSelectionSpec, right?

Do you think using the JavaScript spread syntax using ... is alright? It seems to work.

dkoes commented 1 month ago

Yes, the model needs to be in the main AtomSelectionSpec. There can be and and there too, but no model specifier within the and/or (I will fix this eventually).

JavierSanchez-Utges commented 1 month ago

Alright, sounds good. Closing this issue then. Thanks!