Ejemplo n.º 1
0
def _CalculateGearyAutocorrelation(mol, lag=1, propertylabel="m"):
    """
    #################################################################
    **Internal used only**

    Calculation of Geary autocorrelation descriptors based on

    different property weights.

    Usage:

    res=_CalculateGearyAutocorrelation(mol,lag=1,propertylabel='m')

    Input: mol is a molecule object.

    lag is the topological distance between atom i and atom j.

    propertylabel is the weighted property.

    Output: res is a numeric value.
    #################################################################
    """

    Natom = mol.GetNumAtoms()

    prolist = []
    for i in mol.GetAtoms():
        temp = GetRelativeAtomicProperty(i.GetSymbol(), propertyname=propertylabel)
        prolist.append(temp)

    aveweight = sum(prolist) / Natom

    tempp = [numpy.square(x - aveweight) for x in prolist]

    GetDistanceMatrix = Chem.GetDistanceMatrix(mol)
    res = 0.0
    index = 0
    for i in range(Natom):
        for j in range(Natom):
            if GetDistanceMatrix[i, j] == lag:
                atom1 = mol.GetAtomWithIdx(i)
                atom2 = mol.GetAtomWithIdx(j)
                temp1 = GetRelativeAtomicProperty(
                    element=atom1.GetSymbol(), propertyname=propertylabel
                )
                temp2 = GetRelativeAtomicProperty(
                    element=atom2.GetSymbol(), propertyname=propertylabel
                )
                res = res + numpy.square(temp1 - temp2)
                index = index + 1
            else:
                res = res + 0.0

    if sum(tempp) == 0 or index == 0:
        result = 0
    else:
        result = (res / index / 2) / (sum(tempp) / (Natom - 1))

    return round(result, 3)
Ejemplo n.º 2
0
def CalculateVDWVolumeMoRSE(ChargeCoordinates):
    """
    #################################################################
    The calculation of  3-D MoRse descriptors 
    
    based on atomic van der Waals volume.
    #################################################################
    """
    R=_GetR(n=30)
    temp=[]
    VDW=[]
    for i in ChargeCoordinates:
        #if i[0]!='H':
        temp.append([float(i[0]),float(i[1]),float(i[2])])
        VDW.append(GetRelativeAtomicProperty(i[3],'V'))
    DM=_GetGementricalDistanceMatrix(temp)
    nAT=len(temp)
    RDFresult={}
    
    for kkk,Ri in enumerate(R):        
        res=0.0
        for j in range(nAT-1):
            for k in range(j+1,nAT):
                res=res+VDW[j]*VDW[k]*math.sin(Ri*DM[j,k])/(Ri*DM[j,k])
        RDFresult['MoRSE'+'V'+str(kkk+1)]=round(res,3)
        
    return RDFresult
Ejemplo n.º 3
0
def CalculateSandersonElectronegativityMoRSE(lcoordinates):
    """
    #################################################################
    The calculation of  3-D MoRse descriptors 
    
    based on atomic sanderson electronegativity.
    #################################################################
    """
    R=_GetR(n=30)
    temp=[]
    En=[]
    for i in lcoordinates:
        #if i[0]!='H':
        temp.append([float(i[0]),float(i[1]),float(i[2])])
        En.append(GetRelativeAtomicProperty(i[3],'En'))
    DM=_GetGementricalDistanceMatrix(temp)
    nAT=len(temp)
    RDFresult={}
    
    for kkk,Ri in enumerate(R):        
        res=0.0
        for j in range(nAT-1):
            for k in range(j+1,nAT):
                res=res+En[j]*En[k]*math.sin(Ri*DM[j,k])/(Ri*DM[j,k])
        RDFresult['MoRSE'+'E'+str(kkk+1)]=round(res,3)
        
    return RDFresult
Ejemplo n.º 4
0
def CalculatePolarizabilityMoRSE(lcoordinates):
    """
    #################################################################
    The calculation of  3-D MoRse descriptors 
    
    based on atomic polarizablity.
    #################################################################
    """
    R=_GetR(n=30)
    temp=[]
    polarizability=[]
    for i in lcoordinates:
        #if i[0]!='H':
        temp.append([float(i[0]),float(i[1]),float(i[2])])
        polarizability.append(GetRelativeAtomicProperty(i[3],'alapha'))
    DM=_GetGementricalDistanceMatrix(temp)
    nAT=len(temp)
    RDFresult={}
    
    for kkk,Ri in enumerate(R):        
        res=0.0
        for j in range(nAT-1):
            for k in range(j+1,nAT):
                res=res+polarizability[j]*polarizability[k]*math.sin(Ri*DM[j,k])/(Ri*DM[j,k])
        RDFresult['MoRSE'+'P'+str(kkk+1)]=round(res,3)
        
    return RDFresult
Ejemplo n.º 5
0
def CalculateVDWVolumeRDF(ChargeCoordinates):
    """
    #################################################################
    The calculation of  radial distribution function 
    
    (RDF) descriptors based on atomic van der Waals volume.
    #################################################################
    """
    R = _GetR(n=30)
    temp = []
    VDW = []
    #    ChargeCoordinates=_ReadCoordinates('temp.arc')
    for i in ChargeCoordinates:
        #if i[0]!='H':
        temp.append([float(i[1]), float(i[2]), float(i[3])])
        VDW.append(GetRelativeAtomicProperty(i[0], 'V'))

    DM = GetGementricalDistanceMatrix(temp)
    nAT = len(temp)
    RDFresult = {}

    for kkk, Ri in enumerate(R):
        res = 0.0
        for j in range(nAT - 1):
            for k in range(j + 1, nAT):
                res = res + VDW[j] * VDW[k] * math.exp(
                    -_beta * math.pow(Ri - DM[j, k], 2))
        RDFresult['RDF' + 'V' + str(kkk + 1)] = round(res, 3)

    return RDFresult
