def toContigScafMap(scaffToContigListDict):
    """
        Transforms the input dictionary (key -> list of items) into the inverse dictionary (item -> key).
        To each item (contig) only one key (scaffold) exists.

        @param scaffToContigListDict: map: scaffold -> list of contigs

        @return: map: contig name -> scaffold name
    """
    contigToScaffDict = dict()
    for scaff in scaffToContigListDict:
        for contig in scaffToContigListDict[scaff]:
            assert contig not in contigToScaffDict, str('Contig: ' + contig + ' is not allowed to be twice in the directory!')
            contigToScaffDict[contig] = scaff
    return contigToScaffDict