コード例 #1
0
ファイル: bwase.c プロジェクト: michaelglass/bwa-colorspace
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);
}
コード例 #2
0
ファイル: bwase.c プロジェクト: fstrozzi/bioruby-bwa
void bwa_cal_pac_pos(const char *prefix, int n_seqs, bwa_seq_t *seqs, int max_mm, float fnr)
{
	int i, j;
	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) {
		if (seqs[i].strand) bwa_cal_pac_pos_core(bwt, 0, &seqs[i], max_mm, fnr);
		for (j = 0; j < seqs[i].n_multi; ++j) {
			bwt_multi1_t *p = seqs[i].multi + j;
			if (p->strand) p->pos = bwt_sa(bwt, p->pos);
		}
	}
	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) {
		if (!seqs[i].strand) bwa_cal_pac_pos_core(0, bwt, &seqs[i], max_mm, fnr);
		for (j = 0; j < seqs[i].n_multi; ++j) {
			bwt_multi1_t *p = seqs[i].multi + j;
			if (!p->strand) p->pos = bwt->seq_len - (bwt_sa(bwt, p->pos) + seqs[i].len);
		}
	}
	bwt_destroy(bwt);
}
コード例 #3
0
ファイル: bwase.c プロジェクト: mpieva/network-aware-bwa
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);
	} 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);
}
コード例 #4
0
ファイル: bwase.cpp プロジェクト: chaolinzhanglab/olego
void jigsaw_cal_pac_pos (const bwt_t *bwt, bwa_seq_t *seq, int max_mm, float fnr, const int *g_log_n)
{
	int j;
	bwa_cal_pac_pos_core(bwt, seq, max_mm, fnr, g_log_n);
	for (j = 0; j < seq->n_multi; ++j) {
		bwt_multi1_t *p = seq->multi + j;
		p->pos = bwt_sa(bwt, p->pos);
	}
}
コード例 #5
0
ファイル: bwase.cpp プロジェクト: chaolinzhanglab/olego
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);
}
コード例 #6
0
ファイル: bwase.c プロジェクト: anachshon/bwa
bwtint_t bwa_sa2pos(const bntseq_t *bns, const bwt_t *bwt, bwtint_t sapos, int len, int *strand)
{
	bwtint_t pos_f;
	int is_rev;
	pos_f = bns_depos(bns, bwt_sa(bwt, sapos), &is_rev); // pos_f
	*strand = !is_rev;
	/* NB: For gapped alignment, pacpos may not be correct, which will be fixed
	 * in bwa_refine_gapped_core(). This line also determines the way "x" is
	 * calculated in bwa_refine_gapped_core() when (ext < 0 && is_end == 0). */
	if (is_rev) pos_f = pos_f + 1 < len? 0 : pos_f - len + 1; // mapped to the forward strand
	return pos_f; // FIXME: it is possible that pos_f < bns->anns[ref_id].offset
}
コード例 #7
0
ファイル: bwase.cpp プロジェクト: chaolinzhanglab/olego
/* calculate the reference genomic positions for an SA interval (an alignment)
 * the allocated memory will be released at jigsaw_free_read_seq_one
 */
void jigsaw_collect_word_hits_sai (const bwt_t *bwt, int wid, int pos_q, const bwt_aln1_t *p, list<jigsaw_word_hit_t*> *hits)
{
	int j;
	//jigsaw_word_hit_t *h;
	int len = p->l - p->k+1;
	if (len <= 0) return;

	for (j = 0; j < len; ++j) {
		jigsaw_word_hit_t *h = (jigsaw_word_hit_t *) calloc(1, sizeof(jigsaw_word_hit_t));
		//h = hits + j;
		h->wid = wid;
		h->pos_q = pos_q;
		h->pos_t = bwt_sa (bwt, p->k + j);
		h->strand = p->a;
		hits->push_back (h);
	}
}