seen = set()
    seen_add = seen.add
    return [x for x in array if not (x in seen or seen_add(x))]


# MAIN
if __name__ == "__main__":
    args = interface()

    input_dir = os.path.abspath(args.IN)
    if not input_dir.endswith('/'):
        input_dir += '/'

    output_dir = os.path.abspath(args.OUT)
    if not output_dir.endswith('/'):
        output_dir += '/'

    task_rank = args.task_rank - 1

    FP = glob.glob(os.path.join(input_dir, '*.hashq.*'))
    FP = [fp[fp.rfind('/') + 1:] for fp in FP]
    FP = list(unique([fp[:fp.index('.')] for fp in FP]))
    file_prefix = FP[task_rank % len(FP)]

    print('Merging sample ' + file_prefix)

    # SUPER DUMB to hardcode the fraction size
    file_fraction = int(task_rank / len(FP))
    hashobject = Fastq_Reader(input_dir, output_dir)
    H = hashobject.hash_counts_from_hashq(file_prefix,
                                          multi_files_fraction=file_fraction)
help_message = 'usage example: python merge_hashq_files.py -r 3 -i /project/home/hashed_reads/ -o /project/home/hashed_reads/'
if __name__ == "__main__":
	try:
		opts, args = getopt.getopt(sys.argv[1:],'hr:i:o:',["filerank=","inputdir=","outputdir="])
	except:
		print help_message
		sys.exit(2)
	for opt, arg in opts:
		if opt in ('-h','--help'):
			print help_message
			sys.exit()
		elif opt in ('-r','--filerank'):
			fr = int(arg) - 1
		elif opt in ('-i','--inputdir'):
			inputdir = arg
			if inputdir[-1] != '/':
				inputdir += '/'
		elif opt in ('-o','--outputdir'):
			outputdir = arg
			if outputdir[-1] != '/':
				outputdir += '/'
	FP = glob.glob(os.path.join(inputdir,'*.hashq.*'))
	FP = [fp[fp.rfind('/')+1:] for fp in FP]
	FP = list(set([fp[:fp.index('.')] for fp in FP]))
	file_prefix = FP[fr%len(FP)]
	# SUPER DUMB to hardcode the fraction size
	file_fraction = fr/len(FP)
	hashobject = Fastq_Reader(inputdir,outputdir)
	H = hashobject.hash_counts_from_hashq(file_prefix,multi_files_fraction=file_fraction)