try:
    import psyco
    psyco.full()
except:
    pass

import sys
from cistematic.core.orthomatcher import orthoMatcher


def main(argv=None):
    if not argv:
        argv = sys.argv

    print "crossmatch: version 1.2"
    if len(argv) < 7:
        print "usage: python %s prefix directory genome1 genefile1 genome2 genefile2 [genome3 genefile3 .....]" % argv[0]
        sys.exit(1)

    prefix = argv[1]
    directory = argv[2]
    matchFiles = {}

    genomesToMatch = (len(argv) - 3) / 2
    for index in range(genomesToMatch):
        genome = argv[3 + index * 2]
        print genome
        if genome not in matchFiles:
            matchFiles[genome] = []

        matchFiles[genome].append(argv[4 + index * 2])

    print matchFiles
    orthoMatcher(matchFiles, prefix, directory, fileList=True)


if __name__ == "__main__":
    main(sys.argv)