Skip to content

Commit

Permalink
Fix asynchrony in input file splitting CRITICAL FIX
Browse files Browse the repository at this point in the history
  • Loading branch information
Ranum committed Jan 15, 2021
1 parent 58a8460 commit 0710136
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions python_only_tool/DemultiplexUsingBarcodes_New_V2.py
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ def return_fastq(self):
######
bin_counter = 0
for i in range(0,int(linesInInputFastq),int(binIterator)):
# Create dictinaries used to store the parsed read information from the fastq files
# Create dictionaries used to store the parsed read information from the fastq files
readsF = {}
readsR = {}
readsF_BC_UMI_dict = {}
Expand Down Expand Up @@ -241,13 +241,14 @@ def return_fastq(self):
lineQuality=str(line[0:].rstrip())
completeReadCounter += 1
if (completeReadCounter == 3):
read_counter += 1
processedRead = FastQRead(name = lineName, \
read = lineRead, \
quality = lineQuality, \
lineNumber = read_counter)
print("Adding Fwd Read Key " + str(str(bin_counter) + "_" + str(read_counter)))
readsF[str(str(bin_counter) + "_" + str(read_counter))]=processedRead
completeReadCounter = 0
read_counter += 1
if (starterF == 1):
line_ct1 += 1

Expand Down Expand Up @@ -293,16 +294,17 @@ def return_fastq(self):
lineQuality=str(line[0:].rstrip())
completeReadCounter += 1
if (completeReadCounter == 3):
read_counter += 1 # The read counter should progress even if a read does not satisfy the following criteria for being retained.
if len(filteredBarcode1) == 0: # The following if statments break the loop if a barcode does not pass the HD <=1 filter
line_ct1 += 1 # If the barcode observed does not match a barcode in our greenlist we escape the loop, count the line and reset the complete read counter.
#line_ct1 += 1 # If the barcode observed does not match a barcode in our greenlist we escape the loop, count the line and reset the complete read counter.
completeReadCounter = 0
continue
elif len(filteredBarcode2) == 0:
line_ct1 += 1
#line_ct1 += 1
completeReadCounter = 0
continue
elif len(filteredBarcode3) == 0:
line_ct1 += 1
#line_ct1 += 1
completeReadCounter = 0
continue
else:
Expand All @@ -314,9 +316,9 @@ def return_fastq(self):
barcode2 = filteredBarcode2[0], \
barcode3 = filteredBarcode3[0], \
umi = lineReadUMI)
print("Adding Rev Read Key " + str(str(bin_counter) + "_" + str(read_counter)))
readsR[str(str(bin_counter) + "_" + str(read_counter))]=processedRead
completeReadCounter = 0 # Reset the complete read counter to 0 because a read has been completely extracted and stored in the dictionary.
read_counter += 1 # The read counter should progress even if a read does not satisfy the criteria for being retained.
if (starterR == 1):
line_ct1 += 1 # There are 4 lines for each read in the fastq file. The line counter needs to progress even if no "if" statements are satisfied.

Expand All @@ -329,6 +331,7 @@ def return_fastq(self):
# while the forward read contains the gene expression information.
# So we need to create a read that contains the barcode information appended to the read name
# and the forward read information stored as the actual read.
print("beginning transfer of barcodes")
for key in readsR.keys():
readF_BC_UMI = barcodeRead(name = readsF[key].name, \
read = readsF[key].read, \
Expand Down

0 comments on commit 0710136

Please sign in to comment.