Esempio n. 1
0
    def addCharges(self, atoms):
        """
        compute gasteiger charges, add them to atoms, return list of new
        charges
        NB: assumes MolKit atoms have bonds
        NB: calls type atoms if all the atoms haven't been babel typed. 
        if babel_types have been set by hand, they will be ok IF every
        atom has a babel type

        """
        #print 'in computeGasteiger'
        #check that atoms have babel_types
        w_babel_types = atoms.get(lambda x: hasattr(x, 'babel_type'))
        if w_babel_types is None or len(w_babel_types)!=len(atoms):
            babel = AtomHybridization()
            #have to have bonds for this
            babel.assignHybridization(atoms)
        Gast = Gasteiger()
        Gast.compute(atoms)
        gastCharges = []
        for c in atoms.gast_charge:
            gastCharges.append(round(c, 4))
        #NB THIS adds entry 'gasteiger' to atom._charges dict
        atoms.addCharges('gasteiger', gastCharges)
        atoms.chargeSet = 'gasteiger'
        #clean-up
        delattr(atoms, 'gast_charge')
        return gastCharges
Esempio n. 2
0
    def addCharges(self, atoms):
        """
        compute gasteiger charges, add them to atoms, return list of new
        charges
        NB: assumes MolKit atoms have bonds
        NB: calls type atoms if all the atoms haven't been babel typed. 
        if babel_types have been set by hand, they will be ok IF every
        atom has a babel type

        """
        #print 'in computeGasteiger'
        #check that atoms have babel_types
        w_babel_types = atoms.get(lambda x: hasattr(x, 'babel_type'))
        if w_babel_types is None or len(w_babel_types) != len(atoms):
            babel = AtomHybridization()
            #have to have bonds for this
            babel.assignHybridization(atoms)
        Gast = Gasteiger()
        Gast.compute(atoms)
        gastCharges = []
        for c in atoms.gast_charge:
            gastCharges.append(round(c, 4))
        #NB THIS adds entry 'gasteiger' to atom._charges dict
        atoms.addCharges('gasteiger', gastCharges)
        atoms.chargeSet = 'gasteiger'
        #clean-up
        delattr(atoms, 'gast_charge')
        return gastCharges
 def computeGasteiger(self):
     #to compute Gasteiger need to:
     #   create an AtomHybridization()
     #   call its assignHybridization method on self.allAtoms
     #   create a Gasteiger()
     #   call its compute method on self.allAtoms
     # THEN move gast_charge into _charges with gasteiger key
     #   set allAtoms.chargeSet to 'gasteiger'
     # THEN delattr gast_charge from allAtoms
     allAts = self.allAtoms
     ah = AtomHybridization()
     ah.assignHybridization(allAts)
     Gast = Gasteiger()
     Gast.compute(allAts)
     gastCharges = []
     for c in allAts.gast_charge:
         gastCharges.append(round(c, 3))
     allAts.addCharges('gasteiger', gastCharges)
     del allAts.gast_charge
     allAts.chargeSet = 'gasteiger'
Esempio n. 4
0
 def computeGasteiger(self):
     #to compute Gasteiger need to:
     #   create an AtomHybridization()
     #   call its assignHybridization method on self.allAtoms
     #   create a Gasteiger()
     #   call its compute method on self.allAtoms
     # THEN move gast_charge into _charges with gasteiger key
     #   set allAtoms.chargeSet to 'gasteiger'
     # THEN delattr gast_charge from allAtoms
     allAts = self.allAtoms
     ah = AtomHybridization()
     ah.assignHybridization(allAts)
     Gast = Gasteiger()
     Gast.compute(allAts)
     gastCharges = []
     for c in allAts.gast_charge:
         gastCharges.append(round(c, 3))
     allAts.addCharges('gasteiger', gastCharges)
     del allAts.gast_charge
     allAts.chargeSet = 'gasteiger'