annotate phage_annotation_table.py @ 6:ef05dd3eabc3 draft

planemo upload commit 62127fc905253ba80484b16eaeb92e6dd789199f-dirty
author cpt
date Fri, 24 May 2024 04:56:30 +0000
parents 32e011fa615c
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
1 #!/usr/bin/env python
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
2 # vim: set fileencoding=utf-8
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
3 import os
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
4 import argparse
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
5 from gff3 import (
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
6 genes,
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
7 get_gff3_id,
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
8 get_rbs_from,
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
9 feature_test_true,
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
10 feature_lambda,
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
11 feature_test_type,
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
12 )
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
13 from CPT_GFFParser import gffParse, gffWrite
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
14 from Bio import SeqIO
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
15 from jinja2 import Environment, FileSystemLoader
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
16 import logging
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
17 from math import floor
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
18
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
19 logging.basicConfig(level=logging.DEBUG)
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
20 log = logging.getLogger(name="pat")
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
21
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
22 # Path to script, required because of Galaxy.
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
23 SCRIPT_PATH = os.path.dirname(os.path.realpath(__file__))
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
24 # Path to the HTML template for the report
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
25
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
26
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
27 def genes_all(feature_list, feature_type=["gene"], sort=False):
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
28 """
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
29 Simple filter to extract gene features from the feature set.
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
30 """
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
31
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
32 if not sort:
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
33 for x in feature_lambda(
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
34 feature_list, feature_test_type, {"types": feature_type}, subfeatures=True
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
35 ):
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
36 yield x
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
37 else:
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
38 data = list(genes_all(feature_list, feature_type, sort=False))
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
39 data = sorted(data, key=lambda feature: feature.location.start)
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
40 for x in data:
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
41 yield x
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
42
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
43
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
44 def checkSubs(feature, qualName):
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
45 subFeats = []
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
46 res = ""
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
47 subFeats = feature.sub_features
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
48 while len(subFeats) > 0:
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
49 for feat in subFeats:
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
50 for i in feat.qualifiers.keys():
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
51 for j in qualName:
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
52 if i == j:
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
53 if res == "":
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
54 res = feat.qualifiers[i][0]
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
55 else:
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
56 res += "; " + feat.qualifiers[i][0]
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
57 if res != "":
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
58 return res
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
59 tempFeats = []
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
60 for feat in subFeats: # Should be breadth-first results
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
61 for x in feat.sub_features:
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
62 tempFeats.append(x)
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
63 subFeats = tempFeats
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
64 return res
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
65
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
66
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
67 def annotation_table_report(record, types, wanted_cols, gaf_data, searchSubs):
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
68 getTypes = []
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
69 for x in [y.strip() for y in types.split(",")]:
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
70 getTypes.append(x)
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
71 getTypes.append("gene")
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
72 sorted_features = list(genes_all(record.features, getTypes, sort=True))
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
73 if wanted_cols is None or len(wanted_cols.strip()) == 0:
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
74 return [], []
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
75 useSubs = searchSubs
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
76
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
77 def rid(record, feature):
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
78 """Organism ID"""
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
79 return record.id
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
80
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
81 def id(record, feature):
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
82 """ID"""
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
83 return feature.id
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
84
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
85 def featureType(record, feature):
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
86 """Type"""
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
87 return feature.type
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
88
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
89 def name(record, feature):
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
90 """Name"""
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
91 for x in ["Name", "name"]:
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
92 for y in feature.qualifiers.keys():
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
93 if x == y:
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
94 return feature.qualifiers[x][0]
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
95 if useSubs:
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
96 res = checkSubs(feature, ["Name", "name"])
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
97 if res != "":
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
98 return res
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
99 return "None"
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
100
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
101 def start(record, feature):
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
102 """Boundary"""
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
103 return str(feature.location.start + 1)
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
104
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
105 def end(record, feature):
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
106 """Boundary"""
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
107 return str(feature.location.end)
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
108
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
109 def location(record, feature):
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
110 """Location"""
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
111 return str(feature.location.start + 1) + "..{0.end}".format(feature.location)
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
112
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
113 def length(record, feature):
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
114 """CDS Length (AA)"""
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
115
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
116 if feature.type == "CDS":
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
117 cdss = [feature]
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
118 else:
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
119 cdss = list(genes(feature.sub_features, feature_type="CDS", sort=True))
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
120
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
121 if cdss == []:
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
122 return "None"
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
123 res = (sum([len(cds) for cds in cdss]) / 3) - 1
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
124 if floor(res) == res:
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
125 res = int(res)
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
126 return str(res)
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
127
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
128 def notes(record, feature):
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
129 """User entered Notes"""
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
130 for x in ["Note", "note", "Notes", "notes"]:
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
131 for y in feature.qualifiers.keys():
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
132 if x == y:
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
133 return feature.qualifiers[x][0]
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
134 if useSubs:
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
135 res = checkSubs(feature, ["Note", "note", "Notes", "notes"])
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
136 if res != "":
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
137 return res
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
138 return "None"
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
139
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
140 def date_created(record, feature):
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
141 """Created"""
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
142 return feature.qualifiers.get("date_creation", ["None"])[0]
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
143
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
144 def date_last_modified(record, feature):
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
145 """Last Modified"""
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
146 res = feature.qualifiers.get("date_last_modified", ["None"])[0]
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
147 if res != "None":
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
148 return res
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
149 if useSubs:
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
150 res = checkSubs(feature, ["date_last_modified"])
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
151 if res != "":
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
152 return res
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
153 return "None"
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
154
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
155 def description(record, feature):
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
156 """Description"""
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
157 res = feature.qualifiers.get("description", ["None"])[0]
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
158 if res != "None":
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
159 return res
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
160 if useSubs:
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
161 res = checkSubs(feature, ["description"])
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
162 if res != "":
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
163 return res
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
164 return "None"
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
165
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
166 def owner(record, feature):
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
167 """Owner
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
168
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
169 User who created the feature. In a 464 scenario this may be one of
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
170 the TAs."""
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
171 for x in ["Owner", "owner"]:
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
172 for y in feature.qualifiers.keys():
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
173 if x == y:
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
174 return feature.qualifiers[x][0]
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
175 if useSubs:
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
176 res = checkSubs(feature, ["Owner", "owner"])
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
177 if res != "":
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
178 return res
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
179 return "None"
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
180
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
181 def product(record, feature):
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
182 """Product
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
183
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
184 User entered product qualifier (collects "Product" and "product"
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
185 entries)"""
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
186 """User entered Notes"""
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
187 for x in ["product", "Product"]:
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
188 for y in feature.qualifiers.keys():
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
189 if x == y:
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
190 return feature.qualifiers[x][0]
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
191 if useSubs:
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
192 res = checkSubs(feature, ["product", "Product"])
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
193 if res != "":
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
194 return res
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
195 return "None"
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
196
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
197 def note(record, feature):
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
198 """Note
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
199
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
200 User entered Note qualifier(s)"""
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
201 return feature.qualifiers.get("Note", [])
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
202
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
203 def strand(record, feature):
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
204 """Strand"""
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
205 return "+" if feature.location.strand > 0 else "-"
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
206
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
207 def sd_spacing(record, feature):
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
208 """Shine-Dalgarno spacing"""
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
209 rbss = get_rbs_from(gene)
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
210 if len(rbss) == 0:
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
211 return "None"
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
212 else:
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
213 resp = []
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
214 for rbs in rbss:
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
215 cdss = list(genes(feature.sub_features, feature_type="CDS", sort=True))
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
216 if len(cdss) == 0:
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
217 return "No CDS"
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
218 if rbs.location.strand > 0:
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
219 distance = min(
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
220 cdss, key=lambda x: x.location.start - rbs.location.end
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
221 )
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
222 distance_val = str(distance.location.start - rbs.location.end)
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
223 resp.append(distance_val)
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
224 else:
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
225 distance = min(
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
226 cdss, key=lambda x: x.location.end - rbs.location.start
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
227 )
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
228 distance_val = str(rbs.location.start - distance.location.end)
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
229 resp.append(distance_val)
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
230
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
231 if len(resp) == 1:
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
232 return str(resp[0])
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
233 return resp
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
234
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
235 def sd_seq(record, feature):
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
236 """Shine-Dalgarno sequence"""
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
237 rbss = get_rbs_from(gene)
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
238 if len(rbss) == 0:
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
239 return "None"
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
240 else:
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
241 resp = []
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
242 for rbs in rbss:
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
243 resp.append(str(rbs.extract(record).seq))
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
244 if len(resp) == 1:
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
245 return str(resp[0])
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
246 else:
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
247 return resp
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
248
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
249 def start_codon(record, feature):
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
250 """Start Codon"""
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
251 if feature.type == "CDS":
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
252 cdss = [feature]
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
253 else:
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
254 cdss = list(genes(feature.sub_features, feature_type="CDS", sort=True))
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
255
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
256 data = [x for x in cdss]
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
257 if len(data) == 1:
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
258 return str(data[0].extract(record).seq[0:3])
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
259 else:
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
260 return [
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
261 "{0} ({1.location.start}..{1.location.end}:{1.location.strand})".format(
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
262 x.extract(record).seq[0:3], x
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
263 )
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
264 for x in data
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
265 ]
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
266
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
267 def stop_codon(record, feature):
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
268 """Stop Codon"""
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
269 return str(feature.extract(record).seq[-3:])
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
270
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
271 def dbxrefs(record, feature):
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
272 """DBxrefs"""
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
273 """User entered Notes"""
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
274 for x in ["Dbxref", "db_xref", "DB_xref", "DBxref", "DB_Xref", "DBXref"]:
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
275 for y in feature.qualifiers.keys():
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
276 if x == y:
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
277 return feature.qualifiers[x][0]
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
278 return "None"
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
279
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
280 def upstream_feature(record, feature):
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
281 """Next gene upstream"""
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
282 if feature.strand > 0:
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
283 upstream_features = [
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
284 x
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
285 for x in sorted_features
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
286 if (
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
287 x.location.start < feature.location.start
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
288 and x.type == "gene"
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
289 and x.strand == feature.strand
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
290 )
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
291 ]
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
292 if len(upstream_features) > 0:
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
293 foundSelf = False
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
294 featCheck = upstream_features[-1].sub_features
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
295 for x in featCheck:
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
296 if x == feature:
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
297 foundSelf = True
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
298 break
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
299 featCheck = featCheck + x.sub_features
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
300 if foundSelf:
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
301 if len(upstream_features) > 1:
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
302 return upstream_features[-2]
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
303 return None
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
304 return upstream_features[-1]
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
305 else:
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
306 return None
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
307 else:
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
308 upstream_features = [
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
309 x
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
310 for x in sorted_features
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
311 if (
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
312 x.location.end > feature.location.end
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
313 and x.type == "gene"
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
314 and x.strand == feature.strand
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
315 )
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
316 ]
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
317
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
318 if len(upstream_features) > 0:
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
319 foundSelf = False
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
320 featCheck = upstream_features[0].sub_features
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
321 for x in featCheck:
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
322 if x == feature:
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
323 foundSelf = True
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
324 break
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
325 featCheck = featCheck + x.sub_features
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
326 if foundSelf:
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
327 if len(upstream_features) > 1:
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
328 return upstream_features[1]
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
329 return None
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
330 return upstream_features[0]
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
331 else:
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
332 return None
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
333
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
334 def upstream_feature__name(record, feature):
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
335 """Next gene upstream"""
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
336 up = upstream_feature(record, feature)
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
337 if up:
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
338 return str(up.id)
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
339 return "None"
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
340
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
341 def ig_dist(record, feature):
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
342 """Distance to next upstream gene on same strand"""
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
343 up = upstream_feature(record, feature)
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
344 if up:
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
345 dist = None
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
346 if feature.strand > 0:
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
347 dist = feature.location.start - up.location.end
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
348 else:
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
349 dist = up.location.start - feature.location.end
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
350 return str(dist)
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
351 else:
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
352 return "None"
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
353
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
354 def _main_gaf_func(record, feature, gaf_data, attr):
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
355 if feature.id in gaf_data:
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
356 return [x[attr] for x in gaf_data[feature.id]]
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
357 return []
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
358
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
359 def gaf_annotation_extension(record, feature, gaf_data):
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
360 """GAF Annotation Extension
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
361
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
362 Contains cross references to other ontologies that can be used
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
363 to qualify or enhance the annotation. The cross-reference is
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
364 prefaced by an appropriate GO relationship; references to
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
365 multiple ontologies can be entered. For example, if a gene
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
366 product is localized to the mitochondria of lymphocytes, the GO
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
367 ID (column 5) would be mitochondrion ; GO:0005439, and the
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
368 annotation extension column would contain a cross-reference to
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
369 the term lymphocyte from the Cell Type Ontology.
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
370 """
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
371 return _main_gaf_func(record, feature, gaf_data, "annotation_extension")
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
372
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
373 def gaf_aspect(record, feature, gaf_data):
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
374 """GAF Aspect code
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
375
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
376 E.g. P (biological process), F (molecular function) or C (cellular component)
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
377 """
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
378 return _main_gaf_func(record, feature, gaf_data, "aspect")
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
379
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
380 def gaf_assigned_by(record, feature, gaf_data):
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
381 """GAF Creating Organisation"""
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
382 return _main_gaf_func(record, feature, gaf_data, "assigned_by")
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
383
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
384 def gaf_date(record, feature, gaf_data):
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
385 """GAF Creation Date"""
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
386 return _main_gaf_func(record, feature, gaf_data, "date")
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
387
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
388 def gaf_db(record, feature, gaf_data):
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
389 """GAF DB"""
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
390 return _main_gaf_func(record, feature, gaf_data, "db")
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
391
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
392 def gaf_db_reference(record, feature, gaf_data):
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
393 """GAF DB Reference"""
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
394 return _main_gaf_func(record, feature, gaf_data, "db_reference")
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
395
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
396 def gaf_evidence_code(record, feature, gaf_data):
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
397 """GAF Evidence Code"""
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
398 return _main_gaf_func(record, feature, gaf_data, "evidence_code")
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
399
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
400 def gaf_go_id(record, feature, gaf_data):
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
401 """GAF GO ID"""
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
402 return _main_gaf_func(record, feature, gaf_data, "go_id")
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
403
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
404 def gaf_go_term(record, feature, gaf_data):
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
405 """GAF GO Term"""
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
406 return _main_gaf_func(record, feature, gaf_data, "go_term")
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
407
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
408 def gaf_id(record, feature, gaf_data):
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
409 """GAF ID"""
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
410 return _main_gaf_func(record, feature, gaf_data, "id")
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
411
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
412 def gaf_notes(record, feature, gaf_data):
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
413 """GAF Notes"""
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
414 return _main_gaf_func(record, feature, gaf_data, "notes")
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
415
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
416 def gaf_owner(record, feature, gaf_data):
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
417 """GAF Creator"""
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
418 return _main_gaf_func(record, feature, gaf_data, "owner")
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
419
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
420 def gaf_with_or_from(record, feature, gaf_data):
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
421 """GAF With/From"""
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
422 return _main_gaf_func(record, feature, gaf_data, "with_or_from")
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
423
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
424 cols = []
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
425 data = []
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
426 funcs = []
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
427 lcl = locals()
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
428 for x in [y.strip().lower() for y in wanted_cols.split(",")]:
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
429 if not x:
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
430 continue
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
431 if x == "type":
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
432 x = "featureType"
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
433 if x in lcl:
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
434 funcs.append(lcl[x])
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
435 # Keep track of docs
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
436 func_doc = lcl[x].__doc__.strip().split("\n\n")
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
437 # If there's a double newline, assume following text is the
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
438 # "help" and the first part is the "name". Generate empty help
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
439 # if not provided
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
440 if len(func_doc) == 1:
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
441 func_doc += [""]
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
442 cols.append(func_doc)
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
443 elif "__" in x:
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
444 chosen_funcs = [lcl[y] for y in x.split("__")]
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
445 func_doc = [
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
446 " of ".join(
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
447 [y.__doc__.strip().split("\n\n")[0] for y in chosen_funcs[::-1]]
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
448 )
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
449 ]
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
450 cols.append(func_doc)
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
451 funcs.append(chosen_funcs)
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
452
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
453 for gene in genes_all(record.features, getTypes, sort=True):
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
454 row = []
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
455 for func in funcs:
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
456 if isinstance(func, list):
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
457 # If we have a list of functions, repeatedly apply them
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
458 value = gene
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
459 for f in func:
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
460 if value is None:
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
461 value = "None"
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
462 break
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
463
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
464 value = f(record, value)
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
465 else:
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
466 # Otherwise just apply the lone function
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
467 if func.__name__.startswith("gaf_"):
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
468 value = func(record, gene, gaf_data)
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
469 else:
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
470 value = func(record, gene)
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
471
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
472 if isinstance(value, list):
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
473 collapsed_value = ", ".join(value)
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
474 value = [str(collapsed_value)] # .encode("unicode_escape")]
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
475 else:
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
476 value = str(value) # .encode("unicode_escape")
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
477
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
478 row.append(value)
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
479 # print row
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
480 data.append(row)
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
481 return data, cols
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
482
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
483
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
484 def parseGafData(file):
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
485 cols = []
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
486 data = {}
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
487 # '10d04a01-5ed8-49c8-b724-d6aa4df5a98d': {
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
488 # 'annotation_extension': '',
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
489 # 'aspect': '',
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
490 # 'assigned_by': 'CPT',
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
491 # 'date': '2017-05-04T16:25:22.161916Z',
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
492 # 'db': 'UniProtKB',
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
493 # 'db_reference': 'GO_REF:0000100',
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
494 # 'evidence_code': 'ISA',
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
495 # 'gene': '0d307196-833d-46e8-90e9-d80f7a041d88',
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
496 # 'go_id': 'GO:0039660',
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
497 # 'go_term': 'structural constituent of virion',
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
498 # 'id': '10d04a01-5ed8-49c8-b724-d6aa4df5a98d',
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
499 # 'notes': 'hit was putative minor structural protein',
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
500 # 'owner': 'amarc1@tamu.edu',
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
501 # 'with_or_from': 'UNIREF90:B2ZYZ7'
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
502 # },
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
503 for row in file:
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
504 if row.startswith("#"):
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
505 # Header
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
506 cols = (
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
507 row.strip().replace("# ", "").replace("GO Term", "go_term").split("\t")
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
508 )
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
509 else:
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
510 line = row.strip().split("\t")
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
511 tmp = dict(zip(cols, line))
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
512 if "gene" not in tmp.keys():
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
513 continue
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
514 if tmp["gene"] not in data:
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
515 data[tmp["gene"]] = []
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
516
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
517 data[tmp["gene"]].append(tmp)
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
518 return data
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
519
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
520
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
521 def evaluate_and_report(
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
522 annotations,
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
523 genome,
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
524 types="gene",
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
525 reportTemplateName="phage_annotation_validator.html",
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
526 annotationTableCols="",
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
527 gafData=None,
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
528 searchSubs=False,
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
529 ):
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
530 """
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
531 Generate our HTML evaluation of the genome
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
532 """
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
533 # Get features from GFF file
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
534 seq_dict = SeqIO.to_dict(SeqIO.parse(genome, "fasta"))
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
535 # Get the first GFF3 record
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
536 # TODO: support multiple GFF3 files.
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
537 at_table_data = []
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
538 gaf = {}
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
539 if gafData:
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
540 gaf = parseGafData(gafData)
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
541
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
542 for record in gffParse(annotations, base_dict=seq_dict):
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
543 if reportTemplateName.endswith(".html"):
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
544 record.id = record.id.replace(".", "-")
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
545 log.info("Producing an annotation table for %s" % record.id)
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
546 annotation_table_data, annotation_table_col_names = annotation_table_report(
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
547 record, types, annotationTableCols, gaf, searchSubs
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
548 )
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
549 at_table_data.append((record, annotation_table_data))
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
550 # break
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
551
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
552 # This is data that will go into our HTML template
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
553 kwargs = {
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
554 "annotation_table_data": at_table_data,
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
555 "annotation_table_col_names": annotation_table_col_names,
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
556 }
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
557
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
558 env = Environment(
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
559 loader=FileSystemLoader(SCRIPT_PATH), trim_blocks=True, lstrip_blocks=True
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
560 )
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
561 if reportTemplateName.endswith(".html"):
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
562 env.filters["nice_id"] = str(get_gff3_id).replace(".", "-")
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
563 else:
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
564 env.filters["nice_id"] = get_gff3_id
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
565
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
566 def join(listy):
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
567 return "\n".join(listy)
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
568
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
569 env.filters.update({"join": join})
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
570 tpl = env.get_template(reportTemplateName)
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
571 return tpl.render(**kwargs).encode("utf-8")
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
572
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
573
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
574 if __name__ == "__main__":
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
575 parser = argparse.ArgumentParser(
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
576 description="rebase gff3 features against parent locations", epilog=""
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
577 )
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
578 parser.add_argument(
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
579 "annotations", type=argparse.FileType("r"), help="Parent GFF3 annotations"
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
580 )
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
581 parser.add_argument("genome", type=argparse.FileType("r"), help="Genome Sequence")
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
582
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
583 parser.add_argument(
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
584 "--types",
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
585 help="Select extra types to display in output (Will always include gene)",
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
586 )
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
587
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
588 parser.add_argument(
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
589 "--reportTemplateName",
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
590 help="Report template file name",
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
591 default="phageqc_report_full.html",
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
592 )
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
593 parser.add_argument(
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
594 "--annotationTableCols",
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
595 help="Select columns to report in the annotation table output format",
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
596 )
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
597 parser.add_argument(
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
598 "--gafData", help="CPT GAF-like table", type=argparse.FileType("r")
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
599 )
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
600 parser.add_argument(
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
601 "--searchSubs",
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
602 help="Attempt to populate fields from sub-features if qualifier is empty",
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
603 action="store_true",
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
604 )
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
605
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
606 args = parser.parse_args()
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
607
32e011fa615c planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
cpt
parents:
diff changeset
608 print(evaluate_and_report(**vars(args)).decode("utf-8"))