; first tentative rule firl for assigning AMBER and GlyCam atom types. This
; is still *ALPHA* code. Use at your own risk. Use this file with
; BALL/source/APPLICATIONS/UTILITIES/assign_typenames_from_rules.
;
; Some of these rules are directly copied from HyperChem assignment rules.
;
; PLEASE note that this file has only been used on sugars yet, so don't
; expect it to work with proteins too well.
;
; Note that these rules use special atom types for certain properties:
;
; Atom type 'E' means that the atom in focus is more electronegative than
; the one which we are about to give a type. This is the same in HyperChem.
; 
; Atom type 'A' discriminates axially substituted C in sugar rings.
; 

[TypenameRules:C]
; equatorial C in sugars 
EC = sp3Hybridized() AND inRing(6) AND connectedTo(CCCC(O)(C)) AND !isAxial()
; equatorial C in sugars 
AC = sp3Hybridized() AND inRing(6) AND connectedTo(CCCC(O)(C)) AND isAxial()
; any sp3 (four explicit substituents)
CT = sp3Hybridized()
; any sp2 carbonyl carbon
C  = sp2Hybridized() AND connectedTo(=O)
; sp2 aromatic carbon in a five-membered ring next to two carbons (e.g.
; C_gamma in tryptophan)
C* = sp2Hybridized() AND inRing(5) AND connectedTo((~C)(~C))
; any sp2 aromatic carbon...
CA = sp2Hybridized() AND connectedTo((~*)(~*))
; ...and C_epsilon of Arg (don't know what this means exactly ?????)
CA = sp2Hybridized() AND connectedTo((NH2)(NH2)(NH))
; sp2 aromatic at junction of five- and six-membered rings (e.g. C_delta in
; tryptophan and C4 and C5 in purines Ade & Gua).
CB = sp2Hybridized() AND inRing(5) AND inRing(6) AND connectedTo(CN)
CB = sp2Hybridized() AND inRing(5) AND connectedTo((C)(C)CNFe)
; sp2 aromatic in a five-membered ring with one substituent and next to a
; nitrogen (e.g. C_gamma in histidine).
CC = sp2Hybridized() AND inRing(5) AND connectedTo(NCCC)
; sp2 aromatic in a five-membered ring, between two nitrogens and bonded to
; one explicit hydrogen (C8 in purines).
CK = sp2Hybridized() AND inRing(5) AND connectedTo((~N)(~N)(-H))
; sp2 carbon, more double bonded character than benzene
;CS = ?????
; sp2 aromatic junction between five- and six-membered rings and bonded to
; C-R and N-R (e.g. C_epsilon in Trp).
CN = sp2Hybridized() AND inRing(5) AND inRing(6) AND connectedTo((NH)(CH))
; sp2 in six-membered ring between two lone pair nitrogens (e.g. C2 in
; purines).
;CQ = sp2Hybridized() AND inRing(6) AND ?????
; sp2 aromatic in a five-membered ring between two nitrogens (e.g.
; C_epsilon in histidine).
CR = sp2Hybridized() AND inRing(5) AND connectedTo((N)(N))
; sp2 aromatic in a five-membered ring next to a carbon and a lone pair
; nitrogen (e.g. C_delta in His(delta)).
CV = sp2Hybridized() AND inRing(5) AND connectedTo((C)(N))
; sp2 aromatic in a five-membered ring next to a carbon and NH (e.g.
; C_delta in His(epsilon) and in Trp).
CW = sp2Hybridized() AND inRing(5) AND connectedTo((C)(NH))
; default: no type
? = true()

[TypenameRules:N]
; ?????
; The hybridization predicates DO NOT WORK FOR NITROGENS! Fixme. Soon.
; any sp3 (four substituents; e.g. lysine-Nzeta). 
N3 = sp3Hybridized()
; sp2 in amides
N  = sp2Hybridized() AND connectedTo(C=O)
; ????? This is a fast hack for using this file for sugars for the moment.
N  = connectedTo((-*)(-*)(C=O))
; sp2 in five- or six-membered ring with substituent (e.g. N9 in purines,
; N1 in pyrimidines).
N* = sp2Hybridized() AND inRing(5) AND connectedTo((@1*****@1)(C))
N* = sp2Hybridized() AND inRing(6) AND connectedTo((@1******@1)(C))
; sp2 in amines (e.g. nucleic acids, Arg, and guanidium ions).
; ????? Klammerung
N2 = sp2Hybridized() AND connectedTo((C)(H)(H)) OR connectedTo((C)(C)(H)) OR connectedTo((C)(C)(C))
; sp2 in aromatic rings with attached hydrogen (e.g. Gua, Trp, protonated
; His)
NA = sp2Hybridized() AND inRing(5) AND connectedTo((*~*)(*~*)(H))
NA = sp2Hybridized() AND inRing(6) AND connectedTo((*~*)(*~*)(H))
; sp2 in five-membered ring with lone pair (e.g. N7 in purines)
NB = sp2Hybridized() AND inRing(5) 
; sp2 in six-membered ring with lone pair (e.g. N3 in purines)
NC = sp2Hybridized() AND inRing(6) 
 
[TypenameRules:O]
; oxygen in TIP3P water model
OW = sp3Hybridized() AND connectedTo((H)(H))
; alcohols, tyrosine, and protonated carboxylic acids
OH = sp3Hybridized() AND connectedTo((C)(H))
; RING OXYGEN FOR L- AND 1C4(D) SUGARS
OL = sp3Hybridized() AND connectedTo((A(C)(C))(C)) AND inRing() AND is4C1()
; glycosidic oxygn
OG = sp3Hybridized() AND connectedTo((C)(C)) AND !inRing()
; ethers and esters
OS = sp3Hybridized() AND connectedTo((C)(C)) AND inRing()
; anionic acids (e.g. carboxyl and phosphate)
O2 = sp2Hybridized() AND connectedTo(CO)
; carbonyl
O  = sp2Hybridized() AND connectedTo(=C)
; default: no type
? = true()

[TypenameRules:H]
; attached to N
H  = connectedTo(N)
; in alchohols and acids
HO = connectedTo(OC)
; in TIP3P water model
HW = connectedTo(OH)
; attached to sulfur
HS = connectedTo(S)
; attached to aromatic carbon
HA = connectedTo(C(~.)(~.))
HA = connectedTo(-C@1=CNC(=O)NCC@1)
; attached to aromatic carbon with two electronegative neighbors (e.g. H8
; of Ade and Gua and H2 of Ade)
H5 = connectedTo(C(~E)(E))
H5 = connectedTo(-C@1=N-C=C-N-C@1)
; attached to aromatic carbon with one electronegative neighbor (e.g. C5 of
; Trp, C6 of Thy).
H4 = connectedTo(C(~E))
H4 = connectedTo(-C@1NC(=O)NCC=C@1)
; attached to aliphatic carbon with three electron-withdrawing substituents
H3 = connectedTo(-C(-E)(-E)(-E)) 
; attached to aliphatic carbon with two electron-withdrawing substituents
H2 = connectedTo(-C(-E)(-E)(-*)) 
; attached to aliphatic carbon with one electron-withdrawing substituent
H1 = connectedTo(-C(-E)(-*)(-*)) 
; attached to aliphatic carbon with no electron-withdrawing substituents
HC = connectedTo(-C(-*)(-*)(-*)) OR connectedTo(-C(=*)(-*))
; attached to carbon directly bonded to formally positive atoms (e.g. C
; next to NH3+ of Lys)
HP = connectedTo(C~NH)
HP = connectedTo(CC(*)(*)(*)(*))
HP = connectedTo(CN(*)(*)(*))
HP = connectedTo(CP(*)(*)(*))
HP = connectedTo(CO(*)(*)(*))
; default: no type
? = true()

[TypenameRules:P]
; default 
P = true()

[TypenameRules:S]
; sulfurs in disulfide linkages
S  = connectedTo(S)
; sulfur in cysteine
SH = connectedTo((C)(H))
; default: no type
? = true()

[TypenameRules:LP]
; default
LP = true()
