def main():
   usage = ( 'usage: %prog --statsScaffoldsContigPathDir=path/to/dir/ [options]\n\n'
             '%prog takes a directory of contig path stats xml files\n'
             '( --statsScaffoldsContigPathDir ) named as NAME.contigPathStats.xml and creates a plot.')
   data = Data()
   parser = OptionParser( usage=usage )
   initOptions( parser )
   las.initOptions( parser )
   lpt.initOptions( parser )
   options, args = parser.parse_args()
   las.checkOptions( options, parser )
   lpt.checkOptions( options, parser )
   checkOptions( options, parser )
   
   assembliesDict = readDir( options.statsScaffoldsContigPathDir, options )
   assembliesList = assembliesDict.values()
   
   if len(assembliesList) <= 20:
      fig, pdf = lpt.initImage( 14.0, 8.0, options, data )
   else:
      fig, pdf = lpt.initImage( 14.0, 24.0, options, data )
   axDict = establishAxis( len(assembliesList), fig, options, data )
   
   assembliesList = createXYData( assembliesList, options )

   assembliesList = normalizeDist( assembliesList, options )
   assembliesList = sorted( assembliesList, 
                            key=lambda x: max(x.yData['insertionErrorSizeDistribution']), 
                            reverse=True )

   drawData( assembliesList, axDict, options, data )
   drawLegend( assembliesList, axDict, options, data )
   
   lpt.writeImage( fig, pdf, options )
Exemple #2
0
def main():
   usage = ( 'usage: %prog [options]\n\n'
             '%prog takes in a reference genome name ( --referenceGenome ),\n'
             'optionally a directory where annotation wig pickles are stored ( --annotPickleDir [optional] ),\n'
             'a directory where maf wig pickles are stored ( --mafPickleDir ), a paired set of chromosome names\n'
             '( --chrNames comma separated ) and chromosome lengths ( --chrLengths comma separated ) and \n'
             'then various other options specifed below to draw a figure.')
   data = Data()
   parser = OptionParser( usage=usage )
   initOptions( parser )
   las.initOptions( parser )
   lpt.initOptions( parser )
   options, args = parser.parse_args()
   checkOptions( options, parser, data )
   las.checkOptions( options, parser )
   lpt.checkOptions( options, parser )
   loadAnnots( options, data )
   loadMafs( options, data )

   normalizeData( options, data )
   transformData( options, data )

   figHeight = ( data.numberOfMafs + len( data.annotationOrder ) + 0.5 ) / 4.0
   fig, pdf = lpt.initImage( 8.0, figHeight, options, data )
   axDict = establishAxes( fig, options, data )
   labelAxes( fig, axDict, options, data )
   drawAnnotations( axDict, options, data )
   drawMafs( axDict, options, data )
   drawLegend( options, data )

   setAxisLimits( axDict, options, data )
   lpt.writeImage( fig, pdf, options )
Exemple #3
0
def main():
    usage = (
        'usage: %prog --subStatsDir=path/to/dir/ [options]\n\n'
        '%prog takes in a directory of substitution stats files ( --subStatsDir )\n'
        'with filenames as NAME.subStats.[upper|lower].xml and produces a plot showing\n'
        'the difference in subs in hap1 versus hap2.\n')
    data = Data()
    parser = OptionParser(usage=usage)
    initOptions(parser)
    las.initOptions(parser)
    lpt.initOptions(parser)
    options, args = parser.parse_args()
    checkOptions(options, parser)
    las.checkOptions(options, parser)
    lpt.checkOptions(options, parser)

    fig, pdf = lpt.initImage(11., 8., options, data)
    axDict = establishAxis(fig, options, data)

    assembliesDict = {}
    assembliesDict = cssp.readSubStatsDir(assembliesDict, options)
    valuesList = createValsList(assembliesDict.values(), options)
    valuesList = sorted(valuesList,
                        key=lambda x: float(x[1]) / x[2],
                        reverse=False)
    drawData(valuesList, axDict, options, data)

    lpt.writeImage(fig, pdf, options)
