@@ -0,0 +1,1704 @@
+#!/usr/bin/env python%0A%22%22%22Read a TSSpredator master table and caclulates the sizes of set%0A   intersections%0A%0A%22%22%22%0A%0A__description__ = %22%22%0A__author__ = %22Konrad Foerstner %3Ckonrad@foerstner.org%3E%22%0A__copyright__ = %222014 by Konrad Foerstner %3Ckonrad@foerstner.org%3E%22%0A__license__ = %22ISC license%22%0A__email__ = %22konrad@foerstner.org%22%0A__version__ = %22%22%0A%0Afrom collections import defaultdict%0Aimport itertools%0Aimport argparse%0Afrom tsspredator import TSSPredatorReader%0A%0Aparser = argparse.ArgumentParser(description=__description__)%0Aparser.add_argument(%22ttspredator_matertable%22, nargs=%22+%22)%0Aargs = parser.parse_args()%0A%0Alibs_and_tsss = defaultdict(set)%0A%0Afor master_table_file in args.ttspredator_matertable:%0A    tss_predator_reader = TSSPredatorReader()%0A    for entry in tss_predator_reader.entries(open(master_table_file)):%0A        # Just require detected not enriched!%0A        if not (entry.is_detected):%0A            continue%0A        libs_and_tsss%5Bentry.genome%5D.add(%22%25s-%25s-%25s%22 %25 (%0A            master_table_file, entry.pos, entry.strand))%0A%0Aprint(%22Total numbers of TSS:%22)%0Afor lib, tsss in libs_and_tsss.items():%0A    print(%22- %25s: %25s%22 %25 (lib, len(tsss)))%0A%0Aprint(%22Size of intersections:%22)%0Afor combo_size in reversed(range(2, len(libs_and_tsss.keys())+1)):%0A    for combination in itertools.combinations(libs_and_tsss.keys(), combo_size):%0A        curr_intersection_set = libs_and_tsss%5Bcombination%5B0%5D%5D%0A        for lib in combination%5B1:%5D:%0A            curr_intersection_set = curr_intersection_set.intersection(libs_and_tsss%5Blib%5D)%0A        print(%22- %25s: %25s%22 %25 (%22, %22.join(combination), len(curr_intersection_set)))%0A%0Afor lib, tsss in libs_and_tsss.items():%0A    with open(%22%25s.csv%22 %25 (lib), %22w%22) as fh:%0A        fh.write(%22%5Cn%22.join(tsss) + %22%5Cn%22)%0A

Add calc_tss_intersections.py