From: Heng Li Date: Fri, 17 Jul 2009 14:29:21 +0000 (+0000) Subject: * samtools-0.1.5-11 (r408) X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=030a404097c6f8b094eca03a8380b35ff81e6c70;p=samtools.git * samtools-0.1.5-11 (r408) * force to overwirte existing MD if it is different from the one calculated from fillmd. * bgzf.c: improved the compatibility with Windows headers --- diff --git a/bam_md.c b/bam_md.c index 45bb1db..ead2346 100644 --- a/bam_md.c +++ b/bam_md.c @@ -59,7 +59,7 @@ void bam_fillmd1(bam1_t *b, char *ref, int is_equal) ksprintf(str, "%d", u); if (!old_nm) bam_aux_append(b, "NM", 'i', 4, (uint8_t*)&nm); else if (nm != old_nm_i) { - fprintf(stderr, "[bam_fillmd1] different NM for read '%s': %d != %d\n", bam1_qname(b), old_nm_i, nm); + fprintf(stderr, "[bam_fillmd1] different NM for read '%s': %d -> %d\n", bam1_qname(b), old_nm_i, nm); bam_aux_del(b, old_nm); bam_aux_append(b, "NM", 'i', 4, (uint8_t*)&nm); } @@ -72,8 +72,11 @@ void bam_fillmd1(bam1_t *b, char *ref, int is_equal) break; if (i < str->l) is_diff = 1; } else is_diff = 1; - if (is_diff) - fprintf(stderr, "[bam_fillmd1] different MD for read '%s': '%s' != '%s'\n", bam1_qname(b), old_md+1, str->s); + if (is_diff) { + fprintf(stderr, "[bam_fillmd1] different MD for read '%s': '%s' -> '%s'\n", bam1_qname(b), old_md+1, str->s); + bam_aux_del(b, old_md); + bam_aux_append(b, "MD", 'Z', str->l + 1, (uint8_t*)str->s); + } } free(str->s); free(str); } diff --git a/bam_tview.c b/bam_tview.c index c6a31cd..441a1b4 100644 --- a/bam_tview.c +++ b/bam_tview.c @@ -384,8 +384,9 @@ 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." +#else // #ifdef _HAVE_CURSES +#include +#warning "No curses library is available; 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"); diff --git a/bamtk.c b/bamtk.c index f162bc3..bbdf82c 100644 --- a/bamtk.c +++ b/bamtk.c @@ -4,7 +4,7 @@ #include "bam.h" #ifndef PACKAGE_VERSION -#define PACKAGE_VERSION "0.1.5-10 (r407)" +#define PACKAGE_VERSION "0.1.5-11 (r408)" #endif int bam_taf2baf(int argc, char *argv[]); @@ -85,7 +85,7 @@ static int usage() fprintf(stderr, " rmdup remove PCR duplicates\n"); fprintf(stderr, " glfview print GLFv3 file\n"); fprintf(stderr, " flagstat simple stats\n"); - fprintf(stderr, " fillmd fill the MD/NM tag and generate '=' bases\n"); + fprintf(stderr, " fillmd recalculate MD/NM tags and '=' bases\n"); fprintf(stderr, "\n"); return 1; } diff --git a/bgzf.c b/bgzf.c index 364ca64..71d8c81 100644 --- a/bgzf.c +++ b/bgzf.c @@ -39,7 +39,7 @@ extern off_t ftello(FILE *stream); extern int fseeko(FILE *stream, off_t offset, int whence); #endif -typedef int8_t byte; +typedef int8_t bgzf_byte_t; static const int DEFAULT_BLOCK_SIZE = 64 * 1024; static const int MAX_BLOCK_SIZE = 64 * 1024; @@ -86,9 +86,9 @@ packInt32(uint8_t* buffer, uint32_t value) buffer[3] = value >> 24; } -inline +static inline int -min(int x, int y) +bgzf_min(int x, int y) { return (x < y) ? x : y; } @@ -211,7 +211,7 @@ deflate_block(BGZF* fp, int block_length) // Deflate the block in fp->uncompressed_block into fp->compressed_block. // Also adds an extra field that stores the compressed block length. - byte* buffer = fp->compressed_block; + bgzf_byte_t* buffer = fp->compressed_block; int buffer_size = fp->compressed_block_size; // Init gzip header @@ -342,10 +342,10 @@ inflate_block(BGZF* fp, int block_length) static int -check_header(const byte* header) +check_header(const bgzf_byte_t* header) { return (header[0] == GZIP_ID1 && - header[1] == (byte) GZIP_ID2 && + header[1] == (bgzf_byte_t) GZIP_ID2 && header[2] == Z_DEFLATED && (header[3] & FLG_FEXTRA) != 0 && unpackInt16((uint8_t*)&header[10]) == BGZF_XLEN && @@ -415,7 +415,7 @@ static int read_block(BGZF* fp) { - byte header[BLOCK_HEADER_LENGTH]; + bgzf_byte_t header[BLOCK_HEADER_LENGTH]; int size = 0; #ifdef _USE_KNETFILE int64_t block_address = knet_tell(fp->x.fpr); @@ -440,7 +440,7 @@ read_block(BGZF* fp) return -1; } int block_length = unpackInt16((uint8_t*)&header[16]) + 1; - byte* compressed_block = (byte*) fp->compressed_block; + bgzf_byte_t* compressed_block = (bgzf_byte_t*) fp->compressed_block; memcpy(compressed_block, header, BLOCK_HEADER_LENGTH); int remaining = block_length - BLOCK_HEADER_LENGTH; #ifdef _USE_KNETFILE @@ -479,7 +479,7 @@ bgzf_read(BGZF* fp, void* data, int length) } int bytes_read = 0; - byte* output = data; + bgzf_byte_t* output = data; while (bytes_read < length) { int available = fp->block_length - fp->block_offset; if (available <= 0) { @@ -491,8 +491,8 @@ bgzf_read(BGZF* fp, void* data, int length) break; } } - int copy_length = min(length-bytes_read, available); - byte* buffer = fp->uncompressed_block; + int copy_length = bgzf_min(length-bytes_read, available); + bgzf_byte_t* buffer = fp->uncompressed_block; memcpy(output, buffer + fp->block_offset, copy_length); fp->block_offset += copy_length; output += copy_length; @@ -545,12 +545,12 @@ bgzf_write(BGZF* fp, const void* data, int length) fp->uncompressed_block = malloc(fp->uncompressed_block_size); } - const byte* input = data; + const bgzf_byte_t* input = data; int block_length = fp->uncompressed_block_size; int bytes_written = 0; while (bytes_written < length) { - int copy_length = min(block_length - fp->block_offset, length - bytes_written); - byte* buffer = fp->uncompressed_block; + int copy_length = bgzf_min(block_length - fp->block_offset, length - bytes_written); + bgzf_byte_t* buffer = fp->uncompressed_block; memcpy(buffer + fp->block_offset, input, copy_length); fp->block_offset += copy_length; input += copy_length;