changeset 6:15f5a3074012 draft

Added snippy core and static binaries for linux and mac.
author simon-gladman
date Thu, 09 Jun 2016 20:15:42 -0400
parents ff31f16f5dfd
children 93d294cd4d59
files macros.xml snippy-core.xml snippy.xml snippy_core_wrapper.pl tool_dependencies.xml
diffstat 5 files changed, 188 insertions(+), 38 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/macros.xml	Thu Jun 09 20:15:42 2016 -0400
@@ -0,0 +1,23 @@
+<macros>
+    <xml name="requirements">
+        <requirements>
+            <requirement type="package" version="3.0">snippy</requirement>
+            <yield/>
+        </requirements>
+    </xml>
+    <xml name="stdio">
+        <stdio>
+            <exit_code range="1:" />
+        </stdio>
+    </xml>
+    <xml name="citations">
+        <citations>
+          <citation type="bibtex">@UNPUBLISHED{Seemann2013,
+            author = "Seemann T",
+            title = "snippy: fast bacterial variant calling from NGS reads",
+            year = "2015",
+            note = "https://github.com/tseemann/snippy"}</citation>
+            <yield />
+        </citations>
+    </xml>
+</macros>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/snippy-core.xml	Thu Jun 09 20:15:42 2016 -0400
@@ -0,0 +1,67 @@
+<tool id="snippy-core" name="snippy-core" version="0.2.0">
+
+  <requirements>
+      <requirement type="package" version="3.0">snippy</requirement>
+  </requirements>
+  <stdio>
+      <exit_code range="1:" />
+  </stdio>
+
+    <command interpreter="perl">
+      <![CDATA[
+
+        snippy_core_wrapper.pl
+        $is_reference
+        --mincov $mincov
+        --indirs '${" ".join(map(str, $indirs))}'
+
+    ]]></command>
+
+    <inputs>
+      <param name="indirs" type="data" multiple="true" format="zip" label="Snippy input zipped dirs" help="Select all the snippy inputs for alignment" />
+      <param name="is_reference" type="boolean" checked="true" truevalue="--noref" falsevalue="" label="Exclude reference" help="Don't include the reference file in the alignment." />
+      <param name="mincov" type="integer" value="10" min="1" label="Minimum coverage" help="Minimum depth of coverage to consider core (default '10')" />
+    </inputs>
+
+    <outputs>
+      <data format="fasta" name="alignment_fasta" label="${tool.name} on ${on_string} core alignment fasta" from_work_dir="core.aln" />
+      <data format="tabular" name="alignment_table" label="${tool.name} on ${on_string} core alignment table" from_work_dir="core.tab" />
+      <data format="txt" name="alignment_summary" label="${tool.name} on ${on_string} core alignment summary" from_work_dir="core.txt" />
+    </outputs>
+
+    <help><![CDATA[
+Synopsis:
+  Combine multiple Snippy folders into a core SNP alignment
+
+Usage:
+  ../../snippy/bin/snippy-core [options] [--noref] snippyDir1/ snippyDir2/ snippyDir3/ ...
+
+Options:
+
+  --help!         This help.
+
+  --quiet!        No output to stderr (default '0').
+
+  --verbose!      Verbose output (default '0').
+
+  --inprefix=s    Preferred input prefix of Snippy files (default 'snps').
+
+  --prefix=s      Output file prefix (default 'core').
+
+  --noref!        Exclude reference (default '0').
+
+  --mincov=i      Minimum depth of coverage to consider core (default '10').
+
+  --aformat=s     Output alignment format: nexus fasta phylip maf clustalw ... (default 'fasta').
+
+    ]]></help>
+
+  <citations>
+    <citation type="bibtex">@UNPUBLISHED{Seemann2013,
+      author = "Seemann T",
+      title = "snippy: fast bacterial variant calling from NGS reads",
+      year = "2015",
+      note = "https://github.com/tseemann/snippy"}</citation>
+  </citations>
+
+</tool>
--- a/snippy.xml	Tue Jun 07 03:41:47 2016 -0400
+++ b/snippy.xml	Thu Jun 09 20:15:42 2016 -0400
@@ -1,16 +1,10 @@
 <tool id="snippy" name="snippy" version="0.2.0">
