### Draw and show inter-chain interface contacts
spectrum-atoms -by chain
construct-contacts
select-contacts [-inter-chain] -name iface
show-contacts [iface]
color-contacts [iface] -col yellow

### Draw and show inter-chain interface contacts plus some adjacent SAS
spectrum-atoms -by chain
construct-contacts
select-contacts [-inter-chain] -name iface
show-contacts [iface]
color-contacts [iface] -col yellow
select-atoms ([-sel-of-contacts iface] and [c<A>]) \
  -full-residues -name iface_atoms_A
select-atoms ([-sel-of-contacts iface] and [c<B>]) \
  -full-residues -name iface_atoms_B
unmark-atoms
show-atoms [iface_atoms_A] -rep sticks
show-atoms [iface_atoms_B] -rep sticks
color-atoms [iface_atoms_A] 0xFF7700 -rep sticks
color-atoms [iface_atoms_B] 0x0077FF -rep sticks
list-selections-of-contacts
list-selections-of-atoms
select-contacts [-a1 [iface_atoms_A] -solvent] \
  -name iface_atoms_A_sas
show-contacts [iface_atoms_A_sas]
color-contacts [iface_atoms_A_sas] -col 0x77FFFF

### Draw and show protein-ligand interface contacts
hide-atoms
show-atoms -rep sticks
color-atoms 0xAAAAAA
select-atoms [-t het] -name ligand
color-atoms [ligand] 0x0011BB
construct-contacts
select-contacts [-a1[ligand]] -name iface
show-contacts [iface]
color-contacts [iface] -col yellow
color-contacts ([iface] and [-solvent]) -col cyan
select-atoms ([-sel-of-contacts iface] and (not [ligand])) \
  -name prot_to_lig
color-atoms [prot_to_lig] -full-residues -col 0x00AA00
color-atoms [prot_to_lig] -col 0xFF2200
hide-atoms -rep sticks
show-atoms ([prot_to_lig] or [ligand]) \
  -full-residues -rep sticks
show-atoms -rep cartoon

### Calculate VoroMQA-light global and local scores
restrict-atoms [-t! het]
construct-contacts
voromqa-global
spectrum-atoms -adjunct voromqa_score_r \
  -scheme rwb -min-val 0.25 -max-val 0.75

### Calculate VoroMQA-dark global and local scores
restrict-atoms [-t! het]
construct-contacts
voromqa-global
voromqa-dark-global
set-adjunct-of-atoms-by-residue-pooling \
  -source-name vd1 -destination-name vd1s \
  -pooling-mode min -smoothing-window 0
spectrum-atoms -adjunct vd1s \
  -scheme rwb -min-val 0.45 -max-val 0.75

### Calculate VoroMQA surface frustration scores
#restrict-atoms [c<A>]
restrict-atoms [-t! het]
construct-contacts
voromqa-global
voromqa-frustration -adj-atom-frustration-energy-mean afem \
  -adj-contact-frustration-energy-mean cfem \
  -smoothing-iterations 1 -smoothing-depth 3
hide-atoms
show-atoms -rep balls
color-atoms 0x555555
spectrum-atoms -adjunct afem -scheme bwr -min-val -0.5 -max-val 0.5

### Calculate VoroMQA inter-chain interface frustration scores
restrict-atoms [-t! het]
construct-contacts
voromqa-global
voromqa-interface-frustration [-inter-chain] \
  -adj-contact-interface-frustration-energy-mean cifem \
  -smoothing-iterations 2
hide-contacts
spectrum-contacts [-inter-chain] -adjunct cifem -scheme bwr -min-val -2 -max-val 1
show-contacts [-inter-chain]

### Draw a subset of empty tangent spheres
construct-contacts
delete-figures -name et_spheres
add-figure-of-triangulation [] -strict \
  -min-radius 0.1 -max-radius 3.0 \
  -as-spheres -figure-name et_spheres
hide-figures
show-figures
color-figures 0xFF7777
hide-atoms
show-atoms -rep balls
color-atoms 0x7777FF

### Calculate geometric exposure values for surface atoms
restrict-atoms [-t! het]
construct-contacts
delete-adjuncts-of-atoms -adjuncts ev
describe-exposure -adj-atom-exposure-value ev \
  -probe-min 2.0 -probe-max 30 -expansion 1 \
  -smoothing-iterations 2 -smoothing-depth 1
hide-atoms
show-atoms
color-atoms 0x555555
spectrum-atoms -adjunct ev -scheme bwr # -min-val 0.1 -max-val 0.5

### Demo multiple representations
grid-by-object

import 4ung.pdb
spectrum-atoms -by chain -scheme co
hide-atoms
show-atoms -rep molsurf

