From: Josh (vermaasj_at_msu.edu)
Date: Fri Aug 11 2023 - 08:32:12 CDT

Hi Bart,

I assume you are using atomselection macros for this?
(https://www.ks.uiuc.edu/Research/vmd/current/ug/node122.html#6706) I
can't find where the protein macro is defined quickly, but there are a
bunch of atomselection macros defined in scripts/vmd/atomselmacros.dat.
There is one set I think would be particularly useful to you, which is
the example macro for selecting conformations based on the altloc flag
in a pdb file:

### PDB 'altloc' conformation selection macros
conformationall altloc ""
conformationA altloc "" or altloc "A"
conformationB altloc "" or altloc "B"
conformationC altloc "" or altloc "C"
conformationD altloc "" or altloc "D"
conformationE altloc "" or altloc "E"
conformationF altloc "" or altloc "F"

If you don't want to hardcode the macros, and use the beta or user field
to store the depth for any given atom, I think you could do something like:

atomselect macro container-2 "beta -2 -1 1 2 3 4"
atomselect macro container-1 "beta -1"
..
atomselect macro container4 "beta 4"

and so on. Then once you have the macros defined, you can do
"container-2 and not container3" like you want. If you REALLY wanted
spaces, you'd need to dig into VMD's internal datastructure and make a
new variable you can select on that has this inheritance property. I
don't think that is needed to get a proof of concept working though.

-Josh

On 8/8/23 10:12 AM, Bart Bruininks wrote:
> Dear VMDers,
>
> I want to add a custom selection word which I can use in the
> graphics/representation/selection input. I have a DirectedAcyclicGraph
> (DAG) structure which I want to use in the selection syntax.
>
> {[-2, 1, 2, [3, -1] 4]}
>
> The above represents a DAG which can be shown as a dict where the key
> is the node and the value are all the nodes that are at equal or
> deeper depth.
> -2 : [-2, -1, 1, 2, 3, 4]
> -1 : [-1]
>  1 : [1]
>  2 : [2]
>  3 : [3, -1]
>  4 : 4
>
> How would I go about making it so that for example 'container' is my
> keyword in the selection and I can then add a value to point at the
> key of interest in the DAG, for example:
>
> container '-2' -> The selection of all atoms which have '-2, -1, 1, 2,
> 3, 4' in their beta value (or if there is a better way)
>
> For now I have the following TCL which I generate with a python script
> using the DAG:
> dict set containment '-2' {'-2' '1' '2' '4' '3' '-1' }
> dict set containment '-1' {'-1' }
> dict set containment '1' {'1' }
> dict set containment '2' {'2' }
> dict set containment '3' {'3' '-1' }
> dict set containment '4' {'4' }
>
> proc get_container {container {mol 0} {rep 0} } {
>     global containment
>     mol modselect $mol $rep beta [dict get $containment $container]
> }
>
> However, the problem here is that I cannot use it in the
> graphics/representations syntax. I would like to be able to state
> things like: 'container -2 and not container 3', which should return
> all atoms with beta '-2, 1, 2, 4'.
>
> I tried to refer to all the indices which satisfy the conditions,
> however, for large files I run into a buffer overflow. I wonder how
> keywords like protein circumvent this problem.
>
> Cheers and thanks in advance,
>
> Bart Bruininks
>
> PS
> If you want to know why I am trying to do this take a look at my
> github for mdvcontainment
> <https://urldefense.com/v3/__https://github.com/BartBruininks/mdvcontainment__;!!DZ3fjg!_WEk7LiGfI4lR3C1rrQZllTcWx6notOq1kvUn6PIf1wGvJBT4vnHw65vjRW6bm4l6Vb0TxfC4rAjofqgARj0XscJ$>.

-- 
Josh Vermaas
vermaasj_at_msu.edu
Assistant Professor, Plant Research Laboratory and Biochemistry and Molecular Biology
Michigan State University
vermaaslab.github.io