@transform( importSVs, suffix(".sv.bed.gz"), 
            add_inputs( buildTranscripts),
            ".sv.overlap" )
def countOverlapBetweenSVsandTranscripts( infiles, outfile ):
    to_cluster = True

    infile, transcripts = infiles

    patterns = ( ("ins", "~ /^ins/" ),
                 ("del", "~ /^del/" ),
                 ("other", "!~ /^(ins|del)/"),
                 ("all", "" ), )
                  
    for suffix, tst in patterns:

        statement = '''
        zcat %(transcripts)s 
        | python %(scriptsdir)s/gtf2table.py 
          --genome-file=%(genome)s 
          --counter=overlap 
          --filename-gff=<( zcat < %(infile)s | awk 'tolower($4) %(tst)s'  )
          --filename-format=bed 
          --reporter=transcripts
          --log=%(outfile)s
        | gzip
        > %(outfile)s.%(suffix)s.gz
        '''

        P.run()
        
###################################################################
###################################################################
###################################################################
emprirical mean residual life or expected shortfall
dataset/ETHPy150Open CGATOxford/cgat/obsolete/pipeline_snps.py/countOverlapBetweenSVsandTranscripts--crossover with--dataset/ETHPy150Open statsmodels/statsmodels/statsmodels/sandbox/distributions/try_pot.py/mean_residual_life