From e981067aab5f47c7b273f07b69adb1797220dda2 Mon Sep 17 00:00:00 2001 From: Heng Li Date: Tue, 3 Mar 2009 11:24:16 +0000 Subject: [PATCH] * samtools-0.1.2-12 * optionally print SAM header --- ChangeLog | 76 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ bamtk.c | 20 ++++++++++++--- 2 files changed, 92 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index 887cc60..8f0ba4d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,79 @@ +------------------------------------------------------------------------ +r153 | lh3lh3 | 2009-03-02 10:45:28 +0000 (Mon, 02 Mar 2009) | 3 lines +Changed paths: + M /trunk/samtools/bamtk.c + M /trunk/samtools/glf.c + + * samtools-0.1.2-11 + * use "GLF\3" as the magic for GLFv3 files + +------------------------------------------------------------------------ +r152 | lh3lh3 | 2009-03-02 10:39:09 +0000 (Mon, 02 Mar 2009) | 5 lines +Changed paths: + M /trunk/samtools/Makefile + M /trunk/samtools/bam_import.c + M /trunk/samtools/bam_index.c + M /trunk/samtools/bam_plcmd.c + M /trunk/samtools/bamtk.c + M /trunk/samtools/glf.c + M /trunk/samtools/glf.h + + * samtools-0.1.2-10 + * fixed a bug in import: core.bin is undefined for unmapped reads + * this bug can be alleviated (not completely solved) in bam_index.c + * update to GLFv3: pos is changed to offset for better compression + +------------------------------------------------------------------------ +r151 | lh3lh3 | 2009-03-01 15:18:43 +0000 (Sun, 01 Mar 2009) | 3 lines +Changed paths: + M /trunk/samtools/misc/wgsim.c + + * wgsim-0.2.3 + * fixed a bug in simulating indels + +------------------------------------------------------------------------ +r145 | lh3lh3 | 2009-02-26 19:43:57 +0000 (Thu, 26 Feb 2009) | 4 lines +Changed paths: + M /trunk/samtools/misc/wgsim.c + + * wgsim-0.2.2 + * allow to print mismatch information as fastq comment. MAQ does + not like long read names. + +------------------------------------------------------------------------ +r141 | lh3lh3 | 2009-02-26 14:53:03 +0000 (Thu, 26 Feb 2009) | 6 lines +Changed paths: + M /trunk/samtools/ChangeLog + M /trunk/samtools/misc/wgsim.c + M /trunk/samtools/misc/wgsim_eval.pl + + * wgsim-0.2.1 + * fixed a bug about color read coordinates + * fixed a bug in read names + * wgsim_eval.pl-0.1.3 + * make the script work with color reads + +------------------------------------------------------------------------ +r140 | lh3lh3 | 2009-02-26 14:02:57 +0000 (Thu, 26 Feb 2009) | 2 lines +Changed paths: + M /trunk/samtools/misc/Makefile + M /trunk/samtools/misc/wgsim.c + + * wgsim: added a note + +------------------------------------------------------------------------ +r139 | lh3lh3 | 2009-02-26 11:39:08 +0000 (Thu, 26 Feb 2009) | 7 lines +Changed paths: + M /trunk/samtools/misc/wgsim.c + M /trunk/samtools/misc/wgsim_eval.pl + + * wgsim-0.2.0 + * considerable code clean up + * print number of substitutions/indels/errors on each read + * potentially support SOLiD simulation, though not tested at the moment + * wgsim_eval.pl-0.1.2 + * change in accordant with wgsim + ------------------------------------------------------------------------ r129 | lh3lh3 | 2009-02-18 22:23:27 +0000 (Wed, 18 Feb 2009) | 3 lines Changed paths: diff --git a/bamtk.c b/bamtk.c index dc1805c..b55415e 100644 --- a/bamtk.c +++ b/bamtk.c @@ -3,7 +3,7 @@ #include "bam.h" #ifndef PACKAGE_VERSION -#define PACKAGE_VERSION "0.1.2-11" +#define PACKAGE_VERSION "0.1.2-12" #endif int bam_taf2baf(int argc, char *argv[]); @@ -35,15 +35,17 @@ int bam_view(int argc, char *argv[]) bamFile fp, fpout = 0; bam_header_t *header; bam1_t *b; - int ret, c, is_bam = 0; - while ((c = getopt(argc, argv, "b")) >= 0) { + int ret, c, is_bam = 0, is_header = 0, is_headeronly = 0; + while ((c = getopt(argc, argv, "bhH")) >= 0) { switch (c) { case 'b': is_bam = 1; break; + case 'h': is_header = 1; break; + case 'H': is_headeronly = 1; break; default: fprintf(stderr, "Unrecognized option: -%c\n", c); return 1; } } if (argc == optind) { - fprintf(stderr, "Usage: samtools view [-b] [ [...]]\n"); + fprintf(stderr, "Usage: samtools view [-bhH] [ [...]]\n"); return 1; } fp = strcmp(argv[optind], "-")? bam_open(argv[optind], "r") : bam_dopen(fileno(stdin), "r"); @@ -53,6 +55,16 @@ int bam_view(int argc, char *argv[]) assert(fpout = bam_dopen(fileno(stdout), "w")); bam_header_write(fpout, header); } + if (is_header || is_headeronly) { + int i; + for (i = 0; i < header->n_targets; ++i) + printf("@SQ\tSN:%s\tLN:%d\n", header->target_name[i], header->target_len[i]); + if (is_headeronly) { + bam_header_destroy(header); + bam_close(fp); + return 0; + } + } if (optind + 1 == argc) { b = (bam1_t*)calloc(1, sizeof(bam1_t)); while ((ret = bam_read1(fp, b)) >= 0) bam_view1(header, b); -- 2.39.2