]> git.donarmstrong.com Git - samtools.git/commitdiff
* samtools-0.1.4-9 (r340)
authorHeng Li <lh3@live.co.uk>
Sat, 13 Jun 2009 10:17:14 +0000 (10:17 +0000)
committerHeng Li <lh3@live.co.uk>
Sat, 13 Jun 2009 10:17:14 +0000 (10:17 +0000)
 * added a warning to razf.c if zlib<1.2.2.1
 * fixed a compilation warning
 * fixed a segfault caused by @RG parsing
 * detect NCURSES in bam_tview.c

INSTALL
Makefile
bam_aux.c
bam_import.c
bam_tview.c
bamtk.c
razf.c
sam_view.c

diff --git a/INSTALL b/INSTALL
index 71a91bc0fe0692099af72dfa5e4258679a32129b..f1cf7aa4079ca1302608dd81c59a7882597975ee 100644 (file)
--- a/INSTALL
+++ b/INSTALL
@@ -11,8 +11,7 @@ The text-based viewer (tview) requires the GNU ncurses library
 <http://www.gnu.org/software/ncurses/>, which comes with Mac OS X and
 most of the modern Linux/Unix distributions. If you do not have this
 library installed, you can still compile the rest of SAMtools by
-manually modifying two lines in Makefile as is described in the
-Makefile.
+manually modifying one line in Makefile.
 
 
 Compilation
index 77523d93a80f9f5fa0c984f1506f47e38cf413fa..724552f1c85961d6c441396b8f363b4602c94ec2 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -2,7 +2,6 @@ CC=                     gcc
 CXX=           g++
 CFLAGS=                -g -Wall -O2 #-m64 #-arch ppc
 CXXFLAGS=      $(CFLAGS)
-### For ncurses: please apply `-D_NO_CURSES' if you do not have ncurses installed
 DFLAGS=                -D_IOLIB=2 -D_FILE_OFFSET_BITS=64 #-D_NO_CURSES
 OBJS=          bam.o bam_import.o bam_pileup.o bam_lpileup.o bam_sort.o bam_index.o \
                        razf.o bgzf.o faidx.o bam_tview.o bam_maqcns.o bam_aux.o bam_plcmd.o \
@@ -34,7 +33,7 @@ lib:libbam.a
 libbam.a:$(OBJS)
                $(AR) -cru $@ $(OBJS)
 
-### For ncurses: comment out `-lcurses' if you do not have ncurses installed
+### For the curses library: comment out `-lcurses' if you do not have curses installed
 samtools:lib bamtk.o
                $(CC) $(CFLAGS) -o $@ bamtk.o -lm -L. -lbam -lcurses -lz
 
index 137f9afffdd016347a48cd85df7a6c0cfd2cebf0..f36bc2351ee0c74ad87f877f7a3797e3281461d8 100644 (file)
--- a/bam_aux.c
+++ b/bam_aux.c
@@ -169,7 +169,9 @@ int bam_strmap_put(void *rg2lib, const char *rg, const char *lib)
        int ret;
        khint_t k;
        khash_t(r2l) *h = (khash_t(r2l)*)rg2lib;
