Skip to content

Commit e3028dc

Browse files
committed
keyerror handle on memmap backend
1 parent 70fd4d6 commit e3028dc

1 file changed

Lines changed: 11 additions & 4 deletions

File tree

seqchromloader/utils.py

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -559,10 +559,14 @@ def extract_bw(chrom, start, end, strand, bigwigs):
559559
if strand=="-":
560560
c = c[::-1]
561561
chroms_array.append(c)
562-
except RuntimeError as e:
563-
logger.warning(e)
562+
except RuntimeError:
563+
#logger.warning(e)
564564
logger.warning(f"RuntimeError happened when accessing {chrom}:{start}-{end}, it's probably due to at least one chromatin track bigwig doesn't have information in this region")
565565
raise BigWigInaccessible(chrom, start, end)
566+
except KeyError:
567+
#logger.warning(e)
568+
logger.warning("KeyError happened when accessing {chrom}:{start}-{end}, it's probably due to at least one chromatin track bigwig doesn't have information in this region")
569+
raise BigWigInaccessible(chrom, start, end)
566570
chroms_array = np.vstack(chroms_array) # create the chromatin track array, shape (num_tracks, length)
567571

568572
return chroms_array
@@ -583,10 +587,13 @@ def extract_single_target(chrom, start, end, strand, target):
583587
target_array = target.values(chrom, start, end)
584588
if strand=="-":
585589
target_array = target_array[::-1]
586-
except RuntimeError as e:
587-
logger.warning(e)
590+
except RuntimeError:
591+
#logger.warning(e)
588592
logger.warning(f"RuntimeError happened when accessing {chrom}:{start}-{end}, it's probably due to at least one chromatin track bigwig doesn't have information in this region")
589593
raise BigWigInaccessible(chrom, start, end)
594+
except KeyError:
595+
logger.warning(f"KeyError happened when accessing {chrom}:{start}-{end}, it's probably due to at least one chromatin track bigwig doesn't have information in this region")
596+
raise BigWigInaccessible(chrom, start, end)
590597
else:
591598
target_array = np.array([np.nan], dtype="float32")
592599
return target_array

0 commit comments

Comments
 (0)