

@merge(countReads, 'reads_summary.load')
def loadReadCounts(infiles, outfile):
    'load read counts into database.'
    to_cluster = False
    outf = P.getTempFile()
    outf.write('track\ttotal_reads\n')
    for infile in infiles:
        track = P.snip(infile, '.nreads')
        lines = IOTools.openFile(infile).readlines()
        nreads = int(lines[0][:(- 1)].split('\t')[1])
        outf.write(('%s\t%i\n' % (track, nreads)))
    outf.close()
    inname = outf.name
    tablename = P.toTable(outfile)
    statement = 'python %(scriptsdir)s/csv2db.py -t %(tablename)s --log=%(outfile)s.log \n                  < %(inname)s > %(outfile)s'
    P.run()
    os.unlink(outf.name)

dataset/ETHPy150Open CGATOxford/cgat/obsolete/pipeline_metagenomecommunities.py loadReadCounts/original