Merge commit 'upstream/0.1.7a.dfsg'
[samtools.git] / bam_md.c
index 8d074870d336677cee2e606ab05ee81a2b4a6f1e..3ca730993cbc01065eb2c76bd66df1640808e032 100644 (file)
--- a/bam_md.c
+++ b/bam_md.c
@@ -132,8 +132,11 @@ int bam_fillmd(int argc, char *argv[])
                                free(ref);
                                ref = fai_fetch(fai, fp->header->target_name[b->core.tid], &len);
                                tid = b->core.tid;
+                               if (ref == 0)
+                                       fprintf(stderr, "[bam_fillmd] fail to find sequence '%s' in the reference.\n",
+                                                       fp->header->target_name[tid]);
                        }
-                       bam_fillmd1(b, ref, is_equal);
+                       if (ref) bam_fillmd1(b, ref, is_equal);
                }
                samwrite(fpout, b);
        }