import 4ung.pdb
spectrum-atoms -by chain -scheme co
hide-atoms
show-atoms -rep sticks
construct-contacts
select-contacts [-inter-chain] -name iface
color-contacts [iface] -col yellow
show-contacts [iface]
select-contacts [-solvent -a1 [-chain B]] -name sas_b
color-contacts [sas_b] -col orange
show-contacts [sas_b]

import 4ung.pdb
spectrum-atoms -by chain -scheme co
construct-contacts
select-contacts [-inter-chain] -name iface
color-contacts [iface] -rep edges -col black
spectrum-contacts [iface] -by residue-ids -scheme random
show-contacts [iface] -rep faces

import 4ung.pdb
spectrum-atoms -by chain -scheme co
color-atoms -col 0xBBBBBB
color-atoms [-chain A -rnum 16] -col cyan
color-atoms [-chain B -rnum 15] -col orange
show-atoms ([-chain A -rnum 16] or [-chain B -rnum 15]) -rep sticks
construct-contacts
select-contacts [-a1 [-chain A -rnum 16]] -name contacts_r1
select-contacts [-a1 [-chain B -rnum 15]] -name contacts_r2
color-contacts ([contacts_r1] or [contacts_r2])  -rep edges -col black
show-contacts ([contacts_r1] or [contacts_r2]) -rep edges
select-contacts [-inter-chain -a1 [-chain A -rnum 16] -a2 [-chain B -rnum 15]] -name iface
color-contacts [iface] -rep faces -col yellow
show-contacts [iface] -rep faces

### Demo mutate sidechains an rescore interface
grid-by-object

import 4ung.pdb -title 4ung_wt
restrict-atoms [-t! het]
hide-atoms
show-atoms -rep cartoon
spectrum-atoms -by chain -scheme oc
construct-contacts
voromqa-global
voromqa-interface-frustration [-inter-chain] \
  -adj-contact-interface-frustration-energy-mean cifem \
  -smoothing-iterations 2
hide-contacts
spectrum-contacts [-inter-chain] -adjunct cifem -scheme bwr -min-val -2 -max-val 1
show-contacts [-inter-chain]
show-atoms [-rname LEU] -rep sticks
color-atoms [-rname LEU] -col 0x00FF00

import 4ung.pdb -title 4ung_mutant
restrict-atoms [-t! het]
set-atom-names -use [-rname LEU] -residue-name ARG
faspr
hide-atoms
show-atoms -rep cartoon
spectrum-atoms -by chain -scheme oc
construct-contacts
voromqa-global
voromqa-interface-frustration [-inter-chain] \
  -adj-contact-interface-frustration-energy-mean cifem \
  -smoothing-iterations 2
hide-contacts
spectrum-contacts [-inter-chain] -adjunct cifem -scheme bwr -min-val -2 -max-val 1
show-contacts [-inter-chain]
show-atoms [-rname ARG] -rep sticks
color-atoms [-rname ARG] -col 0xFFFF00

### Demo analysis of empty space
grid-by-object

import 3szd.pdb -title 3szd1

construct-contacts
copy-object 3szd1 3szd2
copy-object 3szd1 3szd3

pick-objects 3szd1
show-atoms -rep sticks
spectrum-atoms -by residue-id

pick-objects 3szd2
delete-figures -name et_spheres
add-figure-of-triangulation [] -strict \
  -min-radius 1.3 -max-radius 10.0 \
  -as-spheres -figure-name et_spheres
hide-figures
show-figures
color-figures 0xFF7777
hide-atoms
show-atoms -rep balls
spectrum-atoms -by residue-id

pick-objects 3szd3
delete-adjuncts-of-atoms -adjuncts ev
describe-exposure -adj-atom-exposure-value ev \
  -probe-min 2.0 -probe-max 30 -expansion 1 \
  -smoothing-iterations 2 -smoothing-depth 1
hide-atoms
show-atoms
color-atoms 0x555555
spectrum-atoms -adjunct ev -scheme bwr

### Demo analysis membrane protein
grid-by-object

import 3szd.pdb -title 3szd1
construct-contacts
copy-object 3szd1 3szd2

pick-objects 3szd1
delete-adjuncts-of-atoms -adjuncts ev
describe-exposure -adj-atom-exposure-value ev \
  -probe-min 2.0 -probe-max 30 -expansion 1 \
  -smoothing-iterations 2 -smoothing-depth 1
hide-atoms
show-atoms
color-atoms 0x555555
spectrum-atoms -adjunct ev -scheme bwr -min-val 0.0 -max-val 0.9

pick-objects 3szd2
voromqa-global
voromqa-frustration -adj-atom-frustration-energy-mean afem \
  -adj-contact-frustration-energy-mean cfem \
  -smoothing-iterations 1 -smoothing-depth 3
hide-atoms
show-atoms -rep balls
color-atoms 0x555555
spectrum-atoms -adjunct afem -scheme bwr

