Exemplo n.º 1
0
def main(argv):
    import genomon_post_analysis.subcode.tools as tools
    import argparse
    
    parser = argparse.ArgumentParser(prog = prog)
    
    parser.add_argument("--version", action = "version", version = tools.version_text())
    parser.add_argument("--config_file", help = "config file", type = str, default = "")

    args = parser.parse_args(argv)
    
    # config
    [config, conf_file] = tools.load_config(args.config_file)
    
    tools.print_conf(config, conf_file, "Genomon Post Analysis")
Exemplo n.º 2
0
def main(mode, argv):

    import os
    import argparse
    
    parser = argparse.ArgumentParser(prog = prog)

    parser.add_argument("--version", action = "version", version = tools.version_text())
    parser.add_argument('mode', choices=['dna', 'rna', 'mutation', 'sv', 'qc', 'fusion', 'starqc'], help = "analysis type")
    parser.add_argument("output_dir", help = "output file path", type = str)
    parser.add_argument("genomon_root", help = "Genomon root path", type = str)
    parser.add_argument("sample_sheet", help = "sample file of Genomon", type = str)
    parser.add_argument("--config_file", help = "config file", type = str, default = "")
    
    # for genomon-call
    parser.add_argument("--input_file_case1", help = "input file", type = str, default = "")
    parser.add_argument("--input_file_case2", help = "input file", type = str, default = "")
    parser.add_argument("--input_file_case3", help = "input file", type = str, default = "")
    parser.add_argument("--input_file_case4", help = "input file", type = str, default = "")
    parser.add_argument("--samtools", help = "samtool's path", type = str, default = "")
    parser.add_argument("--bedtools", help = "bedtool's path", type = str, default = "")
    
    args = parser.parse_args(argv)
    
    # dirs
    output_dir = os.path.abspath(args.output_dir)
    if (os.path.exists(output_dir) == False):
        os.mkdir(output_dir)
        
    genomon_root = os.path.abspath(args.genomon_root)
    
    # config
    [config, conf_file] = tools.load_config(args.config_file)
    
    sample_conf = capture.load_sample_conf(args.sample_sheet, False)
    if sample_conf == None:
        return
        
    # call functions
    if args.mode == "all":
        if mode == "dna":
            sample_dic = capture.sample_to_list(sample_conf, "sv", genomon_root, config)
            if tools.config_getboolean(config, "igv", "enable") == True:
                call_image_capture("sv", sample_dic, output_dir, genomon_root, sample_conf, config)
            if tools.config_getboolean(config, "bam", "enable") == True:
                call_bam_pickup("sv", sample_dic, output_dir, genomon_root, args.samtools, args.bedtools, sample_conf, config)
            call_merge_result("sv", sample_dic, output_dir, genomon_root, config)
            
            sample_dic = capture.sample_to_list(sample_conf, "mutation", genomon_root, config)
            if tools.config_getboolean(config, "igv", "enable") == True:
                call_image_capture("mutation", sample_dic, output_dir, genomon_root, sample_conf, config)
            if tools.config_getboolean(config, "bam", "enable") == True:
                call_bam_pickup("mutation", sample_dic, output_dir, genomon_root, args.samtools, args.bedtools, sample_conf, config)
            call_merge_result("mutation", sample_dic, output_dir, genomon_root, config)
            
            sample_dic = capture.sample_to_list(sample_conf, "qc", genomon_root, config)
            call_merge_result("qc", sample_dic, output_dir, genomon_root,  config)
    
        elif mode == "rna":
            sample_dic = capture.sample_to_list(sample_conf, "fusionfusion", genomon_root, config)
            call_merge_result("fusion", sample_dic, output_dir, genomon_root,  config)
    
            sample_dic = capture.sample_to_list(sample_conf, "qc", genomon_root, config)
            call_merge_result("starqc", sample_dic, output_dir, genomon_root,  config)
        
    else:
        sample_dic = arg_to_file(args.mode, genomon_root, args, config)
        num = 0
        for key in sample_dic: num += len(sample_dic[key])
        if num == 0:
            sample_dic = capture.sample_to_list(sample_conf, args.mode, genomon_root, config)
            
        if args.mode == "qc":
            call_merge_result(args.mode, sample_dic, output_dir, genomon_root,  config)
        elif args.mode == "fusion":
            call_merge_result(args.mode, sample_dic, output_dir, genomon_root,  config)
        elif args.mode == "starqc":
            call_merge_result(args.mode, sample_dic, output_dir, genomon_root,  config)        
        else:
            if tools.config_getboolean(config, "igv", "enable") == True:
                call_image_capture(args.mode,  sample_dic, output_dir, genomon_root, sample_conf, config)
            if tools.config_getboolean(config, "bam", "enable") == True:
                call_bam_pickup(args.mode,  sample_dic, output_dir, genomon_root, args.samtools, args.bedtools, sample_conf, config)
            call_merge_result(args.mode, sample_dic, output_dir, genomon_root, config)