]> git.donarmstrong.com Git - samtools.git/commitdiff
* samtools-0.1.3-7 (r246)
authorHeng Li <lh3@live.co.uk>
Tue, 28 Apr 2009 12:10:23 +0000 (12:10 +0000)
committerHeng Li <lh3@live.co.uk>
Tue, 28 Apr 2009 12:10:23 +0000 (12:10 +0000)
 * incorporated revisions from Nils Homer
 * enhanced support of displaying color-space reads

13 files changed:
ChangeLog
Makefile [deleted file]
Makefile.am [new file with mode: 0644]
Makefile.generic [new file with mode: 0644]
autogen.sh [new file with mode: 0644]
bam.h
bam_aux.c
bam_tview.c
bamtk.c
cleanup.sh [new file with mode: 0644]
configure.ac [new file with mode: 0644]
misc/Makefile [deleted file]
misc/Makefile.generic [new file with mode: 0644]

index e2958e7bd496013398e66d1d2d46655f3dbb7e5a..a096816027cd67abdd8d8e139ea0ead703203186 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,104 @@
+------------------------------------------------------------------------
+r244 | lh3lh3 | 2009-04-25 11:49:40 +0100 (Sat, 25 Apr 2009) | 3 lines
+Changed paths:
+   M /trunk/samtools/bam_md.c
+   M /trunk/samtools/bamtk.c
+
+ * samtools-0.1.3-6 (r244)
+ * fixed segfault for unmapped reads
+
+------------------------------------------------------------------------
+r243 | lh3lh3 | 2009-04-24 21:27:26 +0100 (Fri, 24 Apr 2009) | 5 lines
+Changed paths:
+   M /trunk/samtools/bam.h
+   M /trunk/samtools/bam_maqcns.c
+   M /trunk/samtools/bam_md.c
+   M /trunk/samtools/bamtk.c
+
+ * samtools-0.1.3-5 (r243)
+ * fixed a long existing bug which may cause memory leak
+ * check MD
+ * consensus calling now works with "=", but indel calling not
+
+------------------------------------------------------------------------
+r242 | lh3lh3 | 2009-04-24 20:44:46 +0100 (Fri, 24 Apr 2009) | 3 lines
+Changed paths:
+   M /trunk/samtools/bam_md.c
+   M /trunk/samtools/bamtk.c
+
+ * samtools-0.1.3-4 (r242)
+ * fixed a memory leak
+
+------------------------------------------------------------------------
+r240 | lh3lh3 | 2009-04-24 16:40:18 +0100 (Fri, 24 Apr 2009) | 5 lines
+Changed paths:
+   M /trunk/samtools/Makefile
+   M /trunk/samtools/Makefile.lite
+   M /trunk/samtools/bam.h
+   M /trunk/samtools/bam_aux.c
+   A /trunk/samtools/bam_md.c
+   M /trunk/samtools/bam_plcmd.c
+   M /trunk/samtools/bamtk.c
+
+ * samtools-0.1.3-3 (r240)
+ * generate MD tag
+ * generate "=" bases
+ * the plain pileup now support "=" bases, but consensus calling and glfgen may fail
+
+------------------------------------------------------------------------
+r239 | lh3lh3 | 2009-04-24 12:08:20 +0100 (Fri, 24 Apr 2009) | 5 lines
+Changed paths:
+   M /trunk/samtools/bam.h
+   M /trunk/samtools/bam_aux.c
+   M /trunk/samtools/bamtk.c
+
+ * samtools-0.1.3-2 (r239)
+ * fixed bugs in bam_aux.c (these functions nevered used by samtools)
+ * removed bam_aux_init()/bam_aux_destroy()
+ * added tagview for testing bam_aux
+
+------------------------------------------------------------------------
+r235 | lh3lh3 | 2009-04-21 23:17:39 +0100 (Tue, 21 Apr 2009) | 3 lines
+Changed paths:
+   M /trunk/samtools/bam_pileup.c
+   M /trunk/samtools/bamtk.c
+
+ * samtools-0.1.3-1
+ * fixed a bug in pileup: the first read in a chromosome may not be printed
+
+------------------------------------------------------------------------
+r232 | lh3lh3 | 2009-04-16 15:25:43 +0100 (Thu, 16 Apr 2009) | 2 lines
+Changed paths:
+   M /trunk/samtools/Makefile.lite
+
+a missing file in Makefile.lite
+
+------------------------------------------------------------------------
+r227 | lh3lh3 | 2009-04-15 22:02:53 +0100 (Wed, 15 Apr 2009) | 2 lines
+Changed paths:
+   M /trunk/samtools/NEWS
+   M /trunk/samtools/bamtk.c
+
+Release samtools-0.1.3
+
+------------------------------------------------------------------------
+r223 | lh3lh3 | 2009-04-15 14:31:32 +0100 (Wed, 15 Apr 2009) | 3 lines
+Changed paths:
+   M /trunk/samtools/bam_plcmd.c
+   M /trunk/samtools/bamtk.c
+
+ * samtools-0.1.2-28
+ * make samtools more robust to weird input such as empty file
+
+------------------------------------------------------------------------
+r222 | lh3lh3 | 2009-04-15 14:05:33 +0100 (Wed, 15 Apr 2009) | 2 lines
+Changed paths:
+   M /trunk/samtools/ChangeLog
+   M /trunk/samtools/NEWS
+   M /trunk/samtools/samtools.1
+
+prepare for release 0.1.3
+
 ------------------------------------------------------------------------
 r221 | lh3lh3 | 2009-04-15 13:32:14 +0100 (Wed, 15 Apr 2009) | 2 lines
 Changed paths:
diff --git a/Makefile b/Makefile
deleted file mode 100644 (file)
index 25897db..0000000
--- a/Makefile
+++ /dev/null
@@ -1,65 +0,0 @@
-CC=                    gcc
-CXX=           g++
-CFLAGS=                -g -Wall -O2 -m64 #-arch ppc
-CXXFLAGS=      $(CFLAGS)
-DFLAGS=                -D_IOLIB=2 -D_FILE_OFFSET_BITS=64 #-D_NO_RAZF #-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 \
-                       bam_mate.o bam_rmdup.o glf.o bam_stat.o kstring.o bam_md.o
-PROG=          razip bgzip samtools
-INCLUDES=      
-LIBS=          -lm -lz
-SUBDIRS=       . misc
-
-.SUFFIXES:.c .o
-
-.c.o:
-               $(CC) -c $(CFLAGS) $(DFLAGS) $(INCLUDES) $< -o $@
-
-all-recur lib-recur clean-recur cleanlocal-recur install-recur:
-               @target=`echo $@ | sed s/-recur//`; \
-               wdir=`pwd`; \
-               list='$(SUBDIRS)'; for subdir in $$list; do \
-                       cd $$subdir; \
-                       $(MAKE) CC="$(CC)" CXX="$(CXX)" DFLAGS="$(DFLAGS)" CFLAGS="$(CFLAGS)" \
-                               INCLUDES="$(INCLUDES)" LIBS="$(LIBS)" $$target || exit 1; \
-                       cd $$wdir; \
-               done;
-
-all:$(PROG)
-
-lib:libbam.a
-
-libbam.a:$(OBJS)
-               $(AR) -cru $@ $(OBJS)
-
-samtools:lib bamtk.o
-               $(CC) $(CFLAGS) -o $@ bamtk.o $(LIBS) -L. -lbam -lcurses
-
-razip:razip.o razf.o
-               $(CC) $(CFLAGS) -o $@ razf.o razip.o $(LIBS)
-
-bgzip:bgzip.o bgzf.o
-               $(CC) $(CFLAGS) -o $@ bgzf.o bgzip.o $(LIBS)
-
-razip.o:razf.h
-bam.o:bam.h razf.h bam_endian.h
-bam_import.o:bam.h kseq.h khash.h razf.h
-bam_pileup.o:bam.h razf.h ksort.h
-bam_plcmd.o:bam.h faidx.h bam_maqcns.h glf.h
-bam_index.o:bam.h khash.h ksort.h razf.h bam_endian.h
-bam_lpileup.o:bam.h ksort.h
-bam_tview.o:bam.h faidx.h bam_maqcns.h
-bam_maqcns.o:bam.h ksort.h bam_maqcns.h
-bam_sort.o:bam.h ksort.h razf.h
-bam_md.o:bam.h faidx.h
-razf.o:razf.h
-glf.o:glf.h
-
-faidx.o:faidx.h razf.h khash.h
-faidx_main.o:faidx.h razf.h
-
-cleanlocal:
-               rm -fr gmon.out *.o a.out *.dSYM $(PROG) *~ *.a
-
-clean:cleanlocal-recur
diff --git a/Makefile.am b/Makefile.am
new file mode 100644 (file)
index 0000000..e2304f7
--- /dev/null
@@ -0,0 +1,56 @@
+EXTRA_DIST = autogen.sh 
+bin_PROGRAMS = bgzip samtools razip
+SUBDIRS = . misc
+
+bgzip_SOURCES = bgzip.c bgzf.c
+bgzip_LDADD = -lm -lz
+
+samtools_SOURCES = bamtk.c bam.c bam_aux.c bam_import.c bam_index.c \
+                                  bam_lpileup.c bam_maqcns.c bam_mate.c bam_md.c bam_pileup.c \
+                                  bam_plcmd.c bam_rmdup.c bam_sort.c bam_stat.c \
+                                  bam_tview.c bgzf.c faidx.c glf.c kstring.c razf.c \
+                                  bam.h bam_endian.h bam_maqcns.h bgzf.h faidx.h glf.h \
+                                  khash.h kseq.h kstring.h ksort.h razf.h zutil.h
+samtools_LDADD = -lm -lz -lcurses
+
+razip_SOURCES = razip.c razf.c
+razip_LDADD = -lm -lz
+dist_bin_SCRIPTS = bowtie2sam.pl export2sam.pl novo2sam.pl samtools.pl soap2sam.pl wgsim_eval.pl zoom2sam.pl
+bin_PROGRAMS = faidx maq2sam-short maq2sam-long md5fa md5sum-lite wgsim
+
+faidx_SOURCES = ../faidx.c ../faidx.c
+#faidx_LDFLAGS = -D_NO_RAZF -DFAIDX_MAIN 
+
+md5fa_SOURCES = md5.c md5.h md5fa.c ../kseq.h
+#md5fa_LDADD = -lz
+
+md5sum_lite_SOURCES = md5.c md5.h
+#md5sum_lite_LDFLAGS = -DMD5SUM_MAIN
+
+maq2sam_short_SOURCES = maq2sam.c
+#maq2sam_short_LDADD = -lz
+
+maq2sam_long_SOURCES = maq2sam.c
+#maq2sam_long_LDADD = -lz
+
+wgsim_SOURCES = wgsim.c 
+wgsim_LDADD = -lm 
+
+faidx:../faidx.c ../faidx.h
+       $(CC) $(CFLAGS) -D_NO_RAZF -DFAIDX_MAIN -o $@ ../faidx.c
+md5fa:md5.o md5fa.o md5.h ../kseq.h
+       $(CC) $(CFLAGS) -o $@ md5.o md5fa.o -lz
+md5fa.o:md5.h md5fa.c
+       $(CC) $(CFLAGS) -c -I.. -o $@ md5fa.c
+md5sum-lite:md5sum-lite.o
+       $(CC) $(CFLAGS) -o $@ md5sum-lite.o
+md5sum-lite.o:md5.c md5.h
+       $(CC) -c $(CFLAGS) -DMD5SUM_MAIN -o $@ md5.c
+maq2sam-short:maq2sam-short.o
+       $(CC) $(CFLAGS) -o $@ maq2sam-short.o -lz 
+maq2sam-short.o:maq2sam.c
+       $(CC) -c $(CFLAGS) -o $@ maq2sam.c 
+maq2sam-long:maq2sam-long.o
+       $(CC) $(CFLAGS) -o $@ maq2sam-long.o -lz 
+maq2sam-long.o:maq2sam.c
+       $(CC) -c $(CFLAGS) -DMAQ_LONGREADS -D_MAQ_LONGREADS -o $@ maq2sam.c 
diff --git a/Makefile.generic b/Makefile.generic
new file mode 100644 (file)
index 0000000..002c71a
--- /dev/null
@@ -0,0 +1,65 @@
+CC=                    gcc
+CXX=           g++
+CFLAGS=                -g -Wall -O2 -m64 #-arch ppc
+CXXFLAGS=      $(CFLAGS)
+DFLAGS=                -D_IOLIB=2 -D_FILE_OFFSET_BITS=64 #-D_NO_RAZF #-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 \
+                       bam_mate.o bam_rmdup.o glf.o bam_stat.o kstring.o bam_md.o
+PROG=          razip bgzip samtools
+INCLUDES=      
+LIBS=          -lm -lz
+SUBDIRS=       . misc
+
+.SUFFIXES:.c .o
+
+.c.o:
+               $(CC) -c $(CFLAGS) $(DFLAGS) $(INCLUDES) $< -o $@
+
+all-recur lib-recur clean-recur cleanlocal-recur install-recur:
+               @target=`echo $@ | sed s/-recur//`; \
+               wdir=`pwd`; \
+               list='$(SUBDIRS)'; for subdir in $$list; do \
+                       cd $$subdir; \
+                       $(MAKE) -f Makefile.generic CC="$(CC)" CXX="$(CXX)" DFLAGS="$(DFLAGS)" CFLAGS="$(CFLAGS)" \
+                               INCLUDES="$(INCLUDES)" LIBS="$(LIBS)" $$target || exit 1; \
+                       cd $$wdir; \
+               done;
+
+all:$(PROG)
+
+lib:libbam.a
+
+libbam.a:$(OBJS)
+               $(AR) -cru $@ $(OBJS)
+
+samtools:lib bamtk.o
+               $(CC) $(CFLAGS) -o $@ bamtk.o $(LIBS) -L. -lbam -lcurses
+
+razip:razip.o razf.o
+               $(CC) $(CFLAGS) -o $@ razf.o razip.o $(LIBS)
+
+bgzip:bgzip.o bgzf.o
+               $(CC) $(CFLAGS) -o $@ bgzf.o bgzip.o $(LIBS)
+
+razip.o:razf.h
+bam.o:bam.h razf.h bam_endian.h
+bam_import.o:bam.h kseq.h khash.h razf.h
+bam_pileup.o:bam.h razf.h ksort.h
+bam_plcmd.o:bam.h faidx.h bam_maqcns.h glf.h
+bam_index.o:bam.h khash.h ksort.h razf.h bam_endian.h
+bam_lpileup.o:bam.h ksort.h
+bam_tview.o:bam.h faidx.h bam_maqcns.h
+bam_maqcns.o:bam.h ksort.h bam_maqcns.h
+bam_sort.o:bam.h ksort.h razf.h
+bam_md.o:bam.h faidx.h
+razf.o:razf.h
+glf.o:glf.h
+
+faidx.o:faidx.h razf.h khash.h
+faidx_main.o:faidx.h razf.h
+
+cleanlocal:
+               rm -fr gmon.out *.o a.out *.dSYM $(PROG) *~ *.a
+
+clean:cleanlocal-recur
diff --git a/autogen.sh b/autogen.sh
new file mode 100644 (file)
index 0000000..99f0a5f
--- /dev/null
@@ -0,0 +1,51 @@
+#!/bin/sh
+
+run ()
+{
+    echo "running: $*"
+    eval $*
+
+    if test $? != 0 ; then
+       echo "error: while running '$*'"
+       exit 1
+    fi
+}
+
+run aclocal
+run autoheader
+run automake -a
+run autoconf
+#!/bin/sh
+
+run ()
+{
+    echo "running: $*"
+    eval $*
+
+    if test $? != 0 ; then
+       echo "error: while running '$*'"
+       exit 1
+    fi
+}
+
+run aclocal
+run autoheader
+run automake -a
+run autoconf
+#!/bin/sh
+
+run ()
+{
+    echo "running: $*"
+    eval $*
+
+    if test $? != 0 ; then
+       echo "error: while running '$*'"
+       exit 1
+    fi
+}
+
+run aclocal
+run autoheader
+run automake -a
+run autoconf
diff --git a/bam.h b/bam.h
index b607f96cc80ec4f3100380b051cb87a54675ac68..4045684230a7cba886a0ed0fa390db3340866f91 100644 (file)
--- a/bam.h
+++ b/bam.h
@@ -606,6 +606,35 @@ extern "C" {
        char bam_aux2A(const uint8_t *s);
        char *bam_aux2Z(const uint8_t *s);
 
+       /*!
+        @abstract     Get the color encoding the previous and current base
+        @param b      pointer to an alignment
+        @param i      The i-th position, 0-based
+        @return       color
+
+        @discussion   Returns 0 no color information is found.
+        */
+       char bam_aux_getCSi(bam1_t *b, int i);
+
+       /*!
+        @abstract     Get the color quality of the color encoding the previous and current base
+        @param b      pointer to an alignment
+        @param i      The i-th position, 0-based
+        @return       color quality
+
+        @discussion   Returns 0 no color information is found.
+        */
+       char bam_aux_getCQi(bam1_t *b, int i);
+
+       /*!
+        @abstract     Get the color error profile at the give position    
+        @param b      pointer to an alignment
+        @return       the original color if the color was an error, '-' (dash) otherwise
+
+        @discussion   Returns 0 no color information is found.
+        */
+       char bam_aux_getCEi(bam1_t *b, int i);
+
        /*!  
          @abstract Calculate the rightmost coordinate of an alignment on the
          reference genome.
index d6f18ea281712a7d89007d7d87291cbf13718c1b..2fa9ac2e83a7a00e2e83a523fe687448e3c4255e 100644 (file)
--- a/bam_aux.c
+++ b/bam_aux.c
@@ -74,7 +74,7 @@ void bam_parse_region(bam_header_t *header, const char *str, int *ref_id, int *b
 
        bam_init_header_hash(header);
        h = (khash_t(s)*)header->hash;
-       
+
        l = strlen(str);
        p = s = (char*)malloc(l+1);
        /* squeeze out "," */
@@ -152,3 +152,105 @@ char *bam_aux2Z(const uint8_t *s)
        if (type == 'Z' || type == 'H') return (char*)s;
        else return 0;
 }