def main():
   usage = ( 'usage: %prog --subStatsDir=path/to/dir/ [options]\n\n'
             '%prog takes in a directory of substitution stats files ( --subStatsDir )\n'
             'with filenames as NAME.subStats.[upper|lower].xml and produces a plot.')
   data = Data()
   parser = OptionParser( usage=usage )
   initOptions( parser )
   las.initOptions( parser )
   lpt.initOptions( parser )
   options, args = parser.parse_args()
   checkOptions( options, parser )
   las.checkOptions( options, parser )
   lpt.checkOptions( options, parser )
   
   if not options.outputRanks:
      fig, pdf = lpt.initImage( 9., 11., options, data )
      axDict = establishAxes( fig, options, data )
   
   assembliesDict = {}
   assembliesDict = readSubStatsDir( assembliesDict, options )
   
   sumErrors( assembliesDict, options )
   normalizeData( assembliesDict, options )

   sortOrder = sorted( assembliesDict, key=lambda key: assembliesDict[ key ].allLo, reverse=False )

   if options.outputRanks:
      rankings( assembliesDict, sortOrder, options, data )
      return

   drawData( assembliesDict, sortOrder, axDict, options, data )
   
   lpt.writeImage( fig, pdf, options )
def main():
   usage = ( 'usage: %prog --subStatsDir=path/to/dir/ [options]\n\n'
             '%prog takes in a directory of substitution stats files ( --subStatsDir )\n'
             'with filenames as NAME.subStats.[upper|lower].xml and produces a plot showing\n'
             'the difference in subs in hap1 versus hap2.\n')
   data = Data()
   parser = OptionParser( usage=usage )
   initOptions( parser )
   las.initOptions( parser )
   lpt.initOptions( parser )
   options, args = parser.parse_args()
   checkOptions( options, parser )
   las.checkOptions( options, parser )
   lpt.checkOptions( options, parser )
   
   fig, pdf = lpt.initImage( 11., 8., options, data )
   axDict = establishAxis( fig, options, data )
   
   assembliesDict = {}
   assembliesDict = cssp.readSubStatsDir( assembliesDict, options )
   valuesList = createValsList( assembliesDict.values(), options )
   valuesList = sorted( valuesList, key = lambda x: float(x[1])/x[2], reverse=False)
   drawData( valuesList, axDict, options, data )
   
   lpt.writeImage( fig, pdf, options )
def main():
   usage = ( 'usage: %prog [options] file1.xml file2.xml\n\n'
             '%prog takes in contiguous path statistics file(s)\n'
             'and creates an image file.' )
   data = Data()
   parser = OptionParser( usage=usage )
   initOptions( parser )
   las.initOptions( parser )
   lpt.initOptions( parser )
   options, args = parser.parse_args()
   checkOptions( args, options, parser )
   las.checkOptions( options, parser )
   lpt.checkOptions( options, parser )
   if not options.outputRanks:
      fig, pdf = lpt.initImage( 11., 8.0, options, data ) # 8
      axDict = establishAxes( fig, options, data )
   
   data.statsList, data.xData = readFiles( options )
   for i in xrange( 0, len( data.statsList )):
      # ensure that the buckets are all in order by their midpoint.
      data.statsList[i] = sorted( data.statsList[i], key=lambda x: x.mid, reverse=False )
   
   if options.outputRanks:
      ranks = rankFiles( options, data )
      printRanks( ranks, options, data )
      sys.exit(0)
      
   drawData( axDict['main'], data.xData, data.statsList, options, data )
   drawLegend( options, data )
   drawAxisLabels( fig, options, data )
   setAxisLimits( axDict['main'], data.xData, options, data )
   establishTicks( axDict['main'], data.xData, options, data )
   
   lpt.writeImage( fig, pdf, options )
