changeset 0:f562c252b285 draft

planemo upload for repository https://github.com/portiahollyoak/Tools commit c31c1a7e9806718e30c9a9036a723e473e09a5eb
author portiahollyoak
date Thu, 26 May 2016 10:48:35 -0400
parents
children 4f0fb855276c
files add_colour.py gff_feature_colours.xml
diffstat 2 files changed, 76 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/add_colour.py	Thu May 26 10:48:35 2016 -0400
@@ -0,0 +1,23 @@
+#!/usr/bin/env python
+# coding: utf-8
+
+import argparse
+import doctest  # This will test if the functions are working
+
+
+parser = argparse.ArgumentParser()
+parser.add_argument("--input", help="GFF file")
+parser.add_argument("--features", nargs='+', help='Features')
+parser.add_argument("--colours",nargs='+', help='Colours for each feature')
+parser.add_argument("--output", help="GFF file with colours")
+args = parser.parse_args()
+
+
+with open(args.output, "w") as output:
+    with open(args.input) as input_file_handle:
+        dictionary = dict(zip(args.features, args.colours))
+        for line in input_file_handle:
+            columns = line.strip().split("\t")
+            if columns[2] in dictionary:
+                columns[8] = columns[8] + "Colour={colour};\n".format(colour = dictionary[columns[2]])
+            output.write("\t".join(columns))
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/gff_feature_colours.xml	Thu May 26 10:48:35 2016 -0400
@@ -0,0 +1,53 @@
+<tool id="gff_feature_colours" name="Add Feature Colours to GFF" version="0.1.0">
+    <requirements>
+    </requirements>
+    <stdio>
+        <exit_code range="1:" />
+    </stdio>
+    <command><![CDATA[
+        python "$__tool_directory__"/add_colour.py
+        --input $input
+        --features
+        #for feature in $feat
+            "${feature.feature}"
+        #end for
+        --colours
+        #for feature in $feat
+            "${feature.feature_colour.value}"
+        #end for
+        --output $output
+    ]]></command>
+    <inputs>
+        <param name="input" type="data" format="gff,gtf" label="Dataset"/>
+        <repeat name="feat" title="Feature to assign a colour">
+            <param name="feature" type="select">
+                <options from_dataset="input">
+                    <column name="name" index="2"/>
+                    <column name="value" index="2"/>
+                    <filter type="unique_value" ref="input" column="2" />
+                </options>
+            </param>
+            <param name="feature_colour" type="color" label="Feature Colour" value="#ff00ff"/>
+        </repeat>
+    </inputs>
+    <outputs>
+        <data format="input" name="output" label="Add feature colours to ${input.element_identifier}" />
+    </outputs>
+    <help><![CDATA[
+Description
+------------
+
+The Add Feature Colours tool allows the user to assign a colour to unique features found in the 3rd column of a GFF file for visualisation in a genome browser. It works by allowing the user to match unique features to a colour and then it will add the assigned colour of that feature to the 9th column of the feature line. This will then be interpreted by the genome browser, and the feature will appear in its assigned colour.
+
+Example
+----------------
+Input:
+
+211000022278978	DHGP    Bari1    515    2242    .    +    .     ID=RR41606_transposable_element;
+
+
+Output:
+
+211000022278978	DHGP    Bari1    515    2242    .    +    .     ID=RR41606_transposable_element;Colour=#ff00ff;
+    ]]></help>
+</tool>