Skip to content

Commit

Permalink
* several modifications for Vienna RNA package 2.0.x.
Browse files Browse the repository at this point in the history
  • Loading branch information
satoken committed Apr 16, 2012
1 parent 0027469 commit 37a08d3
Show file tree
Hide file tree
Showing 11 changed files with 70 additions and 14 deletions.
7 changes: 5 additions & 2 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# Process this file with autoconf to produce a configure script.

AC_PREREQ(2.61)
AC_INIT(centroid_fold, 0.0.9, no-define)
AC_INIT(centroid_fold, 0.0.10, no-define)
AM_INIT_AUTOMAKE([-Wall foreign])
AM_CONFIG_HEADER(config.h)
AC_CONFIG_SRCDIR([src/centroid_fold.cpp])
Expand Down Expand Up @@ -72,7 +72,10 @@ AC_ARG_WITH([vienna-rna], AS_HELP_STRING([--with-vienna-rna], [support Vienna RN
LDFLAGS="-L${with_vienna_rna}/lib $LDFLAGS"
fi
)
AC_CHECK_LIB(RNA, init_pf_fold)
AC_CHECK_LIB(RNA, pf_fold)

AC_CHECK_FUNC(energy_of_structure,
[AC_DEFINE([HAVE_VIENNA20], [], [have the Vienna RNA package version 1.8 or above])])

# Checks for header files.
AC_CHECK_HEADER([ViennaRNA/ribo.h],
Expand Down
2 changes: 1 addition & 1 deletion src/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,4 @@ libcentroid_a_SOURCES = \
probconsRNA/probcons.h \
contralign/contralign.h \
diana.cpp diana.h ps_plot.cpp ps_plot.h naview.c \
engine/new_param.h engine/new_param.c
engine/boltzmann_param.h engine/boltzmann_param.c
5 changes: 5 additions & 0 deletions src/aln.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,12 @@ energy_of_struct(const std::string& paren) const
}
s.erase(std::remove(s.begin(), s.end(), '-'), s.end());
p.erase(std::remove(p.begin(), p.end(), '-'), p.end());
#ifdef HAVE_VIENNA20
e += Vienna::energy_of_structure(s.c_str(), p.c_str(), -1);
#else
Vienna::eos_debug=-1;
e += Vienna::energy_of_struct(s.c_str(), p.c_str());
#endif
}
return e/num_aln();
}
Expand Down
20 changes: 18 additions & 2 deletions src/engine/alifold.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ extern "C" {
};

extern "C" {
#include "engine/new_param.h"
#include "engine/boltzmann_param.h"
};

AliFoldModel::
Expand All @@ -76,7 +76,7 @@ AliFoldModel(bool canonical_only, uint max_bp_dist,
xsubi[2] += (unsigned short) ((unsigned)seed >> 12);
}

copy_new_parameters();
copy_boltzmann_parameters();
if (param) Vienna::read_parameter_file(param);
}

Expand Down Expand Up @@ -126,7 +126,11 @@ calculate_posterior(const Aln& aln)
strcpy(str2, str_.c_str());
}
// scaling parameters to avoid overflow
#ifdef HAVE_VIENNA20
double min_en = Vienna::alifold((const char**)seqs, str2);
#else
double min_en = Vienna::alifold(seqs, str2);
#endif
double kT = (Vienna::temperature+273.15)*1.98717/1000.; /* in Kcal */
Vienna::pf_scale = exp(-(1.07*min_en)/kT/aln.size());
Vienna::free_alifold_arrays();
Expand All @@ -137,7 +141,11 @@ calculate_posterior(const Aln& aln)
Vienna::pair_info* pi;
#endif
if (!str_.empty()) strcpy(str2, str_.c_str());
#ifdef HAVE_VIENNA20
Vienna::alipf_fold((const char**)seqs, str2, &pi);
#else
Vienna::alipf_fold(seqs, str2, &pi);
#endif
for (uint k=0; pi[k].i!=0; ++k)
bp_.update(pi[k].i-1, pi[k].j-1, pi[k].p);
free(pi);
Expand All @@ -162,7 +170,11 @@ prepare_stochastic_traceback(const Aln& aln)
strcpy(str2, str_.c_str());
}
// scaling parameters to avoid overflow
#ifdef HAVE_VIENNA20
double min_en = Vienna::alifold((const char**)seqs, str2);
#else
double min_en = Vienna::alifold(seqs, str2);
#endif
double kT = (Vienna::temperature+273.15)*1.98717/1000.; /* in Kcal */
Vienna::pf_scale = exp(-(1.07*min_en)/kT/aln.size());
Vienna::free_alifold_arrays();
Expand All @@ -173,7 +185,11 @@ prepare_stochastic_traceback(const Aln& aln)
Vienna::pair_info* pi;
#endif
if (!str_.empty()) strcpy(str2, str_.c_str());
#ifdef HAVE_VIENNA20
Vienna::alipf_fold((const char**)seqs, str2, &pi);
#else
Vienna::alipf_fold(seqs, str2, &pi);
#endif

if (str2) delete[] str2;
free_aln(seqs);
Expand Down
18 changes: 17 additions & 1 deletion src/engine/new_param.c → src/engine/boltzmann_param.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@
http://www.cs.ubc.ca/labs/beta/Projects/RNA-Params/data/parameters_BLstar_Vienna.txt
*/

