changeset 11:e04dbae2abe0 draft

planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tool_collections/cufflinks/cufflinks commit 82ee6fc860c52c531b7a57bbb346ab1a67a434a5
author devteam
date Sun, 19 Feb 2017 12:12:28 -0500
parents 83bec71c5c9f
children d080005cffe1
files cuff_macros.xml cufflinks_wrapper.py cufflinks_wrapper.xml tool_dependencies.xml
diffstat 4 files changed, 68 insertions(+), 40 deletions(-) [+]
line wrap: on
line diff
--- a/cuff_macros.xml	Tue Feb 07 18:39:22 2017 -0500
+++ b/cuff_macros.xml	Sun Feb 19 12:12:28 2017 -0500
@@ -8,14 +8,6 @@
     </requirements>
   </xml>
 
-  <xml name="stdio">
-    <stdio>
-        <exit_code range="1:" />
-        <exit_code range=":-1" />
-        <regex match="Error" />
-        <regex match="Exception" />
-    </stdio>
-  </xml>
   <xml name="condition_inputs">
     <!-- DEFAULT : use BAM/SAM files -->
     <conditional name="in_type">
--- a/cufflinks_wrapper.py	Tue Feb 07 18:39:22 2017 -0500
+++ b/cufflinks_wrapper.py	Sun Feb 19 12:12:28 2017 -0500
@@ -7,7 +7,71 @@
 import sys
 import tempfile
 
-from galaxy.datatypes.util.gff_util import gff_attributes_to_str, parse_gff_attributes
+
+def parse_gff_attributes( attr_str ):
+    """
+    Parses a GFF/GTF attribute string and returns a dictionary of name-value
+    pairs. The general format for a GFF3 attributes string is
+
+        name1=value1;name2=value2
+
+    The general format for a GTF attribute string is
+
+        name1 "value1" ; name2 "value2"
+
+    The general format for a GFF attribute string is a single string that
+    denotes the interval's group; in this case, method returns a dictionary
+    with a single key-value pair, and key name is 'group'
+    """
+    attributes_list = attr_str.split(";")
+    attributes = {}
+    for name_value_pair in attributes_list:
+        # Try splitting by '=' (GFF3) first because spaces are allowed in GFF3
+        # attribute; next, try double quotes for GTF.
+        pair = name_value_pair.strip().split("=")
+        if len( pair ) == 1:
+            pair = name_value_pair.strip().split("\"")
+        if len( pair ) == 1:
+            # Could not split for some reason -- raise exception?
+            continue
+        if pair == '':
+            continue
+        name = pair[0].strip()
+        if name == '':
+            continue
+        # Need to strip double quote from values
+        value = pair[1].strip(" \"")
+        attributes[ name ] = value
+
+    if len( attributes ) == 0:
+        # Could not split attributes string, so entire string must be
+        # 'group' attribute. This is the case for strictly GFF files.
+        attributes['group'] = attr_str
+    return attributes
+
+
+def gff_attributes_to_str( attrs, gff_format ):
+    """
+    Convert GFF attributes to string. Supported formats are GFF3, GTF.
+    """
+    if gff_format == 'GTF':
+        format_string = '%s "%s"'
+        # Convert group (GFF) and ID, parent (GFF3) attributes to transcript_id, gene_id
+        id_attr = None
+        if 'group' in attrs:
+            id_attr = 'group'
+        elif 'ID' in attrs:
+            id_attr = 'ID'
+        elif 'Parent' in attrs:
+            id_attr = 'Parent'
+        if id_attr:
+            attrs['transcript_id'] = attrs['gene_id'] = attrs[id_attr]
+    elif gff_format == 'GFF3':
+        format_string = '%s=%s'
+    attrs_strs = []
+    for name, value in attrs.items():
+        attrs_strs.append( format_string % ( name, value ) )
+    return " ; ".join( attrs_strs )
 
 
 def stop_err(msg):
@@ -70,23 +134,6 @@
 
     (options, args) = parser.parse_args()
 
-    # output version # of tool
-    try:
-        with tempfile.NamedTemporaryFile() as tmp_stdout:
-            returncode = subprocess.call(args='cufflinks --no-update-check 2>&1', stdout=tmp_stdout, shell=True)
-            stdout = None
-            with open(tmp_stdout.name) as tmp_stdout2:
-                for line in tmp_stdout2:
-                    if line.lower().find('cufflinks v') >= 0:
-                        stdout = line.strip()
-                        break
-        if stdout:
-            sys.stdout.write('%s\n' % stdout)
-        else:
-            raise Exception
-    except:
-        sys.stdout.write('Could not determine Cufflinks version\n')
-
     # If doing bias correction, set/link to sequence file.
     if options.do_bias_correction:
         if options.ref_file:
--- a/cufflinks_wrapper.xml	Tue Feb 07 18:39:22 2017 -0500
+++ b/cufflinks_wrapper.xml	Sun Feb 19 12:12:28 2017 -0500
@@ -1,16 +1,11 @@
-<tool id="cufflinks" name="Cufflinks" version="@VERSION@.1">
+<tool id="cufflinks" name="Cufflinks" version="@VERSION@.2">
     <description>transcript assembly and FPKM (RPKM) estimates for RNA-Seq data</description>
     <macros>
       <import>cuff_macros.xml</import>
     </macros>
-    <requirements>
-      <requirement type="package" version="0.7.3">bx-python</requirement>
-      <requirement type="package" version="1.9.0">six</requirement>
-      <requirement type="package" version="2.2.1">cufflinks</requirement>
-    </requirements>
-    <expand macro="stdio" />
+    <expand macro="requirements" />
     <version_command>cufflinks 2>&amp;1 | head -n 1</version_command>
-    <command>
+    <command detect_errors="aggressive">
         python '$__tool_directory__/cufflinks_wrapper.py'
             --input '$input'
             --assembled-isoforms-output '$assembled_isoforms'
--- a/tool_dependencies.xml	Tue Feb 07 18:39:22 2017 -0500
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,6 +0,0 @@
-<?xml version="1.0"?>
-<tool_dependency>
-    <package name="cufflinks" version="2.2.1">
-        <repository changeset_revision="899067a260d1" name="package_cufflinks_2_2_1" owner="devteam" toolshed="https://toolshed.g2.bx.psu.edu" />
-    </package>
-</tool_dependency>