def main():
    usage = (
        "usage: %prog --statsScaffoldsContigPathDir=path/to/dir/ [options]\n\n"
        "%prog takes a directory of contig path stats xml files\n"
        "( --statsScaffoldsContigPathDir ) named as NAME.contigPathStats.xml and creates a plot."
    )
    data = Data()
    parser = OptionParser(usage=usage)
    initOptions(parser)
    las.initOptions(parser)
    lpt.initOptions(parser)
    options, args = parser.parse_args()
    las.checkOptions(options, parser)
    lpt.checkOptions(options, parser)
    checkOptions(options, parser)

    assembliesDict = readDir(options.statsScaffoldsContigPathDir, options)
    assembliesList = assembliesDict.values()

    if len(assembliesList) <= 20:
        fig, pdf = lpt.initImage(14.0, 8.0, options, data)
    else:
        fig, pdf = lpt.initImage(14.0, 24.0, options, data)
    axDict = establishAxis(len(assembliesList), fig, options, data)

    assembliesList = createXYData(assembliesList, options)

    assembliesList = normalizeDist(assembliesList, options)
    assembliesList = sorted(assembliesList, key=lambda x: max(x.yData["insertionErrorSizeDistribution"]), reverse=True)

    drawData(assembliesList, axDict, options, data)
    drawLegend(assembliesList, axDict, options, data)

    lpt.writeImage(fig, pdf, options)
Exemple #8
0
def main():
    usage = ('usage: %prog [options] --dir=path/to/dir/\n\n'
             '%prog takes in a copy statistics file\n'
             'and creates an image file.')
    data = Data()
    parser = OptionParser(usage=usage)
    initOptions(parser)
    las.initOptions(parser)
    lpt.initOptions(parser)
    options, args = parser.parse_args()
    checkOptions(args, options, parser)
    las.checkOptions(options, parser)
    lpt.checkOptions(options, parser)
    if not options.outputRanks:
        fig, pdf = lpt.initImage(8.0, 10.0, options, data)

    stats = readFiles(options)
    sortedOrder = sorted(stats.values(),
                         key=lambda x: x.sumLower,
                         reverse=False)

    if options.outputRanks:
        rankings(sortedOrder, options, data)
        return

    axDict = establishAxes(fig, options, data)
    drawData(axDict, sortedOrder, options, data)
    drawLegend(options, data)
    drawAxisLabels(axDict, stats, options, data)
    setAxisLimits(axDict, options, data)

    lpt.writeImage(fig, pdf, options)
def main():
   usage = ( 'usage: %prog [options] --dir=path/to/dir/\n\n'
             '%prog takes in a copy statistics file\n'
             'and creates an image file.' )
   data = Data()
   parser = OptionParser( usage=usage )
   initOptions( parser )
   las.initOptions( parser )
   lpt.initOptions( parser )
   options, args = parser.parse_args()
   checkOptions( args, options, parser )
   las.checkOptions( options, parser )
   lpt.checkOptions( options, parser )
   if not options.outputRanks:
      fig, pdf = lpt.initImage( 8.0, 10.0, options, data )

   stats = readFiles( options )
   sortedOrder = sorted( stats.values(), key=lambda x: x.sumLower, reverse=False )
   
   if options.outputRanks:
      rankings( sortedOrder, options, data )
      return

   axDict = establishAxes( fig, options, data )
   drawData( axDict, sortedOrder, options, data )
   drawLegend( options, data )
   drawAxisLabels( axDict, stats, options, data )
   setAxisLimits( axDict, options, data )
   
   lpt.writeImage( fig, pdf, options )
