Skip to content

Commit

Permalink
* bug fix
Browse files Browse the repository at this point in the history
  • Loading branch information
satoken committed Sep 14, 2012
1 parent f7850d1 commit 524759b
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 23 deletions.
20 changes: 8 additions & 12 deletions src/alifold.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,12 @@ fold(const ALN& aln, const std::vector<Fasta>& fa, BP& bp) const
char** seqs = alloc_aln(aln, fa);

// scaling parameters to avoid overflow
char* res = new char[L+1];
std::string res(L+1, ' ');
#ifdef HAVE_VIENNA20
double min_en = Vienna::alifold((const char**)seqs, res);
double min_en = Vienna::alifold((const char**)seqs, &res[0]);
#else
double min_en = Vienna::alifold(seqs, res);
double min_en = Vienna::alifold(seqs, &res[0]);
#endif
delete[] res;
double kT = (Vienna::temperature+273.15)*1.98717/1000.; /* in Kcal */
Vienna::pf_scale = exp(-(1.07*min_en)/kT/L);
Vienna::free_alifold_arrays();
Expand Down Expand Up @@ -95,25 +94,22 @@ fold(const ALN& aln, const std::vector<Fasta>& fa, const std::string& str, BP& b
char** seqs = alloc_aln(aln, fa);

// scaling parameters to avoid overflow
char* res = new char[L+1];
strcpy(res, p.c_str());
std::string res(p);
#ifdef HAVE_VIENNA20
double min_en = Vienna::alifold((const char**)seqs, res);
double min_en = Vienna::alifold((const char**)seqs, &res[0]);
#else
double min_en = Vienna::alifold(seqs, res);
double min_en = Vienna::alifold(seqs, &res[0]);
#endif
double kT = (Vienna::temperature+273.15)*1.98717/1000.; /* in Kcal */
Vienna::pf_scale = exp(-(1.07*min_en)/kT/L);
Vienna::free_alifold_arrays();

strcpy(res, p.c_str());
pair_info* pi;
#ifdef HAVE_VIENNA20
Vienna::alipf_fold((const char**)seqs, res, &pi);
Vienna::alipf_fold((const char**)seqs, &p[0], &pi);
#else
Vienna::alipf_fold(seqs, res, &pi);
Vienna::alipf_fold(seqs, &p[0], &pi);
#endif
delete[] res;

bp.resize(L);
for (uint k=0; pi[k].i!=0; ++k)
Expand Down
16 changes: 5 additions & 11 deletions src/fold.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,8 @@ calculate(const std::string& seq, BP& bp)
// scaling parameters to avoid overflow
if (1 /*L>1600*/)
{
char *res = new char[L+1];
float min_en = Vienna::fold(const_cast<char*>(seq.c_str()), res);
delete[] res;
std::string res(L+1, ' ');
float min_en = Vienna::fold(const_cast<char*>(seq.c_str()), &res[0]);
float sfact = 1.07;
float kT = (Vienna::temperature+273.15)*1.98717/1000.; /* in Kcal */
Vienna::pf_scale = exp(-(sfact*min_en)/kT/seq.size());
Expand Down Expand Up @@ -130,10 +129,8 @@ calculate(const std::string& seq, const std::string& str, BP& bp)
// scaling parameters to avoid overflow
if (1 /*L>1600*/)
{
char* res = new char[L+1];
strcpy(res, p.c_str());
float min_en = Vienna::fold(const_cast<char*>(seq.c_str()), res);
delete[] res;
std::string res(p);
float min_en = Vienna::fold(const_cast<char*>(seq.c_str()), &res[0]);
float sfact = 1.07;
float kT = (Vienna::temperature+273.15)*1.98717/1000.; /* in Kcal */
Vienna::pf_scale = exp(-(sfact*min_en)/kT/seq.size());
Expand All @@ -143,10 +140,7 @@ calculate(const std::string& seq, const std::string& str, BP& bp)
#ifndef HAVE_VIENNA20
Vienna::init_pf_fold(L);
#endif
char* res = new char[L+1];
strcpy(res, p.c_str());
Vienna::pf_fold(const_cast<char*>(seq.c_str()), res);
delete[] res;
Vienna::pf_fold(const_cast<char*>(seq.c_str()), &p[0]);

#ifdef HAVE_VIENNA20
FLT_OR_DBL* pr = Vienna::export_bppm();
Expand Down

0 comments on commit 524759b

Please sign in to comment.