arg_parser.add_argument("--distance_cutoff", help="r2, or kb distance")
args = arg_parser.parse_args()

#
# Create directories and logging dirs:
#
#ShellUtils.mkdirs(args.output_dir_path)
if args.distance_type == "ld":
	output_dir_path = args.output_dir_path+"/ld"+str(args.distance_cutoff)
	ld_cutoff = args.distance_cutoff
if args.distance_type == "kb":
	output_dir_path = args.output_dir_path+"/kb"+str(args.distance_cutoff)
	kb_cutoff = args.distance_cutoff


ShellUtils.mkdirs(output_dir_path + "/snplists/")
ShellUtils.mkdirs(output_dir_path + "/ldlists/")
log_dir_path = output_dir_path + "/log" # Pascal - FIXED ERROR. : before it was /log/
ShellUtils.mkdirs(log_dir_path)

print("Running with %s option, using cutoff %s"%(args.distance_type,args.distance_cutoff))

#
#prepare queue parameters and commands
#
##TODO@@ Adjust queue parameters??
queue_name = "cbs"
#walltime="604800" # 60*60*24*7=7 days
#walltime="86400" # 60*60*24=1 day
mem_per_job="10gb" #=>> PBS: job killed: mem job total 4323312 kb exceeded limit 3145728 kb
flags = "sharedmem"
	print "The genotype_prefix is set to: %s" % genotype_prefix
	print "You will overwrite files in /snplists and /ldlists if the parameters in step1/ and step2/ do not match"
	print "Plese confirm that this is the correct paths to use by typing 'yes'"
	while ans != 'yes':
	 	ans = raw_input("Confirm: ")
	print "Ok let's start..."

######### Non-finished statement for checking if /snplists path. #######
# if True:
# 	snp_list_dir = os.path.join(output_dir_path, "snplists")
# 	if os.listdir(snp_list_dir):  # directory is NOT empty
# 		print "It apears that the /snplists path is non-empty"
#########################################################################


ShellUtils.mkdirs(output_dir_path + "/snplists/") #TODO: remove trailing slash and see if it still works
ShellUtils.mkdirs(output_dir_path + "/ldlists/") #TODO: remove trailing slash and see if it still works
log_dir_path = output_dir_path + "/log" # Pascal - FIXED ERROR. : before it was /log/
ShellUtils.mkdirs(log_dir_path)

print("Running with %s option, using cutoff %s"%(args.distance_type,args.distance_cutoff))

#
#prepare queue parameters and commands
#
##TODO@@ Adjust queue parameters??
queue_name = "idle" # default - 06/15/2014
#queue_name = "idle" 
walltime="604800" # 60*60*24*7=7 days
#walltime="86400" # 60*60*24=24 hours - 06/15/2014
#mem_per_job="15gb" #=>> PBS: job killed: mem job total 4323312 kb exceeded limit 3145728 kb
# Parse arguments  
arg_parser = argparse.ArgumentParser(description="Run parse_matched_SNPs.py")
arg_parser.add_argument("--plink_matched_snps_path", \
	help="""Path for plink_matched_snps.py results which contain 3 directories [ldlists, log, snplists],
e.g. /home/projects/tp/childrens/snpsnap/data/step2/1KG_full_queue/ld0.5/
NB. please use symlinks in the path, i.e. do not use /net/home...""", required=True)
#NB. Also check that the path has a trailing slash (/)
args = arg_parser.parse_args()

path = os.path.abspath(args.plink_matched_snps_path) # Trailing slash are removed/corrected - NICE!
#^^^ E.g. "/home/projects/tp/tools/matched_snps/src/hapmap/ld0.5/"
#^^^ E.g. "/home/projects/tp/childrens/snpsnap/data/step2/1KG_test_thin0.1/ld0.5/"
log_dir_path = path + "/log" #PASCAL: PROBLEM fixed with extra slash
stat_gene_density_path = path + "/stat_gene_density"
ShellUtils.mkdirs(stat_gene_density_path)

### Make sure that the genotype prefix is correct ###
if False:
	ans = ""
	print "*** SAFETY CHECK! ***"
	print "You specifed --plink_matched_snps_path to be: %s" % args.plink_matched_snps_path
	#print "NB Please check that the path has a trailing slash (/) - It may not work without - FIX THIS!"
	print "Plese confirm that this is the correct path to use by typing 'yes'"
	while ans != 'yes':
	 	ans = raw_input("Confirm: ")
	print "Ok let's start..."


submit(path, stat_gene_density_path)