def main():
   usage = ( 'usage: %prog --statsScaffoldsContigPathDir=path/to/dir/ '
             '--statsContigssContigPathDir=path/to/dir/ [options]\n\n'
             '%prog takes a directory of scaffold-alignment contig path stats xml files\n'
             '( --statsScaffoldsContigPathDir ) named as NAME.pathStats.xml, contig-alignment '
             'contig path stats xml files ( --statsContigsContigPathDir ) named as NAME.pathStats.xml,'
             ' and creates a plot.\n')
   data = Data()
   parser = OptionParser( usage=usage )
   initOptions( parser )
   cscp.initOptions( parser )
   las.initOptions( parser )
   lpt.initOptions( parser )
   options, args = parser.parse_args()
   cscp.checkOptions( options, parser )
   las.checkOptions( options, parser )
   lpt.checkOptions( options, parser )
   checkOptions( options, parser )
   
   assembliesList = readDirs( options )
   assembliesList = sorted( assembliesList, key=lambda x: x.valuesDict[ options.sortOn ], 
                            reverse=True )

   maxesMax, minsMin = findMaxMin( assembliesList, options )
   if options.outputRanks:
      rankings( assembliesList, options )
      return

   fig, pdf = lpt.initImage( 10.0, 8.0, options, data )
   axDict = establishAxis( fig, options, data )

   drawData( assembliesList, maxesMax, minsMin, axDict, options )
   
   lpt.writeImage( fig, pdf, options )
def main():
    usage = ('usage: %prog')
    parser = OptionParser(usage=usage)
    initOptions(parser)
    las.initOptions(parser)
    options, args = parser.parse_args()
    checkOptions(args, options, parser)
    las.checkOptions(options, parser)

    assembliesDict = processDirectory(options)

    outputDict(assembliesDict, options)
def main():
   usage = ('usage: %prog')
   parser = OptionParser( usage = usage )
   initOptions( parser )
   las.initOptions( parser )
   options, args = parser.parse_args()
   checkOptions( args, options, parser )
   las.checkOptions( options, parser )
   
   assembliesDict = processDirectory(options)
   
   outputDict(assembliesDict, options)
def main():
   usage = ( 'usage: %prog [options] < summarizeRankings.out\n\n'
             '%prog takes in the output of summarizeRankings.py and reports only the.\n'
             'top assembly per team. Use --reRank to rerank the top assembly per team\n'
             'the tops from all the other teams.')
   parser = OptionParser( usage=usage )
   initOptions( parser )
   las.initOptions( parser )
   options, args = parser.parse_args()
   checkOptions( options, parser )
   las.checkOptions( options, parser )
   
   if not options.reRank:
      simpleProcessStream( options )
   else:
      fullProcessStream( options )
def main():
    usage = (
        'usage: %prog --statsScaffoldsContigPathDir=path/to/dir/ --statsContigsContigPathDir=path/to/dir/ [options]\n\n'
        '%prog takes in the contig path statistics directories from both the Scaffolds and Contigs alignments\n'
        '( --statsScaffoldsContigPathDir --statsContigsContigPathDir ) and prints to STDOUT a latex formatted table.'
    )
    parser = OptionParser(usage=usage)
    initOptions(parser)
    las.initOptions(parser)
    options, args = parser.parse_args()
    checkOptions(args, options, parser)
    las.checkOptions(options, parser)

    assembliesList = readDirs(options)
    calculateErrors(assembliesList, options)

    assembliesList = performSort(assembliesList, options)

    sortString = {
        'totalErrors': 'the sum of the errors (\\(\\sum\\) err)',
        'errorsPerMappedBase': 'errors per mapped base (ePmb)',
        'totalScaffoldGaps+totalBleedingHeartScaffoldGaps':
        'the sum of the total number of scaffold gaps and liberal scaffold gaps (scf)',
        'scaffolds':
        'the sum of the total number of scaffold gaps and liberal scaffold gaps (scf)',
        'totalContigEnds+totalContigEndsWithNs':
        'the sum of total contig ends and the total contigs ending with N\'s (ctgE+ctgN)',
        'totalHomoToHeteroSwitches':
        'the total homozygous to heterozygous switches (hom/het sw)',
        'errorsPerContig': 'errors per contig (ePc)',
        'totalContigEndsWithInsert': 'total contigs ending with insert (e-i)',
        'totalErrorsHaplotypeToHaplotype':
        'total haplotype to haplotype errors (h-h)',
        'totalErrorsHaplotypeToInsert':
        'total haplotype to insert errors (h-i)',
        'totalErrorsHaplotypeToDeletion':
        'total haplotype to deletion errors (h-d)',
        'totalErrorsNonSpecific': 'total non--specific errors (nonSpec)'
    }

    caption = 'The table is sorted on %s. Column headers are total homozygous to heterozygous switches (hom/het sw), sum of the total scaffold gaps and liberal scaffold gaps (scf), the sum of total contig ends and the total contigs ending with N\'s (ctgE+ctgN), errors per contig (ePc), errors per mapped base (ePmb), total contigs ending with insert (e-i), total haplotype to haplotype errors (h-h), total haplotype to insert errors (h-i), total haplotype to deletion errors (h-d), total non--specific errors (nonSpec) and sum of the errors (\\(\\sum\\) err).' % sortString[
        options.sortOn]

    if options.outputRanks:
        printRanks(assembliesList, options)
    else:
        printTable(assembliesList, '', options)
