# HG changeset patch # User greg # Date 1496940718 14400 # Node ID 7000422fbaff8552c692e1b89db222e2dfe6bdf8 Uploaded diff -r 000000000000 -r 7000422fbaff .shed.yml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/.shed.yml Thu Jun 08 12:51:58 2017 -0400 @@ -0,0 +1,14 @@ +name: plant_tribes_gene_family_phylogeny_builder +owner: greg +description: | + Contains a tool that creates multiple sequence alignments and inferred maximum likelihood phylogenies for orthogroups. +homepage_url: https://github.com/dePamphilis/PlantTribes +long_description: | + This tool is one of the PlantTribes collection of automated modular analysis pipelines that utilize objective classifications of + complete protein sequences from sequenced plant genomes to perform comparative evolutionary studies. It performs phylogenomic + analyses by creating multiple sequence alignments and inferred maximum likelihood phylogenies for orthogroups produced by the + GeneFamilyAligner tool. +remote_repository_url: https://github.com/gregvonkuster/galaxy_tools/tree/master/tools/plant_tribes/gene_family_phylogeny_builder +type: unrestricted +categories: +- Phylogenetics diff -r 000000000000 -r 7000422fbaff gene_family_phylogeny_builder.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/gene_family_phylogeny_builder.py Thu Jun 08 12:51:58 2017 -0400 @@ -0,0 +1,58 @@ +#!/usr/bin/env python +import argparse +import os + +import utils + +OUTPUT_DIR = 'geneFamilyPhylogenies_dir' + +parser = argparse.ArgumentParser() + +parser.add_argument('--alignment_type', dest='alignment_type', help='Input alignments type produced by the GeneFamilyAligner') +parser.add_argument('--bootstrap_replicates', dest='bootstrap_replicates', type=int, default=None, help='Number of replicates for rapid bootstrap analysis') +parser.add_argument('--config_dir', dest='config_dir', help='Directory containing default configuration files') +parser.add_argument('--max_orthogroup_size', dest='max_orthogroup_size', type=int, help='Maximum number of sequences in orthogroup alignments') +parser.add_argument('--method', dest='method', help='Protein clustering method') +parser.add_argument('--min_orthogroup_size', dest='min_orthogroup_size', type=int, help='Minimum number of sequences in orthogroup alignments') +parser.add_argument('--num_threads', dest='num_threads', type=int, help='Number of threads to use for execution') +parser.add_argument('--orthogroup_aln', dest='orthogroup_aln', help='Input dataset files_path') +parser.add_argument('--output_phylip', dest='output_phylip', default=None, help='Output for orthogroup phylip multiple sequence alignments') +parser.add_argument('--output_phylip_dir', dest='output_phylip_dir', default=None, help='output_phylip.files_path') +parser.add_argument('--output_tree', dest='output_tree', default=None, help='Output for phylogenetic trees') +parser.add_argument('--output_tree_dir', dest='output_tree_dir', default=None, help='output_tree.files_path') +parser.add_argument('--rooting_order', dest='rooting_order', default=None, help='Rooting order configuration for rooting trees') +parser.add_argument('--scaffold', dest='scaffold', help='Orthogroups or gene families proteins scaffold') +parser.add_argument('--sequence_type', dest='sequence_type', help='Sequence type used in the phylogenetic inference') +parser.add_argument('--tree_inference', dest='tree_inference', help='Phylogenetic trees inference method') + +args = parser.parse_args() + +# Build the command line. +cmd = 'GeneFamilyPhylogenyBuilder' +cmd += ' --alignment_type %s' % args.alignment_type +if args.bootstrap_replicates is not None: + cmd += ' --bootstrap_replicates %d' % args.bootstrap_replicates +cmd += ' --config_dir %s' % args.config_dir +cmd += ' --max_orthogroup_size %d' % args.max_orthogroup_size +cmd += ' --method %s' % args.method +cmd += ' --min_orthogroup_size %d' % args.min_orthogroup_size +cmd += ' --num_threads %d' % args.num_threads +cmd += ' --orthogroup_aln %s' % args.orthogroup_aln +if args.rooting_order is not None: + cmd += ' --rooting_order %s' % args.rooting_order +cmd += ' --scaffold %s' % args.scaffold +cmd += ' --sequence_type %s' % args.sequence_type +cmd += ' --tree_inference %s' % args.tree_inference + +# Run the command. +utils.run_command(cmd) + +# Handle outputs. +if args.output_phylip is not None and args.output_phylip_dir is not None: + src_output_dir = os.path.join(OUTPUT_DIR, 'phylip_aln') + utils.move_directory_files(src_output_dir, args.output_phylip_dir) + utils.write_html_output(args.output_phylip, 'Orthogroup phylip multiple sequence alignments', args.output_phylip_dir) +if args.output_tree is not None and args.output_tree_dir is not None: + src_output_dir = os.path.join(OUTPUT_DIR, 'orthogroups_tree') + utils.move_directory_files(src_output_dir, args.output_tree_dir, copy=True) + utils.write_html_output(args.output_tree, 'Phylogenetic trees', args.output_tree_dir) diff -r 000000000000 -r 7000422fbaff gene_family_phylogeny_builder.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/gene_family_phylogeny_builder.xml Thu Jun 08 12:51:58 2017 -0400 @@ -0,0 +1,246 @@ + + builds phylogenetic trees of aligned orthologous gene family clusters + + macros.xml + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + output_pttree_dir_cond['output_pttree_dir'] == 'yes' + + + tree_inference_cond['tree_inference'] == 'raxml' + + + + + + +This tool is one of the PlantTribes collection of automated modular analysis pipelines for comparative and evolutionary +analyses of genome-scale gene families and transcriptomes. This tool performs gene family phylogenetic inference of +multiple sequence alignments produced by the GeneFamilyAligner tool. + +----- + +**Required options** + + * **Orthogroup alignments** - orthogroup alignment fasta files produced by the GeneFamilyAligner tool selected from your history. Depending on how the GeneFamilyAligner tool was executed, these could either be pre-processed alignments, trimmed alignments or both trimmed and filtered alignments. + * **Gene family scaffold** - one of the PlantTribes gene family scaffolds installed into Galaxy by the PlantTribes Scaffold Download Data Manager tool. + * **Protein clustering method** - gene family scaffold protein clustering method as described in the AssemblyPostProcessor tool. + * **Phylogenetic inference method** - method for estimating orthogroup maximum likelihood (ML) phylogenetic trees. PlantTribes estimates ML phylogenetic trees using either RAxML or FastTree algorithms. + +**Other options** + + * **Rooting order configuration** - select 'Yes' to enable selection of a rooting order configuration file for RAxML. Scaffold configuration templates (.rootingOrder.config) of how to customize the RAxML ML tree rooting order can be found in the scaffold data installed into Galaxy via the PlantTribes Scaffolds Download Data Manager tool, and is also available at the PlantTribes GitHub `repository`_. Phylogenetic tree rooting order settings shown in these templates are used as defaults if 'No' is selected. + * **Bootstrap replicates** - number of bootstrap replicates for RAxML to conduct a rapid bootstrap analysis and search for the best-scoring ML tree (default = 100). + * **Maximum orthogroup size** - maximum number of sequences allowed in orthogroup alignments (default = 100). + * **Minimum orthogroup size** - minimum number of sequences allowed in orthogroup alignments (default = 4). + * **Output additional directory of phylogenetic tree files** - selecting 'Yes' will produce an additional output that has an associated directory of files that are copies of the elements of the phylogenetic trees output dataset collection (this output will be used for future downstream tools). + +.. _repository: https://github.com/dePamphilis/PlantTribes/tree/master/config + + + + + + @article{Wall2008, + journal = {Nucleic Acids Research}, + author = {2. Wall PK, Leebens-Mack J, Muller KF, Field D, Altman NS}, + title = {PlantTribes: a gene and gene family resource for comparative genomics in plants}, + year = {2008}, + volume = {36}, + number = {suppl 1}, + pages = {D970-D976},} + + + @article{Sasidharan2012, + journal = {Nucleic Acids Research}, + author = {3. Sasidharan R, Nepusz T, Swarbreck D, Huala E, Paccanaro A}, + title = {GFam: a platform for automatic annotation of gene families}, + year = {2012}, + pages = {gks631},} + + + @article{Li2003, + journal = {Genome Research} + author = {4. Li L, Stoeckert CJ, Roos DS}, + title = {OrthoMCL: identification of ortholog groups for eukaryotic genomes}, + year = {2003}, + volume = {13}, + number = {9}, + pages = {2178-2189},} + + + @article{Emms2015, + journal = {Genome Biology} + author = {5. Emms DM, Kelly S}, + title = {OrthoFinder: solving fundamental biases in whole genome comparisons dramatically improves orthogroup inference accuracy}, + year = {2015}, + volume = {16}, + number = {1}, + pages = {157},} + + + @article{Stamatakis2014, + journal = {Bioinformatics}, + author = {6. Stamatakis A}, + title = {RAxML Version 8: A tool for Phylogenetic Analysis and Post-Analysis of Large Phylogenies}, + year = {2014}, + url = {http://sco.h-its.org/exelixis/web/software/raxml/index.html},} + + + @article{Price2010, + journal = {PLoS one}, + author = {7. Price MN, Dehal PS, Arkin AP}, + title = {FastTree 2-approximately maximim-likelihood trees for large alignments}, + year = {2010}, + volume = {5}, + number = {3}, + pages = {e9490},} + + + diff -r 000000000000 -r 7000422fbaff macros.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/macros.xml Thu Jun 08 12:51:58 2017 -0400 @@ -0,0 +1,130 @@ + + + 1.0 + + + plant_tribes_assembly_post_processor + + + + + plant_tribes_gene_family_aligner + + + + + plant_tribes_gene_family_classifier + + + + + plant_tribes_gene_family_integrator + + + + + plant_tribes_kaks_analysis + + + + + r-optparse + + + + + plant_tribes_gene_family_phylogeny_builder + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @misc{None, + journal = {None}, + author = {1. Wafula EK}, + title = {Manuscript in preparation}, + year = {None}, + url = {https://github.com/dePamphilis/PlantTribes},} + + + diff -r 000000000000 -r 7000422fbaff plant_tribes_scaffolds.loc.sample --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/plant_tribes_scaffolds.loc.sample Thu Jun 08 12:51:58 2017 -0400 @@ -0,0 +1,4 @@ +## Plant Tribes scaffolds +#Value Name Path Description +#22Gv1.0 22Gv1.0 /plant_tribes/scaffolds/22Gv1.0 22 plant genomes (Angiosperms clusters, version 1.0; 22Gv1.0) +#22Gv1.1 22Gv1.1 /plant_tribes/scaffolds/22Gv1.1 22 plant genomes (Angiosperms clusters, version 1.1; 22Gv1.1) diff -r 000000000000 -r 7000422fbaff tool_data_table_conf.xml.sample --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tool_data_table_conf.xml.sample Thu Jun 08 12:51:58 2017 -0400 @@ -0,0 +1,6 @@ + + + value, name, path, description + +
+
diff -r 000000000000 -r 7000422fbaff utils.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/utils.py Thu Jun 08 12:51:58 2017 -0400 @@ -0,0 +1,80 @@ +import os +import shutil +import subprocess +import sys + +FSTDERR = 'stderr.txt' +FSTDOUT = 'stdout.txt' + + +def check_execution_errors(rc, fstderr, fstdout): + if rc != 0: + fh = open(fstdout, 'rb') + out_msg = fh.read() + fh.close() + fh = open(fstderr, 'rb') + err_msg = fh.read() + fh.close() + msg = '%s\n%s\n' % (str(out_msg), str(err_msg)) + stop_err(msg) + + +def get_response_buffers(): + fstderr = os.path.join(os.getcwd(), FSTDERR) + fherr = open(fstderr, 'wb') + fstdout = os.path.join(os.getcwd(), FSTDOUT) + fhout = open(fstdout, 'wb') + return fstderr, fherr, fstdout, fhout + + +def move_directory_files(source_dir, destination_dir, copy=False): + source_directory = os.path.abspath(source_dir) + destination_directory = os.path.abspath(destination_dir) + if not os.path.isdir(destination_directory): + os.makedirs(destination_directory) + for dir_entry in os.listdir(source_directory): + source_entry = os.path.join(source_directory, dir_entry) + if copy: + shutil.copy(source_entry, destination_directory) + else: + shutil.move(source_entry, destination_directory) + + +def run_command(cmd): + fstderr, fherr, fstdout, fhout = get_response_buffers() + proc = subprocess.Popen(args=cmd, stderr=fherr, stdout=fhout, shell=True) + rc = proc.wait() + # Check results. + fherr.close() + fhout.close() + check_execution_errors(rc, fstderr, fstdout) + + +def stop_err(msg): + sys.exit(msg) + + +def write_html_output(output, title, dir): + with open(output, 'w') as fh: + dir_items = sorted(os.listdir(dir)) + # Directories can only contain either files or directories, + # but not both. + if len(dir_items) > 0: + item_path = os.path.join(dir, dir_items[0]) + if os.path.isdir(item_path): + header = 'Directories' + else: + header = 'Datasets' + else: + header = '' + fh.write('

%s: %d items

\n' % (title, len(dir_items))) + fh.write('

\n') + fh.write('%s\n' % header) + for index, fname in enumerate(dir_items): + if index % 2 == 0: + bgcolor = '#D8D8D8' + else: + bgcolor = '#FFFFFF' + link = '%s\n' % (fname, fname) + fh.write('\n' % (bgcolor, link)) + fh.write('
%s
\n')