~ubuntu-branches/ubuntu/trusty/bwa/trusty

« back to all changes in this revision

Viewing changes to bwtaln.c

  • Committer: Bazaar Package Importer
  • Author(s): Charles Plessy
  • Date: 2011-02-08 16:11:12 UTC
  • mfrom: (1.1.7 upstream)
  • Revision ID: james.westby@ubuntu.com-20110208161112-1fvt0mtygl8rhajf
Tags: 0.5.9-1
* New usptream release
  - Upstream moved to GitHub (debian/upstream-metadata.yaml).
  - Checked copyright; one file was removed (debian/copyright).
* Migrated the Debian source package to Git (debian/control).
* Use Debhelper 8 (debian/control, debian/compat).

Show diffs side-by-side

added added

removed removed

Lines of Context:
115
115
                seq[0] = p->seq; seq[1] = p->rseq;
116
116
                if (max_l < p->len) {
117
117
                        max_l = p->len;
118
 
                        w[0] = (bwt_width_t*)calloc(max_l + 1, sizeof(bwt_width_t));
119
 
                        w[1] = (bwt_width_t*)calloc(max_l + 1, sizeof(bwt_width_t));
 
118
                        w[0] = (bwt_width_t*)realloc(w[0], (max_l + 1) * sizeof(bwt_width_t));
 
119
                        w[1] = (bwt_width_t*)realloc(w[1], (max_l + 1) * sizeof(bwt_width_t));
 
120
                        memset(w[0], 0, (max_l + 1) * sizeof(bwt_width_t));
 
121
                        memset(w[1], 0, (max_l + 1) * sizeof(bwt_width_t));
120
122
                }
121
123
                bwt_cal_width(bwt[0], p->len, seq[0], w[0]);
122
124
                bwt_cal_width(bwt[1], p->len, seq[1], w[1]);
154
156
}
155
157
#endif
156
158
 
 
159
bwa_seqio_t *bwa_open_reads(int mode, const char *fn_fa)
 
160
{
 
161
        bwa_seqio_t *ks;
 
162
        if (mode & BWA_MODE_BAM) { // open BAM
 
163
                int which = 0;
 
164
                if (mode & BWA_MODE_BAM_SE) which |= 4;
 
165
                if (mode & BWA_MODE_BAM_READ1) which |= 1;
 
166
                if (mode & BWA_MODE_BAM_READ2) which |= 2;
 
167
                if (which == 0) which = 7; // then read all reads
 
168
                ks = bwa_bam_open(fn_fa, which);
 
169
        } else ks = bwa_seq_open(fn_fa);
 
170
        return ks;
 
171
}
 
172
 
157
173
void bwa_aln_core(const char *prefix, const char *fn_fa, const gap_opt_t *opt)
158
174
{
159
175
        int i, n_seqs, tot_seqs = 0;
163
179
        bwt_t *bwt[2];
164
180
 
165
181
        // initialization
166
 
        ks = bwa_seq_open(fn_fa);
 
182
        ks = bwa_open_reads(opt->mode, fn_fa);
167
183
 
168
184
        { // load BWT
169
185
                char *str = (char*)calloc(strlen(prefix) + 10, 1);
174
190
 
175
191
        // core loop
176
192
        fwrite(opt, sizeof(gap_opt_t), 1, stdout);
177
 
        while ((seqs = bwa_read_seq(ks, 0x40000, &n_seqs, opt->mode & BWA_MODE_COMPREAD, opt->trim_qual)) != 0) {
 
193
        while ((seqs = bwa_read_seq(ks, 0x40000, &n_seqs, opt->mode, opt->trim_qual)) != 0) {
178
194
                tot_seqs += n_seqs;
179
195
                t = clock();
180
196
 
230
246
        gap_opt_t *opt;
231
247
 
232
248
        opt = gap_init_opt();
233
 
        while ((c = getopt(argc, argv, "n:o:e:i:d:l:k:cLR:m:t:NM:O:E:q:f:")) >= 0) {
 
249
        while ((c = getopt(argc, argv, "n:o:e:i:d:l:k:cLR:m:t:NM:O:E:q:f:b012IB:")) >= 0) {
234
250
                switch (c) {
235
251
                case 'n':
236
252
                        if (strstr(optarg, ".")) opt->fnr = atof(optarg), opt->max_diff = -1;
252
268
                case 'q': opt->trim_qual = atoi(optarg); break;
253
269
                case 'c': opt->mode &= ~BWA_MODE_COMPREAD; break;
254
270
                case 'N': opt->mode |= BWA_MODE_NONSTOP; opt->max_top2 = 0x7fffffff; break;
255
 
        case 'f': freopen(optarg, "wb", stdout); break;
 
271
                case 'f': xreopen(optarg, "wb", stdout); break;
 
272
                case 'b': opt->mode |= BWA_MODE_BAM; break;
 
273
                case '0': opt->mode |= BWA_MODE_BAM_SE; break;
 
274
                case '1': opt->mode |= BWA_MODE_BAM_READ1; break;
 
275
                case '2': opt->mode |= BWA_MODE_BAM_READ2; break;
 
276
                case 'I': opt->mode |= BWA_MODE_IL13; break;
 
277
                case 'B': opt->mode |= atoi(optarg) << 24; break;
256
278
                default: return 1;
257
279
                }
258
280
        }
279
301
                fprintf(stderr, "         -E INT    gap extension penalty [%d]\n", opt->s_gape);
280
302
                fprintf(stderr, "         -R INT    stop searching when there are >INT equally best hits [%d]\n", opt->max_top2);
281
303
                fprintf(stderr, "         -q INT    quality threshold for read trimming down to %dbp [%d]\n", BWA_MIN_RDLEN, opt->trim_qual);
 
304
        fprintf(stderr, "         -f FILE   file to write output to instead of stdout\n");
 
305
                fprintf(stderr, "         -B INT    length of barcode\n");
282
306
                fprintf(stderr, "         -c        input sequences are in the color space\n");
283
307
                fprintf(stderr, "         -L        log-scaled gap penalty for long deletions\n");
284
308
                fprintf(stderr, "         -N        non-iterative mode: search for all n-difference hits (slooow)\n");
285
 
        fprintf(stderr, "         -f FILE   file to write output to instead of stdout\n");
 
309
                fprintf(stderr, "         -I        the input is in the Illumina 1.3+ FASTQ-like format\n");
 
310
                fprintf(stderr, "         -b        the input read file is in the BAM format\n");
 
311
                fprintf(stderr, "         -0        use single-end reads only (effective with -b)\n");
 
312
                fprintf(stderr, "         -1        use the 1st read in a pair (effective with -b)\n");
 
313
                fprintf(stderr, "         -2        use the 2nd read in a pair (effective with -b)\n");
286
314
                fprintf(stderr, "\n");
287
315
                return 1;
288
316
        }