copy-object 3szd2 3szd3
pick-objects 3szd3
construct-contacts
voromqa-global
voromqa-frustration \
  -smoothing-iterations 3 -smoothing-depth 1
describe-exposure \
  -probe-min 2.0 -probe-max 30 -expansion 1 \
  -smoothing-iterations 3 -smoothing-depth 1
voromqa-membrane-place \
  -adj-atom-weighted-membrane-place-value weighted_membrane_place_value \
  -membrane-width 20 -membrane-width-extended 24
set-adjunct-of-atoms-by-expression \
  -use [-v weighted_membrane_place_value] -expression _logistic \
  -input-adjuncts weighted_membrane_place_value \
  -parameters 1 30 0.3 -output-adjunct area_alt_part
set-adjunct-of-contacts-by-atom-adjuncts \
  -atoms [-v area_alt_part=0.01:1] \
  -contacts [-solvent] -source-name area_alt_part \
  -destination-name area_alt_part -pooling-mode min
hide-atoms
hide-contacts
color-contacts -col yellow
spectrum-contacts -adjunct area_alt_part -scheme bwr -min-val 0 -max-val 1
show-contacts [-solvent] -rep faces

import 3szd.pdb -include-heteroatoms -title 3szd_opm
restrict-atoms [-rname DUM]
hide-atoms
show-atoms -rep balls
color-atoms 0x777777

### Demo ensemble contacts
import-session ensemble.vses
pick-objects
hide-atoms
show-atoms -rep sticks
spectrum-atoms
construct-contacts-radically-fast -no-intra-residue -generate-graphics
show-contacts [-a1 [-rnum 1:30] -a2 [-rnum 170:9999] -no-solvent]
spectrum-contacts -by area -min-val 0 -max-val 15 -scheme wm
animate-loop-picked-objects -time-step 200

### Demo layers of contacts
import 4ung.pdb -title objB0

copy-object objB0 objB1
pick-objects objB1
construct-contacts-radically-fast -generate-graphics -no-intra-chain -restrict-circle -0.4 -thicken-graphics 0.002
show-contacts [-inter-chain] -rep faces
color-contacts -col 0x00FFFF

copy-object objB0 objB2
pick-objects objB2
construct-contacts-radically-fast -generate-graphics -no-intra-chain -restrict-circle -0.8 -thicken-graphics 0.003
show-contacts [-inter-chain] -rep faces
color-contacts -col 0x00AA00

copy-object objB0 objB3
pick-objects objB3
construct-contacts-radically-fast -generate-graphics -no-intra-chain -restrict-circle -1.2  -thicken-graphics 0.004
show-contacts [-inter-chain] -rep faces
color-contacts -col 0xFFFF00

copy-object objB0 objB4
pick-objects objB4
construct-contacts-radically-fast -generate-graphics -no-intra-chain -restrict-circle -1.6  -thicken-graphics 0.005
show-contacts [-inter-chain] -rep faces
color-contacts -col 0xFF2222

copy-object objB0 objB5
pick-objects objB5

construct-contacts-radically-fast -generate-graphics -no-intra-chain -adjunct-circle-restrictions -1.6 -1.2 -0.8 -0.4 -0.0000001

show-contacts [-inter-chain] -rep faces
color-contacts -col 0xAA22FF

pick-objects
hide-atoms

delete-objects objB0

show-contacts [-inter-chain] -rep edges
color-contacts -rep edges -col 0x000000

select-contacts [-inter-chain] -name iface -on-objects objB5
orient -atoms [-sel-of-contacts iface]
rotate -angle -90 -axis 0 0 1

color-atoms [-chain A] -col 0xCCCCCC
color-atoms [-chain B] -col 0xFFAA88
show-atoms -rep cartoon sticks -on-objects objB5
rotate -angle 180 -axis 0 1 0

### Demo VCBlock
import 4ung.pdb
select-atoms [-chain A -rnum 16] -name asel1
select-atoms [-chain B -rnum 15] -name asel2
construct-contacts-radically-fast -calculate-adjacencies -generate-graphics
vcblocks -sel-for-display [-a1 [asel1] -a2 [asel2]]
select-contacts [-a1 [asel1] -no-solvent] -name csel1
select-contacts [-a1 [asel2] -no-solvent] -name csel2
select-atoms ([-sel-of-contacts csel1] and [-sel-of-contacts csel2]) -full-residues -name aselCommon
hide-atoms
show-atoms [aselCommon] -rep sticks
color-atoms [aselCommon] -col 0xFFFFFF
color-atoms ([asel1] or [asel2]) -col 0xFFBBFF
color-contacts -col black -rep edges
spectrum-contacts -by residue-ids -rep faces -scheme rygwbwbcgyr
zoom-by-atoms [-sel-of-contacts _visible]

