Beispiel #1
0
def Calculate3DWienerWithH(ChargeCoordinates: List[List[float]]) -> float:
    """Calculate 3D Wiener index from geometrical distance matrix of a MOPAC optimized molecule (including Hs).

    :param ChargeCoordinates: Atomic coordinates and charges as read by chemopy.GeoOpt._ReadCoordinates
    """
    temp = []
    for i in ChargeCoordinates:
        temp.append([float(i[1]), float(i[2]), float(i[3])])
    DistanceMatrix = GetGeometricalDistanceMatrix(temp)
    return round(scipy.sum(DistanceMatrix) / 2.0, 3)
Beispiel #2
0
def CalculateGeometricalDiameter(
        ChargeCoordinates: List[List[float]]) -> float:
    """Calculate the geometrical diameter.

    :param ChargeCoordinates: Atomic coordinates and charges as read by chemopy.GeoOpt._ReadCoordinates
    """
    temp = []
    for i in ChargeCoordinates:
        temp.append([float(i[1]), float(i[2]), float(i[3])])
    DistanceMatrix = GetGeometricalDistanceMatrix(temp)
    temp1 = scipy.amax(DistanceMatrix, axis=0)
    return round(max(temp1), 3)
Beispiel #3
0
def CalculateAbsEigenvalueSumOnGeometricMatrix(
        ChargeCoordinates: List[List[float]]) -> float:
    """Calculate the absolute eigenvalue sum on geometry matrix (SEig).

    This is the sum of the absolute eigenvalues of the geometry matrix.
    :param ChargeCoordinates: Atomic coordinates and charges as read by chemopy.GeoOpt._ReadCoordinates
    """
    temp = []
    for i in ChargeCoordinates:
        temp.append([float(i[1]), float(i[2]), float(i[3])])
    DistanceMatrix = GetGeometricalDistanceMatrix(temp)
    u, s, vt = scipy.linalg.svd(DistanceMatrix)
    return round(sum(abs(s)), 3)
Beispiel #4
0
def CalculateAverageGeometricalDistanceDegree(
        ChargeCoordinates: List[List[float]]) -> float:
    """Calculate the average geometric distance degree (AGDD).

    This is the ratio between the sum of all geometric distance degrees and the atoms.
    :param ChargeCoordinates: Atomic coordinates and charges as read by chemopy.GeoOpt._ReadCoordinates
    """
    temp = []
    for i in ChargeCoordinates:
        temp.append([float(i[1]), float(i[2]), float(i[3])])
    DistanceMatrix = GetGeometricalDistanceMatrix(temp)
    nAT = len(temp)
    res = sum(sum(DistanceMatrix)) / nAT
    return round(res, 3)
Beispiel #5
0
def CalculateUnweightRDF(ChargeCoordinates):
    """Calculate unweighted RDF descriptors."""
    R = GetR(n=30)
    temp = []
