define bg  (*.n4,*.n6,*.n7, *.o4,*.o6, *.c5,*.c6, (*.c4,*.c7 and pyrimidine), (*.c8 and purine)) and dna
define sg  (*.o2,*.n3,*.n2,*.c2,(*.c4 and purine)) and dna
define dez (*.C?*,*.O?*) and dna

define phos_pol *.O?P and dna
define phos_npol *.P and dna

echo "Polar atoms in phosphoric acid -- set 'phos_pol' "
echo "Nonpolar atoms in phosphoric acid -- set 'phos_npol' "
echo "     "

define pol *.O??, *.N??
define npol *.C??, *.P??, *.S??

define dez_pol (dez and pol)
define dez_npol (dez and npol)
echo "Polar atoms in deoxyribose -- set 'dez_pol' "
echo "Nonpolar atoms in deoxyribose -- set 'dez_npol' "
echo "     "

define bg_pol (bg and pol)
define bg_npol (bg and npol)
echo "Polar atoms in major groove -- set 'bg_pol' "
echo "Nonpolar atoms in major groove -- set 'bg_npol' "
echo "     "

define sg_pol (sg and pol)
define sg_npol (sg and npol)                                         
echo "Polar atoms in minor groove -- set 'sg_pol' "
echo "Nonpolar atoms in minor groove -- set 'sg_npol' "
echo "     "

define prot_pol (protein and pol)
define prot_npol (protein and npol)
echo "Polar atoms in protein -- set 'prot_pol' "
echo "Nonpolar atoms in protein -- set 'prot_npol' "
 
define p1 within(3.5,dez_pol)  and prot_pol
define p2 within(3.5,phos_pol)  and prot_pol
define p3 within(3.5,bg_pol) and prot_pol
define p4 within(3.5,sg_pol) and prot_pol

define np1 within(4.5,dez_npol) and prot_npol
define np2 within(4.5,phos_npol) and prot_npol
define np3 within(4.5,bg_npol) and prot_npol
define np4 within(4.5,sg_npol) and prot_npol
pause

restrict none
select prot_pol
cpk 30
color red

select prot_pol
cpk 30
color red
select prot_npol
cpk 30
color blue

select dna
backbone 40
color yellow
pause

select p1
color green
cpk 100
echo "polar: dez & protein"
pause
select p1
cpk off

select p2
color green
cpk 100
echo "polar: phosphorus & prootein"
pause
select p2
cpk off

select p3
color green
cpk 100
echo "polar: major groove & protein"
pause
select p3
cpk off

select p4
color green
cpk 100
echo "polar: minor groove & protein"
pause
select p4
cpk off

select np1
color green
cpk 100
echo "non-polar: dez & protein"
pause
select np1
cpk off

select np2
color green
cpk 100
echo "non-polar: phosphorus & protein"
pause
select np2
cpk off

select np3
color green
cpk 100
echo "non-polar: major groove & protein"
pause
select np3
cpk off

select np4
color green
cpk 100
echo "non-polar: minor groove & protein"
pause
select np4
cpk off

