raiseargparse.ArgumentTypeError("{0} does not exist".format(x))
returnx
# found on https://stackoverflow.com/questions/14117415/in-python-using-argparse-allow-only-positive-integers
defcheck_positive(value):
ivalue=int(value)
ifivalue<=0:
raiseargparse.ArgumentTypeError("%s is an invalid positive int value"%value)
returnivalue
# Parse command-line arguments
defparse_arguments():
parser=argparse.ArgumentParser(description="Takes as input FASTA file of cDNA sequences, a CSV with sequence counts, and mean and std. dev. of fragment lengths. Outputs most terminal fragment (within desired length range) for each sequence.")
parser.add_argument('--fasta',required=True,type=extant_file,help="FASTA file with cDNA sequences")
parser.add_argument('--counts',required=True,type=extant_file,help="CSV file with sequence counts")
parser.add_argument('--mean',required=False,default=10,type=int,help="Mean fragment length (default: 10)")
parser.add_argument('--std',required=False,default=1,type=int,help="Standard deviation fragment length (defafult: 1)")
parser.add_argument('--mean',required=False,default=10,type=check_positive,help="Mean fragment length (default: 10)")
parser.add_argument('--std',required=False,default=1,type=check_positive,help="Standard deviation fragment length (defafult: 1)")