]> git.donarmstrong.com Git - samtools.git/commitdiff
Merge branch 'master' of github.com:samtools/samtools
authorPetr Danecek <pd3@sanger.ac.uk>
Thu, 21 Jun 2012 07:56:39 +0000 (08:56 +0100)
committerPetr Danecek <pd3@sanger.ac.uk>
Thu, 21 Jun 2012 07:56:39 +0000 (08:56 +0100)
1  2 
bam_tview.c

diff --combined bam_tview.c
index bba732d394c26db679c334db80a69c3d1b5f59dc,20e6f466dfdf9ab0a2ba444e4181a20115b0632e..1967b7c7c99f8e70400c4989a925a464dc4fa7e9
@@@ -20,6 -20,7 +20,7 @@@
  #include <assert.h>
  #include <string.h>
  #include <math.h>
+ #include <unistd.h>
  #include "bam.h"
  #include "faidx.h"
  #include "bam2bcf.h"
@@@ -440,8 -441,7 +441,8 @@@ void error(const char *format, ...
          fprintf(stderr, "\n");
          fprintf(stderr, "Usage: bamtk tview [options] <aln.bam> [ref.fasta]\n");
          fprintf(stderr, "Options:\n");
 -        fprintf(stderr, "   -s STR      display only reads from this sample\n");
 +        fprintf(stderr, "   -p chr:pos      go directly to this position\n");
 +        fprintf(stderr, "   -s STR          display only reads from this sample\n");
          fprintf(stderr, "\n\n");
      }
      else
  int bam_tview_main(int argc, char *argv[])
  {
        tview_t *tv;
 -    char *samples=NULL;
 +    char *samples=NULL, *position=NULL;
      int c;
 -    while ((c = getopt(argc, argv, "s:")) >= 0) {
 +    while ((c = getopt(argc, argv, "s:p:")) >= 0) {
          switch (c) {
              case 's': samples=optarg; break;
 +            case 'p': position=optarg; break;
              default: error(NULL);
          }
      }
        if (argc==optind) error(NULL);
        tv = tv_init(argv[optind], (optind+1>=argc)? 0 : argv[optind+1], samples);
 -      tv_draw_aln(tv, 0, 0);
 +    if ( position )
 +    {
 +        int _tid = -1, _beg, _end;
 +        bam_parse_region(tv->header, position, &_tid, &_beg, &_end);
 +        if (_tid >= 0) { tv->curr_tid = _tid; tv->left_pos = _beg; }
 +    }
 +      tv_draw_aln(tv, tv->curr_tid, tv->left_pos);
        tv_loop(tv);
        tv_destroy(tv);
        return 0;