void bwa_cal_pac_pos(const char *prefix, int n_seqs, bwa_seq_t *seqs, int max_mm, float fnr) { int i; char str[1024]; bwt_t *bwt; // load forward SA strcpy(str, prefix); strcat(str, ".bwt"); bwt = bwt_restore_bwt(str); strcpy(str, prefix); strcat(str, ".sa"); bwt_restore_sa(str, bwt); for (i = 0; i != n_seqs; ++i) { bwa_seq_t *p = seqs + i; int max_diff = fnr > 0.0? bwa_cal_maxdiff(p->len, BWA_AVG_ERR, fnr) : max_mm; if ((p->type == BWA_TYPE_UNIQUE || p->type == BWA_TYPE_REPEAT) && p->strand) { // reverse strand only p->pos = bwt_sa(bwt, p->sa); p->seQ = p->mapQ = bwa_approx_mapQ(p, max_diff); } } bwt_destroy(bwt); // load reverse BWT and SA strcpy(str, prefix); strcat(str, ".rbwt"); bwt = bwt_restore_bwt(str); strcpy(str, prefix); strcat(str, ".rsa"); bwt_restore_sa(str, bwt); for (i = 0; i != n_seqs; ++i) { bwa_seq_t *p = seqs + i; int max_diff = fnr > 0.0? bwa_cal_maxdiff(p->len, BWA_AVG_ERR, fnr) : max_mm; if ((p->type == BWA_TYPE_UNIQUE || p->type == BWA_TYPE_REPEAT) && !p->strand) { // forward strand only /* NB: For gapped alignment, p->pos may not be correct, * which will be fixed in refine_gapped_core(). This * line also determines the way "x" is calculated in * refine_gapped_core() when (ext < 0 && is_end == 0). */ p->pos = bwt->seq_len - (bwt_sa(bwt, p->sa) + p->len); p->seQ = p->mapQ = bwa_approx_mapQ(p, max_diff); } } bwt_destroy(bwt); }
/** * Derive the actual position in the read from the given suffix array * coordinates. Note that the position will be approximate based on * whether indels appear in the read and whether calculations are * performed from the start or end of the read. */ void bwa_cal_pac_pos_core(const bntseq_t *bns, const bwt_t *bwt, bwa_seq_t *seq, const int max_mm, const float fnr) { int max_diff, strand; if (seq->type != BWA_TYPE_UNIQUE && seq->type != BWA_TYPE_REPEAT) return; max_diff = fnr > 0.0? bwa_cal_maxdiff(seq->len, BWA_AVG_ERR, fnr) : max_mm; seq->seQ = seq->mapQ = bwa_approx_mapQ(seq, max_diff); seq->pos = bwa_sa2pos(bns, bwt, seq->sa, seq->len, &strand); seq->strand = strand; seq->seQ = seq->mapQ = bwa_approx_mapQ(seq, max_diff); }
/** * Derive the actual position in the read from the given suffix array * coordinates. Note that the position will be approximate based on * whether indels appear in the read and whether calculations are * performed from the start or end of the read. */ void bwa_cal_pac_pos_core(const bwt_t *forward_bwt, const bwt_t *reverse_bwt, bwa_seq_t *seq, const int max_mm, const float fnr) { int max_diff; if (seq->type != BWA_TYPE_UNIQUE && seq->type != BWA_TYPE_REPEAT) return; max_diff = fnr > 0.0? bwa_cal_maxdiff(seq->len, BWA_AVG_ERR, fnr) : max_mm; if (seq->strand) { // reverse strand only seq->pos = bwt_sa(forward_bwt, seq->sa); seq->seQ = seq->mapQ = bwa_approx_mapQ(seq, max_diff); } else { // forward strand only /* NB: For gapped alignment, p->pos may not be correct, which * will be fixed in refine_gapped_core(). This line also * determines the way "x" is calculated in * refine_gapped_core() when (ext < 0 && is_end == 0). */ seq->pos = reverse_bwt->seq_len - (bwt_sa(reverse_bwt, seq->sa) + seq->len); seq->seQ = seq->mapQ = bwa_approx_mapQ(seq, max_diff); } }
void bwa_cal_pac_pos_core(const bwt_t *bwt, bwa_seq_t *seq, const int max_mm, const float fnr, const int *g_log_n) { int max_diff; if (seq->type != BWA_TYPE_UNIQUE && seq->type != BWA_TYPE_REPEAT) return; max_diff = fnr > 0.0? bwa_cal_maxdiff(seq->len, BWA_AVG_ERR, fnr) : max_mm; seq->pos = bwt_sa(bwt, seq->sa); seq->seQ = seq->mapQ = bwa_approx_mapQ(seq, max_diff, g_log_n); }