#!/usr/bin/env python

#executing script for IDR predictor in command line.

#import stuff for making CLI
import os
import sys
import argparse

#import pandas as pd
import pandas as pd
#import protfasta
import protfasta

#from metapredict import meta 
from metapredict import meta

#Parse command line arguments.
parser = argparse.ArgumentParser(description='Graph predicted disorder of amino acid sequences.')
parser.add_argument('data_file', help='Path to fasta file containing sequences to be predicted.')
parser.add_argument('output_path', help='Path for the returned disorder graphs.')
parser.add_argument('-D', '--DPI', default=150, type=int, metavar='DPI',
					help='Optional. Set DPI to change resolution of output graphs. Default is 150.')
parser.add_argument('--remove_characters', action='store_true', 
		help='Use if you want to avoid using any non-alphabetic characters in the fasta headers as file names')

args = parser.parse_args()

DPI=args.DPI

# Test to see if the data_file exists
test_data_file = os.path.abspath(args.data_file)
if not os.path.isfile(test_data_file):
    raise FileNotFoundError('Datafile does not exist.')

# Test to see that the output path is valid
test_output_path = os.path.abspath(args.output_path)
if not os.path.exists(test_output_path):
    raise FileNotFoundError('Output path is not valid.')

if args.remove_characters:
	remove_char = True
else:
	remove_char = False

#run graph_disorder_fasta. For more info, see the graph_disorder_fasta function in meta.py.
meta.graph_disorder_fasta(filepath = args.data_file, DPI=DPI, output_path = args.output_path, remove_characters=remove_char)
#graph_disorder_fasta(filepath, DPI=150, save=True, output_path="", remove_characters=False):