#!python

from pyroe import make_splici_txome

if __name__ == "__main__":
    import argparse
    import sys

    # Create the parser
    parser = argparse.ArgumentParser(description='The pyroe package provides useful functions for preparing input files required by alevin-fry.',
                                        prog='pyroe')
    subparsers = parser.add_subparsers(title='subcommands', dest='command',
                                        description='valid subcommands',
                                        help='additional help')
    parser_makeSplici = subparsers.add_parser('make-splici', help='Make splici reference')
    parser_makeSplici.add_argument('genome_path', metavar='genome-path', type=str, help='The path to a genome fasta file.')
    parser_makeSplici.add_argument('gtf_path', metavar='gtf-path', type=str, help='The path to a gtf file.')
    parser_makeSplici.add_argument('read_length', metavar='read-length', type=int, help='The read length of the single-cell experiment being processed (determines flank size).')
    parser_makeSplici.add_argument('output_dir', metavar='output-dir', type=str, help='The output directory where splici reference files will be written.')
    parser_makeSplici.add_argument('--filename-prefix', type=str, default="splici", help='The file name prefix of the generated output files.')
    parser_makeSplici.add_argument('--flank-trim-length', type=int, default=5, help='Determines the amount subtracted from the read length to get the flank length.')
    parser_makeSplici.add_argument('--extra-spliced', type=str, help='The path to an extra spliced sequence fasta file.')
    parser_makeSplici.add_argument('--extra-unspliced', type=str, help='The path to an extra unspliced sequence fasta file.')
    parser_makeSplici.add_argument('--bt-path', type=str, default="bedtools", help='The path to bedtools v2.30.0 or greater.')
    parser_makeSplici.add_argument('--no-bt', action='store_true', help='A flag indicates whether bedtools will be used for generating splici reference files.')
    parser_makeSplici.add_argument('--dedup-seqs', action='store_true', help='A flag indicates whether identical sequences will be deduplicated.')
    parser_makeSplici.add_argument('--no-flanking-merge', action='store_true', help='A flag indicates whether flank lengths will be considered when merging introns.')

    # Execute the parse_args() method
    args = parser.parse_args()
    if args.command != 'make-splici':
        print(parser.print_help())
        sys.exit(1)
 
    make_splici_txome.make_splici_txome(
    genome_path=args.genome_path,
    gtf_path=args.gtf_path,
    read_length=args.read_length,
    output_dir=args.output_dir,
    flank_trim_length=args.flank_trim_length,
    filename_prefix=args.filename_prefix,
    extra_spliced=args.extra_spliced,
    extra_unspliced=args.extra_unspliced,
    dedup_seqs=args.dedup_seqs,
    no_bt=args.no_bt,
    bt_path=args.bt_path,
    no_flanking_merge=args.no_flanking_merge)