#ifdef HAVE_CONFIG_H
#include "config.h"
#endif

#include <stdio.h>
#include <string.h>
#include <assert.h>
Expand Down Expand Up @@ -5971,12 +5975,20 @@ static void copy_MLparams(const int values[])
ML_BASE37 = values[0];
ML_closing37 = values[1];
ML_intern37 = values[2];
#ifdef HAVE_VIENNA20
TerminalAU37 = values[3];
#else
TerminalAU = values[3];
#endif
}

static void copy_ninio(const int values[])
{
#ifdef HAVE_VIENNA20
ninio37 = values[0];
#else
F_ninio37[2] = values[0];
#endif
MAX_NINIO = values[1];
}

Expand All @@ -5986,12 +5998,16 @@ static void copy_Tetra_loop(const struct tetra_loops tl[])
while (tl[i].s!=NULL && i<200) {
strcpy(&Tetraloops[7*i], tl[i].s);
strcat(Tetraloops, " ");
#ifdef HAVE_VIENNA20
Tetraloop37[i] = tl[i].e;
#else
TETRA_ENERGY37[i] = tl[i].e;
#endif
i++;
}
}

void copy_new_parameters()
void copy_boltzmann_parameters()
{
copy_stacks(stack37, stack37a);
copy_mismatch(mismatchH37, mismatchH37a);
Expand Down
6 changes: 6 additions & 0 deletions src/engine/boltzmann_param.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#ifndef __INC_BOLTZMANN_PARAM_H__
#define __INC_BOLTZMANN_PARAM_H__

void copy_boltzmann_parameters();

#endif
8 changes: 6 additions & 2 deletions src/engine/mccaskill.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ extern "C" {
#endif

extern "C" {
#include "engine/new_param.h"
#include "engine/boltzmann_param.h"
};

McCaskillModel::
Expand Down Expand Up @@ -80,7 +80,7 @@ McCaskillModel(bool canonical_only, uint max_bp_dist,
xsubi[2] += (unsigned short) ((unsigned)seed >> 12);
}

copy_new_parameters();
copy_boltzmann_parameters();
if (param) Vienna::read_parameter_file(param);
}

Expand All @@ -99,7 +99,9 @@ calculate_posterior(const std::string& seq)
{
bp_.resize(seq.size());
Vienna::pf_scale = -1;
#ifndef HAVE_VIENNA20
Vienna::init_pf_fold(seq.size());
#endif
if (str_.empty()) {
Vienna::pf_fold(const_cast<char*>(seq.c_str()), NULL);
} else {
Expand Down Expand Up @@ -127,7 +129,9 @@ prepare_stochastic_traceback(const std::string& seq)
bk_st_back_=Vienna::st_back;
Vienna::st_back=1;
Vienna::pf_scale = -1;
#ifndef HAVE_VIENNA20
Vienna::init_pf_fold(seq.size());
#endif
if (str_.empty()) {
Vienna::pf_fold(const_cast<char*>(seq.c_str()), NULL);
} else {
Expand Down
2 changes: 2 additions & 0 deletions src/engine/mccaskillhom.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,9 @@ calculate_posterior(const TH& th)

bp_.resize(seq.size());
Vienna::pf_scale = -1;
#ifndef HAVE_VIENNA20
Vienna::init_pf_fold(seq.size());
#endif
if (str_.empty()) {
Vienna::pf_fold(const_cast<char*>(seq.c_str()), NULL);
} else {
Expand Down
6 changes: 0 additions & 6 deletions src/engine/new_param.h

This file was deleted.

8 changes: 8 additions & 0 deletions src/folding_engine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,12 @@ const std::string& get_seq(const std::string& t) { return t; }
static
float calc_energy(const std::string& t, const std::string& s)
{
#ifdef HAVE_VIENNA20
return Vienna::energy_of_structure(t.c_str(), s.c_str(), -1);
#else
Vienna::eos_debug = -1;
return Vienna::energy_of_struct(t.c_str(), s.c_str());
#endif
}
#endif

Expand All @@ -82,8 +86,12 @@ float calc_energy(const Aln& aln, const std::string& s)
static
float calc_energy(const TH& t, const std::string& s)
{
#ifdef HAVE_VIENNA20
return Vienna::energy_of_structure(t.first.c_str(), s.c_str(), -1);
#else
Vienna::eos_debug = -1;
return Vienna::energy_of_struct(t.first.c_str(), s.c_str());
#endif
}
#endif

Expand Down
2 changes: 2 additions & 0 deletions src/util.h
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,9 @@ pf_fold(CONTRALIGN::SparseMatrix<T>*& bp, const std::string& seq, const std::str
//if (param) Vienna::read_parameter_file (param);
if (bp!=NULL) delete bp;
Vienna::pf_scale = -1;
#ifndef HAVE_VIENNA20
Vienna::init_pf_fold(seq.size());
#endif
if (str.empty()) {
Vienna::pf_fold(const_cast<char*>(seq.c_str()), NULL);
} else {
Expand Down

0 comments on commit 37a08d3

Please sign in to comment.