Exemplo n.º 1
0
    def __get_uniprot_reactions(self):
        """
        Purpose: Takes reactions in the form of 'HSAXXX HSAXXX ReactionType HSAPathway and
        converts each hsaXXX id to a swissprot uniprot id. Stores results inside a set of tuples
        with the form (uprotA, uprotB, reaction label).

        @return: Set of 4-tuples with the form (uprotA, uprotB, reaction label, direction).
        """
        if self.__verbose:
            print("Converting KEGG reactions to UniProt reactions...")
        reaction_set = set()
        for reaction in self.kegg_reactions:
            hsa1 = reaction[0]
            hsa2 = reaction[1]
            reaction_type = reaction[2]

            if hsa1 not in self.hsa_to_uprot.keys() \
                    or hsa2 not in self.hsa_to_uprot.keys():
                continue
            else:
                u_prot_1 = self.hsa_to_uprot[hsa1]
                u_prot_2 = self.hsa_to_uprot[hsa2]
                ppi = PPI(u_prot_1, u_prot_2, [reaction_type])

                if u_prot_1 != u_prot_2:
                    reaction_set.add(ppi)

                if self.__verbose:
                    print("\tReaction: {}\t{}\t{}".format(
                        ppi.p1, ppi.p2, ppi.get_reaction_type_string()
                    ))
        reaction_set = set([(ppi.p1, ppi.p2, ppi.get_reaction_type_string()) for ppi in reaction_set])
        return reaction_set
Exemplo n.º 2
0
    exclude = [
        # None yet
    ]

    ppis = []
    n_ptms = []
    unknown_ppis = []
    unknown_n_ptms = []
    for ptm in ptms:
        clause_1 = (ptm.modification_type not in exclude) and ptm.has_enzyme()
        clause_2 = ptm.enzyme_hprd_id != ptm.substrate_hprd_id
        clause_3 = ptm.substrate_hprd_id != '-'
        if clause_1 and clause_2 and clause_3:
            ppi = PPI(
                ptm.substrate_hprd_id,
                ptm.enzyme_hprd_id,
                ptm.modification_type.strip().lower().replace(' ', '-').split(',')
            )
            ppis.append(ppi)
            n_ptms.append(ptm)
        else:
            ppi = PPI(
                ptm.substrate_hprd_id,
                ptm.enzyme_hprd_id,
                ptm.modification_type.strip().lower().replace(' ', '-').split(',')
            )
            unknown_ppis.append(ppi)
            unknown_n_ptms.append(ptm)

    # Since there's a many swissprot to hprd_id mapping, priortise P, Q and O.
    t = {'P':0, 'Q':1, 'O':2}