changeset 1:386166019772 draft

Uploaded
author crs4
date Tue, 07 Jan 2014 04:48:50 -0500
parents 0ec408bcfc80
children f20db7280f89
files readme.rst ssake.py ssake.xml tool_dependencies.xml
diffstat 4 files changed, 81 insertions(+), 86 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/readme.rst	Tue Jan 07 04:48:50 2014 -0500
@@ -0,0 +1,13 @@
+SSAKE wrapper
+==============
+
+Version history
+---------------
+
+- Release 1: Update to SSAKE 3.8.1. Add <version_command>. Make pylint happier. Simplify code. Add readme.rst .
+- Release 0: Initial release in the Tool Shed.
+
+Development
+-----------
+
+Development is hosted at https://bitbucket.org/crs4/orione-tools . Contributions and bug reports are very welcome!
--- a/ssake.py	Wed Sep 11 12:51:21 2013 -0400
+++ b/ssake.py	Tue Jan 07 04:48:50 2014 -0500
@@ -35,90 +35,12 @@
     return result
 
 
-class SSAKE:
-    def __init__(self, logger, options):
-        self.logger = logger
-        self.executables = ('SSAKE', 'makePairedOutput2EQUALfiles.pl', 'makePairedOutput2UNEQUALfiles.pl')
-        self.logger.debug(which(self.executables[0]))
-        self.logger.debug(which(self.executables[1]))
-        self.logger.debug(which(self.executables[2]))
-        self.logger.debug('Creating temp dir')
-        self.wd = tempfile.mkdtemp()
-        
-        self.kind_of_reads = int(options.kind_of_reads)
-        if not (self.kind_of_reads):
-            self.infile = options.if_unpaired
-            self.paired = 0
-        else:
-            self.infile_r1 = options.if_paired_r1
-            self.infile_r2 = options.if_paired_r2
-            self.paired = 1
-            self.insert_size = options.insert_size
-            self.minnumlinks = options.minnumlinks
-            self.error = options.error
-            self.maxlinkratio = options.maxlinkratio
-            self.minoverlap = options.minoverlap
-        self.mindepthofcoverage = options.mindepthofcoverage
-        self.minoverlappingbases = options.minoverlappingbases
-        self.mincall = options.mincall
-        self.baseratio = options.baseratio
-        self.ignore_header = options.ignore_header
-        self.prefix = options.prefix
-        self.contigs = options.contigs
-        self.log = options.logfile
-        self.short = options.short
-        self.singlets = options.singlets
-        if options.seeds_file:
-            self.seeds_file = options.seeds_file
-
-    def run(self):
-        """ """
-        os.chdir(self.wd)
-        seeds = ''
-        if hasattr(self, 'seeds_file'):
-            seeds = " -s %s" % self.seeds_file
-        if self.kind_of_reads == 1:
-            cmd = "%s %s %s %d" % (
-                self.executables[1], self.infile_r1, self.infile_r2,
-                self.insert_size)
-            self.logger.info("Preparing data")
-            execute(cmd)
-            paired_file = "%s/paired.fa" % self.wd
-            command = "%s -f %s -k %d -e %s -a %s -x %d" % (self.executables[0], paired_file, self.minnumlinks, self.error, self.maxlinkratio, self.minoverlap)
-        elif self.kind_of_reads == 2:
-            cmd = "%s %s %s %d" % (
-                self.executables[2], self.infile_r1, self.infile_r2,
-                self.insert_size)
-            self.logger.info("Preparing data")
-            execute(cmd)
-            paired_file = "%s/paired.fa" % self.wd
-            unpaired_file = "%s/unpaired.fa" % self.wd
-            command = "%s -f %s -g %s -k %d -e %s -a %s -x %d" % (self.executables[0], paired_file, unpaired_file, self.minnumlinks, self.error, self.maxlinkratio, self.minoverlap)
-        else:
-            command = "%s -f %s" % (self.executables[0], self.infile)
-        command += " %s -w %d -m %d -o %d -r %s -h %s -b %s -p %s" % (seeds, self.mindepthofcoverage, self.minoverlappingbases, self.mincall, self.baseratio, self.ignore_header, self.prefix, self.paired)
-        self.logger.debug(command)
-        self.logger.info("Executing SSAKE")
-        execute(command)
-
-        with open("%s.log" % os.path.join(self.wd, self.prefix), 'rb') as ssake_log_file:
-            self.logger.info("\n".join(["Log from SSAKE", ssake_log_file.read()]))
-        self.logger.info("Moving result files")
-        shutil.move("%s.contigs" % os.path.join(self.wd, self.prefix), self.contigs)
-        shutil.move("%s.short" % os.path.join(self.wd, self.prefix), self.short)
-        shutil.move("%s.singlets" % os.path.join(self.wd, self.prefix), self.singlets)
-
-    def __del__(self):
-        shutil.rmtree(self.wd)
-
-
 LOG_FORMAT = '%(asctime)s|%(levelname)-8s|%(message)s'
 LOG_DATEFMT = '%Y-%m-%d %H:%M:%S'
 LOG_LEVELS = ['DEBUG', 'INFO', 'WARNING', 'ERROR', 'CRITICAL']
 
 
 def __main__():
-    """ main function """
     parser = optparse.OptionParser()
     parser.add_option('--if_unpaired', dest='if_unpaired', help='Unpaired FASTA input file name')
     parser.add_option('--if_paired_r1', dest='if_paired_r1', help='Paired FASTA reads 1 input file name')
