コード例 #1
0
def maxmins(atoms):
    xmax = -999999999
    xmin = 999999999
    ymax = -999999999
    ymin = 999999999
    zmax = -99999999
    zmin = 999999999
    xs = 0
    ys = 0
    zs = 0
    num = 0
    nx = Atributs.atomt("xcoor")
    ny = Atributs.atomt("ycoor")
    nz = Atributs.atomt("zcoor")
    for i in range(len(atoms) - 1):
        linia = atoms[i]
        x = linia[nx]
        y = linia[ny]
        z = linia[nz]
        if x > xmax: xmax = x
        if x <= xmin: xmin = x
        if y > ymax: ymax = y
        if y <= ymin: ymin = y
        if z > zmax: zmax = z
        if z <= zmin: zmin = z
        num += 1
        xs = xs + x
        ys = ys + y
        zs = zs + z
        llista = [xmin, ymin, zmin], [xmax, ymax, zmax], [(round(xs / num, 4)),
                                                          round(ys / num, 4),
                                                          round(zs / num, 4)]
    return (llista)
コード例 #2
0
    def plot_atoms(self):
        xs = []
        ys = []
        zs = []
        cs = []
        watoms = []
        if self.tipus == 1:
            watoms = [
                atom for atom in self.atoms
                if atom[Atributs.atomt("idTAtom")] == True
            ]
        if self.tipus == 2:
            watoms = [
                residu for residu in self.residus
                if residu[Atributs.residut("idTResidu")] == True
            ]
        self.tipus2 = 1
        for linia in watoms:
            if self.tipus == 1:
                x = linia[Atributs.atomt("xcoor")]
                y = linia[Atributs.atomt("ycoor")]
                z = linia[Atributs.atomt("zcoor")]
            if self.tipus == 2:
                x = linia[Atributs.residut("xcoor")]
                y = linia[Atributs.residut("ycoor")]
                z = linia[Atributs.residut("zcoor")]

            # Get color
            chain = linia[Atributs.atomt("idChain")]
            colors = Colors(chain, 1)
            col = colors.color_molecula()

            xs.append(x)
            ys.append(y)
            zs.append(z)
            cs.append(col)

        fig = plt.figure(figsize=(10, 5))
        ax = fig.add_subplot(111, projection='3d')
        ax.set_facecolor([0.98, 0.92, 0.84])  # blanc antic
        ax.text2D(-0.10,
                  0.95,
                  self.capcalera,
                  horizontalalignment='left',
                  verticalalignment='top',
                  family='Serif',
                  size=9,
                  transform=ax.transAxes)
        ax.scatter(xs, ys, zs, c=cs, marker='o', alpha=0.35)
        ax.set_xlabel('Eix X')
        ax.set_ylabel('Eix Y')
        ax.set_zlabel('Eix Z')
        plt.show()
コード例 #3
0
    def __init__(self, fitxer):
        self.fitxer = fitxer
        E = Entitat(self.fitxer)
        self.linies = E.get_linies()
        dadestotals = E.crear_entitat()
        self.capcalera = dadestotals[0]
        self.molecules = dadestotals[2]
        self.residus = dadestotals[3]
        self.atoms = dadestotals[4]
        self.nom_taula = dadestotals[5]

        self.nomResidu = Atributs.residut("nomResidu")
        self.nomElement = Atributs.atomt("elemQuim")
        self.idTResidu = Atributs.residut("idTResidu")
        self.idTAtom = Atributs.atomt("idTAtom")
コード例 #4
0
    def plot2d_3d(self):
        fig = plt.figure(figsize=(11, 5))
        ax = fig.add_subplot(111, projection='3d')
        ax.text2D(-0.10,
                  -0.10,
                  self.capcalera,
                  horizontalalignment='left',
                  verticalalignment='top',
                  family='Serif',
                  size=8,
                  transform=ax.transAxes)
        self.tipus2 = 1
        ax_xy = fig.add_subplot(331)
        ax_xy.set_title('X/Y')
        ax_xz = fig.add_subplot(333)
        ax_xz.set_title('X/Z')
        ax_zy = fig.add_subplot(334)
        ax_zy.set_title('Z/Y')
        ax.set_facecolor([0.98, 0.92, 0.84])  # blanc antic
        zx, zy, zz = [], [], []

        idchains = Atributs.residut("idChain")
        idresidus = Atributs.residut("idResidu")
        idresatom = Atributs.atomt("idResidu")
        aprot = Atributs.atomt("idTAtom")

        idx = Atributs.atomt("xcoor")
        idy = Atributs.atomt("ycoor")
        idz = Atributs.atomt("zcoor")

        vella_mol = ""
        for chain_id in self.molecules:
            if chain_id != vella_mol:
                atr = Colors(chain_id)
                nom = atr.color_molecula()
                vella_mol = chain_id
            xs = []
            ys = []
            zs = []
            wresidus = [
                res for res in self.residus if res[idchains] == chain_id
            ]
            for residu in wresidus:
                watoms = []
                watoms = [
                    atom for atom in self.atoms
                    if atom[idresatom] == residu[idresidus]
                    and atom[idchains] == chain_id and atom[aprot] == True
                ]
                for atom in watoms:
                    x = atom[idx]
                    y = atom[idy]
                    z = atom[idz]
                    xs.append(x)
                    ys.append(y)
                    zs.append(z)
                    atr = Colors(chain_id, 1)
                    nom = atr.color_molecula()
            ax.scatter(xs, ys, zs, marker='*', color=nom, alpha=0.35)
            ax_xy.scatter(xs, ys, marker='.', color=nom, alpha=0.15)
            ax_xz.scatter(xs, zs, marker='.', color=nom, alpha=0.15)
            ax_zy.scatter(zs, ys, marker='.', color=nom, alpha=0.15)
            # ax.text2D(0.05, 0.95, self.capcalera, transform=ax.transAxes)
            # ax.text(9, 0, 0,self.capcalera , color='red')
        plt.show()