Skip to content

Commit 4d78e80

Browse files
committed
better error handling on chromatin bigwigs
1 parent 6211a00 commit 4d78e80

1 file changed

Lines changed: 8 additions & 4 deletions

File tree

tpcav/helper.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
import torch
1717
from deeplift.dinuc_shuffle import dinuc_shuffle
1818
from pyfaidx import Fasta
19-
from seqchromloader.utils import dna2OneHot, extract_bw
19+
from seqchromloader.utils import dna2OneHot, extract_bw, BigWigInaccessible
2020

2121
logger = logging.getLogger(__name__)
2222

@@ -116,9 +116,13 @@ def dataframe_to_chrom_tracks_iter(
116116
if bigwigs is not None and len(bigwigs) > 0:
117117
chrom_arrs = []
118118
for row in df.itertuples(index=False):
119-
chrom = extract_bw(
120-
row.chrom, row.start, row.end, getattr(row, "strand", "+"), bigwigs
121-
)
119+
try:
120+
chrom = extract_bw(
121+
row.chrom, row.start, row.end, getattr(row, "strand", "+"), bigwigs
122+
)
123+
except BigWigInaccessible as e:
124+
logger.warning(e)
125+
continue
122126
chrom_arrs.append(chrom)
123127
if batch_size is not None and len(chrom_arrs) == batch_size:
124128
yield torch.tensor(np.stack(chrom_arrs))

0 commit comments

Comments
 (0)