# HG changeset patch # User matnguyen # Date 1551771400 18000 # Node ID baf1e89b42eb1a31ec847d99a1ec4b43299fc773 # Parent c1b6f5fbbcadd7f4c8a7063a2c399448b645670e Added config builder diff -r c1b6f5fbbcad -r baf1e89b42eb galaxy/tools/concatenator/concatenator --- a/galaxy/tools/concatenator/concatenator Fri Feb 01 16:56:03 2019 -0500 +++ b/galaxy/tools/concatenator/concatenator Tue Mar 05 02:36:40 2019 -0500 @@ -6,9 +6,18 @@ parser = ap.ArgumentParser(prog='concatenater', conflict_handler='resolve', description="Concatenates all accessions and their associated paths") -input = parser.add_argument_group('Input', '') -input.add_argument('-n', '--name', nargs='+', required=True, help="Sample name (accessions)") -input.add_argument('-i', '--input', nargs='+', required=True, help="Paths to calls") +subparser = parser.add_subparsers(dest='subcommand') + +variant_parser = subparser.add_parser(name='variant', help="Concatenate variant call files") +variant_parser.add_argument('-n', '--name', nargs='+', required=True, help="Sample name (accessions)") +variant_parser.add_argument('-i', '--input', nargs='+', required=True, help="Paths to calls") + +cluster_parser = subparser.add_parser('cluster') +cluster_parser.add_argument('--mlst', metavar="MLST", type=str, help="MLST clusters/distance matrix") +cluster_parser.add_argument('--snp', metavar="SNP", type=str, help="SNP clusters/distance matrix") +cluster_parser.add_argument('--cnv', metavar="CNV", type=str, help="CNV clusters/distance matrix") +cluster_parser.add_argument('--spoligo', metavar="SPOLIGO", type=str, help="Spoligotyping clusters/distance matrix") +# cluster_parser.add_argument('--kwip', metavar="KWIP", type=str, help="Kwip clusters/distance matrix") if len(sys.argv) == 1: parser.print_usage() @@ -17,5 +26,13 @@ args = parser.parse_args() output = open('paths.txt', 'w') -for index,path in enumerate(args.input): - output.write("%s=%s\n" % (args.name[index], path)) +if args.subcommand == 'variant': + for index,path in enumerate(args.input): + output.write("%s=%s\n" % (args.name[index], path)) +elif args.subcommand == 'cluster': + variant_types = [(args.mlst, 'MLST'), (args.snp, 'SNP'), (args.cnv, 'CNV'), (args.spoligo, 'spoligotyping')] + for variant in variant_types: + if variant[0] == None: + continue + else: + output.write("%s=%s\n" % (variant[1], variant[0])) diff -r c1b6f5fbbcad -r baf1e89b42eb galaxy/tools/concatenator/concatenator.xml --- a/galaxy/tools/concatenator/concatenator.xml Fri Feb 01 16:56:03 2019 -0500 +++ b/galaxy/tools/concatenator/concatenator.xml Tue Mar 05 02:36:40 2019 -0500 @@ -5,12 +5,70 @@ + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff -r c1b6f5fbbcad -r baf1e89b42eb galaxy/tools/config_builder/config_builder --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/galaxy/tools/config_builder/config_builder Tue Mar 05 02:36:40 2019 -0500 @@ -0,0 +1,185 @@ +#!/usr/bin/env python + +import sys +import yaml +import argparse as ap + +parser = ap.ArgumentParser(prog='config_builder', conflict_handler='resolve', + description="Builds the config file for PathOGiST") + +parser.add_argument('yaml', help="Blank config file") +parser.add_argument('forward', help="File to list of forward reads") +parser.add_argument('reverse', help="File to list of reverse reads") +parser.add_argument('output', help="Output prefix for final consensus clustering and visualization") + +tools = parser.add_argument_group('Tools') +tools.add_argument('--snippy', action='store_true', help="Run Snippy") +tools.add_argument('--kwip', action='store_true', help="Run Kwip") +tools.add_argument('--prince', action='store_true', help="Run Prince") +tools.add_argument('--spotyping', action='store_true', help="Run Spotyping") +tools.add_argument('--mentalist', action='store_true', help="Run Mentalist") + +mentalist = parser.add_argument_group('Mentalist') +mentalist.add_argument('--local_file', action='store_true', help="Use local database") +mentalist.add_argument('--build_db', action='store_true', help="Build a database") +mentalist.add_argument('--download_pubmlst', action='store_true', help="Download pubMLST scheme") +mentalist.add_argument('--download_cgmlst', action='store_true', help="Download cgMLST scheme") +mentalist.add_argument('--download_enterobase', action='store_true', help="Download Enterobase scheme") + +mentalist.add_argument('--local_db', metavar="STRING", help="Location of database") +mentalist.add_argument('--kmer', metavar="INT", help="Kmer size") +mentalist.add_argument('--fasta_files', metavar="STRING", help="Location of FASTA files for MLST scheme") +mentalist.add_argument('--profile', metavar="STRING", help="Profile file for known genotypes") +mentalist.add_argument('--scheme', metavar="STRING", help="Species name or scheme ID") +mentalist.add_argument('--entero_scheme', metavar="STRING", help="(S)almonella, (Y)ersinia, or (E)scherichia/Shigella") +mentalist.add_argument('--entero_type', metavar="STRING", help="'cg' or 'wg' for cgMLST or wgMLST, respectively.") +mentalist.add_argument('--mutation_threshold', metavar="INT", help="Maximum number of mutations when looking for novel " + "alleles") +mentalist.add_argument('--kt', metavar="INT", help="Minimum number of times a kmer is seen to be considered present " + "in the sample") + +kwip = parser.add_argument_group('Kwip') +kwip.add_argument('--N', metavar="INT", help="Number of tables") +kwip.add_argument('--x', metavar="INT", help="Maximum table size") +kwip.add_argument('--ksize', metavar="INT", help="kmer size to use") +kwip.add_argument('--unique_kmers', metavar="INT", help="Approximate number of unique kmers in the input set") + +snippy = parser.add_argument_group('Snippy') +snippy.add_argument('--reference', metavar="STRING", help="Reference genome. Supports FASTA, GenBank, EMBL (not GFF)") +snippy.add_argument('--mapqual', metavar="INT", help="Minimum read mapping quality to consider") +snippy.add_argument('--basequal', metavar="INT", help="Minimum base quality to consider") +snippy.add_argument('--mincov', metavar="INT", help="Minimum coverage of variant site") +snippy.add_argument('--minfrac', metavar="FLOAT", help="Minimum proportion for variant evidence") + +clustering = parser.add_argument_group('Clustering') +clustering.add_argument('--fine_snp', action='store_true', help="Use SNP as a fine datatype") +clustering.add_argument('--fine_mlst', action='store_true', help="Use MLST as a fine datatype") +clustering.add_argument('--fine_kwip', action='store_true', help="Use Kwip as a fine datatype") +clustering.add_argument('--fine_spoligo', action='store_true', help="Use Spoligotyping as a fine datatype") +clustering.add_argument('--fine_cnv', action='store_true', help="Use CNV as a fine datatype") +clustering.add_argument('--snp_thresh', metavar="INT", help="Threshold value for SNP") +clustering.add_argument('--mlst_thresh', metavar="INT", help="Threshold value for MLST") +clustering.add_argument('--kwip_thresh', metavar="INT", help="Threshold value for Kwip") +clustering.add_argument('--spoligo_thresh', metavar="INT", help="Threshold value for Spoligotyping") +clustering.add_argument('--cnv_thresh', metavar="INT", help="Threshold value for CNV") +clustering.add_argument('--less_constraints', action='store_true', help="Use less constraints when clustering") +clustering.add_argument('--method', metavar="STRING", help="Use `C4` or `ILP` as clustering method") +clustering.add_argument('--no_presolve', action='store_true', help="Do not perform presolving") +clustering.add_argument('--visualize', action='store_true', help="Visualize clusters") + +if len(sys.argv) == 1: + parser.print_usage() + sys.exit(1) + +args = parser.parse_args() + +with open(args.yaml) as f: + list_doc = yaml.load(f) + +for line in list_doc: + if line == 'temp': + list_doc[line] = 'tmp_dir' + + if line == 'threads': + pass + + if line == 'run': + if args.snippy: + list_doc[line]['snippy'] = 1 + if args.kwip: + list_doc[line]['kwip'] = 1 + if args.prince: + list_doc[line]['prince'] = 1 + if args.spotyping: + list_doc[line]['spotyping'] = 1 + if args.mentalist: + list_doc[line]['mentalist'] = 1 + + if line == 'genotyping': + # Forward and reverse reads + list_doc[line]['input_reads']['forward_reads'] = args.forward + list_doc[line]['input_reads']['reverse_reads'] = args.reverse + + if args.mentalist: + if args.local_file: + list_doc[line]['mentalist']['local_file']['database'] = args.local_db + elif args.build_db: + list_doc[line]['mentalist']['build_db']['options']['k'] = args.kmer + list_doc[line]['mentalist']['build_db']['options']['fasta_files'] = args.fasta_files + list_doc[line]['mentalist']['build_db']['options']['profile'] = args.profile + elif args.download_pubmlst: + list_doc[line]['mentalist']['download_pubmlst']['options']['k'] = args.kmer + list_doc[line]['mentalist']['download_pubmlst']['options']['scheme'] = args.scheme + elif args.download_cgmlst: + list_doc[line]['mentalist']['download_cgmlst']['options']['k'] = args.kmer + list_doc[line]['mentalist']['download_cgmlst']['options']['scheme'] = args.scheme + elif args.download_enterobase: + list_doc[line]['mentalist']['download_enterobase']['options']['k'] = args.kmer + list_doc[line]['mentalist']['download_enterobase']['options']['scheme'] = args.entero_scheme + list_doc[line]['mentalist']['download_enterobase']['options']['type'] = args.entero_type + + if args.mutation_threshold: + list_doc[line]['mentalist']['call']['options']['mutation_threshold'] = args.mutation_threshold + if args.kt: + list_doc[line]['mentalist']['call']['options']['kt'] = args.kt + + if args.kwip: + if args.N: + list_doc[line]['kwip']['khmer_options']['N'] = args.N + if args.x: + list_doc[line]['kwip']['khmer_options']['x'] = args.x + if args.ksize: + list_doc[line]['kwip']['khmer_options']['ksize'] = args.ksize + if args.unique_kmers: + list_doc[line]['kwip']['khmer_options']['unique-kmers'] = args.unique_kmers + + if args.snippy: + list_doc[line]['snippy']['options']['reference'] = args.reference + if args.mapqual: + list_doc[line]['snippy']['options']['mapqual'] = args.mapqual + if args.basequal: + list_doc[line]['snippy']['options']['basequal'] = args.basequal + if args.mincov: + list_doc[line]['snippy']['options']['mincov'] = args.mincov + if args.minfrac: + list_doc[line]['snippy']['options']['minfrac'] = args.minfrac + + if line == 'clustering': + list_doc[line]['output_prefix'] = args.output + + fine = [] + if args.fine_snp: + fine.append('SNP') + if args.fine_mlst: + fine.append('MLST') + if args.fine_kwip: + fine.append('kWIP') + if args.fine_spoligo: + fine.append('spoligotyping') + if args.fine_cnv: + fine.append('CNV') + list_doc[line]['fine_clusterings'] = fine + + if args.snp_thresh: + list_doc[line]['thresholds']['SNP'] = args.snp_thresh + if args.mlst_thresh: + list_doc[line]['thresholds']['MLST'] = args.snp_thresh + if args.kwip_thresh: + list_doc[line]['thresholds']['kWIP'] = args.snp_thresh + if args.spoligo_thresh: + list_doc[line]['thresholds']['spoligotyping'] = args.snp_thresh + if args.cnv_thresh: + list_doc[line]['thresholds']['CNV'] = args.snp_thresh + + if args.less_constraints: + list_doc[line]['all_constraints'] = False + if args.method: + list_doc[line]['method'] = args.method + if args.no_presolve: + list_doc[line]['presolve'] = False + if args.visualize: + list_doc[line]['visualize'] = True + +with open("config.yaml", 'w') as f: + yaml.dump(list_doc, f) + diff -r c1b6f5fbbcad -r baf1e89b42eb galaxy/tools/config_builder/config_builder.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/galaxy/tools/config_builder/config_builder.xml Tue Mar 05 02:36:40 2019 -0500 @@ -0,0 +1,243 @@ + + : Creates and populates the config file to run PathOGiST + + pathogist + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff -r c1b6f5fbbcad -r baf1e89b42eb galaxy/tools/visualization/visualization.xml --- a/galaxy/tools/visualization/visualization.xml Fri Feb 01 16:56:03 2019 -0500 +++ b/galaxy/tools/visualization/visualization.xml Tue Mar 05 02:36:40 2019 -0500 @@ -5,7 +5,7 @@