@transform(loadLiverTestesUnique, suffix(".bed.load"), ".gc_content")
def exportLiverTestesUniqueGC( infile, outfile ):
    track = P.snip( os.path.basename( infile ), ".liver.testes.unique.bed.load" ).replace(".","_").replace("-","_")
    geneset_name = PARAMS["geneset_name"]
    # Connect to DB
    dbhandle = sqlite3.connect( PARAMS["database"] )
    cc = dbhandle.cursor()
    statement = "ATTACH DATABASE '%s' AS annotations; "  % (PARAMS["geneset_database"])
    cc.execute(statement)
    # Extract data from db
    query = '''SELECT pGC
                FROM %(track)s_capseq_composition c, %(track)s_intervals i, 
                %(track)s_liver_testes_unique_intervals s
                WHERE c.gene_id=i.interval_id
                AND i.contig=s.contig
                AND i.start=s.start''' % locals()
    cc.execute( query )
    E.info( query )
    # Write to file
    outs = open( outfile, "w")
    #outs.write("gene_id\n")
    for result in cc:
        pre = ""
        for r in result:
            outs.write("%s%s" % (pre, str(r)) )
            pre = "\t"
        outs.write("\n")
    cc.close()
    outs.close()

############################################################
Export list of genes with TSS associated CAPseq intervals in both liver and testes
dataset/ETHPy150Open CGATOxford/cgat/obsolete/pipeline_proj007.py/exportLiverTestesUniqueGC