def read_prophage_table(infile):
    """
    Reads tab-delimited table with columns for:
    1 - path to GenBank file,
    2 - replicon id,
    3 - prophage start coordinate,
    4 - prophage end coordinate,
    5 (optional) - prophage name (if not provided pp1, pp2, etc. 
    will be assigned for each file)
    :param infile: path to the file
    :return prophages: dictionary of GenBank file(s) paths, replicons and prophages coordinates
    """

    prophages = {}
    with open(infile) as inf:
        for line in inf:
            if line.startswith('#'): continue

            line = line.strip().split('\t')
            file_path, replicon_id, start, end = line[:4]

            # adjust coords to Python's indexing
            coords = (int(start) - 1, int(end) - 1)

            if start > end:
                start, end = end, start

            if file_path in prophages:
                pp_cnt = len(prophages[file_path]) + 1
            else: 
                pp_cnt = 1

            pp = line[4] if len(line) == 5 else  f"pp{pp_cnt}"

            try:
                prophages[file_path][replicon_id][coords] = pp
            except KeyError:
                try:
                    prophages[file_path][replicon_id] = {coords: pp}
                except KeyError:
                    prophages[file_path] = {replicon_id: {coords: pp}}

    return prophages