#!/usr/bin/python2

def get_argument_parser():
    parser = argparse.ArgumentParser(
        description="RCAS provides intuitive reports and publication ready graphics"
        " from input peak intervals in BED foramt, generated from clip-seq.")

    parser.add_argument("BED",
                        metavar="BED",
                        nargs="*",
                        help="Target intervals in BED format.")

    parser.add_argument("--RCAS_path", "-r",
                        metavar="path/to/RCAS",
                        required=True,
                        help="Path to RCAS.")

    parser.add_argument("--genome", "-g",
                        metavar="FILE",
                        required=True,
                        help="Reference genome whose version should conform with"
                        " generation of input peak invervals.")

    parser.add_argument("--gff3", "-f",
                        metavar="FILE",
                        required=True,
                        help="Annotation reference in gff3 format.")

    parser.add_argument("--run_motif", "-m",
                        default="False",
                        choices=["True", "False"],
                        help="True: run motif search."
                        " False (default): not run motif search.")

    parser.add_argument("--run_PATHrich", "-p",
                        default="False",
                        choices=["True", "False"],
                        help="True: run pathway enrichment."
                        " False (default): not run pathway enrichment.")

    parser.add_argument("--run_GOrich", "-t",
                        default="False",
                        choices=["True", "False"],
                        help="True: run GO-term enrichment."
                        " False (default): not run GO-term enrichment.")

    parser.add_argument("--run_coverage", "-c",
                        default="False",
                        choices=["True", "False"],
                        help="True: run coverage profile."
                        " False (default): not run coverage_profile profile.")

    return parser

def generate_config():
    pass

def call_snakemake():
    pass

if __name__ == '__main__':

    import argparse

    #process commandline Arguments
    parser = get_argument_parser()
    args = parser.parse_args()

@@ -2154,16 +2154,152 @@
 parser%0A%0A
+def extract_key(filename):%0A    base = os.path.basename(filename)%0A    key = base.split(%22.%22)%5B:-1%5D%0A    key = %22.%22.join(key)%0A    return key%0A%0A
 def gene
@@ -2310,27 +2310,596 @@
 _config(
+args
 ):%0A    
-pass
+BED_files = args.BED%0A    infiles = %7B%7D%0A%0A    for BED in BED_files:%0A        infiles%5Bextract_key(BED)%5D = BED%0A%0A    config = %7B%0A      %22RCAS_path%22: os.path.abspath(args.RCAS_path),%0A%0A      %22gff3%22: args.gff3,%0A%0A      %22genome%22: args.genome,%0A%0A      %22infile%22: infiles,%0A%0A      %22switch%22: %7B%0A        %22run_motif%22: args.run_motif,%0A        %22run_PATHrich%22: args.run_PATHrich,%0A        %22run_GOrich%22: args.run_GOrich,%0A        %22run_coverage%22: args.run_coverage%0A      %7D%0A    %7D%0A%0A    # Writing JSON data%0A    with open('config.json', 'w') as f:%0A         json.dump(config, f, sort_keys=True, indent=4)
 %0A%0Adef ca
@@ -2951,17 +2951,16 @@
 ain__':%0A
-%0A
     impo
@@ -2970,16 +2970,46 @@
 argparse
+%0A    import json%0A    import os
 %0A%0A    #p
@@ -3072,16 +3072,16 @@
 arser()%0A
-
     args
@@ -3103,8 +3103,35 @@
 _args()%0A
+%0A    generate_config(args)%0A

define function to dump arguments to config.json