Beispiel #1
0
def test_system(command=None, options=None, exit_on_failure=False, output=False) :
    binaries = { 
        'preprocess' : {
            '*'         : ['sff2fastq'],
            'chimeras'  : ['uchime'],
            'denoise'   : ['PyroDist', 'FCluster', 'PyroNoise'],
        },
        'cluster' : {
            '*'         : ['pagan'],
            'labels'    : ['blastn', 'makeblastdb']
        },
        'label' : {
            '*'         : ['blastn', 'makeblastdb']
        },
        'summary' : {},
        'showcounts' : {},
        'showlabels' : {},
        'phylogeny' : {
            '*'         : ['pagan', 'exonerate', 'bppphysamp'],
            'denovo'    : ['raxml']
        },
        'heatmap' : {},
        'wasabi' : {},
        'test' : {}
    }

    def print_out(s) :
        if output :
            print s
        else :
            if 'not found' in s :
                print >> stderr, s.lstrip()

    fail = False

    for b in [command] if command else binaries :
        if binaries[b] :
            print_out("checking system for %s command dependancies :" % bold(b))
            for o in binaries[b] :
                if o == '*' or not options or options[o] :
                    for p in binaries[b][o] :
                        installed = System.is_installed(p)
                        print_out("    %s %s%s" % (p, "" if o == "*" else "(needed for --%s) " % o, 
                            bold_green("found.") if installed else bold_red("not found!")))
                    
                    if not installed :
                        fail = True    
            print_out("")

    # for some reason using pip to install cairo always fails
    # so check for it here instead
#    print "checking for python modules :"
#    try :
#        import cairo
#        print "    pycairo (needed by 'heatmap' command) " + bold_green("found.")
#    except ImportError :
#        print "    pycairo (needed by 'heatmap' command) " + bold_red("not found!")
#        fail = True
#    print ""

    if exit_on_failure and fail :
        exit(1)