From: peterjc
Date: Wed, 4 Apr 2012 10:43:12 +0000 (+0100)
Subject: Catch missing reference error in faidx (avoids floating point exception)
X-Git-Url: https://git.donarmstrong.com/?p=samtools.git;a=commitdiff_plain;h=e3bb71f3f845ccf3668d9ce63277b8d8324d42c3
Catch missing reference error in faidx (avoids floating point exception)
---
diff --git a/faidx.c b/faidx.c
index f0798fc..51c82ac 100644
--- a/faidx.c
+++ b/faidx.c
@@ -337,6 +337,11 @@ char *fai_fetch(const faidx_t *fai, const char *str, int *len)
} else s[name_end] = ':', name_end = l;
}
} else iter = kh_get(s, h, str);
+ if(iter == kh_end(h)) {
+ fprintf(stderr, "[fai_fetch] Warning - Reference %s not found in FASTA file, returning empty sequence\n", str);
+ free(s);
+ return 0;
+ };
val = kh_value(h, iter);
// parse the interval
if (name_end < l) {