Skip to content

Commit 2db270e

Browse files
committed
fix: catching lines without transcript_ids
1 parent ec260ae commit 2db270e

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

gtfsort/src/utils.rs

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,14 @@ impl<'a> Layers<'a> {
7474

7575
for i in self.layer.iter() {
7676
total += i.2.len() + 1;
77-
let transcripts = self.mapper.get(&i.1).unwrap();
77+
78+
let transcripts = if let Some(transcripts) = self.mapper.get(&i.1) {
79+
transcripts
80+
} else {
81+
// log::warn!("Transcript not found in mapper for gene {} -> {}", i.1, i.2);
82+
&vec![]
83+
};
84+
7885
for j in transcripts.iter() {
7986
total += self.helper.get(j).unwrap().len() + 1;
8087
let exons = self.inner.get(j).unwrap();
@@ -243,7 +250,14 @@ pub fn write_obj_mmaped<'a, P: AsRef<Path> + Debug>(
243250
for i in chr.layer.iter() {
244251
writeln!(output, "{}", i.2)?;
245252

246-
let transcripts = chr.mapper.get(&i.1).unwrap();
253+
// INFO: catching potential error expansion from mapper.get(&i.1)
254+
// INFO: that may occur in gene lines without transcript_id
255+
let transcripts = if let Some(transcripts) = chr.mapper.get(&i.1) {
256+
transcripts
257+
} else {
258+
&vec![]
259+
};
260+
247261
for j in transcripts.iter() {
248262
writeln!(output, "{}", chr.helper.get(j).unwrap())?;
249263
let exons = chr.inner.get(j).unwrap();

0 commit comments

Comments
 (0)