Example #1
0
 def send_query(self, query):
     if self.makeSocket():
       self.soc.send(query)
     else:
        printf("ERROR\tCannot create or connect socket\n")
Example #2
0
    def getReactionListLines(self):
        my_base_pathways = self.call_func("all-pathways :all T")
        pwy_count=0
        unique_rxns ={}
        if self.DEBUG:
           printf("Extracting the reaction list..\n")
        for pathway in my_base_pathways:
            if self.DEBUG:
               printf(" " + pathway)
            sys.stdout.flush()
            pwy_count +=1
            mygenes = self.genes_of_pathway(pathway,'T')
            totalrxns = self.get_slot_values(pathway, "REACTION-LIST")

            for rxn in totalrxns:
                unique_rxns[rxn] = 1

            pathway_common_name = self.get_slot_value(pathway,"common-name")
            if not  pathway_common_name:
                pathway_common_name = "?"

            num_reactions = len(totalrxns)
            num_predicted_orfs = len(mygenes)

            num_covered_rxns =0
            num_genes =0
            orf_strings = {}

            for reaction in totalrxns :

                rngenes = self.genes_of_reaction(reaction,"T")

                rxngenes = []
                for rngene in rngenes:
                    rxngenes.append(self.get_slot_value(rngene,"common-name"))

                if rxngenes: # this reaction is covered
                    num_covered_rxns+= 1

                rxn_name = self.get_slot_value(reaction,"common-name")
                if not rxn_name:
                    rxn_name = '???'

                if reaction in unique_rxns:
                    unique_rxns[reaction]= {}
                    unique_rxns[reaction]['name'] = rxn_name
                    unique_rxns[reaction]['ORFs'] = rxngenes

                    if rxngenes:
                        unique_rxns[reaction]['covered']= 1
                    else :
                        unique_rxns[reaction]['covered']= 0

                    unique_rxns[reaction]['num_pwys']= 1

                else :
                    unique_rxns[reaction]['covered']= 1
                    unique_rxns[reaction]['num_pwys']+=1

                num_genes += len(rxngenes);
                for rxngene in rxngenes:
                    orf_strings[rxngene] =1

                    # done for the reactions in a  pathway
            outputstr =  "PWY:" + "\t" + pathway + "\t" + pathway_common_name \
                         + "\t" + str(num_reactions) + "\t" + str(num_covered_rxns) + "\t" + str(num_predicted_orfs)

            for orf_string in orf_strings.keys():
                outputstr += "\t" + orf_string
            outputstr += "\n";

        # printing the reactions MOST important part of the calculation
        rxnOutputStrings=[]

        for reaction in unique_rxns.keys():
            rxnOutputStr = reaction + "\t" + unique_rxns[reaction]['name']

            for orf in unique_rxns[reaction]['ORFs']:
                rxnOutputStr += "\t" + orf

            rxnOutputStrings.append(rxnOutputStr)
        return rxnOutputStrings
Example #3
0
 def sendStartSignal(self):
     if self.DEBUG:
        printf("Starting up pathway tools\n")
     process = Process(target=startUpPathwayTools, args=(self._ptoolsExec,))
     process.start()
Example #4
0
 def send_query(self, query):
     if self.makeSocket():
         self.soc.send(query)
     else:
         printf("ERROR\tCannot create or connect socket\n")
Example #5
0
    def getReactionListLines(self):
        my_base_pathways = self.call_func("all-pathways :all T")
        pwy_count = 0
        unique_rxns = {}
        if self.DEBUG:
            printf("INFO\tExtracting the reaction list\n")
        for pathway in my_base_pathways:
            if self.DEBUG:
                printf(" " + pathway)
            sys.stdout.flush()
            pwy_count += 1
            mygenes = self.genes_of_pathway(pathway, 'T')
            totalrxns = self.get_slot_values(pathway, "REACTION-LIST")

            for rxn in totalrxns:
                unique_rxns[rxn] = 1

            pathway_common_name = self.get_slot_value(pathway, "common-name")
            if not pathway_common_name:
                pathway_common_name = "?"

            num_reactions = len(totalrxns)
            num_predicted_orfs = len(mygenes)

            num_covered_rxns = 0
            num_genes = 0
            orf_strings = {}

            for reaction in totalrxns:

                rngenes = self.genes_of_reaction(reaction, "T")

                rxngenes = []
                for rngene in rngenes:
                    rxngenes.append(self.get_slot_value(rngene, "common-name"))

                if rxngenes:  # this reaction is covered
                    num_covered_rxns += 1

                rxn_name = self.get_slot_value(reaction, "common-name")
                if not rxn_name:
                    rxn_name = '???'

                if reaction in unique_rxns:
                    unique_rxns[reaction] = {}
                    unique_rxns[reaction]['name'] = rxn_name
                    unique_rxns[reaction]['ORFs'] = rxngenes

                    if rxngenes:
                        unique_rxns[reaction]['covered'] = 1
                    else:
                        unique_rxns[reaction]['covered'] = 0

                    unique_rxns[reaction]['num_pwys'] = 1

                else:
                    unique_rxns[reaction]['covered'] = 1
                    unique_rxns[reaction]['num_pwys'] += 1

                num_genes += len(rxngenes)
                for rxngene in rxngenes:
                    orf_strings[rxngene] = 1

                    # done for the reactions in a  pathway
            outputstr =  "PWY:" + "\t" + pathway + "\t" + pathway_common_name \
                         + "\t" + str(num_reactions) + "\t" + str(num_covered_rxns) + "\t" + str(num_predicted_orfs)

            for orf_string in orf_strings.keys():
                outputstr += "\t" + orf_string
            outputstr += "\n"

        # printing the reactions MOST important part of the calculation
        rxnOutputStrings = []

        for reaction in unique_rxns.keys():
            rxnOutputStr = reaction + "\t" + unique_rxns[reaction]['name']

            for orf in unique_rxns[reaction]['ORFs']:
                rxnOutputStr += "\t" + orf

            rxnOutputStrings.append(rxnOutputStr)
        return rxnOutputStrings
Example #6
0
 def sendStartSignal(self):
     if self.DEBUG:
         printf("INFO\tStarting up pathway tools\n")
     process = Process(target=startUpPathwayTools,
                       args=(self._ptoolsExec, ))
     process.start()