diff add_colour.py @ 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
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