Esempio n. 1
0
 def print_tree(self, tree, indent):
     for c in tree:
         if c in self.id_to_name:
             for i in range(indent):
                 printf('\t')
             printf('%s\n', self.id_to_name[c])
         self.print_tree(tree[c], indent + 1)
 def print_tree(self, tree, indent):
     for c in tree:
         if c in self.id_to_name:
           for i in range(indent):
              printf('\t')
           printf('%s\n',self.id_to_name[c])
         self.print_tree(tree[c], indent+1)
 def construct_tree(self):
     self.tree['1'] = {}
     indent = 0
     self.seen_tids = {}
     printf('%s\n',self.id_to_name['1'])
     self.seen_tids['1'] = 1
     self.grow_tree(self.tree['1'],'1', indent+1)
     
     print "Leaf count " + str(self.leafcount)
Esempio n. 4
0
    def construct_tree(self):
        self.tree['1'] = {}
        indent = 0
        self.seen_tids = {}
        printf('%s\n', self.id_to_name['1'])
        self.seen_tids['1'] = 1
        self.grow_tree(self.tree['1'], '1', indent + 1)

        print "Leaf count " + str(self.leafcount)
Esempio n. 5
0
def call_commands_serially(commands, status_update_callback, logger,
                           stepslogger, params):
    """Run list of commands, one after another """
    #logger.write("Executing commands.\n\n")
    from sys import exit
    make = False
    for c in commands:
        if c[3] == 'stop':
            print "Stopping!"
            return
            break

        if params['verbose']:
            eprintf("\n\n\nIssuing Command : %s\n", c[1])

        eprintf("%s" % (c[0]))
        if c[3] in ['yes', 'redo'] and c[4]:
            result = getstatusoutput(c[1])
            if result[0] == 0:
                if c[3] in ['redo']:
                    eprintf('..... Redo Success!\n')
                else:
                    eprintf('..... Success!\n')
            else:
                eprintf('..... Error!\n')
                #print c
        elif c[3] == 'grid' and c[4]:
            blastgrid(c[1])
            continue
        elif c[3] == 'skip':
            eprintf('..... Skipping!\n')
            continue
        else:
            eprintf('..... Already Computed!\n')
            continue

        #status_update_callback('%s\n%s' %(result[0], result[0]))

        logger.write('COMMAND : \n%s \n' % (c[1]))
        if result[0] == 0:
            logger.write('Success!:\n%s\n' % (result[1]))
        else:
            #print result[1]
            try:
                printf('Error! : %s\n' % (result[1]))
                logger.write('Error!:\n%s\n' % (result[1]))
            except:
                pass

            break

        timestamp_pattern = '%Y-%m-%d %H:%M:%S'
        timestamp = datetime.now().strftime(timestamp_pattern)
        stepslogger.write('%s\t%s\n' % (c[2], timestamp))
Esempio n. 6
0
def call_commands_serially(commands, status_update_callback, logger, stepslogger, params ):
    """Run list of commands, one after another """
    #logger.write("Executing commands.\n\n")
    from sys import exit
    make = False
    for c in commands:
        if c[3]=='stop':
           print "Stopping!"
           return 
           break

        if params['verbose']:
             eprintf("\n\n\nIssuing Command : %s\n", c[1])

        eprintf("%s" %(c[0]))
        if c[3] in ['yes', 'redo' ] and c[4]:
           result = getstatusoutput(c[1])
           if result[0] == 0 :
             if c[3] in ['redo']:
                eprintf('..... Redo Success!\n')
             else:
                eprintf('..... Success!\n')
           else:
             eprintf('..... Error!\n')
             #print c
        elif c[3]=='grid' and c[4]:
           blastgrid(c[1])
           continue  
        elif c[3]=='skip':
           eprintf('..... Skipping!\n')
           continue
        else:
           eprintf('..... Already Computed!\n')
           continue

        #status_update_callback('%s\n%s' %(result[0], result[0]))

        logger.write('COMMAND : \n%s \n' %( c[1]))
        if result[0] == 0 :
            logger.write('Success!:\n%s\n' %( result[1]))
        else:
            #print result[1]
            try:
               printf('Error! : %s\n' %(result[1]))
               logger.write('Error!:\n%s\n' %( result[1]))
            except:
               pass

            break 

        timestamp_pattern='%Y-%m-%d %H:%M:%S'
        timestamp = datetime.now().strftime(timestamp_pattern)
        stepslogger.write('%s\t%s\n' %( c[2], timestamp))