-       char *key = strdup(rg);
+       char *key;
+       if (h == 0) return 1;
+       key = strdup(rg);
        k = kh_put(r2l, h, key, &ret);
        if (ret) kh_val(h, k) = strdup(lib);
        else {
@@ -183,6 +185,7 @@ const char *bam_strmap_get(const void *rg2lib, const char *rg)
 {
        const khash_t(r2l) *h = (const khash_t(r2l)*)rg2lib;
        khint_t k;
+       if (h == 0) return 0;
        k = kh_get(r2l, h, rg);
        if (k != kh_end(h)) return (const char*)kh_val(h, k);
        else return 0;
@@ -191,9 +194,11 @@ const char *bam_strmap_get(const void *rg2lib, const char *rg)
 void *bam_strmap_dup(const void *rg2lib)
 {
        const khash_t(r2l) *h = (const khash_t(r2l)*)rg2lib;
-       khash_t(r2l) *g = kh_init(r2l);
+       khash_t(r2l) *g;
        khint_t k, l;
        int ret;
+       if (h == 0) return 0;
+       g = kh_init(r2l);
        for (k = kh_begin(h); k < kh_end(h); ++k) {
                if (kh_exist(h, k)) {
                        char *key = strdup(kh_key(h, k));
index c08547345056a356b6b07b50e931c9baff05f48c..c7f866701edd87f37e18fbc9768ed63f68be7f9e 100644 (file)
@@ -153,7 +153,9 @@ int sam_header_parse_rg(bam_header_t *h)
        char *p, *q, *s, *r;
        int n = 0;
 
-       bam_strmap_destroy(h->rg2lib);
+       // free
+       bam_strmap_destroy(h->rg2lib); h->rg2lib = 0;
+       if (h->l_text < 3) return 0;
        // parse @RG lines
        h->rg2lib = bam_strmap_init();
        rgid = calloc(1, sizeof(kstring_t));
@@ -193,6 +195,10 @@ int sam_header_parse_rg(bam_header_t *h)
        }
        free(rgid->s); free(rgid);
        free(rglib->s); free(rglib);
+       if (n == 0) {
+               bam_strmap_destroy(h->rg2lib);
+               h->rg2lib = 0;
+       }
        return n;
 }
 
index 5858e3b40c5999aed6ac09d91e681de4cb55a8c1..c26273c7152f4e678911eccddca9b4c5701c63cf 100644 (file)
@@ -1,5 +1,6 @@
 #ifndef _NO_CURSES
 #include <curses.h>
+#ifdef NCURSES_VERSION
 #include <ctype.h>
 #include <assert.h>
 #include <string.h>
@@ -303,7 +304,7 @@ void tv_loop(tview_t *tv)
        tid = tv->curr_tid; pos = tv->left_pos;
        while (1) {
                int c = getch();
-               if(256 < c) {c = 1 + (c%256);} // Terminal was displaying ctrl-H as 263 via ssh from Mac OS X 10.5 computer 
+               //if(256 < c) {c = 1 + (c%256);} // Terminal was displaying ctrl-H as 263 via ssh from Mac OS X 10.5 computer 
                switch (c) {
                        case '?': tv_win_help(tv); break;
                        case '\033':
@@ -361,4 +362,12 @@ int bam_tview_main(int argc, char *argv[])
        tv_destroy(tv);
        return 0;
 }
+#else // #ifdef NCURSES_VERSION
+#warning "The ncurses library is unavailable; tview is disabled."
+int bam_tview_main(int argc, char *argv[])
+{
+       fprintf(stderr, "[bam_tview_main] The ncurses library is unavailable; tview is not compiled.\n");
+       return 1;
+}
 #endif
+#endif // #ifndef _NO_CURSES
diff --git a/bamtk.c b/bamtk.c
index 852213e3580c90de58052537ed19f003a0340de8..54b19f3dd0931bc76bb97d81a8723d0fe17e5ff5 100644 (file)
--- a/bamtk.c
+++ b/bamtk.c
@@ -3,7 +3,7 @@
 #include "bam.h"
 
 #ifndef PACKAGE_VERSION
-#define PACKAGE_VERSION "0.1.4-8 (r338)"
+#define PACKAGE_VERSION "0.1.4-9 (r340)"
 #endif
 
 int bam_taf2baf(int argc, char *argv[]);
diff --git a/razf.c b/razf.c
index c782cad33f323ff8af511c805945e10c7f41a8cf..b56065b9e22f54fa4f8a9c31260970ff2a8808c7 100644 (file)
--- a/razf.c
+++ b/razf.c
@@ -27,8 +27,6 @@
  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
- *
- * To compile razf.c, zlib-1.2.3(or greater) is required.
  */
 
 #ifndef _NO_RAZF
@@ -56,6 +54,7 @@ struct _gz_header_s {
     int     hcrc;
     int     done;
 };
+#warning "zlib < 1.2.2.1; RAZF writing is disabled."
 #endif
 
 #define DEF_MEM_LEVEL 8
index 50192f17f647bf64dc1b060343095d37ce120218..95a52c82513c41349afbc86d89249c068b3d20c4 100644 (file)
@@ -14,7 +14,7 @@ static inline int __g_skip_aln(const bam_header_t *h, const bam1_t *b)
        if (g_library) {
                uint8_t *s = bam_aux_get(b, "RG");
                if (s) {
-                       const char *p = bam_strmap_get(h->rg2lib, s + 1);
+                       const char *p = bam_strmap_get(h->rg2lib, (char*)(s + 1));
                        return (p && strcmp(p, g_library) == 0)? 0 : 1;
                } else return 1;
        } else return 0;