+
+char bam_aux_getCSi(bam1_t *b, int i)
+{
+       uint8_t *c = bam_aux_get(b, "CS");
+       char *cs = NULL;
+
+       // return the base if the tag was not found
+       if(0 == c) return 0;
+
+       cs = bam_aux2Z(c);
+       // adjust for strandedness and leading adaptor
+       if(bam1_strand(b)) i = strlen(cs) - 1 - i;
+       else i++;
+       return cs[i];
+}
+
+char bam_aux_getCQi(bam1_t *b, int i)
+{
+       uint8_t *c = bam_aux_get(b, "CQ");
+       char *cq = NULL;
+       
+       // return the base if the tag was not found
+       if(0 == c) return 0;
+
+       cq = bam_aux2Z(c);
+       // adjust for strandedness
+       if(bam1_strand(b)) i = strlen(cq) - 1 - i;
+       return cq[i];
+}
+
+char bam_aux_nt2int(char a)
+{
+       switch(toupper(a)) {
+               case 'A':
+                       return 0;
+                       break;
+               case 'C':
+                       return 1;
+                       break;
+               case 'G':
+                       return 2;
+                       break;
+               case 'T':
+                       return 3;
+                       break;
+               default:
+                       return 4;
+                       break;
+       }
+}
+
+char bam_aux_ntnt2cs(char a, char b)
+{
+       a = bam_aux_nt2int(a);
+       b = bam_aux_nt2int(b);
+       if(4 == a || 4 == b) return '4';
+       return "0123"[(int)(a ^ b)];
+}
+
+char bam_aux_getCEi(bam1_t *b, int i)
+{
+       int cs_i;
+       uint8_t *c = bam_aux_get(b, "CS");
+       char *cs = NULL;
+       char prev_b, cur_b;
+       char cur_color, cor_color;
+
+       // return the base if the tag was not found
+       if(0 == c) return 0;
+       
+       cs = bam_aux2Z(c);
+
+       // adjust for strandedness and leading adaptor
+       if(bam1_strand(b)) { //reverse strand
+               cs_i = strlen(cs) - 1 - i;
+               // get current color
+               cur_color = cs[cs_i];
+               // get previous base
+               prev_b = (0 == cs_i) ? cs[0] : bam_nt16_rev_table[bam1_seqi(bam1_seq(b), i+1)];
+               // get current base
+               cur_b = bam_nt16_rev_table[bam1_seqi(bam1_seq(b), i)]; 
+       }
+       else {
+               cs_i=i+1;
+               // get current color
+               cur_color = cs[cs_i];
+               // get previous base
+               prev_b = (0 == i) ? cs[0] : bam_nt16_rev_table[bam1_seqi(bam1_seq(b), i-1)];
+               // get current base
+               cur_b = bam_nt16_rev_table[bam1_seqi(bam1_seq(b), i)];
+       }
+
+       // corrected color
+       cor_color = bam_aux_ntnt2cs(prev_b, cur_b);
+
+       if(cur_color == cor_color) { 
+               return '-';
+       }
+       else {
+               return cur_color;
+       }
+}
index 77d60a0a9cc18386121c2d2b74fc61b5b4a8fe72..c6780c302c285bf6dbcad4bd378d9514fa5deefb 100644 (file)
 #define TV_MAX_GOTO  40
 #define TV_LOW_MAPQ  10
 