def main():
    usage = (
        'usage: %prog [options] < summarizeRankings.out\n\n'
        '%prog takes in the output of summarizeRankings.py and reports only the.\n'
        'top assembly per team. Use --reRank to rerank the top assembly per team\n'
        'the tops from all the other teams.')
    parser = OptionParser(usage=usage)
    initOptions(parser)
    las.initOptions(parser)
    options, args = parser.parse_args()
    checkOptions(options, parser)
    las.checkOptions(options, parser)

    if not options.reRank:
        simpleProcessStream(options)
    else:
        fullProcessStream(options)
def main():
   usage = ('usage: %prog --subsetFile=file [options] < table.tab\n\n')
   parser = OptionParser( usage=usage )
   las.initOptions( parser )
   options, args = parser.parse_args()
   las.checkOptions( options, parser )

   for line in sys.stdin:
      line = line.strip()
      if line == '':
         continue
      if line.startswith('#'):
         print line
         continue
      if line.split('\t')[0] not in options.assemblySubset:
         continue
      print line
Exemple #17
0
def main():
    usage = ('usage: %prog --subsetFile=file [options] < table.tab\n\n')
    parser = OptionParser(usage=usage)
    las.initOptions(parser)
    options, args = parser.parse_args()
    las.checkOptions(options, parser)

    for line in sys.stdin:
        line = line.strip()
        if line == '':
            continue
        if line.startswith('#'):
            print line
            continue
        if line.split('\t')[0] not in options.assemblySubset:
            continue
        print line
def main():
    usage = (
        'usage: %prog --statsScaffoldsContigPathDir=path/to/dir/ '
        '--statsContigssContigPathDir=path/to/dir/ '
        '--statsScaffoldsContigPathPhasingDir=path/to/dir/ [options]\n\n'
        '%prog takes a directory of scaffold-alignment contig path stats xml files\n'
        '( --statsScaffoldsContigPathDir ) named as NAME.pathStats.xml, contig-alignment '
        'contig path stats xml files ( --statsContigsContigPathDir ) named as NAME.pathStats.xml,'
        'scaffold-alignment contig path phasing stats xml files ( --statsScaffoldsContigPathPhasingDir )'
        ' named as NAME.hap%d.pathStats.xml and creates a  plot.\n')
    data = Data()
    parser = OptionParser(usage=usage)
    initOptions(parser)
    cscp.initOptions(parser)
    las.initOptions(parser)
    lpt.initOptions(parser)
    options, args = parser.parse_args()
    cscp.checkOptions(options, parser)
    las.checkOptions(options, parser)
    lpt.checkOptions(options, parser)
    checkOptions(options, parser)

    assembliesList = readData(options)
    assembliesList = sorted(assembliesList,
                            key=lambda x: x.valuesDict[options.sortOn],
                            reverse=True)

    maxesMax, minsMin = findMaxMin(assembliesList, options)
    if options.outputRanks:
        rankings(assembliesList, options)
        return

    fig, pdf = lpt.initImage(10.0, 8.0, options, data)
    axDict = establishAxis(fig, options, data)

    drawData(assembliesList, maxesMax, minsMin, axDict, options)

    lpt.writeImage(fig, pdf, options)
