def setAtomTypeForSulfurs(self, mol): num_atoms = len(mol.atoms) atom = Atom() atom_linked = Atom() index = -1 i = 0 while i < num_atoms: atom = mol.atoms[i] if atom.element.lower() == "S".lower(): atom_linked = mol.atoms[atom.linkage[0]] if atom.num_linkages == 2: # SG311: sulphur, SH, -S- atom.atomType = "SG311" if not atom.isRingAtom: if atom.isThiocarbonylS: # SG2D1: thiocarbonyl S atom.atomType = "SG2D1" elif atom.num_linkages == 2 and atom.numSulfurAtoms == 1 and atom.numCarbonAtoms == 1: # SG301: sulfur C-S-S-C type atom.atomType = "SG301" elif atom.isDeprotonatedSulfur: # SG302: thiolate sulfur (-1) atom.atomType = "SG302" elif atom.num_linkages == 3 and atom.numCarbonAtoms == 2 and atom.numOxygenAtoms == 1: # SG3O3: neutral sulfoxide sulfur atom.atomType = "SG3O3" if atom.numOxygenAtoms >= 2: charge = self.getCharge(mol, i) if charge == -1: # SG3O1: sulfate -1 sulfur atom.atomType = "SG3O1" elif charge == 0: # SG3O2: neutral sulfone/sulfonamide sulfur atom.atomType = "SG3O2" else: if atom.numOxygenAtoms >= 2 and self.getCharge(mol, i) == 0: # SG3O2: neutral sulfone/sulfonamide sulfur atom.atomType = "SG3O2" elif atom.numRingAtoms[0] == 5: # SG2R50: THIP, thiophene atom.atomType = "SG2R50" i += 1
def setAtomTypeForMiscellaneousAtoms(self, mol): num_atoms = len(mol.atoms) atom = Atom() atom_linked = Atom() index = -1 i = 0 while i < num_atoms: atom = mol.atoms[i] if atom.element.lower() == "P".lower(): if atom.numSulfurAtoms == 0: charge = self.getCharge(mol, i) if charge == 0: # PG0: neutral phosphate atom.atomType = "PG0" elif charge == -1: # PG1: phosphate -1 atom.atomType = "PG1" elif charge == -2: # PG2: phosphate -2 atom.atomType = "PG2" else: j = 0 while j < atom.num_linkages: atom_linked = mol.atoms[atom.linkage[j]] if atom_linked.element.lower() == "O".lower( ) and atom_linked.num_linkages == 1: # OG2S1: mono-thio S-P bond modulated oxygen; lsk atom_linked.atomType = "OG2S1" j += 1 elif atom.element.lower() == "LP".lower(): # LPH: Lone pair for halogens atom.atomType = "LPH" elif atom.element.lower() == "AL".lower(): if self.countSpecificElement(mol, i, "F") == 4: # ALG1: Aluminum, for ALF4, AlF4- atom.atomType = "ALG1" elif atom.element.lower() == "S".lower(): if atom.num_linkages == 1: atom_linked = mol.atoms[atom.linkage[0]] if atom_linked.element.lower() == "P".lower(): if num_S == 1: # SG2P1: mono-thio S-P bond; lsk atom.atomType = "SG2P1" elif num_S == 2: # SG2P2: di-thio S-P bond; lsk atom.atomType = "SG2P2" i += 1
def setAtomTypeForHydrogens(self, mol): num_atoms = len(mol.atoms) atom = Atom() atom_linked = Atom() i = 0 while i < num_atoms: atom = mol.atoms[i] if atom.element.lower() == "H".lower(): atom_linked = mol.atoms[atom.linkage[0]] element = atom_linked.element atomType = atom_linked.atomType if atom_linked.isAromatic: # HGR61: aromatic H atom.atomType = "HGR61" if element.lower() == "C".lower(): if not atom_linked.isAromatic: if atom_linked.numHydrogenAtoms == 1: # HGA1: alphatic proton, CH atom.atomType = "HGA1" elif atom_linked.numHydrogenAtoms == 2: # HGA2: alphatic proton, CH2 atom.atomType = "HGA2" elif atom_linked.numHydrogenAtoms == 3: # HGA3: alphatic proton, CH3 atom.atomType = "HGA3" if self.hasCarbonDoubleBond(mol, atom_linked): if atom_linked.numHydrogenAtoms == 1: # HGA4: alkene proton; RHC= atom.atomType = "HGA4" elif atom_linked.numHydrogenAtoms == 2: # HGA5: alkene proton; H2C=CR atom.atomType = "HGA5" num_fluorides = self.countSpecificElement( mol, atom_linked, "F") if num_fluorides > 0: if num_fluorides == 1: # HGA6: aliphatic H on fluorinated C, monofluoro atom.atomType = "HGA6" elif num_fluorides == 2: # HGA7: aliphatic H on fluorinated C, difluoro atom.atomType = "HGA7" if atom_linked.numNitrogenAtoms > 0: index = self.getIndex(mol, atom_linked, "N") if not mol.atoms[index].isProtonatedNitrogen: num_methyl = self.countMethyl( mol, mol.atoms[index]) if num_methyl == 3 and mol.atoms[ index].numHydrogenAtoms == 0: # HGAAM0: aliphatic H, NEUTRAL trimethylamine (#) atom.atomType = "HGAAM0" elif num_methyl == 2 and mol.atoms[ index].numHydrogenAtoms == 1: # HGAAM1: aliphatic H, NEUTRAL dimethylamine (#) atom.atomType = "HGAAM1" elif num_methyl == 1 and mol.atoms[ index].numHydrogenAtoms == 2: # HGAAM2: aliphatic H, NEUTRAL methylamine (#) atom.atomType = "HGAAM2" if atom_linked.numHydrogenAtoms == 3 and atom_linked.numNitrogenAtoms == 1: if mol.atoms[index].atomType.lower( ) == "NG3P0".lower(): # HGP5: polar H on quarternary ammonium salt (choline) atom.atomType = "HGP5" if atom_linked.num_linkages == 2 and self.hasTripleBond( atom_linked): # HGPAM1: polar H, NEUTRAL dimethylamine (#), terminal alkyne H atom.atomType = "HGPAM1" # HGR52: Aldehyde H, formamide H (RCOH); nonpolar H, neutral 5-mem planar ring C adjacent to heteroatom or + charge # CG201, CG202, CG203, CG204 # CG2R51, CG2R52, CG2R53 linked to heteroatom # CG2D1, CG2DC1 linked to protonated N if atomType != None and ( atomType.lower() == "CG2O1".lower() or atomType.lower() == "CG2O2".lower() or atomType.lower() == "CG2O3".lower() or atomType.lower() == "CG2O4".lower()): atom.atomType = "HGR52" elif atomType != None and ( atomType.lower() == "CG2R51".lower() or atomType.lower() == "CG2R52".lower() or atomType.lower() == "CG2R53".lower()) and self.hasHeteroAtom( mol, atom_linked): atom.atomType = "HGR52" elif atomType != None and ( atomType.lower() == "CG2D1".lower() or atomType.lower() == "CG2DC1".lower() ) and self.hasProtonatedNitrogen(mol, atom_linked): atom.atomType = "HGR52" if atomType != None and atomType.lower() == "CG2R53".lower( ) and self.hasProtonatedNitrogen(mol, atom_linked): # HGR53: nonpolar H, +ve charge HIS he1(+1) atom.atomType = "HGR53" if atom_linked.isAromatic and atom_linked.numRingAtoms[ 0] == 5 and atomType.lower() == "CG2R51".lower( ) and not self.hasHeteroAtom(mol, atom_linked): # HGR51: nonpolar H, neutral 5-mem planar ring C, LJ based on benzene atom.atomType = "HGR51" if atom_linked.isRingAtom: if atom_linked.isAromatic: if atom_linked.numRingAtoms[0] == 6: if self.isTypeHGR62(mol, atom_linked): # HGR62: nonpolar H, neutral 6-mem planar ring C adjacent to heteroatom atom.atomType = "HGR62" if atom_linked.isProtonatedPyridine or atom_linked.isProtonatedPyrimidine: # HGR63: nonpolar H, NAD+ nicotineamide all ring CH hydrogens atom.atomType = "HGR63" elif atom_linked.numRingAtoms[0] == 7: # HGR71: nonpolar H, neutral 7-mem arom ring, AZUL, azulene, kevo atom.atomType = "HGR71" elif element.lower() == "N".lower(): if not atom_linked.isAromatic: if not atom_linked.isProtonatedNitrogen: num_methyl = self.countMethyl(mol, atom_linked) if num_methyl == 2: # HGAAM1: aliphatic H, NEUTRAL dimethylamine (#) atom.atomType = "HGAAM1" elif num_methyl == 1: # HGAAM2: aliphatic H, NEUTRAL methylamine (#) atom.atomType = "HGAAM2" if atomType != None and atomType.lower() == "NG311".lower( ): if atom_linked.numCarbonAtoms == 2: # HGPAM1: polar H, NEUTRAL dimethylamine (#), terminal alkyne H atom.atomType = "HGPAM1" elif atom_linked.numCarbonAtoms == 1 and ( atom_linked.numSulfurAtoms == 1 or atom_linked.numOxygenAtoms == 1): # HGP1: polar H atom.atomType = "HGP1" elif atomType != None and atomType.lower( ) == "NG321".lower(): if atom_linked.numCarbonAtoms == 1: # HGPAM2: polar H, NEUTRAL methylamine (#) atom.atomType = "HGPAM2" elif atom_linked.numSulfurAtoms == 1: # HGP1: polar H atom.atomType = "HGP1" elif atom_linked.num_linkages == 3 and not atom_linked.isProtonatedNitrogen and atom_linked.numHydrogenAtoms == 3: # HGPAM3: polar H, NEUTRAL ammonia (#) atom.atomType = "HGPAM3" if atomType != None and ( atomType.lower() == "NG2P1".lower() or atomType.lower() == "NG3P3".lower() or atomType.lower() == "NG2R52".lower() or atomType.lower() == "NG3P2".lower() or atomType.lower() == "NG3P1".lower()): # HGP2: polar H, +ve charge # NG2P1, NG3P3, NG2R52, NG3P2, NG3P1 atom.atomType = "HGP2" elif atomType != None and atomType.lower( ) == "NG2P1".lower(): # HGP3: polar H, thiol atom.atomType = "HGP3" elif element.lower() == "S".lower(): if atomType != None and atomType.lower() == "SG311".lower( ): # HGP3: polar H, thiol atom.atomType = "HGP3" if atomType != None and ( atomType.lower() == "OG311".lower() or atomType.lower() == "NG2S2".lower() or atomType.lower() == "NG2S1".lower() or atomType.lower() == "NG2R51".lower() or atomType.lower() == "NG2S3".lower() or atomType.lower() == "NG2R61".lower() or atomType.lower() == "NG2D1".lower() or atomType.lower() == "NG3C51".lower() or atomType.lower() == "NG2R53".lower() or atomType.lower() == "NG3N1".lower() or atomType.lower() == "NG2R43".lower()): # HGP1: polar H # OG311, NG2S2, NG2S1, NG2R51, NG2S3, # NG2R61, NG2D1, NG3C51, NG2R53, NG3N1, # NG2R43 atom.atomType = "HGP1" if atomType.lower() == "NG321".lower( ) and atom_linked.numSulfurAtoms == 1: atom.atomType = "HGP1" if atom_linked.isProtonatedNitrogen and atomType.lower( ) == "NG2R61".lower(): # HGP2: polar H, +ve charge atom.atomType = "HGP2" if atom_linked.element.lower() == "N".lower( ) and not atom_linked.isProtonatedNitrogen and atom_linked.numHydrogenAtoms == 2 and self.hasAromaticBond( mol, atom_linked): # HGP4: polar H, neutral conjugated -NH2 group (NA bases) atom.atomType = "HGP4" i += 1
def setAtomTypeForOxygens(self, mol): num_atoms = len(mol.atoms) atom = Atom() atom_linked = Atom() index = -1 i = 0 while i < num_atoms: atom = mol.atoms[i] if atom.element.lower() == "O".lower(): atom_linked = mol.atoms[atom.linkage[0]] if not atom.isRingAtom: if atom_linked.isCarbonyl: if atom_linked.numRingAtoms[ 0] == 6 and atom_linked.isAromatic: # OG2D4: 6-mem aromatic carbonyl oxygen (nucleic bases) atom.atomType = "OG2D4" elif atom_linked.numRingAtoms[0] == 5: if not atom_linked.isKetone and ( atom_linked.isAmide or atom_linked.isEster): if not atom.isDeprotonatedOxygen: # OG2D1: carbonyl O: amides, esters, [neutral] carboxylic acids, aldehydes, uera atom.atomType = "OG2D1" elif atom.num_linkages == 2 and atom.numHydrogenAtoms == 1: # OG311: hydroxyl oxygen atom.atomType = "OG311" else: if not atom_linked.isKetone and ( atom_linked.isAmide or atom_linked.isEster): if not atom.isDeprotonatedOxygen: # OG2D1: carbonyl O: amides, esters, [neutral] carboxylic acids, aldehydes, uera atom.atomType = "OG2D1" else: # OG2D2: carbonyl O: negative groups: carboxylates, carbonate atom.atomType = "OG2D2" else: # OG2D3: carbonyl O: ketones atom.atomType = "OG2D3" elif self.isTypeOG2D5(mol, i): # OG2D5: CO2 oxygen atom.atomType = "OG2D5" elif atom_linked.atomType != None and atom_linked.atomType.lower( ) == "NG2O1".lower(): # OG2N1: NITB, nitrobenzene atom.atomType = "OG2N1" elif atom.isPOxide or atom.isSOxide: if atom.num_linkages == 1: # OG2P1: =O in phosphate or sulfate atom.atomType = "OG2P1" elif atom.num_linkages == 2 and atom.numHydrogenAtoms == 0: # OG303: phosphate/sulfate ester oxygen atom.atomType = "OG303" elif atom.num_linkages == 2 and atom.numHydrogenAtoms == 1: # OG311: hydroxyl oxygen atom.atomType = "OG311" elif atom.num_linkages == 2 and atom.numHydrogenAtoms == 1: # OG311: hydroxyl oxygen atom.atomType = "OG311" elif atom.num_linkages == 2 and atom.numCarbonAtoms == 2: # OG301: ether -O- !SHOULD WE HAVE A SEPARATE ENOL ETHER??? IF YES, SHOULD WE MERGE IT WITH OG3R60??? atom.atomType = "OG301" if atom.isEster and atom.num_linkages == 2 and atom.numCarbonAtoms == 2: # OG302: ester -O- atom.atomType = "OG302" elif self.isTypeOG304(mol, i): # OG304: linkage oxygen in pyrophosphate/pyrosulphate atom.atomType = "OG304" elif not atom.isEster and atom.isDeprotonatedOxygen and ( atom.numCarbonAtoms == 1 or atom.numNitrogenAtoms == 1): # OG312: ionized alcohol oxygen atom.atomType = "OG312" else: if atom.isFuran: # OG2R50: FURA, furan atom.atomType = "OG2R50" elif atom.isFuranose: # OG3C51: 5-mem furanose ring oxygen (ether) atom.atomType = "OG3C51" elif atom.numRingAtoms[0] == 6: # OG3R60: O in 6-mem cyclic enol ether (PY01, PY02) or ester atom.atomType = "OG3R60" if not self.linkedCarbonHasDoundBond(mol, i): # OG3C61: DIOX, dioxane, ether in 6-membered ring !SHOULD WE MERGE THIS WITH OG3R60??? atom.atomType = "OG3C61" elif atom.numRingAtoms[ 0] == 3 and atom.num_linkages == 2 and atom.numCarbonAtoms == 2: # OG3C31: epoxide oxygen, 1EOX, 1BOX, sc atom.atomType = "OG3C31" i += 1
def setAtomTypingNitrogen(self, mol): num_atoms = len(mol.atoms) atom = Atom() iminCarbonIndex = -1 i = 0 while i < num_atoms: atom = mol.atoms[i] if atom.element.lower() == "N".lower(): # NG1T1: N for cyano group if self.getIndexAtomType(mol, i, "CG1N1") != -1: atom.atomType = "NG1T1" # NG2D1: N for neutral imine/Schiff's base (C=N-R, acyclic amidine, gunaidine) # NG2P1: N for protonated imine/Schiff's base (C=N(+)H-R, acyclic amidinium, guanidinium) iminCarbonIndex = self.getIndexOfImineCarbon(mol, i) if iminCarbonIndex != -1: if not mol.atoms[iminCarbonIndex].isProtonatedImineGroup: atom.atomType = "NG2D1" else: atom.atomType = "NG2P1" if atom.isAmide: if atom.num_linkages == 3: if atom.numHydrogenAtoms == 0: # NG2S0: N,N-disubstituted amide, proline N (CO=NRR') atom.atomType = "NG2S0" elif atom.numHydrogenAtoms == 1: # NG2S1: peptide nitrogen (CO=NHR) atom.atomType = "NG2S1" elif atom.numHydrogenAtoms == 2: # NG2S2: terminal amide nitrogen (CO=NH2) atom.atomType = "NG2S2" if atom.isRingAtom: if not atom.isBridgingAtom: if atom.isAmide and atom.numRingAtoms[0] == 4: # NG2R43: amide in 4-memebered ring (planar), AZDO, lsk atom.atomType = "NG2R43" elif atom.numRingAtoms[0] == 5: if not atom.isProtonatedNitrogen and atom.num_linkages == 2 and atom.numHydrogenAtoms == 0: # NG2R50: double bound neutral 5-mem planar ring, purine N7 atom.atomType = "NG2R50" elif not atom.isProtonatedNitrogen and atom.num_linkages == 3: if atom.isAromatic: # NG2R51: single bound neutral 5-mem planar (all atom types sp2) ring, his, trp pyrrole (fused) atom.atomType = "NG2R51" if self.isTypeNG2R53(mol, i): # NG2R53: amide in 5-memebered NON-SP2 ring (slightly pyramidized), 2PDO, kevo atom.atomType = "NG2R53" if self.isBipyrroleNitrogen(mol, i): # NG2R57: 5-mem ring, bipyrroles atom.atomType = "NG2R57" if not atom.isAromatic and ( atom.numHydrogenAtoms == 0 or atom.numHydrogenAtoms == 1) and not atom.isAmide: # NG3C51: secondary sp3 amine in 5-membered ring atom.atomType = "NG3C51" elif iminCarbonIndex != -1 and mol.atoms[ iminCarbonIndex].isProtonatedImineGroup: # NG2R52: protonated schiff base, amidinium, guanidinium in 5-membered ring, HIS, 2HPP, kevo atom.atomType = "NG2R52" elif atom.isAromatic and atom.num_linkages == 3 and not self.hasDoubleBond( mol, i): # NG2R51: single bound neutral 5-mem planar (all atom types sp2) ring, his, trp pyrrole (fused) atom.atomType = "NG2R51" elif atom.numRingAtoms[0] == 6: if atom.isAromatic and atom.numHydrogenAtoms == 0: # NG2R60: double bound neutral 6-mem planar ring, pyr1, pyzn atom.atomType = "NG2R60" if atom.isAromatic and (self.hasCarbonyl(mol, i) or atom.isProtonatedNitrogen): # NG2R61: single bound neutral 6-mem planar ring imino nitrogen; glycosyl linkage atom.atomType = "NG2R61" if self.isTypeNG2R62(mol, i): # NG2R62: double bound 6-mem planar ring with heteroatoms in o or m, pyrd, pyrm atom.atomType = "NG2R62" if self.isTypeNG2R67(mol, i): # NG2R67: 6-mem planar ring substituted with 6-mem planar ring (N-phenyl pyridinones etc.) atom.atomType = "NG2R67" else: if self.isTypeNG2RC0(mol, i): # NG2RC0: 6/5-mem ring bridging N, indolizine, INDZ, kevo atom.atomType = "NG2RC0" if not atom.isAmide and not atom.isProtonatedNitrogen and iminCarbonIndex == -1: if self.isTypeNG301(mol, i): # NG301: neutral trimethylamine nitrogen atom.atomType = "NG301" elif atom.numRingAtoms[0] != 5 and self.isTypeNG311( mol, i): # NG311: neutral dimethylamine nitrogen atom.atomType = "NG311" elif self.isTypeNG321(mol, i): # NG321: neutral methylamine nitrogen atom.atomType = "NG321" elif atom.num_linkages == 3 and atom.numHydrogenAtoms == 3: # NG331: neutral ammonia nitrogen atom.atomType = "NG331" elif self.isTypeNG3N1(mol, i): # NG3N1: N in hydrazine, HDZN atom.atomType = "NG3N1" # NG2S3: external amine ring nitrogen (planar/aniline), phosphoramidate (PO3-NR2), sulfamate (SO3-NR2) if self.isTypeNG2S3(mol, i): atom.atomType = "NG2S3" # NG2O1: NITB, nitrobenzene if atom.num_linkages == 3 and atom.numOxygenAtoms == 2 and atom.numCarbonAtoms == 1: atom.atomType = "NG2O1" if not atom.isRingAtom and atom.isProtonatedNitrogen and atom.numHydrogenAtoms == 0: # NG3P0: quarternary N+, choline atom.atomType = "NG3P0" elif atom.isRingAtom and not atom.isAromatic and atom.isProtonatedNitrogen and atom.numHydrogenAtoms == 1: # NG3P1: tertiary NH+ (PIP) atom.atomType = "NG3P1" elif atom.isRingAtom and not atom.isAromatic and atom.isProtonatedNitrogen and atom.numHydrogenAtoms == 2: # NG3P2: secondary NH2+ (proline) atom.atomType = "NG3P2" elif not atom.isRingAtom and atom.isProtonatedNitrogen and atom.numHydrogenAtoms == 3: # NG3P3: primary NH3+, phosphatidylethanolamine atom.atomType = "NG3P3" i += 1
def setAtomTypeForHalogens(self, mol): num_atoms = len(mol.atoms) atom = Atom() atom_linked = Atom() index = -1 num_element = 0 i = 0 while i < num_atoms: atom = mol.atoms[i] if atom.element.lower() == "CL".lower(): atom_linked = mol.atoms[atom.linkage[0]] if atom_linked.isAromatic and atom_linked.numRingAtoms[0] == 6: # CLGR1: CHLB, chlorobenzene atom.atomType = "CLGR1" else: num_element = self.countSpecificElement( mol, atom.linkage[0], "CL") if num_element == 1 or num_element == 2: # CLGA1: CLET, DCLE, chloroethane, 1,1-dichloroethane atom.atomType = "CLGA1" elif num_element == 3: # CLGA3: TCLE, 1,1,1-trichloroethane atom.atomType = "CLGA3" elif atom.element.lower() == "BR".lower(): atom_linked = mol.atoms[atom.linkage[0]] if atom_linked.isAromatic and atom_linked.numRingAtoms[0] == 6: # BRGR1: BROB, bromobenzene atom.atomType = "BRGR1" else: num_element = self.countSpecificElement( mol, atom.linkage[0], "BR") if num_element == 1: # BRGA1: BRET, bromoethane atom.atomType = "BRGA1" elif num_element == 2: # BRGA2: DBRE, 1,1-dibromoethane atom.atomType = "BRGA2" elif num_element == 3: # BRGA3: TBRE, 1,1,1-dibromoethane atom.atomType = "BRGA3" elif atom.element.lower() == "I".lower(): atom_linked = mol.atoms[atom.linkage[0]] if atom_linked.isAromatic and atom_linked.numRingAtoms[0] == 6: # IGR1: IODB, iodobenzene atom.atomType = "IGR1" elif atom.element.lower() == "F".lower(): atom_linked = mol.atoms[atom.linkage[0]] if atom_linked.isAromatic: # FGR1: aromatic flourine atom.atomType = "FGR1" else: num_element = self.countSpecificElement( mol, atom.linkage[0], "F") if num_element == 1: # FGA1: aliphatic fluorine, monofluoro atom.atomType = "FGA1" elif num_element == 2: # FGA2: aliphatic fluorine, difluoro atom.atomType = "FGA2" elif num_element == 3: # FGA3: aliphatic fluorine, trifluoro atom.atomType = "FGA3" elif num_element == 4: # FGP1: anionic F, for ALF4 AlF4- atom.atomType = "FGP1" i += 1