#    ChargeCoordinates=_ReadCoordinates('temp.arc')
    for i in ChargeCoordinates:
        # if i[0]!='H':
        temp.append([float(i[1]), float(i[2]), float(i[3])])
    DM = GetGeometricalDistanceMatrix(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 + math.exp(-_beta * math.pow(Ri - DM[j, k], 2))
        RDFresult[f'RDFU{kkk + 1}'] = round(res, 3)
    return RDFresult
Beispiel #6
0
def CalculateHarary3D(ChargeCoordinates: List[List[float]]) -> float:
    """Calculate 3D-Harary index as the sum of all the reciprocal geometric distances.

    :param ChargeCoordinates: Atomic coordinates and charges as read by chemopy.GeoOpt._ReadCoordinates
    """
    temp = []
    for i in ChargeCoordinates:
        temp.append([float(i[1]), float(i[2]), float(i[3])])
    DistanceMatrix = GetGeometricalDistanceMatrix(temp)
    nAT = len(temp)
    res = 0.0
    for i in range(nAT - 1):
        for j in range(i + 1, nAT):
            if DistanceMatrix[i, j] == 0:
                cds = 0.0
            else:
                cds = 1. / DistanceMatrix[i, j]
            res = res + cds
    return round(res, 3)
Beispiel #7
0
def CalculatePolarizabilityRDF(ChargeCoordinates):
    """Calculate RDF descriptors with Polarizability schemes."""
    R = GetR(n=30)
    temp = []
    polarizability = []
#    ChargeCoordinates=_ReadCoordinates('temp.arc')
    for i in ChargeCoordinates:
        # if i[0]!='H':
        temp.append([float(i[1]), float(i[2]), float(i[3])])
        polarizability.append(GetRelativeAtomicProperty(i[0], 'alapha'))
    DM = GetGeometricalDistanceMatrix(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.exp(-_beta * math.pow(Ri - DM[j, k], 2))
        RDFresult[f'RDFP{kkk + 1}'] = round(res, 3)
    return RDFresult
Beispiel #8
0
def CalculateMassRDF(mol, ChargeCoordinates):
    """Calculate RDF descriptors with Mass schemes."""
    mol.addh()
    mass = [i.atomicmass for i in mol.atoms]
    R = GetR(n=30)
    temp = []
#    ChargeCoordinates=_ReadCoordinates('temp.arc')
    for i in ChargeCoordinates:
        # if i[0]!='H':
        temp.append([float(i[1]), float(i[2]), float(i[3])])
    DM = GetGeometricalDistanceMatrix(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 + mass[j] * mass[k] * math.exp(-_beta * math.pow(Ri - DM[j, k], 2))
        RDFresult[f'RDFM{kkk + 1}'] = round(res / 144, 3)
    return RDFresult
Beispiel #9
0
def CalculateVDWVolumeRDF(ChargeCoordinates):
    """Calculate RDF with atomic van der Waals volume shemes."""
    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 = GetGeometricalDistanceMatrix(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[f'RDFV{kkk + 1}'] = round(res, 3)
    return RDFresult
Beispiel #10
0
def CalculateUnweightMoRSE(ChargeCoordinates: List[List[float]]) -> dict:
    """Calculate unweighted 3D MoRse descriptors.

    :param ChargeCoordinates: Atomic coordinates and charges as read by chemopy.GeoOpt._ReadCoordinates
    """
    R = GetR(n=30)
    temp = []
    #    ChargeCoordinates=_ReadCoordinates('temp.arc')
    for i in ChargeCoordinates:
        # if i[0]!='H':
        temp.append([float(i[1]), float(i[2]), float(i[3])])
    DM = GetGeometricalDistanceMatrix(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 + math.sin(Ri * DM[j, k]) / (Ri * DM[j, k])
        RDFresult[f'MoRSEU{kkk + 1}'] = round(res, 3)
    return RDFresult
Beispiel #11
0
def CalculatePetitjean3DIndex(ChargeCoordinates: List[List[float]]) -> float:
    """Calculate Petitjean Index from molecular gemetrical distance matrix.

    The 3D Petitjean shape index (PJI3) is calculated
    dividing the difference between geometric diameter and
    radius by the geometric radius [P.A. Bath, A.R. Poirrette,
    P. Willett, F.H. Allen, J.Chem.Inf.Comput.Sci. 1995, 35, 714-716].
    The geometric radius of a molecule is defined as the minimum
    geometric eccentricity and the diameter is defined as the
    maximum geometric eccentricity in the molecule, the atom
    geometric eccentricity being the longest geometric distance
    from the considered atom to any other atom in the molecule.

    :param ChargeCoordinates: Atomic coordinates and charges as read by chemopy.GeoOpt._ReadCoordinates
    """
    temp = []
    for i in ChargeCoordinates:
        temp.append([float(i[1]), float(i[2]), float(i[3])])
    DistanceMatrix = GetGeometricalDistanceMatrix(temp)
    temp1 = scipy.amax(DistanceMatrix, axis=0)
    return round(max(temp1) / min(temp1) - 1.0, 3)
Beispiel #12
0
def CalculateAtomicNumberMoRSE(mol: Chem.Mol,
                               ChargeCoordinates: List[List[float]]) -> dict:
    """Calculate 3D MoRse descriptors from atomic number.

    :param ChargeCoordinates: Atomic coordinates and charges as read by chemopy.GeoOpt._ReadCoordinates
    """
    R = GetR(n=30)
    temp = []
    mass = [i.atomicnum for i in mol.atoms]
    for i in ChargeCoordinates:
        # if i[0]!='H':
        temp.append([float(i[1]), float(i[2]), float(i[3])])
    DM = GetGeometricalDistanceMatrix(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 + mass[j] * mass[k] * math.sin(
                    Ri * DM[j, k]) / (Ri * DM[j, k])
        RDFresult[f'MoRSEN{kkk + 1}'] = round(res / 144, 3)
    return RDFresult
Beispiel #13
0
def CalculateVDWVolumeMoRSE(ChargeCoordinates: List[List[float]]) -> dict:
    """Calculate 3D MoRse descriptors from van der Waals volume.

    :param ChargeCoordinates: Atomic coordinates and charges as read by chemopy.GeoOpt._ReadCoordinates
    """
    R = GetR(n=30)
    temp = []
    VDW = []
    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 = GetGeometricalDistanceMatrix(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[f'MoRSEV{kkk + 1}'] = round(res, 3)
    return RDFresult