Ejemplo n.º 1
0
def calc_contact_order(chimera: Chimera = None, filename: str = None, diss_cutoff: int = 8):
    """
    The contact order of a protein is a measure of the locality of the inter-amino acid contacts in the
    native folded state. It is computed as the average seqeuence distance between residues that form contacts
    below a threshold in the folded protein divided by the total length of the protein"
    :param chimera: A Chimera object with n residues.
    :param filename: path to a pdb file
    :param diss_cutoff: The maximum distance in Armstrong between two residues to be in contact, default 8 Angstroms
    :return: the contact order (%)
    """
    if chimera and filename:
        raise ValueError("Only a Chimera object or the path to a pdb file must be specified")
    if not chimera and not filename:
        raise ValueError("At least a Chimera object or the path to a pdb file must be specified")
    if filename:
        chimera = Chimera(filename=filename)
    chimera.renumberResidues()
    metr = MetricSelfDistance("protein and noh", groupsel="residue", metric="contacts", threshold=diss_cutoff,
                              pbc=False)
    a = metr.project(chimera)
    mapping = metr.getMapping(chimera)
    matrix, _, _ = contactVecToMatrix(a[0], mapping.atomIndexes)
    triang = np.triu(matrix)
    idx1, idx2 = np.where(triang)
    total_contacts = len(idx1)
    total_residues = chimera.numResidues
    summation = np.sum(idx2 - idx1)
    co = 1 / (total_contacts * total_residues) * summation
    print(f"Contact order is {co*100} %")
    return co * 100
Ejemplo n.º 2
0
 def show_vertex(self, vertex: Graph.vertex) -> Chimera:
     """
     Shows the protein that corresponds to that specific vertex with the
     fragment colored in red
     :param vertex: A Graph.vertex object. The domain to be shown,
     :return: A Chimera object with an internal representation of the fragment
     """
     graph = self.graph
     domain = graph.vp.domain[vertex]
     start = int(round(np.mean(graph.vp.start[vertex])))
     end = int(round(np.mean(graph.vp.end[vertex])))
     domain_path = get_SCOP_domain(domain)
     mol = Chimera(filename=domain_path, validateElements=False)
     mol.renumberResidues()
     mol.reps.add(sel='protein', style='NewCartoon', color=8)
     mol.reps.add(sel=f"protein and resid '{start}' to '{end}'",
                  style='NewCartoon',
                  color=1)
     mol.view(name=domain)
     return mol