comparison 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
comparison
equal deleted inserted replaced
-1:000000000000 0:f562c252b285
1 #!/usr/bin/env python
2 # coding: utf-8
3
4 import argparse
5 import doctest # This will test if the functions are working
6
7
8 parser = argparse.ArgumentParser()
9 parser.add_argument("--input", help="GFF file")
10 parser.add_argument("--features", nargs='+', help='Features')
11 parser.add_argument("--colours",nargs='+', help='Colours for each feature')
12 parser.add_argument("--output", help="GFF file with colours")
13 args = parser.parse_args()
14
15
16 with open(args.output, "w") as output:
17 with open(args.input) as input_file_handle:
18 dictionary = dict(zip(args.features, args.colours))
19 for line in input_file_handle:
20 columns = line.strip().split("\t")
21 if columns[2] in dictionary:
22 columns[8] = columns[8] + "Colour={colour};\n".format(colour = dictionary[columns[2]])
23 output.write("\t".join(columns))