Mercurial > repos > portiahollyoak > gff_feature_colours
annotate add_colour.py @ 1:4f0fb855276c draft default tip
planemo upload for repository https://github.com/portiahollyoak/Tools commit 5f5802314b55f52ea4b3f9f515ec46a5a770696d-dirty
| author | portiahollyoak |
|---|---|
| date | Thu, 26 May 2016 11:07:21 -0400 |
| parents | f562c252b285 |
| children |
| rev | line source |
|---|---|
|
0
f562c252b285
planemo upload for repository https://github.com/portiahollyoak/Tools commit c31c1a7e9806718e30c9a9036a723e473e09a5eb
portiahollyoak
parents:
diff
changeset
|
1 #!/usr/bin/env python |
|
f562c252b285
planemo upload for repository https://github.com/portiahollyoak/Tools commit c31c1a7e9806718e30c9a9036a723e473e09a5eb
portiahollyoak
parents:
diff
changeset
|
2 # coding: utf-8 |
|
f562c252b285
planemo upload for repository https://github.com/portiahollyoak/Tools commit c31c1a7e9806718e30c9a9036a723e473e09a5eb
portiahollyoak
parents:
diff
changeset
|
3 |
|
f562c252b285
planemo upload for repository https://github.com/portiahollyoak/Tools commit c31c1a7e9806718e30c9a9036a723e473e09a5eb
portiahollyoak
parents:
diff
changeset
|
4 import argparse |
|
f562c252b285
planemo upload for repository https://github.com/portiahollyoak/Tools commit c31c1a7e9806718e30c9a9036a723e473e09a5eb
portiahollyoak
parents:
diff
changeset
|
5 import doctest # This will test if the functions are working |
|
f562c252b285
planemo upload for repository https://github.com/portiahollyoak/Tools commit c31c1a7e9806718e30c9a9036a723e473e09a5eb
portiahollyoak
parents:
diff
changeset
|
6 |
|
f562c252b285
planemo upload for repository https://github.com/portiahollyoak/Tools commit c31c1a7e9806718e30c9a9036a723e473e09a5eb
portiahollyoak
parents:
diff
changeset
|
7 |
|
f562c252b285
planemo upload for repository https://github.com/portiahollyoak/Tools commit c31c1a7e9806718e30c9a9036a723e473e09a5eb
portiahollyoak
parents:
diff
changeset
|
8 parser = argparse.ArgumentParser() |
|
f562c252b285
planemo upload for repository https://github.com/portiahollyoak/Tools commit c31c1a7e9806718e30c9a9036a723e473e09a5eb
portiahollyoak
parents:
diff
changeset
|
9 parser.add_argument("--input", help="GFF file") |
|
f562c252b285
planemo upload for repository https://github.com/portiahollyoak/Tools commit c31c1a7e9806718e30c9a9036a723e473e09a5eb
portiahollyoak
parents:
diff
changeset
|
10 parser.add_argument("--features", nargs='+', help='Features') |
|
f562c252b285
planemo upload for repository https://github.com/portiahollyoak/Tools commit c31c1a7e9806718e30c9a9036a723e473e09a5eb
portiahollyoak
parents:
diff
changeset
|
11 parser.add_argument("--colours",nargs='+', help='Colours for each feature') |
|
f562c252b285
planemo upload for repository https://github.com/portiahollyoak/Tools commit c31c1a7e9806718e30c9a9036a723e473e09a5eb
portiahollyoak
parents:
diff
changeset
|
12 parser.add_argument("--output", help="GFF file with colours") |
|
f562c252b285
planemo upload for repository https://github.com/portiahollyoak/Tools commit c31c1a7e9806718e30c9a9036a723e473e09a5eb
portiahollyoak
parents:
diff
changeset
|
13 args = parser.parse_args() |
|
f562c252b285
planemo upload for repository https://github.com/portiahollyoak/Tools commit c31c1a7e9806718e30c9a9036a723e473e09a5eb
portiahollyoak
parents:
diff
changeset
|
14 |
|
f562c252b285
planemo upload for repository https://github.com/portiahollyoak/Tools commit c31c1a7e9806718e30c9a9036a723e473e09a5eb
portiahollyoak
parents:
diff
changeset
|
15 |
|
f562c252b285
planemo upload for repository https://github.com/portiahollyoak/Tools commit c31c1a7e9806718e30c9a9036a723e473e09a5eb
portiahollyoak
parents:
diff
changeset
|
16 with open(args.output, "w") as output: |
|
f562c252b285
planemo upload for repository https://github.com/portiahollyoak/Tools commit c31c1a7e9806718e30c9a9036a723e473e09a5eb
portiahollyoak
parents:
diff
changeset
|
17 with open(args.input) as input_file_handle: |
|
f562c252b285
planemo upload for repository https://github.com/portiahollyoak/Tools commit c31c1a7e9806718e30c9a9036a723e473e09a5eb
portiahollyoak
parents:
diff
changeset
|
18 dictionary = dict(zip(args.features, args.colours)) |
|
f562c252b285
planemo upload for repository https://github.com/portiahollyoak/Tools commit c31c1a7e9806718e30c9a9036a723e473e09a5eb
portiahollyoak
parents:
diff
changeset
|
19 for line in input_file_handle: |
|
f562c252b285
planemo upload for repository https://github.com/portiahollyoak/Tools commit c31c1a7e9806718e30c9a9036a723e473e09a5eb
portiahollyoak
parents:
diff
changeset
|
20 columns = line.strip().split("\t") |
|
f562c252b285
planemo upload for repository https://github.com/portiahollyoak/Tools commit c31c1a7e9806718e30c9a9036a723e473e09a5eb
portiahollyoak
parents:
diff
changeset
|
21 if columns[2] in dictionary: |
|
f562c252b285
planemo upload for repository https://github.com/portiahollyoak/Tools commit c31c1a7e9806718e30c9a9036a723e473e09a5eb
portiahollyoak
parents:
diff
changeset
|
22 columns[8] = columns[8] + "Colour={colour};\n".format(colour = dictionary[columns[2]]) |
|
f562c252b285
planemo upload for repository https://github.com/portiahollyoak/Tools commit c31c1a7e9806718e30c9a9036a723e473e09a5eb
portiahollyoak
parents:
diff
changeset
|
23 output.write("\t".join(columns)) |
