- if (argc == 1) {
- fprintf(stderr, "Usage: bamtk tview <aln.bam> [ref.fasta]\n");
- return 1;
- }
- tv = tv_init(argv[1], (argc == 2)? 0 : argv[2]);
- tv_draw_aln(tv, 0, 0);
+ char *samples=NULL, *position=NULL;
+ int c;
+ 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);
+ 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);