def print_taxonomy_information(pathways,ranked_pathways, enzymes, enzymesmap):
    for  key in ranked_pathways:
        taxons = {}
        for rxn in pathways[key]['rxns']:   
           for enzyme in pathways[key]['rxns'][rxn]:   
                taxons[pathways[key]['rxns'][rxn][enzyme]] = True

        #lca.build_independent_taxons(taxons)

        for rxn in pathways[key]['rxns']:   
           print '   ' + rxn
           for enzyme in pathways[key]['rxns'][rxn]:   
               printf("\t%s\t%s\n",  enzyme, enzymesmap[pathways[key]['rxns'][rxn][enzyme]])
def print_taxonomy_information(pathways, ranked_pathways, enzymes, enzymesmap):
    for key in ranked_pathways:
        taxons = {}
        for rxn in pathways[key]['rxns']:
            for enzyme in pathways[key]['rxns'][rxn]:
                taxons[pathways[key]['rxns'][rxn][enzyme]] = True

        #lca.build_independent_taxons(taxons)

        for rxn in pathways[key]['rxns']:
            print '   ' + rxn
            for enzyme in pathways[key]['rxns'][rxn]:
                printf("\t%s\t%s\n", enzyme,
                       enzymesmap[pathways[key]['rxns'][rxn][enzyme]])
def dry_run_status( commands ):
    for command in commands:
        printf("%s", command[0])
        if command[4] == True:
           printf("%s", " Required")
        else:
           printf("%s", " Not Required")
    printf("\n")
def print_taxonomy_information(pathways, ranked_pathways, enzymes, lca):
    for key in ranked_pathways:
        print key
        taxons = []
        for rxn in pathways[key]['rxns']:
            for enzyme in pathways[key]['rxns'][rxn]:
                taxons.append(pathways[key]['rxns'][rxn][enzyme])

        lca.build_independent_taxons(taxons)

        for rxn in pathways[key]['rxns']:
            print '   ' + rxn
            for enzyme in pathways[key]['rxns'][rxn]:
                printf("         %s\t%s", enzyme,
                       pathways[key]['rxns'][rxn][enzyme])
                printf(" [ ")
                for child in lca.get_independent_parent(
                        pathways[key]['rxns'][rxn][enzyme]):
                    printf("\t%s", child)
                printf(" ]\n")
def call_commands_serially(commands, status_update_callback, logger, stepslogger, params ):
    """Run list of commands, one after another """
    #logger.write("Executing commands.\n\n")
    from sys import exit
    
    make = False
    for c in commands:
        if c[3]=='stop':
           print "Stopping!"
           stepslogger.write('%s\t%s\n' %(c[2], "STOPPED"))
           return (0,'')

        if params['verbose']:
             eprintf("\n\n\nEXECUTED COMMAND : %s\n", c[1])

        eprintf("%s" %(c[0]))
        stepslogger.write('%s\t%s\n' %(c[2], "RUNNING"))
        if c[3]=='missing':
           print "..... Input Missing!"
           stepslogger.write('%s\t%s\n' %(c[2], "INPUT_MISSING"))
           return (0,'')


        if c[3] in ['yes', 'redo' ] and c[4]:
           #result = getstatusoutput(c[1])
           result = execute_pipeline_stage(c[1])
           if result[0] == 0 :
             if c[3] in ['redo']:
                eprintf('..... Redo Success!\n')
                stepslogger.write('%s\t%s\n' %(c[2], "SUCCESS"))
             else:
                eprintf('..... Success!\n')
                stepslogger.write('%s\t%s\n' %(c[2], "SUCCESS"))
           else:
             eprintf('..... Failed!\n')
             stepslogger.write('%s\t%s\n' %(c[2], "FAILED"))
             #print c
        elif c[3]=='grid' and c[4]:
           blastgrid(c[1])
           continue  
        elif c[3]=='skip':
           eprintf('..... Skipping!\n')
           stepslogger.write('%s\t%s\n' %(c[2], "SKIPPED"))
           continue
        elif c[3]=='missing':
           eprintf('..... Input Missing!\n')
           stepslogger.write('%s\t%s\n' %(c[2], "INPUT_MISSING"))
           continue
        else:
           eprintf('..... Already Computed!\n')
           stepslogger.write('%s\t%s\n' %(c[2], "ALREADY_COMPUTED"))
           continue

        #status_update_callback('%s\n%s' %(result[0], result[0]))

        logger.write('COMMAND : \n%s \n' %( c[1]))
        if result[0] == 0 :
            logger.write('Success!:\n%s\n' %( result[1]))
        else:
            #print result[1]
            try:
               printf('Error! : %s\n' %(result[1]))
               logger.write('Error!:\n%s\n' %( result[1]))
            except:
               pass

            break