Ejemplo n.º 6
0
def CalculateSandersonElectronegativityRDF(lcoordinates):
    """
    The calculation of  radial distribution function
    (RDF) descriptors based on atomic electronegativity.
    """
    R = _GetR(n=30)
    temp = []
    EN = []
    #    lcoordinates=_ReadCoordinates('temp.arc')
    for i in lcoordinates:
        #if i[0]!='H':
        temp.append([float(i[0]), float(i[1]), float(i[2])])
        EN.append(GetRelativeAtomicProperty(i[3], 'En'))

    DM = GetGementricalDistanceMatrix(temp)
    nAT = len(temp)
    RDFresult = {}

    for kkk, Ri in enumerate(R):
        res = 0.0
        for j in range(nAT - 1):
            for k in range(j + 1, nAT):
                res = res + EN[j] * EN[k] * math.exp(
                    -_beta * math.pow(Ri - DM[j, k], 2))
        RDFresult['RDF' + 'E' + str(kkk + 1)] = round(res, 3)

    return RDFresult
Ejemplo n.º 7
0
def GetPropertyMatrix(AtomLabel, proname='m'):
    """
    #################################################################
    #################################################################
    """
    res = []
    for i in AtomLabel:
        res.append(GetRelativeAtomicProperty(i, proname))

    return scipy.matrix(scipy.diag(res))
Ejemplo n.º 8
0
def _CalculateMoreauBrotoAutocorrelation(mol, lag=1, propertylabel="m"):
    """
    #################################################################
    **Internal used only**

    Calculation of Moreau-Broto autocorrelation descriptors based on

    different property weights.

    Usage:

    res=_CalculateMoreauBrotoAutocorrelation(mol, lag=1,propertylabel='m')

    Input: mol is a molecule object.

    lag is the topological distance between atom i and atom j.

    propertylabel is the weighted property.

    Output: res is a numeric value.
    #################################################################
    """

    Natom = mol.GetNumAtoms()

    GetDistanceMatrix = Chem.GetDistanceMatrix(mol)
    res = 0.0
    for i in range(Natom):
        for j in range(Natom):
            if GetDistanceMatrix[i, j] == lag:
                atom1 = mol.GetAtomWithIdx(i)
                atom2 = mol.GetAtomWithIdx(j)
                temp1 = GetRelativeAtomicProperty(element=atom1.GetSymbol(),
                                                  propertyname=propertylabel)
                temp2 = GetRelativeAtomicProperty(element=atom2.GetSymbol(),
                                                  propertyname=propertylabel)
                res = res + temp1 * temp2
            else:
                res = res + 0.0

    return round(numpy.log(res / 2 + 1), 3)
Ejemplo n.º 9
0
def _GetBurdenMatrix(mol, propertylabel='m'):
    """
    #################################################################
    *Internal used only**
    
    Calculate Burden matrix and their eigenvalues.
    #################################################################
    """
    mol = Chem.AddHs(mol)
    Natom = mol.GetNumAtoms()

    AdMatrix = Chem.GetAdjacencyMatrix(mol)
    bondindex = numpy.argwhere(AdMatrix)
    AdMatrix1 = numpy.array(AdMatrix, dtype=numpy.float32)

    #The diagonal elements of B, Bii, are either given by
    #the carbon normalized atomic mass,
    #van der Waals volume, Sanderson electronegativity,
    #and polarizability of atom i.

    for i in range(Natom):
        atom = mol.GetAtomWithIdx(i)
        temp = GetRelativeAtomicProperty(element=atom.GetSymbol(),
                                         propertyname=propertylabel)
        AdMatrix1[i, i] = round(temp, 3)

    #The element of B connecting atoms i and j, Bij,
    #is equal to the square root of the bond
    #order between atoms i and j.

    for i in bondindex:
        bond = mol.GetBondBetweenAtoms(int(i[0]), int(i[1]))
        if bond.GetBondType().name == 'SINGLE':
            AdMatrix1[i[0], i[1]] = round(numpy.sqrt(1), 3)
        if bond.GetBondType().name == "DOUBLE":
            AdMatrix1[i[0], i[1]] = round(numpy.sqrt(2), 3)
        if bond.GetBondType().name == "TRIPLE":
            AdMatrix1[i[0], i[1]] = round(numpy.sqrt(3), 3)
        if bond.GetBondType().name == "AROMATIC":
            AdMatrix1[i[0], i[1]] = round(numpy.sqrt(1.5), 3)

    ##All other elements of B (corresponding non bonded
    #atom pairs) are set to 0.001
    bondnonindex = numpy.argwhere(AdMatrix == 0)

    for i in bondnonindex:
        if i[0] != i[1]:

            AdMatrix1[i[0], i[1]] = 0.001

    return numpy.real(numpy.linalg.eigvals(AdMatrix1))