<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
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 \
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
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 {
{
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;
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));
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));
}
free(rgid->s); free(rgid);
free(rglib->s); free(rglib);
+ if (n == 0) {
+ bam_strmap_destroy(h->rg2lib);
+ h->rg2lib = 0;
+ }
return n;
}
#ifndef _NO_CURSES
#include <curses.h>
+#ifdef NCURSES_VERSION
#include <ctype.h>
#include <assert.h>
#include <string.h>
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':
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
#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[]);
* 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
int hcrc;
int done;
};
+#warning "zlib < 1.2.2.1; RAZF writing is disabled."
#endif
#define DEF_MEM_LEVEL 8
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;