]> git.donarmstrong.com Git - samtools.git/commitdiff
* samtools-0.1.5-18 (r423)
authorHeng Li <lh3@live.co.uk>
Fri, 31 Jul 2009 09:19:59 +0000 (09:19 +0000)
committerHeng Li <lh3@live.co.uk>
Fri, 31 Jul 2009 09:19:59 +0000 (09:19 +0000)
 * output additional information in pileup indel lines, for the purepose
   of debugging at the moment
 * in tview, optionally allow to treat reference skip as deletion

bam_maqcns.c
bam_maqcns.h
bam_plcmd.c
bam_tview.c
bamtk.c
misc/samtools.pl

index 464288ae7da0ac74f1443bbb55c03684927cb391..f36b0ee2ab443affe0635866a8d593c5cb54fdf7 100644 (file)
@@ -439,7 +439,7 @@ bam_maqindel_ret_t *bam_maqindel(int n, int pos, const bam_maqindel_opt_t *mi, c
                                }
                                if (score[i*n+j] < s) score[i*n+j] = s; // choose the higher of the two scores
                                if (pscore[i*n+j] > ps) pscore[i*n+j] = ps;
-                               if (types[i] != 0) score[i*n+j] -= mi->indel_err;
+                               //if (types[i] != 0) score[i*n+j] -= mi->indel_err;
                                //printf("%d, %d, %d, %d, %d, %d, %d\n", p->b->core.pos + 1, seg.qbeg, i, types[i], j,
                                //         score[i*n+j], pscore[i*n+j]);
                        }
@@ -499,6 +499,15 @@ bam_maqindel_ret_t *bam_maqindel(int n, int pos, const bam_maqindel_opt_t *mi, c
                                if (s1 > s2) ret->gl[0] += s1 - s2 < mi->q_indel? s1 - s2 : mi->q_indel;
                                else ret->gl[1] += s2 - s1 < mi->q_indel? s2 - s1 : mi->q_indel;
                        }
+                       // write cnt_ref and cnt_ambi
+                       if (max1_i != 0 && max2_i != 0) {
+                               for (j = 0; j < n; ++j) {
+                                       int diff1 = score[j] - score[max1_i * n + j];
+                                       int diff2 = score[j] - score[max2_i * n + j];
+                                       if (diff1 > 0 && diff2 > 0) ++ret->cnt_ref;
+                                       else if (diff1 == 0 || diff2 == 0) ++ret->cnt_ambi;
+                               }
+                       }
                }
                free(score); free(pscore); free(ref2); free(inscns);
        }
