Exemplo n.º 1
0
def cmpH5Summarize(inCmp, movieSummary = True, refSummary = True):
    """Summarize a cmp.h5 file"""
    reader = CmpH5Reader(inCmp)
    tstr   = "filename: %s\nversion:  %s\nn reads:  %d\nn refs:   " + \
        "%d\nn movies: %d\nn bases:  %d\navg rl:   %d\navg acc:  %g"
    
    rl,acc,mov = zip(*[(r.readLength,r.accuracy,r.movieInfo[0]) for r in reader ])
    
    summaryStr = (tstr % (os.path.basename(reader.file.filename), reader.version, len(reader),
                          len(reader.referenceInfoTable), len(set(mov)), NP.sum(rl),
                          NP.round(NP.mean(rl)), NP.round(NP.mean(acc), 4)))
    eTbl = Tbl(nBases = Sum(ReadLength), avgReadLength = Mean(ReadLength), 
               avgAccuracy = Mean(Accuracy))
    
    movieSummaryTxt = rec2txt(toRecArray(query(reader, what = eTbl, groupBy = Movie)),
                              padding = 5, precision = 1)
    
    refSummaryTxt = rec2txt(toRecArray(query(reader, what = eTbl, groupBy = Reference)),
                            padding = 5, precision = 1)
   
    return (summaryStr + 
            ("\n\n\t Movie Summary:\n" + (movieSummaryTxt if movieSummary else "\n")) + 
            ("\n\n\t Reference Summary:\n" + (refSummaryTxt if refSummary else "\n")))
Exemplo n.º 2
0
def prettyPrint(res):
    print rec2txt(res, padding = 20, precision = 2)