Skip to content

Commit

Permalink
Check that the object last_line is a bytes-like object that needs to …
Browse files Browse the repository at this point in the history
…be decoded
  • Loading branch information
verku committed Nov 12, 2024
1 parent 2014a76 commit 1c2e728
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions workflow/scripts/gerp_derived_alleles.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,9 +101,14 @@ def read_vcf_windows(vcfFile, chrom, start, end):
break
elif currentVcfChrom == chrom and nextVcfChrom != chrom and currentVcfPos >= int(start) and currentVcfPos > int(end):
break
if len(lineDeque) == 1: # handle the last line in the file
lastVcfChrom = lineDeque[0].strip().split('\t')[0] # get the chromosome name of the line in the deque
lastVcfPos = int(lineDeque[0].strip().split('\t')[1]) # get the position of the line
if len(lineDeque) == 1: # handle the last line in the file
last_line = lineDeque[0]
if isinstance(last_line, bytes):
last_line = last_line.decode('utf8').strip()
else:
last_line = last_line.strip()
lastVcfChrom = last_line.split('\t')[0] # get the chromosome name of the line in the deque
lastVcfPos = int(last_line.split('\t')[1]) # get the position of the line
if lastVcfChrom == chrom and lastVcfPos >= int(start) and lastVcfPos == int(end):
n_rows += 1
break
Expand Down

0 comments on commit 1c2e728

Please sign in to comment.