Skip to content

Commit

Permalink
* samtools-0.1.2-24
Browse files Browse the repository at this point in the history
 * in merge, gives a warning rather than error if the target sequence length is different
 * allow empty header
  • Loading branch information
Heng Li committed Apr 12, 2009
1 parent 3c65ee9 commit 8cc87ac
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 7 deletions.
1 change: 0 additions & 1 deletion bam.c
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,6 @@ bam_header_t *bam_header_read(bamFile fp)
bam_read(fp, header->text, header->l_text);
bam_read(fp, &header->n_targets, 4);
if (bam_is_be) bam_swap_endian_4p(&header->n_targets);
assert(header->n_targets > 0);
// read reference sequence names and lengths
header->target_name = (char**)calloc(header->n_targets, sizeof(char*));
header->target_len = (uint32_t*)calloc(header->n_targets, 4);
Expand Down
2 changes: 1 addition & 1 deletion bam_import.c
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ bam_header_t *sam_header_read2(const char *fn)
assert(fp);
ks = ks_init(fp);
str = (kstring_t*)calloc(1, sizeof(kstring_t));
while (ks_getuntil(ks, 0, str, &dret) >= 0) {
while (ks_getuntil(ks, 0, str, &dret) > 0) {
char *s = strdup(str->s);
int len, i;
i = kh_size(hash);
Expand Down
12 changes: 8 additions & 4 deletions bam_sort.c
Original file line number Diff line number Diff line change
Expand Up @@ -66,13 +66,17 @@ void bam_merge_core(int by_qname, const char *out, int n, char * const *fn)
else { // validate multiple baf
if (hout->n_targets != hin->n_targets) {
fprintf(stderr, "[bam_merge_core] file '%s' has different number of target sequences. Abort!\n", fn[i]);
abort();
exit(1);
}
for (j = 0; j < hout->n_targets; ++j) {
if (strcmp(hout->target_name[j], hin->target_name[j]) || hout->target_len[j] != hin->target_len[j]) {
fprintf(stderr, "[bam_merge_core] file '%s' has a different target sequence. Abort!\n", fn[i]);
abort();
if (strcmp(hout->target_name[j], hin->target_name[j])) {
fprintf(stderr, "[bam_merge_core] different target sequence name: '%s' != '%s' in file '%s'. Abort!\n",
hout->target_name[j], hin->target_name[j], fn[i]);
exit(1);
}
if (hout->target_len[j] != hin->target_len[j])
fprintf(stderr, "[bam_merge_core] different target sequence length: %d != %d in file '%s'. Continue.\n",
hout->target_len[j], hin->target_len[j], fn[i]);
}
bam_header_destroy(hin);
}
Expand Down
2 changes: 1 addition & 1 deletion bamtk.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#include "bam.h"

#ifndef PACKAGE_VERSION
#define PACKAGE_VERSION "0.1.2-23"
#define PACKAGE_VERSION "0.1.2-24"
#endif

int bam_taf2baf(int argc, char *argv[]);
Expand Down
4 changes: 4 additions & 0 deletions kseq.h
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,10 @@ typedef struct __kstring_t {
break; \
} \
} \
if (str->l == 0) { \
str->m = 1; \
str->s = (char*)calloc(1, 1); \
} \
str->s[str->l] = '\0'; \
return str->l; \
}
Expand Down

0 comments on commit 8cc87ac

Please sign in to comment.