index 36704d7bce51104e1a8d73ed233f8ebd4b8ce582..2a82aeee8057f5992570d0896a1621b9116057cd 100644 (file)
@@ -24,7 +24,8 @@ typedef struct {
 
 typedef struct {
        int indel1, indel2;
-       int cnt1, cnt2, cnt_ambi, cnt_anti;
+       int cnt1, cnt2, cnt_anti;
+       int cnt_ref, cnt_ambi;
        char *s[2];
        //
        int gt, gl[2];
index 391767ab134833f5dcc5ea914866fd7f10b97718..5bf1ed095096b7cd91fc99d2256467b89e394d33 100644 (file)
@@ -284,7 +284,8 @@ static int pileup_func(uint32_t tid, uint32_t pos, int n, const bam_pileup1_t *p
                printf("%d\t%d\t", rms_mapq, n);
                printf("%s\t%s\t", r->s[0], r->s[1]);
                //printf("%d\t%d\t", r->gl[0], r->gl[1]);
-               printf("%d\t%d\t%d\n", r->cnt1, r->cnt2, r->cnt_anti);
+               printf("%d\t%d\t%d\t", r->cnt1, r->cnt2, r->cnt_anti);
+               printf("%d\t%d\n", r->cnt_ref, r->cnt_ambi);
                bam_maqindel_ret_destroy(r);
        }
        return 0;
index 441a1b4c9581a628735713cfc1464e87c548ff95..019e3773cea2730a46d21277fe577b10f284a26b 100644 (file)
@@ -52,7 +52,7 @@ typedef struct {
        faidx_t *fai;
        bam_maqcns_t *bmc;
 
-       int ccol, last_pos, row_shift, base_for, color_for, is_dot, l_ref, ins;
+       int ccol, last_pos, row_shift, base_for, color_for, is_dot, l_ref, ins, no_skip;
        char *ref;
 } tview_t;
 
@@ -195,7 +195,7 @@ tview_t *tv_init(const char *fn, const char *fn_fa)
        tv->mrow = 24; tv->mcol = 80;
        getmaxyx(stdscr, tv->mrow, tv->mcol);
        tv->wgoto = newwin(3, TV_MAX_GOTO + 10, 10, 5);
-       tv->whelp = newwin(27, 40, 5, 5);
+       tv->whelp = newwin(28, 40, 5, 5);
        tv->color_for = TV_COLOR_MAPQ;
        start_color();
        init_pair(1, COLOR_BLUE, COLOR_BLACK);
@@ -228,6 +228,14 @@ void tv_destroy(tview_t *tv)
 int tv_fetch_func(const bam1_t *b, void *data)
 {
        tview_t *tv = (tview_t*)data;
+       if (tv->no_skip) {
+               uint32_t *cigar = bam1_cigar(b); // this is cheating...
+               int i;
+               for (i = 0; i <b->core.n_cigar; ++i) {
+                       if ((cigar[i]&0xf) == BAM_CREF_SKIP)
+                               cigar[i] = cigar[i]>>4<<4 | BAM_CDEL;
+               }
+       }
        bam_lplbuf_push(b, tv->lplbuf);
        return 0;
 }
@@ -311,6 +319,7 @@ static void tv_win_help(tview_t *tv) {
        mvwprintw(win, r++, 2, "c          Color for cs color");
        mvwprintw(win, r++, 2, "z          Color for cs qual");
        mvwprintw(win, r++, 2, ".          Toggle on/off dot view");
+       mvwprintw(win, r++, 2, "s          Toggle on/off ref skip");
        mvwprintw(win, r++, 2, "N          Turn on nt view");
        mvwprintw(win, r++, 2, "C          Turn on cs view");
        mvwprintw(win, r++, 2, "i          Toggle on/off ins");
@@ -339,6 +348,7 @@ void tv_loop(tview_t *tv)
                        case 'n': tv->color_for = TV_COLOR_NUCL; break;
                        case 'c': tv->color_for = TV_COLOR_COL; break;
                        case 'z': tv->color_for = TV_COLOR_COLQ; break;
+                       case 's': tv->no_skip = !tv->no_skip; break;
                        case KEY_LEFT:
                        case 'h': --pos; break;
                        case KEY_RIGHT:
diff --git a/bamtk.c b/bamtk.c
index 9e766737e4cfcfd17403bf186fc8cfc43184aa1c..f827aecb07dab38749212ccbadf80cbf6131e6c6 100644 (file)
--- a/bamtk.c
+++ b/bamtk.c
@@ -4,7 +4,7 @@
 #include "bam.h"
 
 #ifndef PACKAGE_VERSION
-#define PACKAGE_VERSION "0.1.5-17 (r422)"
+#define PACKAGE_VERSION "0.1.5-18 (r423)"
 #endif
 
 int bam_taf2baf(int argc, char *argv[]);
index 06c24dc6230c1d9baef40387574c02c9cda26d63..ade52899ef23e06293d2ad0ff7e81e67d857937f 100755 (executable)
@@ -24,6 +24,7 @@ sub showALEN {
   die(qq/Usage: samtools.pl showALEN <in.sam>\n/) if (@ARGV == 0 && -t STDIN);
   while (<>) {
        my @t = split;
+       next if (/^\@/ || @t < 11);
        my $l = 0;
        $_ = $t[5];
        s/(\d+)[SMI]/$l+=$1/eg;