def readJunctions(filename_junctions):
    '''read junctions from a tab-separated file.

    returns a dictionary of dictionaries for splice junctions per
    contig and position.
    '''

    junctions = collections.defaultdict(dict)
    infile = open(filename_junctions, "r")
    njunctions = 0

    for line in infile:
        if line.startswith("#"):
            continue
        data = line[:-1].split("\t")
        if data[0] == "contig":
            continue
        contig, strand, end, start, frame = data[:5]
        start, end, frame = int(start), int(end), int(frame)
        j = junctions[contig]
        if end in j:
            j[end].add((strand, start, frame))
        else:
            j[end] = set(((strand, start, frame),))
        njunctions += 1

    infile.close()
    E.info("read %i junctions for %i contigs" % (njunctions, len(junctions)))
    return junctions
dataset/ETHPy150Open CGATOxford/cgat/scripts/snp2table.py/readJunctions/original