# HG changeset patch # User portiahollyoak # Date 1464274115 14400 # Node ID f562c252b285fd0c7081fb0bf955aa2bf75cfe55 planemo upload for repository https://github.com/portiahollyoak/Tools commit c31c1a7e9806718e30c9a9036a723e473e09a5eb diff -r 000000000000 -r f562c252b285 add_colour.py --- /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 diff -r 000000000000 -r f562c252b285 gff_feature_colours.xml --- /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 @@ + + + + + + + + + + + + + + + + + + + + + + + + +