Пример #1
0
    def assign_bond_order1(self, atoms, bonds):
        """ """

        hyb_val = [0,3,2,1]
        converter = TypeConverter("HYB")
        for a in atoms:
            hyb = converter.convert(a.babel_type, 'dummy')
            a._redo = hyb_val[int(hyb)]
            #print a.full_name(), a.babel_type, hyb, a._redo

        for b in bonds:
            # initialize bondOrder attribute
            if b.bondOrder is None:
                b.bondOrder = 1
            sum_code = b.atom1._redo + b.atom2._redo
            #print b, sum_code
            if sum_code == 6:
                b.bondOrder = 3
            elif sum_code == 4:
                b.bondOrder = 2
            else:
                b.bondOrder = 1
            
            if self.is_carboxyl(b):
                b.bondOrder = 2

            if b.bondOrder < 1 or b.bondOrder > 3:
                print "Bond %s is wierd - Bond order is %d\n" % \
                      (b, b.bondOrder)

        self.check_for_conjugation(atoms)

        # cleanup
        for a in atoms:
            delattr(a, '_redo')
Пример #2
0
    def find_aromatic_rings(self):
        """ """
        converter = TypeConverter("HYB")
       
        for r in self.rings.rings:
            is_aromatic = 0
            if len(r['atoms']) == 5 or len(r['atoms']) == 6:
                is_aromatic = 1
                for a in r['atoms']:
                    # check to see if the atom is sp2 
	            # if not, the ring isn't aromatic
                    hyb_str = converter.convert(a.babel_type, 'all_caps')
                    hyb = int(hyb_str)
                    if hyb != 2:
                        is_aromatic = 0
                        break

                    # check to see if the atom has 3 bonds to
                    # heavy atoms in the same ring.
                    # If not, the ring isn't aromatic

                    if self.count_arom_atm_bonds(a, r) != 3:
                        is_aromatic = 0
                        break
    
            if is_aromatic:
                r['aromatic'] = 1
                for a in r['atoms']: a.arom_atm = 1
Пример #3
0
    def find_aromatic_rings(self):
        """ """
        converter = TypeConverter("HYB")

        for r in self.rings.rings:
            is_aromatic = 0
            if len(r['atoms']) == 5 or len(r['atoms']) == 6:
                is_aromatic = 1
                for a in r['atoms']:
                    # check to see if the atom is sp2
                    # if not, the ring isn't aromatic
                    hyb_str = converter.convert(a.babel_type, 'all_caps')
                    hyb = int(hyb_str)
                    if hyb != 2:
                        is_aromatic = 0
                        break

                    # check to see if the atom has 3 bonds to
                    # heavy atoms in the same ring.
                    # If not, the ring isn't aromatic

                    if self.count_arom_atm_bonds(a, r) != 3:
                        is_aromatic = 0
                        break

            if is_aromatic:
                r['aromatic'] = 1
                for a in r['atoms']:
                    a.arom_atm = 1
Пример #4
0
    def assign_bond_order1(self, atoms, bonds):
        """ """

        hyb_val = [0, 3, 2, 1]
        converter = TypeConverter("HYB")
        for a in atoms:
            hyb = converter.convert(a.babel_type, 'dummy')
            a._redo = hyb_val[int(hyb)]
            #print a.full_name(), a.babel_type, hyb, a._redo

        for b in bonds:
            # initialize bondOrder attribute
            if b.bondOrder is None:
                b.bondOrder = 1
            sum_code = b.atom1._redo + b.atom2._redo
            #print b, sum_code
            if sum_code == 6:
                b.bondOrder = 3
            elif sum_code == 4:
                b.bondOrder = 2
            else:
                b.bondOrder = 1

            if self.is_carboxyl(b):
                b.bondOrder = 2

            if b.bondOrder < 1 or b.bondOrder > 3:
                print "Bond %s is wierd - Bond order is %d\n" % \
                      (b, b.bondOrder)

        self.check_for_conjugation(atoms)

        # cleanup
        for a in atoms:
            delattr(a, '_redo')
Пример #5
0
    def lookup_sigma_params(self, atoms):
        """ """

        converter = TypeConverter("MAP")
        for a in atoms:
            type = converter.convert(a.babel_type)
            if type[:2] in self.par.keys():
                a._gast_par = self.par[type]
            else:
                print "Sorry, there are no Gasteiger parameters available for atom %s" % a.full_name()
                a._gast_par = [0.0, 0.0, 0.0, 1.0]
Пример #6
0
    def assign_hybrid_radii(self, atoms):
        """ """
        converter = TypeConverter("XYZ")
        for a in atoms:
            atm_type = converter.convert(a.babel_type, 'zero')
            if atm_type == 0:
                atm_type = a.babel_type
            atm_type = converter.clean_atom_type(atm_type)

            a.babel_cov_rad = babel_elements[atm_type]['cov_rad']
            a.babel_bond_ord_rad = babel_elements[atm_type]['bond_ord_rad']
            a.babel_max_bonds = babel_elements[atm_type]['max_bonds']
