#!/usr/bin/python3
import os
import argparse
'''
This script takes an input file containing space separated label pairs.
Lines starting with # are ignored.

It then constructs filenames using PWC directory and extension as
  <pwc>/A/A_B.<ext>

where A,B is a given pair.
'''

parser = argparse.ArgumentParser(description='get pair files from a list of pairs')
parser.add_argument('-f', '--fpairs',    dest='fpairs',     help='file with pairs',             metavar='FILE', required=True)
parser.add_argument('-p', '--pwc',       dest='pwc',        help='root dir for pairwise files', metavar='FILE', required=True)
parser.add_argument('-e', '--ext',       dest='ext',        help='pairwise file extension',     metavar='FILE', required=False, default='.brh')

options = parser.parse_args()

with open(options.fpairs,'r') as fh:
    for line in fh:
        line = line.strip().rstrip('\n')
        if len(line)==0: continue
        if line[0]=='#': continue
        elems = line.split()
        A = elems[0]
        B = elems[1]
        fname = os.path.join(options.pwc,'{}/{}_{}{}'.format(A,A,B,options.ext))
        print(fname)