@@ -154,9 +76,70 @@
         logging.basicConfig(**kwargs)
         logger = logging.getLogger('SSAKE scaffold assembly')
 
-    S = SSAKE(logger, options)
-    S.run()
-    return
+    executables = ('SSAKE', 'makePairedOutput2EQUALfiles.pl', 'makePairedOutput2UNEQUALfiles.pl')
+    logger.debug(which(executables[0]))
+    logger.debug(which(executables[1]))
+    logger.debug(which(executables[2]))
+    logger.debug('Creating temp dir')
+    kind_of_reads = int(options.kind_of_reads)
+    if not (kind_of_reads):
+        infile = options.if_unpaired
+        paired = 0
+    else:
+        infile_r1 = options.if_paired_r1
+        infile_r2 = options.if_paired_r2
+        paired = 1
+        insert_size = options.insert_size
+        minnumlinks = options.minnumlinks
+        error = options.error
+        maxlinkratio = options.maxlinkratio
+        minoverlap = options.minoverlap
+    mindepthofcoverage = options.mindepthofcoverage
+    minoverlappingbases = options.minoverlappingbases
+    mincall = options.mincall
+    baseratio = options.baseratio
+    ignore_header = options.ignore_header
+    prefix = options.prefix
+    contigs = options.contigs
+    short = options.short
+    singlets = options.singlets
+    seeds = " -s %s" % options.seeds_file if options.seeds_file else ''
+    wd = tempfile.mkdtemp()
+    try:
+        os.chdir(wd)
+        if kind_of_reads == 1:
+            cmd = "%s %s %s %d" % (
+                executables[1], infile_r1, infile_r2,
+                insert_size)
+            logger.info("Preparing data")
+            execute(cmd)
+            paired_file = "%s/paired.fa" % wd
+            command = "%s -f %s -k %d -e %s -a %s -x %d" % (executables[0], paired_file, minnumlinks, error, maxlinkratio, minoverlap)
+        elif kind_of_reads == 2:
+            cmd = "%s %s %s %d" % (
+                executables[2], infile_r1, infile_r2,
+                insert_size)
+            logger.info("Preparing data")
+            execute(cmd)
+            paired_file = "%s/paired.fa" % wd
+            unpaired_file = "%s/unpaired.fa" % wd
+            command = "%s -f %s -g %s -k %d -e %s -a %s -x %d" % (executables[0], paired_file, unpaired_file, minnumlinks, error, maxlinkratio, minoverlap)
+        else:
+            command = "%s -f %s" % (executables[0], infile)
+        command += " %s -w %d -m %d -o %d -r %s -h %s -b %s -p %s" % (seeds, mindepthofcoverage, minoverlappingbases, mincall, baseratio, ignore_header, prefix, paired)
+        logger.debug(command)
+        logger.info("Executing SSAKE")
+        execute(command)
+
+        with open("%s.log" % os.path.join(wd, prefix), 'rb') as ssake_log_file:
+            logger.info("\n".join(["Log from SSAKE", ssake_log_file.read()]))
+        logger.info("Moving result files")
+        shutil.move("%s.contigs" % os.path.join(wd, prefix), contigs)
+        shutil.move("%s.short" % os.path.join(wd, prefix), short)
+        shutil.move("%s.singlets" % os.path.join(wd, prefix), singlets)
+    finally:
+        shutil.rmtree(wd)
+
 
 if __name__ == "__main__":
     __main__()
--- a/ssake.xml	Wed Sep 11 12:51:21 2013 -0400
+++ b/ssake.xml	Tue Jan 07 04:48:50 2014 -0500
@@ -1,8 +1,9 @@
 <tool id="ssake" name="SSAKE" version="0.0.10">
   <description>short DNA sequences assembler</description>
   <requirements>
-    <requirement type="package" version="3.8">ssake</requirement>
+    <requirement type="package" version="3.8.1">ssake</requirement>
   </requirements>
+  <version_command>SSAKE 2&gt;&amp;1 | sed -n 's/.*\(SSAKE \[.*\]\).*/\1/p'</version_command>
   <command interpreter="python">
   ssake.py
   #if $kind_of_reads.kind_of_reads_select == '0'
--- a/tool_dependencies.xml	Wed Sep 11 12:51:21 2013 -0400
+++ b/tool_dependencies.xml	Tue Jan 07 04:48:50 2014 -0500
@@ -1,11 +1,9 @@
 <?xml version="1.0"?>
 <tool_dependency>
-  <package name="ssake" version="3.8">
+  <package name="ssake" version="3.8.1">
     <install version="1.0">
       <actions>
-        <action type="download_by_url" target_filename="ssake_v3-8.tar.gz">http://www.bcgsc.ca/platform/bioinfo/software/ssake/releases/3.8/ssake_v3-8-tar.gz</action>
-        <!-- fix for Perl >= 5.16.0-->
-        <action type="shell_command">sed -i -e 's/require "getopts.pl"/use Getopt::Std/' -e 's/&amp;Getopts/getopts/' SSAKE tools/TQSfastq.pl</action>
+        <action type="download_by_url" target_filename="ssake_v3-8-1.tar.gz">http://www.bcgsc.ca/platform/bioinfo/software/ssake/releases/3.8.1/ssake_v3.8.1-tar.gz</action>
         <action type="move_directory_files">
           <source_directory>.</source_directory>
           <destination_directory>$INSTALL_DIR</destination_directory>