Skip to content

Commit 888430e

Browse files
committed
Switch JBrowse data directories to be under data/ and create Docker mount
Increase Ensembl REST API timeout
1 parent 86ba295 commit 888430e

File tree

11 files changed

+268
-274
lines changed

11 files changed

+268
-274
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
bin/dicey
44
bin/ncbi-blast-2.7.1+
55
bin/primer3
6-
jbrowse/data.*
6+
jbrowse/data*
77
jbrowse/Makefile
88
jbrowse/setup.log
99
jbrowse/jbrowse.conf

docker-compose.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ services:
1010
- ./bin:/var/www/html/bin
1111
- ./docs:/var/www/html/docs
1212
- ./src:/var/www/html/src
13+
- ./jbrowse/data:/var/www/html/jbrowse/data
1314
- ./jbrowse/plugins/ColorByCDS:/var/www/html/jbrowse/plugins/ColorByCDS
1415
- ./jbrowse/plugins/ExportSequence:/var/www/html/jbrowse/plugins/ExportSequence
1516
- ./crispr-icon.png:/var/www/html/crispr-icon.png

src/guide-finder/GuideAdd.py

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -22,21 +22,21 @@
2222
class GuideAdd:
2323
def __init__(self, **kwargs):
2424
""" class for interfacing to the guide collection """
25-
# check required inputs set
25+
# check required inputs set
2626
for parameter in ['batchID', 'guideID', 'label']:
2727
if parameter not in kwargs:
28-
self.sendErrorHTML("'{parameter}' not set".format(**locals()))
28+
self.sendErrorHTML("'{parameter}' not set".format(**locals()))
2929
self.dbConnection = Config()
3030
self.batchID = kwargs['batchID']
3131
self.guideID = kwargs['guideID']
3232
self.label = kwargs['label']
3333
self.notes = kwargs['notes'] if 'notes' in kwargs else ''
34-
34+
3535
# fetch the stored guide info
3636
self.metadata, self.guide = self.parseJSON()
3737
self.rgen = self.getRGEN(str(self.metadata['rgenID']))
3838
# redefine the connection to the database based on the genome
39-
self.dbConnection = Config(self.metadata['genome'])
39+
self.dbConnection = Config(self.metadata['genome'])
4040
# determine if the guide already exists
4141
self.existingGuide = self.existingGuideInDatabase()
4242

@@ -46,12 +46,12 @@ def __init__(self, **kwargs):
4646
self.rewriteGFF()
4747
print("Successfully Updated Guide")
4848
else:
49-
# insert the guide into the database
49+
# insert the guide into the database
5050
self.insertGuide()
5151
self.rewriteGFF()
5252
print("Successfully Inserted Guide")
5353

54-
54+
5555
def rewriteGFF(self):
5656
""" rewrite the gff file """
5757
# intialize the strings
@@ -65,7 +65,7 @@ def rewriteGFF(self):
6565
sortedGuideCoordinates = sorted([int(x) for x in guideCoordinates.split('-')])
6666
# calculate the pam coordinates
6767
rgen = self.getRGEN(guideRecord['rgenID'])
68-
pamLocation = rgen['PamLocation']
68+
pamLocation = rgen['PamLocation']
6969
if (pamLocation == 'downstream' and strand == '+') or (pamLocation == 'upstream' and strand == '-'):
7070
pamStart = sortedGuideCoordinates[-1]
7171
pamEnd = int(pamStart) + len(guideRecord['pamSeq'])
@@ -107,9 +107,9 @@ def rewriteGFF(self):
107107

108108
# increment the count
109109
idCounter += 1
110-
110+
111111
#try:
112-
guideGFF = os.path.join(self.dbConnection.ROOT_PATH, str('jbrowse/data.'+self.metadata['genome']+"/gRNA_CRISPR.gff"))
112+
guideGFF = os.path.join(self.dbConnection.ROOT_PATH, str('jbrowse/data/'+self.metadata['genome']+"/gRNA_CRISPR.gff"))
113113
gffFile = open(guideGFF, 'wb')
114114
gffFile.write(featureStr.encode('utf-8'))
115115
gffFile.write(pamStr.encode('utf-8'))
@@ -118,7 +118,7 @@ def rewriteGFF(self):
118118
#except Exception as e:
119119
# self.sendErrorHTML(str(e))
120120