Пример #7
0
    def lookup_sigma_params(self, atoms):
        """ """

        converter = TypeConverter("MAP")
        for a in atoms:
            type = converter.convert(a.babel_type)
            if type[:2] in self.par.keys():
                a._gast_par = self.par[type]
            else:
                print "Sorry, there are no Gasteiger parameters available for atom %s" % a.full_name(
                )
                a._gast_par = [0.0, 0.0, 0.0, 1.0]
Пример #8
0
    def assign_hybrid_radii(self, atoms):
        """ """
        converter = TypeConverter("XYZ")
        for a in atoms:
            atm_type = converter.convert(a.babel_type, 'zero')
            if atm_type == 0:
                atm_type = a.babel_type
            atm_type = converter.clean_atom_type(atm_type)

            a.babel_cov_rad = babel_elements[atm_type]['cov_rad']
            a.babel_bond_ord_rad = babel_elements[atm_type]['bond_ord_rad']
            a.babel_max_bonds = babel_elements[atm_type]['max_bonds']
Пример #9
0
    def count_missing_hydrogens(self, atoms):
        """ """
        missing = 0
        converter = TypeConverter("HAD")

        for a in atoms:
            temp_type = converter.convert(a.babel_type, 'zero')

            if temp_type == 0:
                print "Unable to assign valence to atom %s type = %s" % \
                      (a.full_name(), a.babel_type)

            type_valence = int(temp_type)
            val = len(a.bonds)
            if val < type_valence and val > 0:
                missing = missing + type_valence - val

        return missing
Пример #10
0
    def count_missing_hydrogens(self, atoms):
        """ """
        missing = 0
        converter = TypeConverter("HAD")
        
        for a in atoms:
            temp_type = converter.convert(a.babel_type, 'zero')

            if temp_type == 0:
                print "Unable to assign valence to atom %s type = %s" % \
                      (a.full_name(), a.babel_type)

            type_valence = int(temp_type)
            val = len(a.bonds)
            if val < type_valence and val > 0:
                missing = missing + type_valence - val

        return missing
Пример #11
0
    def estimate_bond_order2(self, bonds):
        """ """
        converter = TypeConverter("HYB")
        for b in bonds:
            bo = 1
            a1 = b.atom1
            a2 = b.atom2
            dist = distance(a1.coords, a2.coords)
            cov_sum = a1.babel_bond_ord_rad + a2.babel_bond_ord_rad
            ratio = dist/cov_sum
            start_type = converter.convert(a1.babel_type, "all_caps")
            end_type = converter.convert(a2.babel_type, "all_caps")

            if ratio <= DOUBLE_TRIPLE_CUTOFF:
                if start_type[0] == '1' and end_type[0] == '1':
                    bo = 3
            elif ratio <= SINGLE_DOUBLE_CUTOFF:
                if start_type[0] == '2' and end_type[0] == '2':
                    bo = 2
            b.bondOrder = bo
Пример #12
0
    def estimate_bond_order2(self, bonds):
        """ """
        converter = TypeConverter("HYB")
        for b in bonds:
            bo = 1
            a1 = b.atom1
            a2 = b.atom2
            dist = distance(a1.coords, a2.coords)
            cov_sum = a1.babel_bond_ord_rad + a2.babel_bond_ord_rad
            ratio = dist / cov_sum
            start_type = converter.convert(a1.babel_type, "all_caps")
            end_type = converter.convert(a2.babel_type, "all_caps")

            if ratio <= DOUBLE_TRIPLE_CUTOFF:
                if start_type[0] == '1' and end_type[0] == '1':
                    bo = 3
            elif ratio <= SINGLE_DOUBLE_CUTOFF:
                if start_type[0] == '2' and end_type[0] == '2':
                    bo = 2
            b.bondOrder = bo