def main():
    usage = (
        'usage: %prog --subStatsDir=path/to/dir/ [options]\n\n'
        '%prog takes in a directory of substitution stats files ( --subStatsDir )\n'
        'with filenames as NAME.subStats.[upper|lower].xml and produces a plot.'
    )
    data = Data()
    parser = OptionParser(usage=usage)
    initOptions(parser)
    las.initOptions(parser)
    lpt.initOptions(parser)
    options, args = parser.parse_args()
    checkOptions(options, parser)
    las.checkOptions(options, parser)
    lpt.checkOptions(options, parser)

    if not options.outputRanks:
        fig, pdf = lpt.initImage(9., 11., options, data)
        axDict = establishAxes(fig, options, data)

    assembliesDict = {}
    assembliesDict = readSubStatsDir(assembliesDict, options)

    sumErrors(assembliesDict, options)
    normalizeData(assembliesDict, options)

    sortOrder = sorted(assembliesDict,
                       key=lambda key: assembliesDict[key].allLo,
                       reverse=False)

    if options.outputRanks:
        rankings(assembliesDict, sortOrder, options, data)
        return

    drawData(assembliesDict, sortOrder, axDict, options, data)

    lpt.writeImage(fig, pdf, options)
def main():
   usage = ( 'usage: %prog --statsScaffoldsContigPathDir=path/to/dir/ --statsContigsContigPathDir=path/to/dir/ [options]\n\n'
             '%prog takes in the contig path statistics directories from both the Scaffolds and Contigs alignments\n'
             '( --statsScaffoldsContigPathDir --statsContigsContigPathDir ) and prints to STDOUT a latex formatted table.' )
   parser = OptionParser( usage=usage )
   initOptions( parser )
   las.initOptions( parser )
   options, args = parser.parse_args()
   checkOptions( args, options, parser )
   las.checkOptions( options, parser )
   
   assembliesList = readDirs( options )
   calculateErrors( assembliesList, options )

   assembliesList = performSort( assembliesList, options )
   
   sortString = { 'totalErrors':'the sum of the errors (\\(\\sum\\) err)',
                  'errorsPerMappedBase':'errors per mapped base (ePmb)',
                  'totalScaffoldGaps+totalBleedingHeartScaffoldGaps':'the sum of the total number of scaffold gaps and liberal scaffold gaps (scf)',
                  'scaffolds':'the sum of the total number of scaffold gaps and liberal scaffold gaps (scf)',
                  'totalContigEnds+totalContigEndsWithNs':'the sum of total contig ends and the total contigs ending with N\'s (ctgE+ctgN)',
                  'totalHomoToHeteroSwitches':'the total homozygous to heterozygous switches (hom/het sw)',
                  'errorsPerContig':'errors per contig (ePc)',
                  'totalContigEndsWithInsert':'total contigs ending with insert (e-i)',
                  'totalErrorsHaplotypeToHaplotype':'total haplotype to haplotype errors (h-h)',
                  'totalErrorsHaplotypeToInsert':'total haplotype to insert errors (h-i)',
                  'totalErrorsHaplotypeToDeletion':'total haplotype to deletion errors (h-d)',
                  'totalErrorsNonSpecific':'total non--specific errors (nonSpec)'
                  }

   caption = 'The table is sorted on %s. Column headers are total homozygous to heterozygous switches (hom/het sw), sum of the total scaffold gaps and liberal scaffold gaps (scf), the sum of total contig ends and the total contigs ending with N\'s (ctgE+ctgN), errors per contig (ePc), errors per mapped base (ePmb), total contigs ending with insert (e-i), total haplotype to haplotype errors (h-h), total haplotype to insert errors (h-i), total haplotype to deletion errors (h-d), total non--specific errors (nonSpec) and sum of the errors (\\(\\sum\\) err).' % sortString[ options.sortOn ]
   
   if options.outputRanks:
      printRanks( assembliesList, options )
   else:
      printTable( assembliesList, '', options )