121-
121+
122122
def getRGEN(self, rgenID):
123123
# fetch the correct rgen record using the rgenID attribute
124124
rgenCollection = self.dbConnection.rgenCollection
@@ -133,16 +133,16 @@ def combineSequence(self, rgen, guideSeq, pamSeq):
133133
if rgen['PamLocation'] == 'downstream':
134134
return guideSeq.upper() + ", " + pamSeq
135135
elif rgen['PamLocation'] == 'upstream':
136-
return pamSeq.upper() + ", " + guideSeq.upper()
136+
return pamSeq.upper() + ", " + guideSeq.upper()
137137
else:
138138
sendErrorHMTL("Unrecognized PAM Location for RGEN: " + str(self.rgen['PamLocation']))
139-
139+
140140
def insertGuide(self):
141141
""" create a new record in the database for the guide """
142142
newGuideRecord = {
143143
'batchName': self.metadata['gene'],
144144
'status': 'Accepted',
145-
'guideScore': self.guide['MIT'] if 'MIT' in self.guide else '',
145+
'guideScore': self.guide['MIT'] if 'MIT' in self.guide else '',
146146
'guideSeq': self.guide['guide_seq'],
147147
'Notes': self.notes,
148148
'inputSearchCoordinates': self.metadata['inputSearchCoordinates'],
@@ -163,7 +163,7 @@ def insertGuide(self):
163163
result = self.dbConnection.guideCollection.insert_one(newGuideRecord)
164164
if not result:
165165
self.sendErrorHTML("Problem inserting record into Database")
166-
166+
167167
def updateGuide(self):
168168
""" find the existing guide and update its notes and label"""
169169
existing_id = self.existingGuide['_id']
@@ -176,7 +176,7 @@ def existingGuideInDatabase(self):
176176
searchQuery = {
177177
"guideSeq": self.guide['guide_seq'],
178178
"pamSeq": self.guide['pam_seq'],
179-
"guideLocation": self.guide['guideLocation']
179+
"guideLocation": self.guide['guideLocation']
180180
}
181181
if self.dbConnection.guideCollection.find(searchQuery).count() > 0:
182182
existingGuide = self.dbConnection.guideCollection.find_one(searchQuery)
@@ -198,7 +198,7 @@ def parseJSON(self):
198198
self.sendErrorHTML("Batch JSON file is misconfigured; no metadata found")
199199

200200
def sendErrorHTML(self, errorString):
201-
""" write error and exit the program """
201+
""" write error and exit the program """
202202
print(errorString)
203203
sys.exit()
204204

@@ -221,12 +221,12 @@ def main():
221221
print(traceback.format_exc())
222222
else:
223223
#parameters = {'guideID': '92+', 'label': 'TestLabel', 'batchID': 'dda41408f7b56fcb3b', 'notes': 'nospecialcharacters'}
224-
#parameters = {'notes': "Le'sfjkd%20fsj#%20s", 'batchID': 'bfd5911343bde9a7cd', 'label': 'Testing%20Update', 'guideID': '6-'}
224+
#parameters = {'notes': "Le'sfjkd%20fsj#%20s", 'batchID': 'bfd5911343bde9a7cd', 'label': 'Testing%20Update', 'guideID': '6-'}
225225
#{'label': 'testinglabel', 'guideID': '6-', 'notes': 'testing notes', 'batchID': '6aa1c0912c773384c7'}
226226
try:
227227
GuideAdd(**parameters)
228228
except Exception as e:
229229
print(str(e))
230230

231231
if __name__ == "__main__":
232-
main()
232+
main()

src/guide-finder/core/categorize_offtargets.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,14 +38,14 @@ def categorizeOffTargets(guideDict, rgenID, genome, batchID):
3838
dbConnection = Config(genome)
3939
rgen = getRgenRecord(rgenID, dbConnection)
4040
# construct bed intersect command
41-
segmentsFile = os.path.join(dbConnection.ROOT_PATH, "jbrowse/data."+genome, "downloads", genome+".segments.bed")
41+
segmentsFile = os.path.join(dbConnection.ROOT_PATH, "jbrowse/data/"+genome, "downloads", genome+".segments.bed")
4242
extendedBed = os.path.join(dbConnection.ROOT_PATH, "src/guide-finder/tempfiles", str(batchID)+"_extended.bed")
4343
bedCommand = ["bedtools", "intersect", "-a", extendedBed, "-b", segmentsFile, "-wb"]
4444
p = Popen(bedCommand, stdin=PIPE, stdout=PIPE, stderr=PIPE)
4545
out, err = p.communicate()
4646
if err:
4747
sys.exit(err)
48-
48+
4949
categorized = []
5050
for line in out.splitlines():
5151
# assign every intersection to its off-target
@@ -59,7 +59,7 @@ def categorizeOffTargets(guideDict, rgenID, genome, batchID):
5959
contextString = str(intersect[-1])
6060
# start the context string or append to the existing one
6161
offTarget['context'] = formatContext('', contextString) if 'context' not in offTarget else formatContext(offTarget['context'], contextString)
62-
62+
6363
return guideDict
6464

6565

@@ -76,7 +76,7 @@ def formatContext(existingContext, newIntersection):
7676
if 'intronic' in existingContext:
7777
return existingContext
7878
elif 'exonic' in existingContext:
79-
return existingContext.replace('exonic', 'exonic/intronic') # give more specific categorization
79+
return existingContext.replace('exonic', 'exonic/intronic') # give more specific categorization
8080
else:
8181
return newIntersection + " | " + existingContext
8282
elif newIntersection == 'intergenic':

0 commit comments

Comments
 (0)