Пример #13
0
    def countMissingBonds(atoms):
        converter = TypeConverter('HYB')
        needDBatoms = []
        canHaveDBatoms = []
        for a in atoms:
            a._needsDB = 0
            a._canHaveDB = 0
            hyb = int(converter.convert(a.babel_type, 'all_caps'))
            if hyb != 2: continue
            if a.babel_type[0] == 'C':
                sum = 0
                for b in a.bonds:
                    sum = sum + b.bondOrder

                if sum == 3:
                    if len(a.bonds) == 3:
                        a._needsDB = 1
                        needDBatoms.append(a)
                    elif len(a.bonds) == 2:  # ==C-- or ==C/
                        a1 = a.bonds[0].atom1
                        if a1 == a: a1 = a.bonds[0].atom2
                        a3 = a.bonds[1].atom1
                        if a3 == a: a3 = a.bonds[1].atom2
                        ang = bond_angle(a1.coords, a.coords, a3.coords)
                        if math.fabs(ang - 180) < 10:  # ==C--
                            a._needDB = 1
                            needDBatoms.append(a)

                elif sum == 2:
                    if len(a.bonds) == 2:
                        a1 = a.bonds[0].atom1
                        if a1 == a: a1 = a.bonds[0].atom2
                        a3 = a.bonds[1].atom1
                        if a3 == a: a3 = a.bonds[1].atom2
                        ang = bond_angle(a1.coords, a.coords, a3.coords)
                        if math.fabs(ang - 180) < 10:
                            a._needsDB = 2
                            needDBatoms.append(a)
                        else:
                            a._needsDB = 1
                            needDBatoms.append(a)

                elif sum == 1:
                    a._needsDB = 1
                    needDBatoms.append(a)

            elif a.babel_type[0] == 'N':
                sum = 0
                for b in a.bonds:
                    sum = sum + b.bondOrder
                if sum == 2 and len(a.bonds) == 2:
                    canHaveDBatoms.append(a)
                    a._canHaveDB = 1

            elif a.babel_type[0] == 'O':
                sum = 0
                for b in a.bonds:
                    sum = sum + b.bondOrder
                if sum == 1:
                    canHaveDBatoms.append(a)
                    a._canHaveDB = 1

        return needDBatoms, canHaveDBatoms
Пример #14
0
    def place_hydrogens2(self, atoms, num_H_to_add):
        """ """

        Hat = []
        converter = TypeConverter("HYB")

        for a in atoms:
            type_name = converter.convert(a.babel_type, 'zero')
            hyb = int(type_name)
            code = a.babel_atomic_number * 10 + hyb
            to_add = a._redo

            if code == 63:  # sp3 carbon
                if to_add == 1:
                    Hat = Hat + self.add_tertiary_hydrogen(a, SP3_C_H_DIST)
                elif to_add == 2:
                    Hat = Hat + self.add_methylene_hydrogens(a, SP3_C_H_DIST)
                elif to_add == 3:
                    Hat = Hat + self.add_methyl_hydrogen(a, SP3_C_H_DIST)
                    Hat = Hat + self.add_methylene_hydrogens(
                        a, SP3_C_H_DIST, Hat[-1])
            elif code == 73:  # sp3 nitrogen
                if to_add == 1:
                    if a.babel_type == "N3+":
                        Hat = Hat + self.add_tertiary_hydrogen(a, SP3_N_H_DIST)
                    else:
                        Hat = Hat + self.add_sp3_N_hydrogen(a, SP3_N_H_DIST)
                elif to_add == 2:
                    Hat = Hat + self.add_methylene_hydrogens(a, SP3_N_H_DIST)
                elif to_add == 3:
                    Hat = Hat + self.add_methyl_hydrogen(a, SP3_N_H_DIST)
                    Hat = Hat + self.add_methylene_hydrogens(
                        a, SP3_N_H_DIST, Hat[-1])

            elif code == 62:  # sp2 carbon
                if to_add == 1:
                    Hat = Hat + self.add_sp2_hydrogen(a, SP2_C_H_DIST)

            elif code == 72:  # sp2 nitrogen
                if to_add == 1:
                    Hat = Hat + self.add_sp2_hydrogen(a, SP2_N_H_DIST)

            elif code == 61:  # sp carbon
                if to_add == 1:
                    Hat = Hat + self.add_sp_hydrogen(a, SP_C_H_DIST)

            elif code == 83:  # sp3 oxygen
                if to_add == 1:
                    Hat = Hat + self.add_methyl_hydrogen(a, SP3_O_H_DIST)

            # save vinyl and amide protons for last,
            # this way we know where to put them

        for a in atoms:

            type_name = converter.convert(a.babel_type, 'zero')
            hyb = int(type_name)
            code = a.babel_atomic_number * 10 + hyb
            to_add = a._redo

            if code == 62:  # sp2 carbon
                if to_add == 2:
                    Hat = Hat + self.add_vinyl_hydrogens(a, SP2_C_H_DIST)

            elif code == 72:  # sp2 nitrogens
                if to_add == 2:
                    Hat = Hat + self.add_vinyl_hydrogens(a, SP2_N_H_DIST)

        return Hat