-    <requirements>
+  <requirements>
       <requirement type="package" version="3.0">snippy</requirement>
-      <requirement type="package" version="1.2">samtools</requirement>
-      <requirement type="package" version="0_9_20_b040236">freebayes</requirement>
-      <requirement type="package" version="0.7.12">bwa</requirement>
-      <requirement type="package" version="0.1.11">vcftools</requirement>
-      <requirement type="package" version="4.0">snpeff</requirement>
-      <requirement type="package" version="8a5602bf07">vcflib</requirement>
-    </requirements>
-    <stdio>
-        <exit_code range="1:" />
-    </stdio>
+  </requirements>
+  <stdio>
+      <exit_code range="1:" />
+  </stdio>
 
     <command><![CDATA[
       #if str( $reftype.ref_type_selector ) == "fasta"
@@ -59,6 +53,10 @@
 
       gunzip out/snps.depth.gz
 
+      &&
+
+      tar -czf out.tgz out
+
 
     ]]></command>
     <inputs>
@@ -125,6 +123,7 @@
       <data format="bam" name="snpsbam" label="${tool.name} on ${on_string} mapped reads (bam)" from_work_dir="out/snps.bam">
         <filter>cleanup is False</filter>
       </data>
+      <data format="zip" name="outdir" label="${tool.name} on ${on_string} out dir" from_work_dir="out.tgz" />
     </outputs>
 
     <tests>
@@ -195,14 +194,13 @@
   --bwaopt [X]      Extra BWA MEM options, eg. -x pacbio (default '')
 
     ]]></help>
+  <citations>
+    <citation type="bibtex">@UNPUBLISHED{Seemann2013,
+      author = "Seemann T",
+      title = "snippy: fast bacterial variant calling from NGS reads",
+      year = "2015",
+      note = "https://github.com/tseemann/snippy"}</citation>
+  </citations>
 
-    <citations>
-      <citation type="bibtex">@UNPUBLISHED{Seemann2013,
-        author = "Seemann T",
-        title = "snippy: fast bacterial variant calling from NGS reads",
-        year = "2015",
-        note = "https://github.com/tseemann/snippy"}
-      </citation>
-    </citations>
 
 </tool>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/snippy_core_wrapper.pl	Thu Jun 09 20:15:42 2016 -0400
