#!/usr/local/bin/julia

using ArgParse

function countNucleotides(DNAstring::String)
	A = count(c->c=='A', DNAstring)
	C = count(c->c=='C', DNAstring)
	G = count(c->c=='G', DNAstring)
	T = count(c->c=='T', DNAstring)
	
	return A, C, G, T
end

function main(args)
	# Argument parsing
	configs = ArgParseSettings()

	add_arg_group!(configs, "Options:")
	@add_arg_table! configs begin
		"--input", "-i"
			help	 = "Input filename"
			required = true
			action	 = :store_arg
			arg_type = String
		"--output", "-o"
			help	 = "Output filename"
			required = true
			action	 = :store_arg
			arg_type = String
		end
	# Store arguments to variables
	parsed_args = parse_args(args, configs)
	infile      = parsed_args["input"]
	outfile     = parsed_args["output"]

	# Read file and count nucleotides 
	DNAstring  = open(f->read(f, String), infile)
	@show A, C, G, T = countNucleotides(DNAstring)
	open(f->write(f, "$A $C $G $T"), outfile, "w+")
	
end

main(ARGS)