Пример #15
0
    def countMissingBonds(atoms):
        converter = TypeConverter('HYB')
        needDBatoms = []
        canHaveDBatoms = []
        for a in atoms:
            a._needsDB = 0
            a._canHaveDB = 0
            hyb = int(converter.convert(a.babel_type, 'all_caps'))
            if hyb != 2: continue         
            if a.babel_type[0] == 'C':
                sum = 0
                for b in a.bonds:
                    sum = sum + b.bondOrder

                if sum == 3:
                    if len(a.bonds)==3:
                        a._needsDB = 1
                        needDBatoms.append(a)
                    elif len(a.bonds)==2: # ==C-- or ==C/
                        a1 = a.bonds[0].atom1
                        if a1==a: a1 = a.bonds[0].atom2
                        a3 = a.bonds[1].atom1
                        if a3==a: a3 = a.bonds[1].atom2
                        ang = bond_angle( a1.coords, a.coords, a3.coords )
                        if math.fabs(ang-180) < 10: # ==C--
                            a._needDB = 1
                            needDBatoms.append(a)
                            
                elif sum == 2:
                    if len(a.bonds)==2:
                        a1 = a.bonds[0].atom1
                        if a1==a: a1 = a.bonds[0].atom2
                        a3 = a.bonds[1].atom1
                        if a3==a: a3 = a.bonds[1].atom2
                        ang = bond_angle( a1.coords, a.coords, a3.coords )
                        if math.fabs(ang-180) < 10:
                            a._needsDB = 2
                            needDBatoms.append(a)
                        else:
                            a._needsDB = 1
                            needDBatoms.append(a)

                elif sum == 1:
                    a._needsDB = 1
                    needDBatoms.append(a)
                    
            elif a.babel_type[0] == 'N':
                sum = 0
                for b in a.bonds:
                    sum = sum + b.bondOrder
                if sum == 2 and len(a.bonds)==2:
                    canHaveDBatoms.append(a)
                    a._canHaveDB = 1

            elif a.babel_type[0] == 'O':
                sum = 0
                for b in a.bonds:
                    sum = sum + b.bondOrder
                if sum == 1:
                    canHaveDBatoms.append(a)
                    a._canHaveDB = 1

        return needDBatoms, canHaveDBatoms
Пример #16
0
    def place_hydrogens2(self, atoms, num_H_to_add):
        """ """

        Hat = []
        converter = TypeConverter("HYB")
        
        for a in atoms:
            type_name = converter.convert(a.babel_type, 'zero')
            hyb = int(type_name)
            code = a.babel_atomic_number * 10 + hyb
            to_add = a._redo
            
            if code == 63: # sp3 carbon
                if to_add==1:
                    Hat = Hat + self.add_tertiary_hydrogen(a, SP3_C_H_DIST)
                elif to_add==2:
                    Hat = Hat + self.add_methylene_hydrogens(a ,SP3_C_H_DIST)
                elif to_add==3:
                    Hat = Hat + self.add_methyl_hydrogen(a, SP3_C_H_DIST)
                    Hat = Hat + self.add_methylene_hydrogens(a, SP3_C_H_DIST,
                                                             Hat[-1])
            elif code == 73: # sp3 nitrogen
                if to_add==1:
                    if a.babel_type=="N3+":
                        Hat = Hat + self.add_tertiary_hydrogen(a, SP3_N_H_DIST)
                    else:
                        Hat = Hat + self.add_sp3_N_hydrogen(a, SP3_N_H_DIST)
                elif to_add==2:
                    Hat = Hat + self.add_methylene_hydrogens(a ,SP3_N_H_DIST)
                elif to_add==3:
                    Hat = Hat + self.add_methyl_hydrogen(a, SP3_N_H_DIST)
                    Hat = Hat + self.add_methylene_hydrogens(a ,SP3_N_H_DIST,
                                                             Hat[-1])
                    
            elif code == 62: # sp2 carbon
                if to_add==1:
                    Hat = Hat + self.add_sp2_hydrogen(a ,SP2_C_H_DIST)

            elif code == 72: # sp2 nitrogen
                if to_add==1:
                    Hat = Hat + self.add_sp2_hydrogen(a ,SP2_N_H_DIST)

            elif code == 61: # sp carbon
                if to_add==1:
                    Hat = Hat + self.add_sp_hydrogen(a ,SP_C_H_DIST)

            elif code == 83: # sp3 oxygen
                if to_add==1:
                    Hat = Hat + self.add_methyl_hydrogen(a, SP3_O_H_DIST)

            # save vinyl and amide protons for last,
            # this way we know where to put them

        for a in atoms:

            type_name = converter.convert(a.babel_type, 'zero')
            hyb = int(type_name)
            code = a.babel_atomic_number * 10 + hyb
            to_add = a._redo

            if code == 62: # sp2 carbon
                if to_add==2:
                    Hat = Hat + self.add_vinyl_hydrogens(a ,SP2_C_H_DIST)

            elif code == 72: # sp2 nitrogens
                if to_add==2:
                    Hat = Hat + self.add_vinyl_hydrogens(a ,SP2_N_H_DIST)

        return Hat