Skip to content

Commit 358a088

Browse files
committed
Fix not-updated Jinja error template path
1 parent a30b411 commit 358a088

File tree

1 file changed

+21
-21
lines changed

1 file changed

+21
-21
lines changed

src/guide-finder/GuideInitialize.py

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
Hillary Elrick, September 9th, 2019
55
66
Class for getting user input to perform a guide search. Given URL variables, returns appropriate HTML page results.
7-
Prints template for guide searching as well as AJAX calls to the GuideSearchAndScore.py program which is displayed the
7+
Prints template for guide searching as well as AJAX calls to the GuideSearchAndScore.py program which is displayed the
88
results section of the HTML template.
99
1010
Requires: initial searchLocation and genome
@@ -41,7 +41,7 @@ def __init__(self, **kwargs):
4141
self.sendErrorHTML("Invalid action string sent: " + str(kwargs['action']))
4242
else:
4343
self.action = kwargs['action']
44-
44+
4545
if self.action in ['initialize', 'update_input']:
4646
# validate searchInput
4747
if 'searchInput' not in kwargs:
@@ -84,8 +84,8 @@ def __init__(self, **kwargs):
8484
def inputRowHTML(self):
8585
""" rebuild the form row for the input region and target gene and return it """
8686
template_values = {
87-
'search_location': self.getInputHTML(),
88-
'available_genes': self.getOverlappingGenesHTML()
87+
'search_location': self.getInputHTML(),
88+
'available_genes': self.getOverlappingGenesHTML()
8989
}
9090
template_path = os.path.join(self.dbConnection.ROOT_PATH, "src/guide-finder/jinja2-templates/input_region.html")
9191
region_template = Template(open(template_path, 'rb').read().decode('utf-8'))
@@ -107,25 +107,25 @@ def initialHTML(self):
107107
return html_result
108108

109109
def sendErrorHTML(self, errorString):
110-
""" format exceptions in HTML to prevent page from crashing """
110+
""" format exceptions in HTML to prevent page from crashing """
111111
if not hasattr(self, 'dbConnection'):
112112
self.dbConnection = Config()
113-
template_path = os.path.join(self.dbConnection.ROOT_PATH, "GuideFinder/templates/error.html")
113+
template_path = os.path.join(self.dbConnection.ROOT_PATH, "src/guide-finder/jinja2-templates/error.html")
114114
error_template = Template(open(template_path, 'rb').read().decode('utf-8'))
115115
html_result = error_template.render(errorString=errorString)
116116
print(html_result)
117117
sys.exit()
118-
118+
119119
def getOrganismHTML(self):
120120
""" convert underscored org database string to HTML with italicization """
121121
org = self.dbConnection.organismName
122122
org = org.replace("_"," ").capitalize()
123-
HTML = "<i>{org}</i> ({genome})".format(org=org, genome=self.genome)
123+
HTML = "<i>{org}</i> ({genome})".format(org=org, genome=self.genome)
124124
return HTML
125-
125+
126126
def getOverlappingGenesHTML(self):
127127
""" Format the overlapped genes into a selection dropdown or text input if no overlap """
128-
128+
129129
# prevent displaying all genes overlapped in case of large input sequence
130130
if len(self.overlappedGenes) < 20 and len(self.overlappedGenes) > 0:
131131
HTML = "<select class='form-control' id='gene' required>"
@@ -135,20 +135,20 @@ def getOverlappingGenesHTML(self):
135135
HTML += "<option value selected='selected'></option>"
136136
for gene in self.overlappedGenes:
137137
HTML += "<option value='{gene}'>{gene}</option>".format(gene=gene)
138-
139-
HTML += "</select>"
138+
139+
HTML += "</select>"
140140
else:
141141
HTML = "<input class='form-control' id='gene' type='text' required>"
142142

143143
return HTML
144-
144+
145145
def getRgenHTML(self):
146146
""" returns the available rgens in a preformmatted HTML select tag """
147147
HTML = '<select class="form-control" id="RGENS" onchange="getProtospacerLengths()">'
148148
for rgen in self.dbConnection.rgenCollection.find().sort([("rgenID",1)]):
149149
HTML += '<option value="{rgenID}">{Shortform}</option>'.format_map(rgen)
150150
HTML += "</select>"
151-
151+
152152
return HTML
153153

154154
def getLengthsHTML(self):
@@ -192,18 +192,18 @@ def getRegionLength(self):
192192
length = abs(int(start)-int(end))
193193
except Exception as e:
194194
return "N/A"
195-
return length
195+
return length
196196

197197
def getOverlappingGenes(self):
198-
""" using Teja's query to find genes in the mongodb that overlap the search input """
198+
""" using Teja's query to find genes in the mongodb that overlap the search input """
199199
try:
200200
chm, start, end = re.search(r"(chr.+?):(\d+)\-(\d+)", self.searchInput).groups()
201201
except Exception as e:
202202
return ["Invalid Input Sequence"]
203203
start = int(start)
204204
end = int(end)
205205
searchQuery = {
206-
'$or': [
206+
'$or': [
207207
{'$and': [
208208
{'start':{'$gte':start}},
209209
{'start':{'$lte':end}},
@@ -213,7 +213,7 @@ def getOverlappingGenes(self):
213213
{'start':{'$lte':start}},
214214
{'end':{'$gte':end}},
215215
{'chr':chm}
216-
]},
216+
]},
217217
{'$and': [
218218
{'end':{'$gte':start}},
219219
{'end':{'$lte':end}},
@@ -225,7 +225,7 @@ def getOverlappingGenes(self):
225225
overlappedGenes.append(gene['Name'])
226226

227227
return overlappedGenes
228-
228+
229229
def getRGEN(self):
230230
# fetch the correct rgen record using the rgenID attribute
231231
rgenCollection = self.dbConnection.rgenCollection
@@ -235,7 +235,7 @@ def getRGEN(self):
235235
else:
236236
raise ValueError("Incorrect number of records returned from RGEN database for rgenID: " + str(rgenID))
237237
return
238-
238+
239239
def isValidInput(inputSeq):
240240
#TODO: code this. some validation done on front end but not for the chr number/letter
241241
if len(inputSeq) == 0:
@@ -266,4 +266,4 @@ def main():
266266

267267

268268
if __name__ == "__main__":
269-
main()
269+
main()

0 commit comments

Comments
 (0)