#! /usr/bin/env python

#==================================================================================================
# germline_filter
# Author: Cristian Caloian (OICR)
# Contact: cristian.caloian@oicr.on.ca
#==================================================================================================

from germline_filter.run import encrypt_germline_vcf, filter_vcf, get_germline_positions

import argparse

parser = argparse.ArgumentParser(prog='germline_filter')
parser.add_argument('--version', action='version', version='germline_filter-1.2')
subparsers = parser.add_subparsers()

#--------------------------------------------------------------------------------------------------
encrypt_germline_file = subparsers.add_parser('encrypt_germline_vcf')
encrypt_germline_file.add_argument('--germline', nargs='+', help="Path to the truth germline vcf files to be encrypted.")
encrypt_germline_file.add_argument('--outdir', help="Path to where the trimmed, hashed, and encrypted truth germline vcf should be written.")
encrypt_germline_file.add_argument('--saltfile', help="File where the salt string for hashing will be written.")
encrypt_germline_file.add_argument('--keyfile', help="File where the key string for decryption will be written.")
encrypt_germline_file.add_argument('--encryption', help="Encryption method to be used.", choices=['AES', 'Blowfish'], default='AES')
encrypt_germline_file.add_argument('--hashing', help="Hashing method to be used.", choices=['md5', 'sha512'], default='sha512')
encrypt_germline_file.set_defaults(func=encrypt_germline_vcf)


#--------------------------------------------------------------------------------------------------
germline_filter = subparsers.add_parser('filter')
germline_filter.add_argument('--somatic', nargs='+', help="Path to the somatic vcf files to be checked for germline calls.")
germline_filter.add_argument('--germline', help="Path to the ENCRYPTED truth germline file, as outputted by the 'encrypt_germline_filter' command.")
germline_filter.add_argument('--saltfile', help="File containg salt string for hashing.")
germline_filter.add_argument('--keyfile', help="File containg key string for decryption.")
germline_filter.add_argument('--encryption', help="Encryption method used at the encryption step.", choices=['AES', 'Blowfish'], default='AES')
germline_filter.add_argument('--hashing', help="Hashing method used at the encryption step.", choices=['md5', 'sha512'], default='sha512')
germline_filter.set_defaults(func=filter_vcf)


#--------------------------------------------------------------------------------------------------
germline_positions = subparsers.add_parser('get_germline_positions')
germline_positions.add_argument("--truth", help="Path to truth germline vcf.")
germline_positions.add_argument("--vcfs", nargs='+', help="Path to somatic vcf files.")
germline_positions.add_argument("--outdir", help="Path to the output directory.")
germline_positions.add_argument("--sample", help="Sample name for which truth file is supplied.")
germline_positions.set_defaults(func=get_germline_positions)


#--------------------------------------------------------------------------------------------------
args = parser.parse_args()
args.func(args)