-#define TV_COLOR_MAPQ  0
-#define TV_COLOR_BASEQ 1
-#define TV_COLOR_NUCL  2
+#define TV_COLOR_MAPQ   0
+#define TV_COLOR_BASEQ  1
+#define TV_COLOR_NUCL   2
+#define TV_COLOR_COL    3
+#define TV_COLOR_COLQ   4
+
+#define TV_BASE_NUCL 0
+#define TV_BASE_COLOR_SPACE 1
 
 typedef struct {
        int mrow, mcol;
@@ -27,7 +32,7 @@ typedef struct {
        faidx_t *fai;
        bam_maqcns_t *bmc;
 
-       int ccol, last_pos, row_shift, color_for, is_nucl, l_ref;
+       int ccol, last_pos, row_shift, base_for, color_for, is_dot, l_ref, ins;
        char *ref;
 } tview_t;
 
@@ -56,10 +61,12 @@ int tv_pl_func(uint32_t tid, uint32_t pos, int n, const bam_pileup1_t *pl, void
        attron(attr);
        mvaddch(2, tv->ccol, c);
        attroff(attr);
-       // calculate maximum insert
-       for (i = 0; i < n; ++i) {
-               const bam_pileup1_t *p = pl + i;
-               if (p->indel > 0 && max_ins < p->indel) max_ins = p->indel;
+       if(tv->ins) {
+               // calculate maximum insert
+               for (i = 0; i < n; ++i) {
+                       const bam_pileup1_t *p = pl + i;
+                       if (p->indel > 0 && max_ins < p->indel) max_ins = p->indel;
+               }
        }
        // core loop
        for (j = 0; j <= max_ins; ++j) {
@@ -68,21 +75,35 @@ int tv_pl_func(uint32_t tid, uint32_t pos, int n, const bam_pileup1_t *pl, void
                        int row = TV_MIN_ALNROW + p->level - tv->row_shift;
                        if (j == 0) {
                                if (!p->is_del) {
-                                       c = bam_nt16_rev_table[bam1_seqi(bam1_seq(p->b), p->qpos)];
-                                       if (!tv->is_nucl && toupper(c) == toupper(rb)) c = bam1_strand(p->b)? ',' : '.';
+                                       if (tv->base_for == TV_BASE_COLOR_SPACE && 
+                                                       (c = bam_aux_getCSi(p->b, p->qpos))) {
+                                               c = bam_aux_getCSi(p->b, p->qpos);
+                                               // assume that if we found one color, we will be able to get the color error
+                                               if (tv->is_dot && '-' == bam_aux_getCEi(p->b, p->qpos)) c = bam1_strand(p->b)? ',' : '.';
+                                       }
+                                       else {
+                                               c = bam_nt16_rev_table[bam1_seqi(bam1_seq(p->b), p->qpos)];
+                                               if (tv->is_dot && toupper(c) == toupper(rb)) c = bam1_strand(p->b)? ',' : '.';
+                                       }
                                } else c = '*';
                        } else { // padding
                                if (j > p->indel) c = '*';
                                else { // insertion
-                                       c = bam_nt16_rev_table[bam1_seqi(bam1_seq(p->b), p->qpos + j)];
-                                       if (j == 0 && !tv->is_nucl && toupper(c) == toupper(rb)) c = bam1_strand(p->b)? ',' : '.';
+                                       if (tv->base_for ==  TV_BASE_NUCL) {
+                                               c = bam_nt16_rev_table[bam1_seqi(bam1_seq(p->b), p->qpos + j)];
+                                               if (j == 0 && tv->is_dot && toupper(c) == toupper(rb)) c = bam1_strand(p->b)? ',' : '.';
+                                       }
+                                       else {
+                                               c = bam_aux_getCSi(p->b, p->qpos + j);
+                                               if (tv->is_dot && '-' == bam_aux_getCEi(p->b, p->qpos + j)) c = bam1_strand(p->b)? ',' : '.';
+                                       }
                                }
                        }
                        if (row > TV_MIN_ALNROW && row < tv->mrow) {
                                int x;
                                attr = 0;
                                if (((p->b->core.flag&BAM_FPAIRED) && !(p->b->core.flag&BAM_FPROPER_PAIR))
-                                       || (p->b->core.flag & BAM_FSECONDARY)) attr |= A_UNDERLINE;
+                                               || (p->b->core.flag & BAM_FSECONDARY)) attr |= A_UNDERLINE;
                                if (tv->color_for == TV_COLOR_BASEQ) {
                                        x = bam1_qual(p->b)[p->qpos]/10 + 1;
                                        if (x > 4) x = 4;
@@ -94,6 +115,24 @@ int tv_pl_func(uint32_t tid, uint32_t pos, int n, const bam_pileup1_t *pl, void
                                } else if (tv->color_for == TV_COLOR_NUCL) {
                                        x = bam_nt16_nt4_table[bam1_seqi(bam1_seq(p->b), p->qpos)] + 5;
                                        attr |= COLOR_PAIR(x);
+                               } else if(tv->color_for == TV_COLOR_COL) {
+                                       x = 0;
+                                       switch(bam_aux_getCSi(p->b, p->qpos)) {
+                                               case '0': x = 0; break;
+                                               case '1': x = 1; break;
+                                               case '2': x = 2; break;
+                                               case '3': x = 3; break;
+                                               case '4': x = 4; break;
+                                               default: x = bam_nt16_nt4_table[bam1_seqi(bam1_seq(p->b), p->qpos)]; break;
+                                       }
+                                       x+=5;
+                                       attr |= COLOR_PAIR(x);
+                               } else if(tv->color_for == TV_COLOR_COLQ) {
+                                       x = bam_aux_getCQi(p->b, p->qpos);
+                                       if(0 == x) x = bam1_qual(p->b)[p->qpos];
+                                       x = x/10 + 1;
+                                       if (x > 4) x = 4;
+                                       attr |= COLOR_PAIR(x);
                                }
                                attron(attr);
                                mvaddch(row, tv->ccol, bam1_strand(p->b)? tolower(c) : toupper(c));
@@ -122,20 +161,21 @@ tview_t *tv_init(const char *fn, const char *fn_fa)
        tv->lplbuf = bam_lplbuf_init(tv_pl_func, tv);
        if (fn_fa) tv->fai = fai_load(fn_fa);
        tv->bmc = bam_maqcns_init();
+       tv->ins = 1;
        bam_maqcns_prepare(tv->bmc);
 
        initscr();
        keypad(stdscr, TRUE);
-    clear();
-    noecho();
-    cbreak();
+       clear();
+       noecho();
+       cbreak();
 #ifdef NCURSES_VERSION
        getmaxyx(stdscr, tv->mrow, tv->mcol);
 #else
        tv->mrow = 80; tv->mcol = 40;
 #endif
        tv->wgoto = newwin(3, TV_MAX_GOTO + 10, 10, 5);
-       tv->whelp = newwin(22,40, 5, 5);
+       tv->whelp = newwin(27, 40, 5, 5);
        tv->color_for = TV_COLOR_MAPQ;
        start_color();
        init_pair(1, COLOR_BLUE, COLOR_BLACK);
@@ -200,8 +240,8 @@ static void tv_win_goto(tview_t *tv, int *tid, int *pos)
        char str[256];
        int i, l = 0;
        wborder(tv->wgoto, '|', '|', '-', '-', '+', '+', '+', '+');
-    mvwprintw(tv->wgoto, 1, 2, "Goto: ");
-    for (;;) {
+       mvwprintw(tv->wgoto, 1, 2, "Goto: ");
+       for (;;) {
                int c = wgetch(tv->wgoto);
                wrefresh(tv->wgoto);
                if (c == KEY_BACKSPACE || c == '\010' || c == '\177') {
@@ -220,35 +260,40 @@ static void tv_win_goto(tview_t *tv, int *tid, int *pos)
                str[l] = '\0';
                for (i = 0; i < TV_MAX_GOTO; ++i) mvwaddch(tv->wgoto, 1, 8 + i, ' ');
                mvwprintw(tv->wgoto, 1, 8, "%s", str);
-    }
+       }
 }
 
 static void tv_win_help(tview_t *tv) {
-    int r = 1;
+       int r = 1;
        WINDOW *win = tv->whelp;
-    wborder(win, '|', '|', '-', '-', '+', '+', '+', '+');
-    mvwprintw(win, r++, 2, "        -=-    Help    -=- ");
-    r++;
-    mvwprintw(win, r++, 2, "?          This window");
-    mvwprintw(win, r++, 2, "Arrows     Small scroll movement");
-    mvwprintw(win, r++, 2, "h,j,k,l    Small scroll movement");
-    mvwprintw(win, r++, 2, "H,J,K,L    Large scroll movement");
-    mvwprintw(win, r++, 2, "ctrl-H     Scroll 1k left");
-    mvwprintw(win, r++, 2, "ctrl-L     Scroll 1k right");
-    mvwprintw(win, r++, 2, "space      Scroll one screen");
-    mvwprintw(win, r++, 2, "backspace  Scroll back one screen");
-    mvwprintw(win, r++, 2, "g          Go to specific location");
-    mvwprintw(win, r++, 2, "b          Color for base quality");
-    mvwprintw(win, r++, 2, "m          Color for mapping qual");
-    mvwprintw(win, r++, 2, "n          Color for nucleotide");
-    mvwprintw(win, r++, 2, ".          Toggle on/off dot view");
-    mvwprintw(win, r++, 2, "q          Exit");
+       wborder(win, '|', '|', '-', '-', '+', '+', '+', '+');
+       mvwprintw(win, r++, 2, "        -=-    Help    -=- ");
+       r++;
+       mvwprintw(win, r++, 2, "?          This window");
+       mvwprintw(win, r++, 2, "Arrows     Small scroll movement");
+       mvwprintw(win, r++, 2, "h,j,k,l    Small scroll movement");
+       mvwprintw(win, r++, 2, "H,J,K,L    Large scroll movement");
+       mvwprintw(win, r++, 2, "ctrl-H     Scroll 1k left");
+       mvwprintw(win, r++, 2, "ctrl-L     Scroll 1k right");
+       mvwprintw(win, r++, 2, "space      Scroll one screen");
+       mvwprintw(win, r++, 2, "backspace  Scroll back one screen");
+       mvwprintw(win, r++, 2, "g          Go to specific location");
+       mvwprintw(win, r++, 2, "m          Color for mapping qual");
+       mvwprintw(win, r++, 2, "n          Color for nucleotide");
+       mvwprintw(win, r++, 2, "b          Color for base quality");
+       mvwprintw(win, r++, 2, "c          Color for cs color");
+       mvwprintw(win, r++, 2, "z          Color for cs qual");
+       mvwprintw(win, r++, 2, ".          Toggle on/off dot view");
+       mvwprintw(win, r++, 2, "N          Turn on nt view");
+       mvwprintw(win, r++, 2, "C          Turn on cs view");
+       mvwprintw(win, r++, 2, "i          Toggle on/off ins");
+       mvwprintw(win, r++, 2, "q          Exit");
        r++;
        mvwprintw(win, r++, 2, "Underline:      Secondary or orphan");
        mvwprintw(win, r++, 2, "Blue:    0-9    Green: 10-19");
        mvwprintw(win, r++, 2, "Yellow: 20-29   White: >=30");
-    wrefresh(win);
-    wgetch(win);
+       wrefresh(win);
+       wgetch(win);
 }
 
 void tv_loop(tview_t *tv)
@@ -259,35 +304,40 @@ void tv_loop(tview_t *tv)
                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 
                switch (c) {
-               case '?': tv_win_help(tv); break;
-               case '\033':
-               case 'q': goto end_loop;
-               case 'g': tv_win_goto(tv, &tid, &pos); break;
-               case 'b': tv->color_for = TV_COLOR_BASEQ; break;
-               case 'm': tv->color_for = TV_COLOR_MAPQ; break;
-               case 'n': tv->color_for = TV_COLOR_NUCL; break;
-               case KEY_LEFT:
-               case 'h': --pos; break;
-               case KEY_RIGHT:
-               case 'l': ++pos; break;
-               case KEY_SLEFT:
-               case 'H': pos -= 20; break;
-               case KEY_SRIGHT:
-               case 'L': pos += 20; break;
-               case '.': tv->is_nucl = !tv->is_nucl; break;
-               case '\010': pos -= 1000; break;
-               case '\014': pos += 1000; break;
-               case ' ': pos += tv->mcol; break;
-               case KEY_UP:
-               case 'j': --tv->row_shift; break;
-               case KEY_DOWN:
-               case 'k': ++tv->row_shift; break;
-               case KEY_BACKSPACE:
-               case '\177': pos -= tv->mcol; break;
+                       case '?': tv_win_help(tv); break;
+                       case '\033':
+                       case 'q': goto end_loop;
+                       case 'g': tv_win_goto(tv, &tid, &pos); break;
+                       case 'm': tv->color_for = TV_COLOR_MAPQ; break;
+                       case 'b': tv->color_for = TV_COLOR_BASEQ; break;
+                       case 'n': tv->color_for = TV_COLOR_NUCL; break;
+                       case 'c': tv->color_for = TV_COLOR_COL; break;
+                       case 'z': tv->color_for = TV_COLOR_COLQ; break;
+                       case KEY_LEFT:
+                       case 'h': --pos; break;
+                       case KEY_RIGHT:
+                       case 'l': ++pos; break;
+                       case KEY_SLEFT:
+                       case 'H': pos -= 20; break;
+                       case KEY_SRIGHT:
+                       case 'L': pos += 20; break;
+                       case '.': tv->is_dot = !tv->is_dot; break;
+                       case 'N': tv->base_for = TV_BASE_NUCL; break;
+                       case 'C': tv->base_for = TV_BASE_COLOR_SPACE; break;
+                       case 'i': tv->ins = !tv->ins; break;
+                       case '\010': pos -= 1000; break;
+                       case '\014': pos += 1000; break;
+                       case ' ': pos += tv->mcol; break;
+                       case KEY_UP:
+                       case 'j': --tv->row_shift; break;
+                       case KEY_DOWN:
+                       case 'k': ++tv->row_shift; break;
+                       case KEY_BACKSPACE:
+                       case '\177': pos -= tv->mcol; break;
 #ifdef KEY_RESIZE
-               case KEY_RESIZE: getmaxyx(stdscr, tv->mrow, tv->mcol); break;
+                       case KEY_RESIZE: getmaxyx(stdscr, tv->mrow, tv->mcol); break;
 #endif
-               default: continue;
+                       default: continue;
                }
                if (pos < 0) pos = 0;
                if (tv->row_shift < 0) tv->row_shift = 0;
diff --git a/bamtk.c b/bamtk.c
index aed8a39dd401fb1ff0d1cd25f7ebda37823f06c1..ab39e9db2a2febc07525ddb34fd45bcbe827668b 100644 (file)
--- a/bamtk.c
+++ b/bamtk.c
@@ -3,7 +3,7 @@
 #include "bam.h"
 
 #ifndef PACKAGE_VERSION
-#define PACKAGE_VERSION "0.1.3-6 (r244)"
+#define PACKAGE_VERSION "0.1.3-7 (r246)"
 #endif
 
 int bam_taf2baf(int argc, char *argv[]);
diff --git a/cleanup.sh b/cleanup.sh
new file mode 100644 (file)
index 0000000..96381e6
--- /dev/null
@@ -0,0 +1,12 @@
+if [ -f "Makefile" ]; then
+       make distclean
+fi
+rm -fr *~ .in .gdb_history Makefile.in aclocal.m4 configure autom4*.cache config.guess config.h.in config.sub depcomp install-sh missing mkinstalldirs
+if [ -f "Makefile" ]; then
+       make distclean
+fi
+rm -fr *~ .in .gdb_history Makefile.in aclocal.m4 configure autom4*.cache config.guess config.h.in config.sub depcomp install-sh missing mkinstalldirs
+if [ -f "Makefile" ]; then
+       make distclean
+fi
+rm -fr *~ .in .gdb_history Makefile.in aclocal.m4 configure autom4*.cache config.guess config.h.in config.sub depcomp install-sh missing mkinstalldirs
diff --git a/configure.ac b/configure.ac
new file mode 100644 (file)
index 0000000..7bd8696
--- /dev/null
@@ -0,0 +1,108 @@
+AC_INIT(SAMTOOLS, 0.1.3)
+AM_CONFIG_HEADER(config.h)
+AM_INIT_AUTOMAKE([no-dependencies])
+AC_CANONICAL_HOST
+
+AC_PROG_INSTALL
+
+AC_PROG_CC
+AC_PROG_CXX
+
+# set CFLAGS and CXXFLAGS
+user_CFLAGS="${CFLAGS} -D_IOLIB=2 -D_FILE_OFFSET_BITS=64"
+generic_CFLAGS="-Wall -L."
+
+AC_ARG_ENABLE(norazf, [  --disable-razf          disable razf support],
+                         [user_DFLAGS="${user_DFLAGS} -D_NO_RAZF"], [])
+AC_ARG_ENABLE(nocurses, [  --disable-curses      disable curses support],
+                         [user_DFLAGS="${user_DFLAGS} -D_NO_CURSES"], [])
+CFLAGS="${generic_CFLAGS} ${user_CFLAGS}"
+CXXFLAGS=$CFLAGS
+
+AC_STDC_HEADERS
+AC_CHECK_FUNCS([bzero memset pow sqrt strcasecmp strdup strstr strtol])
+AC_CHECK_HEADERS([zlib.h fcntl.h malloc.h stddef.h])
+AC_CHECK_TYPES([ptrdiff_t])
+AC_C_CONST
+AC_C_INLINE
+AC_FUNC_FSEEKO
+AC_FUNC_MALLOC
+AC_FUNC_MEMCMP
+AC_FUNC_REALLOC
+AC_HEADER_STDBOOL
+AC_TYPE_OFF_T
+AC_TYPE_SIZE_T
+
+AC_OUTPUT([Makefile misc/Makefile])
+AC_INIT(SAMTOOLS, 0.1.3)
+AM_CONFIG_HEADER(config.h)
+AM_INIT_AUTOMAKE([no-dependencies])
+AC_CANONICAL_HOST
+
+AC_PROG_INSTALL
+
+AC_PROG_CC
+AC_PROG_CXX
+
+# set CFLAGS and CXXFLAGS
+user_CFLAGS="${CFLAGS} -D_IOLIB=2 -D_FILE_OFFSET_BITS=64"
+generic_CFLAGS="-Wall -L."
+
+AC_ARG_ENABLE(norazf, [  --disable-razf          disable razf support],
+                         [user_DFLAGS="${user_DFLAGS} -D_NO_RAZF"], [])
+AC_ARG_ENABLE(nocurses, [  --disable-curses      disable curses support],
+                         [user_DFLAGS="${user_DFLAGS} -D_NO_CURSES"], [])
+CFLAGS="${generic_CFLAGS} ${user_CFLAGS}"
+CXXFLAGS=$CFLAGS
+
+AC_STDC_HEADERS
+AC_CHECK_FUNCS([bzero memset pow sqrt strcasecmp strdup strstr strtol])
+AC_CHECK_HEADERS([zlib.h fcntl.h malloc.h stddef.h])
+AC_CHECK_TYPES([ptrdiff_t])
+AC_C_CONST
+AC_C_INLINE
+AC_FUNC_FSEEKO
+AC_FUNC_MALLOC
+AC_FUNC_MEMCMP
+AC_FUNC_REALLOC
+AC_HEADER_STDBOOL
+AC_TYPE_OFF_T
+AC_TYPE_SIZE_T
+
+AC_OUTPUT([Makefile misc/Makefile])
+AC_INIT(SAMTOOLS, 0.1.3)
+AM_CONFIG_HEADER(config.h)
+AM_INIT_AUTOMAKE([no-dependencies])
+AC_CANONICAL_HOST
+
+AC_PROG_INSTALL
+
+AC_PROG_CC
+AC_PROG_CXX
+
+# set CFLAGS and CXXFLAGS
+user_CFLAGS="${CFLAGS} -D_IOLIB=2 -D_FILE_OFFSET_BITS=64"
+generic_CFLAGS="-Wall -L."
+
+AC_ARG_ENABLE(norazf, [  --disable-razf          disable razf support],
+                         [user_DFLAGS="${user_DFLAGS} -D_NO_RAZF"], [])
+AC_ARG_ENABLE(nocurses, [  --disable-curses      disable curses support],
+                         [user_DFLAGS="${user_DFLAGS} -D_NO_CURSES"], [])
+CFLAGS="${generic_CFLAGS} ${user_CFLAGS}"
+CXXFLAGS=$CFLAGS
+
+AC_STDC_HEADERS
+AC_CHECK_FUNCS([bzero memset pow sqrt strcasecmp strdup strstr strtol])
+AC_CHECK_HEADERS([zlib.h fcntl.h malloc.h stddef.h])
+AC_CHECK_TYPES([ptrdiff_t])
+AC_C_CONST
+AC_C_INLINE
+AC_FUNC_FSEEKO
+AC_FUNC_MALLOC
+AC_FUNC_MEMCMP
+AC_FUNC_REALLOC
+AC_HEADER_STDBOOL
+AC_TYPE_OFF_T
+AC_TYPE_SIZE_T
+
+AC_OUTPUT([Makefile misc/Makefile])
diff --git a/misc/Makefile b/misc/Makefile
deleted file mode 100644 (file)
index 0f65881..0000000
+++ /dev/null
@@ -1,58 +0,0 @@
-CC=                    gcc
-CXX=           g++
-CFLAGS=                -g -Wall -O2 -m64 #-arch ppc
-CXXFLAGS=      $(CFLAGS)
-DFLAGS=                #-D_FILE_OFFSET_BITS=64
-OBJS=          
-PROG=          faidx md5sum-lite md5fa maq2sam-short maq2sam-long wgsim
-INCLUDES=      -I..
-LIBS=          -lm -lz
-SUBDIRS=       .
-
-.SUFFIXES:.c .o
-
-.c.o:
-               $(CC) -c $(CFLAGS) $(DFLAGS) $(INCLUDES) $< -o $@
-
-all:$(PROG)
-
-lib-recur all-recur clean-recur cleanlocal-recur install-recur:
-               @target=`echo $@ | sed s/-recur//`; \
-               wdir=`pwd`; \
-               list='$(SUBDIRS)'; for subdir in $$list; do \
-                       cd $$subdir; \
-                       $(MAKE) CC="$(CC)" CXX="$(CXX)" DFLAGS="$(DFLAGS)" CFLAGS="$(CFLAGS)" \
-                               INCLUDES="$(INCLUDES)" $$target || exit 1; \
-                       cd $$wdir; \
-               done;
-
-lib:
-
-wgsim:wgsim.o
-               $(CC) $(CFLAGS) -o $@ wgsim.o -lm
-
-faidx:../faidx.c ../faidx.h
-               $(CC) $(CFLAGS) -D_NO_RAZF -DFAIDX_MAIN -o $@ ../faidx.c
-
-md5fa:md5.o md5fa.o md5.h ../kseq.h
-               $(CC) $(CFLAGS) -o $@ md5.o md5fa.o -lz
-
-md5sum-lite:md5sum-lite.o
-               $(CC) $(CFLAGS) -o $@ md5sum-lite.o
-
-md5sum-lite.o:md5.c md5.h
-               $(CC) -c $(CFLAGS) -DMD5SUM_MAIN -o $@ md5.c
-
-maq2sam-short:maq2sam.c
-               $(CC) $(CFLAGS) -o $@ maq2sam.c -lz
-
-maq2sam-long:maq2sam.c
-               $(CC) $(CFLAGS) -DMAQ_LONGREADS -o $@ maq2sam.c -lz
-
-md5fa.o:md5.h md5fa.c
-               $(CC) $(CFLAGS) -c -I.. -o $@ md5fa.c
-
-cleanlocal:
-               rm -fr gmon.out *.o a.out *.dSYM $(PROG) *~ *.a
-
-clean:cleanlocal-recur
diff --git a/misc/Makefile.generic b/misc/Makefile.generic
new file mode 100644 (file)
index 0000000..0f65881
--- /dev/null
@@ -0,0 +1,58 @@
+CC=                    gcc
+CXX=           g++
+CFLAGS=                -g -Wall -O2 -m64 #-arch ppc
+CXXFLAGS=      $(CFLAGS)
+DFLAGS=                #-D_FILE_OFFSET_BITS=64
+OBJS=          
+PROG=          faidx md5sum-lite md5fa maq2sam-short maq2sam-long wgsim
+INCLUDES=      -I..
+LIBS=          -lm -lz
+SUBDIRS=       .
+
+.SUFFIXES:.c .o
+
+.c.o:
+               $(CC) -c $(CFLAGS) $(DFLAGS) $(INCLUDES) $< -o $@
+
+all:$(PROG)
+
+lib-recur all-recur clean-recur cleanlocal-recur install-recur:
+               @target=`echo $@ | sed s/-recur//`; \
+               wdir=`pwd`; \
+               list='$(SUBDIRS)'; for subdir in $$list; do \
+                       cd $$subdir; \
+                       $(MAKE) CC="$(CC)" CXX="$(CXX)" DFLAGS="$(DFLAGS)" CFLAGS="$(CFLAGS)" \
+                               INCLUDES="$(INCLUDES)" $$target || exit 1; \
+                       cd $$wdir; \
+               done;
+
+lib:
+
+wgsim:wgsim.o
+               $(CC) $(CFLAGS) -o $@ wgsim.o -lm
+
+faidx:../faidx.c ../faidx.h
+               $(CC) $(CFLAGS) -D_NO_RAZF -DFAIDX_MAIN -o $@ ../faidx.c
+
+md5fa:md5.o md5fa.o md5.h ../kseq.h
+               $(CC) $(CFLAGS) -o $@ md5.o md5fa.o -lz
+
+md5sum-lite:md5sum-lite.o
+               $(CC) $(CFLAGS) -o $@ md5sum-lite.o
+
+md5sum-lite.o:md5.c md5.h
+               $(CC) -c $(CFLAGS) -DMD5SUM_MAIN -o $@ md5.c
+
+maq2sam-short:maq2sam.c
+               $(CC) $(CFLAGS) -o $@ maq2sam.c -lz
+
+maq2sam-long:maq2sam.c
+               $(CC) $(CFLAGS) -DMAQ_LONGREADS -o $@ maq2sam.c -lz
+
+md5fa.o:md5.h md5fa.c
+               $(CC) $(CFLAGS) -c -I.. -o $@ md5fa.c
+
+cleanlocal:
+               rm -fr gmon.out *.o a.out *.dSYM $(PROG) *~ *.a
+
+clean:cleanlocal-recur