Skip to content

Commit 3ee938e

Browse files
authored
add: allow not providing bigwig files
1 parent d9cbdd6 commit 3ee938e

1 file changed

Lines changed: 14 additions & 11 deletions

File tree

seqchromloader/utils.py

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -316,17 +316,20 @@ def extract_info(chrom, start, end, label, genome_pyfasta, bigwigs, target_bam,
316316

317317
#chromatin track
318318
chroms_array = []
319-
try:
320-
for idx, bigwig in enumerate(bigwigs):
321-
c = (np.nan_to_num(bigwig.values(chrom, start, end))).astype(np.float32)
322-
if strand=="-":
323-
c = c[::-1]
324-
chroms_array.append(c)
325-
except RuntimeError as e:
326-
logging.warning(e)
327-
logging.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")
328-
raise BigWigInaccessible(chrom, start, end)
329-
chroms_array = np.vstack(chroms_array) # create the chromatin track array, shape (num_tracks, length)
319+
if bigwigs is not None and len(bigwigs)>0:
320+
try:
321+
for idx, bigwig in enumerate(bigwigs):
322+
c = (np.nan_to_num(bigwig.values(chrom, start, end))).astype(np.float32)
323+
if strand=="-":
324+
c = c[::-1]
325+
chroms_array.append(c)
326+
except RuntimeError as e:
327+
logging.warning(e)
328+
logging.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")
329+
raise BigWigInaccessible(chrom, start, end)
330+
chroms_array = np.vstack(chroms_array) # create the chromatin track array, shape (num_tracks, length)
331+
else:
332+
chroms_array = None
330333
# label
331334
label_array = np.array(label, dtype=np.int32)[np.newaxis]
332335
# counts

0 commit comments

Comments
 (0)