]> git.donarmstrong.com Git - samtools.git/blobdiff - bam_plcmd.c
* samtools-0.1.9-1 (r786)
[samtools.git] / bam_plcmd.c
index 23602ccd5bcf6dc116632fa1bdb9483993aebf92..c23726ec51272658f1c7b876d0822085a57ea2b7 100644 (file)
@@ -473,6 +473,7 @@ int bam_pileup(int argc, char *argv[])
                        bam_plp_set_mask(iter, d->mask);
                        while ((ret = samread(fp, b)) >= 0) {
                                int skip = 0;
+                               if ((int)b->core.tid < 0) break;
                                // update d->ref if necessary
                                if (d->fai && (int)b->core.tid != d->tid) {
                                        free(d->ref);
@@ -527,6 +528,8 @@ int bam_pileup(int argc, char *argv[])
 #define MPLP_NO_COMP 0x20
 #define MPLP_NO_ORPHAN 0x40
 #define MPLP_REALN   0x80
+#define MPLP_FMT_DP 0x100
+#define MPLP_FMT_SP 0x200
 
 typedef struct {
        int max_mq, min_mq, flag, min_baseQ, capQ_thres;
@@ -713,7 +716,7 @@ static int mpileup(mplp_conf_t *conf, int n, char **fn)
                        for (i = 0; i < gplp.n; ++i)
                                bcf_call_glfgen(gplp.n_plp[i], gplp.plp[i], ref16, bca, bcr + i);
                        bcf_call_combine(gplp.n, bcr, ref16, &bc);
-                       bcf_call2bcf(tid, pos, &bc, b);
+                       bcf_call2bcf(tid, pos, &bc, b, (conf->flag&(MPLP_FMT_DP|MPLP_FMT_SP))? bcr : 0, (conf->flag&MPLP_FMT_SP));
                        bcf_write(bp, bh, b);
                        bcf_destroy(b);
                } else {
@@ -769,7 +772,7 @@ int bam_mpileup(int argc, char *argv[])
        mplp.min_baseQ = 13;
        mplp.capQ_thres = 0;
        mplp.flag = MPLP_NO_ORPHAN | MPLP_REALN;
-       while ((c = getopt(argc, argv, "gf:r:l:M:q:Q:uaORC:B")) >= 0) {
+       while ((c = getopt(argc, argv, "gf:r:l:M:q:Q:uaORC:BDS")) >= 0) {
                switch (c) {
                case 'f':
                        mplp.fai = fai_load(optarg);
@@ -783,6 +786,8 @@ int bam_mpileup(int argc, char *argv[])
                case 'B': mplp.flag &= ~MPLP_REALN & ~MPLP_NO_ORPHAN; break;
                case 'O': mplp.flag |= MPLP_NO_ORPHAN; break;
                case 'R': mplp.flag |= MPLP_REALN; break;
+               case 'D': mplp.flag |= MPLP_FMT_DP; break;
+               case 'S': mplp.flag |= MPLP_FMT_SP; break;
                case 'C': mplp.capQ_thres = atoi(optarg); break;
                case 'M': mplp.max_mq = atoi(optarg); break;
                case 'q': mplp.min_mq = atoi(optarg); break;
@@ -801,6 +806,8 @@ int bam_mpileup(int argc, char *argv[])
                fprintf(stderr, "         -g          generate BCF output\n");
                fprintf(stderr, "         -u          do not compress BCF output\n");
                fprintf(stderr, "         -B          disable BAQ computation\n");
+               fprintf(stderr, "         -D          output per-sample DP\n");
+               fprintf(stderr, "         -S          output per-sample SP (strand bias P-value, slow)\n");
                fprintf(stderr, "\n");
                fprintf(stderr, "Notes: Assuming diploid individuals.\n\n");
                return 1;