From d33abf127f2f5cbe4a3129d10b8f85a501a21857 Mon Sep 17 00:00:00 2001 From: Heng Li Date: Thu, 29 Mar 2012 14:45:00 -0400 Subject: [PATCH] check *.64.bwt first and then *.bwt --- bwtaln.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/bwtaln.c b/bwtaln.c index 9db63c8..014734c 100644 --- a/bwtaln.c +++ b/bwtaln.c @@ -227,17 +227,19 @@ char *bwa_infer_prefix(const char *hint) l_hint = strlen(hint); prefix = malloc(l_hint + 3 + 4 + 1); strcpy(prefix, hint); - strcpy(prefix + l_hint, ".bwt"); + strcpy(prefix + l_hint, ".64.bwt"); if ((fp = fopen(prefix, "rb")) != 0) { - prefix[l_hint] = 0; + fclose(fp); + prefix[l_hint + 3] = 0; return prefix; } else { - strcpy(prefix + l_hint, ".64.bwt"); + strcpy(prefix + l_hint, ".bwt"); if ((fp = fopen(prefix, "rb")) == 0) { free(prefix); return 0; } else { - prefix[l_hint + 3] = 0; + fclose(fp); + prefix[l_hint] = 0; return prefix; } }