@@ -0,0 +1,80 @@
+#!/usr/bin/env perl
+
+#--------------------------------------
+#
+#        snippy_core_wrapper.pl
+#
+# This is an intermediary script between snippy-core.xml and snippy-core
+# It:
+#   - Copys the supplied zipped snippy output files to the working dir
+#   - Untars them to their datafile name
+#   - Builds the snippy-core command and captures the stdout and stderr to files
+#   - Runs the snippy-core command
+#
+#--------------------------------------
+
+use warnings;
+use strict;
+use File::Copy;
+use File::Basename;
+
+my(@Options, $indirs, $mincov, $noref);
+setOptions();
+
+my @list_of_dirs = split /\s+/, $indirs;
+
+#The list of final directories to be passed to snippy-core will be stored here.
+my @snippy_outs;
+
+foreach my $d (@list_of_dirs){
+  #print STDERR "$d\n";
+  my $bn = basename($d);
+  my ($name, $dir, $ext) = fileparse($d, '\..*');
+  copy($d, $bn);
+  #print STDERR "$d, $bn, $name, $dir, $ext\n";
+  `tar -xf $bn`;
+  move("./out", "./$name");
+  unlink($bn);
+  push @snippy_outs, $name;
+}
+
+my $commandline = "snippy-core ";
+
+$commandline .= "--noref " if $noref;
+$commandline .= "--mincov $mincov " if $mincov;
+$commandline .= join(" ", @snippy_outs);
+print STDERR "snippy-core commandline: $commandline\n";
+
+my $ok = system($commandline);
+
+#----------------------------------------------------------------------
+# Option setting routines
+
+sub setOptions {
+  use Getopt::Long;
+
+  @Options = (
+    {OPT=>"help",    VAR=>\&usage,             DESC=>"This help"},
+    {OPT=>"mincov=i",  VAR=>\$mincov, DEFAULT=>'10.0', DESC=>"The minimum coverage to consider."},
+    {OPT=>"noref!", VAR=>\$noref, DEFAULT=>0, DESC=>"Don't include the reference in the alignment."},
+    {OPT=>"indirs=s", VAR=>\$indirs, DEFAULT=>"", DESC=>"A whitespace delimited list of the snippy output zipped dirs."},
+  );
+
+  &GetOptions(map {$_->{OPT}, $_->{VAR}} @Options) || usage();
+
+  # Now setup default values.
+  foreach (@Options) {
+    if (defined($_->{DEFAULT}) && !defined(${$_->{VAR}})) {
+      ${$_->{VAR}} = $_->{DEFAULT};
+    }
+  }
+}
+
+sub usage {
+  print "Usage: $0 [options] -i inputfile > ... \n";
+  foreach (@Options) {
+    printf "  --%-13s %s%s.\n",$_->{OPT},$_->{DESC},
+           defined($_->{DEFAULT}) ? " (default '$_->{DEFAULT}')" : "";
+  }
+  exit(1);
+}
--- a/tool_dependencies.xml	Tue Jun 07 03:41:47 2016 -0400
+++ b/tool_dependencies.xml	Thu Jun 09 20:15:42 2016 -0400
@@ -1,24 +1,6 @@
 <?xml version="1.0"?>
 <tool_dependency>
     <package name="snippy" version="3.0">
-        <repository changeset_revision="f8b5ebbd6121" name="package_snippy_3_0" owner="simon-gladman" toolshed="https://toolshed.g2.bx.psu.edu" />
-    </package>
-    <package name="samtools" version="1.2">
-        <repository changeset_revision="f6ae3ba3f3c1" name="package_samtools_1_2" owner="iuc" toolshed="https://toolshed.g2.bx.psu.edu" />
-    </package>
-    <package name="freebayes" version="0_9_20_b040236">
-        <repository changeset_revision="059e6e3d99cc" name="package_freebayes_0_9_20_b040236" owner="devteam" toolshed="https://toolshed.g2.bx.psu.edu" />
-    </package>
-    <package name="bwa" version="0.7.12">
-        <repository changeset_revision="6af9b24ddeee" name="package_bwa_0_7_12" owner="iuc" toolshed="https://toolshed.g2.bx.psu.edu" />
-    </package>
-    <package name="vcfftools" version="0.1.11">
-        <repository changeset_revision="710efaae2ff8" name="package_vcftools_0_1_11" owner="devteam" toolshed="https://toolshed.g2.bx.psu.edu" />
-    </package>
-    <package name="snpeff" version="4.0">
-        <repository changeset_revision="792d8f4485fb" name="package_snpeff_4_0" owner="iuc" toolshed="https://toolshed.g2.bx.psu.edu" />
-    </package>
-    <package name="vcflib" version="8a5602bf07">
-        <repository changeset_revision="7e67466b033e" name="package_vcflib_8a5602bf07" owner="iuc" toolshed="https://toolshed.g2.bx.psu.edu" />
+        <repository changeset_revision="d23c3f138c54" name="package_snippy_3_0" owner="simon-gladman" toolshed="https://toolshed.g2.bx.psu.edu" />
     </package>
 </tool_dependency>