Skip to content

Commit

Permalink
Support MinGW32 compilation.
Browse files Browse the repository at this point in the history
  • Loading branch information
satoken committed Jan 27, 2016
1 parent 86f7503 commit 1dc41c4
Show file tree
Hide file tree
Showing 11 changed files with 125 additions and 47 deletions.
3 changes: 3 additions & 0 deletions config.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@
/* Define to 1 if you have the <memory.h> header file. */
#undef HAVE_MEMORY_H

/* have mkstemp() in the standard library */
#undef HAVE_MKSTEMP

/* define if the compiler implements namespaces */
#undef HAVE_NAMESPACES

Expand Down
63 changes: 63 additions & 0 deletions configure
Original file line number Diff line number Diff line change
Expand Up @@ -6152,6 +6152,61 @@ _ACEOF
LIBS="-lRNA $LIBS"
else
{ $as_echo "$as_me:${as_lineno-$LINENO}: try '-fopenmp'" >&5
$as_echo "$as_me: try '-fopenmp'" >&6;}
CXXFLAGS_BAK=${CXXFLAGS}
CXXFLAGS="-fopenmp ${CXXFLAGS}"
unset ac_cv_lib_RNA_pf_fold
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for pf_fold in -lRNA" >&5
$as_echo_n "checking for pf_fold in -lRNA... " >&6; }
if ${ac_cv_lib_RNA_pf_fold+:} false; then :
$as_echo_n "(cached) " >&6
else
ac_check_lib_save_LIBS=$LIBS
LIBS="-lRNA $LIBS"
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
/* Override any GCC internal prototype to avoid an error.
Use char because int might match the return type of a GCC
builtin and then its argument prototype would still apply. */
#ifdef __cplusplus
extern "C"
#endif
char pf_fold ();
int
main ()
{
return pf_fold ();
;
return 0;
}
_ACEOF
if ac_fn_cxx_try_link "$LINENO"; then :
ac_cv_lib_RNA_pf_fold=yes
else
ac_cv_lib_RNA_pf_fold=no
fi
rm -f core conftest.err conftest.$ac_objext \
conftest$ac_exeext conftest.$ac_ext
LIBS=$ac_check_lib_save_LIBS
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_RNA_pf_fold" >&5
$as_echo "$ac_cv_lib_RNA_pf_fold" >&6; }
if test "x$ac_cv_lib_RNA_pf_fold" = xyes; then :
cat >>confdefs.h <<_ACEOF
#define HAVE_LIBRNA 1
_ACEOF
LIBS="-lRNA $LIBS"
else
CXXFLAGS=${CXXFLAGS_BAK}
fi
fi
Expand All @@ -6173,6 +6228,14 @@ fi
ac_fn_cxx_check_func "$LINENO" "mkstemp" "ac_cv_func_mkstemp"
if test "x$ac_cv_func_mkstemp" = xyes; then :
$as_echo "#define HAVE_MKSTEMP /**/" >>confdefs.h
fi
# Checks for typedefs, structures, and compiler characteristics.
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for stdbool.h that conforms to C99" >&5
$as_echo_n "checking for stdbool.h that conforms to C99... " >&6; }
Expand Down
12 changes: 11 additions & 1 deletion configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,14 @@ 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, pf_fold)
AC_CHECK_LIB([RNA], [pf_fold], [],
[
AC_MSG_NOTICE([try '-fopenmp'])
CXXFLAGS_BAK=${CXXFLAGS}
CXXFLAGS="-fopenmp ${CXXFLAGS}"
unset ac_cv_lib_RNA_pf_fold
AC_CHECK_LIB([RNA], [pf_fold], [], [ CXXFLAGS=${CXXFLAGS_BAK} ])
])

AC_CHECK_FUNC(energy_of_structure,
[AC_DEFINE([HAVE_VIENNA20], [], [have the Vienna RNA package version 1.8 or above])])
Expand All @@ -91,6 +98,9 @@ AC_CHECK_FUNC(energy_of_structure,
AC_CHECK_HEADER([ViennaRNA/ribo.h],
[AC_DEFINE([HAVE_VIENNA18], [], [have the Vienna RNA package version 2.0 or above])])

AC_CHECK_FUNC([mkstemp],
[AC_DEFINE([HAVE_MKSTEMP], [], [have mkstemp() in the standard library])])

# Checks for typedefs, structures, and compiler characteristics.
AC_HEADER_STDBOOL
AC_C_CONST
Expand Down
48 changes: 24 additions & 24 deletions src/contralign/InferenceEngine.ipp
Original file line number Diff line number Diff line change
Expand Up @@ -307,10 +307,10 @@ void InferenceEngine<RealT>::LoadSequences(const MultiSequence &seqs)
// allocate memory
x.clear(); x.resize(LX+1);
y.clear(); y.resize(LY+1);
aligned_to_x.clear(); aligned_to_x.resize(LX+1, Sequence::UNKNOWN);
aligned_to_y.clear(); aligned_to_y.resize(LY+1, Sequence::UNKNOWN);
true_aligned_to_x.clear(); true_aligned_to_x.resize(LX+1, Sequence::UNKNOWN);
true_aligned_to_y.clear(); true_aligned_to_y.resize(LY+1, Sequence::UNKNOWN);
aligned_to_x.clear(); aligned_to_x.resize(LX+1, Sequence::UnKnown);
aligned_to_y.clear(); aligned_to_y.resize(LY+1, Sequence::UnKnown);
true_aligned_to_x.clear(); true_aligned_to_x.resize(LX+1, Sequence::UnKnown);
true_aligned_to_y.clear(); true_aligned_to_y.resize(LY+1, Sequence::UnKnown);

// convert sequences
const std::string &sx = seqX.GetData();
Expand Down Expand Up @@ -413,9 +413,9 @@ void InferenceEngine<RealT>::UseLoss(const std::pair<std::vector<int>, std::vect

int count = 0;
for (int i = 1; i <= LX; i++)
if (true_aligned_to_x[i] != Sequence::UNKNOWN && true_aligned_to_x[i] != Sequence::UNALIGNED) count++;
if (true_aligned_to_x[i] != Sequence::UnKnown && true_aligned_to_x[i] != Sequence::UnAligned) count++;
for (int i = 1; i <= LY; i++)
if (true_aligned_to_y[i] != Sequence::UNKNOWN && true_aligned_to_y[i] != Sequence::UNALIGNED) count++;
if (true_aligned_to_y[i] != Sequence::UnKnown && true_aligned_to_y[i] != Sequence::UnAligned) count++;

per_position_loss = example_loss / RealT(count);
}
Expand Down Expand Up @@ -449,14 +449,14 @@ inline RealT InferenceEngine<RealT>::ScoreMatch(int i, int j, int s) const
Assert(0 < i && i <= LX && 0 < j && j <= LY, "Invalid indices.");
Assert(0 <= s && s < K, "Invalid state.");

if ((aligned_to_x[i] != Sequence::UNKNOWN && aligned_to_x[i] != j) ||
(aligned_to_y[j] != Sequence::UNKNOWN && aligned_to_y[j] != i))
if ((aligned_to_x[i] != Sequence::UnKnown && aligned_to_x[i] != j) ||
(aligned_to_y[j] != Sequence::UnKnown && aligned_to_y[j] != i))
return RealT(NEG_INF);

return RealT(0)
#if defined(HAMMING_LOSS)
+ ((true_aligned_to_x[i] == Sequence::UNKNOWN || true_aligned_to_x[i] == Sequence::UNALIGNED || true_aligned_to_x[i] == j) ? RealT(0) : per_position_loss)
+ ((true_aligned_to_y[j] == Sequence::UNKNOWN || true_aligned_to_y[j] == Sequence::UNALIGNED || true_aligned_to_y[j] == i) ? RealT(0) : per_position_loss)
+ ((true_aligned_to_x[i] == Sequence::UnKnown || true_aligned_to_x[i] == Sequence::UnAligned || true_aligned_to_x[i] == j) ? RealT(0) : per_position_loss)
+ ((true_aligned_to_y[j] == Sequence::UnKnown || true_aligned_to_y[j] == Sequence::UnAligned || true_aligned_to_y[j] == i) ? RealT(0) : per_position_loss)
#endif
#if PARAMS_MATCH
+ score_match[x[i]][y[j]].first
Expand Down Expand Up @@ -487,8 +487,8 @@ inline void InferenceEngine<RealT>::CountMatch(int i, int j, int s, RealT value)
Assert(0 < i && i <= LX && 0 < j && j <= LY, "Invalid indices.");
Assert(0 <= s && s < K, "Invalid state.");

if ((aligned_to_x[i] != Sequence::UNKNOWN && aligned_to_x[i] != j) ||
(aligned_to_y[j] != Sequence::UNKNOWN && aligned_to_y[j] != i))
if ((aligned_to_x[i] != Sequence::UnKnown && aligned_to_x[i] != j) ||
(aligned_to_y[j] != Sequence::UnKnown && aligned_to_y[j] != i))
return;

#if PARAMS_MATCH
Expand Down Expand Up @@ -526,12 +526,12 @@ inline RealT InferenceEngine<RealT>::ScoreInsertX(int i, int j, int s) const
Assert(0 < i && i <= LX && 0 <= j && j <= LY, "Invalid indices.");
Assert(0 <= s && s < K, "Invalid state.");

if (aligned_to_x[i] != Sequence::UNKNOWN && aligned_to_x[i] != Sequence::UNALIGNED)
if (aligned_to_x[i] != Sequence::UnKnown && aligned_to_x[i] != Sequence::UnAligned)
return RealT(NEG_INF);

return RealT(0)
#if defined(HAMMING_LOSS)
+ ((true_aligned_to_x[i] == Sequence::UNKNOWN || true_aligned_to_x[i] == Sequence::UNALIGNED) ? RealT(0) : per_position_loss)
+ ((true_aligned_to_x[i] == Sequence::UnKnown || true_aligned_to_x[i] == Sequence::UnAligned) ? RealT(0) : per_position_loss)
#endif
#if PARAMS_INSERT
+ score_insert[x[i]].first
Expand Down Expand Up @@ -562,7 +562,7 @@ inline void InferenceEngine<RealT>::CountInsertX(int i, int j, int s, RealT valu
Assert(0 < i && i <= LX && 0 <= j && j <= LY, "Invalid indices.");
Assert(0 <= s && s < K, "Invalid state.");

if (aligned_to_x[i] != Sequence::UNKNOWN && aligned_to_x[i] != Sequence::UNALIGNED)
if (aligned_to_x[i] != Sequence::UnKnown && aligned_to_x[i] != Sequence::UnAligned)
return;

#if PARAMS_INSERT
Expand Down Expand Up @@ -601,12 +601,12 @@ inline RealT InferenceEngine<RealT>::ScoreInsert2X(int i, int j, int s) const
Assert(0 < i && i <= LX && 0 <= j && j <= LY, "Invalid indices.");
Assert(0 <= s && s < K, "Invalid state.");

if (aligned_to_x[i] != Sequence::UNKNOWN && aligned_to_x[i] != Sequence::UNALIGNED)
if (aligned_to_x[i] != Sequence::UnKnown && aligned_to_x[i] != Sequence::UnAligned)
return RealT(NEG_INF);

return RealT(0)
#if defined(HAMMING_LOSS)
+ ((true_aligned_to_x[i] == Sequence::UNKNOWN || true_aligned_to_x[i] == Sequence::UNALIGNED) ? RealT(0) : per_position_loss)
+ ((true_aligned_to_x[i] == Sequence::UnKnown || true_aligned_to_x[i] == Sequence::UnAligned) ? RealT(0) : per_position_loss)
#endif
#if PARAMS_INSERT
+ score_insert[x[i]].first
Expand Down Expand Up @@ -637,7 +637,7 @@ inline void InferenceEngine<RealT>::CountInsert2X(int i, int j, int s, RealT val
Assert(0 < i && i <= LX && 0 <= j && j <= LY, "Invalid indices.");
Assert(0 <= s && s < K, "Invalid state.");

if (aligned_to_x[i] != Sequence::UNKNOWN && aligned_to_x[i] != Sequence::UNALIGNED)
if (aligned_to_x[i] != Sequence::UnKnown && aligned_to_x[i] != Sequence::UnAligned)
return;

#if PARAMS_INSERT
Expand Down Expand Up @@ -676,12 +676,12 @@ inline RealT InferenceEngine<RealT>::ScoreInsertY(int i, int j, int s) const
Assert(0 <= i && i <= LX && 0 < j && j <= LY, "Invalid indices.");
Assert(0 <= s && s < K, "Invalid state.");

if (aligned_to_y[j] != Sequence::UNKNOWN && aligned_to_y[j] != Sequence::UNALIGNED)
if (aligned_to_y[j] != Sequence::UnKnown && aligned_to_y[j] != Sequence::UnAligned)
return RealT(NEG_INF);

return RealT(0)
#if defined(HAMMING_LOSS)
+ ((true_aligned_to_y[j] == Sequence::UNKNOWN || true_aligned_to_y[j] == Sequence::UNALIGNED) ? RealT(0) : per_position_loss)
+ ((true_aligned_to_y[j] == Sequence::UnKnown || true_aligned_to_y[j] == Sequence::UnAligned) ? RealT(0) : per_position_loss)
#endif
#if PARAMS_INSERT
+ score_insert[y[j]].first
Expand Down Expand Up @@ -712,7 +712,7 @@ inline void InferenceEngine<RealT>::CountInsertY(int i, int j, int s, RealT valu
Assert(0 <= i && i <= LX && 0 < j && j <= LY, "Invalid indices.");
Assert(0 <= s && s < K, "Invalid state.");

if (aligned_to_y[j] != Sequence::UNKNOWN && aligned_to_y[j] != Sequence::UNALIGNED)
if (aligned_to_y[j] != Sequence::UnKnown && aligned_to_y[j] != Sequence::UnAligned)
return;

#if PARAMS_INSERT
Expand Down Expand Up @@ -751,12 +751,12 @@ inline RealT InferenceEngine<RealT>::ScoreInsert2Y(int i, int j, int s) const
Assert(0 <= i && i <= LX && 0 < j && j <= LY, "Invalid indices.");
Assert(0 <= s && s < K, "Invalid state.");

if (aligned_to_y[j] != Sequence::UNKNOWN && aligned_to_y[j] != Sequence::UNALIGNED)
if (aligned_to_y[j] != Sequence::UnKnown && aligned_to_y[j] != Sequence::UnAligned)
return RealT(NEG_INF);

return RealT(0)
#if defined(HAMMING_LOSS)
+ ((true_aligned_to_y[j] == Sequence::UNKNOWN || true_aligned_to_y[j] == Sequence::UNALIGNED) ? RealT(0) : per_position_loss)
+ ((true_aligned_to_y[j] == Sequence::UnKnown || true_aligned_to_y[j] == Sequence::UnAligned) ? RealT(0) : per_position_loss)
#endif
#if PARAMS_INSERT
+ score_insert[y[j]].first
Expand Down Expand Up @@ -787,7 +787,7 @@ inline void InferenceEngine<RealT>::CountInsert2Y(int i, int j, int s, RealT val
Assert(0 <= i && i <= LX && 0 < j && j <= LY, "Invalid indices.");
Assert(0 <= s && s < K, "Invalid state.");

if (aligned_to_y[j] != Sequence::UNKNOWN && aligned_to_y[j] != Sequence::UNALIGNED)
if (aligned_to_y[j] != Sequence::UnKnown && aligned_to_y[j] != Sequence::UnAligned)
return;

#if PARAMS_INSERT
Expand Down
8 changes: 4 additions & 4 deletions src/contralign/MultiSequence.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -503,11 +503,11 @@ std::pair<std::vector<int>, std::vector<int> > MultiSequence::GetAlignedTo() con
Assert(x.length() == y.length(), "Length mismatch.");

#if !FORCE_UNIQUE_PARSES
std::vector<int> aligned_to_x(sequences[0]->GetCompressedLength() + 1, Sequence::UNKNOWN);
std::vector<int> aligned_to_y(sequences[1]->GetCompressedLength() + 1, Sequence::UNKNOWN);
std::vector<int> aligned_to_x(sequences[0]->GetCompressedLength() + 1, Sequence::UnKnown);
std::vector<int> aligned_to_y(sequences[1]->GetCompressedLength() + 1, Sequence::UnKnown);
#else
std::vector<int> aligned_to_x(sequences[0]->GetCompressedLength() + 1, Sequence::UNALIGNED);
std::vector<int> aligned_to_y(sequences[1]->GetCompressedLength() + 1, Sequence::UNALIGNED);
std::vector<int> aligned_to_x(sequences[0]->GetCompressedLength() + 1, Sequence::UnAligned);
std::vector<int> aligned_to_y(sequences[1]->GetCompressedLength() + 1, Sequence::UnAligned);
#endif

int i = 0;
Expand Down
18 changes: 9 additions & 9 deletions src/contralign/SStruct.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ enum FileFormat
};

const int SStruct::UNPAIRED = 0;
const int SStruct::UNKNOWN = -1;
const int SStruct::UnKnown = -1;

//////////////////////////////////////////////////////////////////////
// SStruct::SStruct()
Expand Down Expand Up @@ -183,7 +183,7 @@ void SStruct::LoadFASTA(const std::string &filename)
// supply empty mapping if none found
if (!consensus_found)
{
mapping = std::vector<int>(sequences[0].length(), UNKNOWN);
mapping = std::vector<int>(sequences[0].length(), UnKnown);
}
}

Expand Down Expand Up @@ -224,7 +224,7 @@ void SStruct::LoadRAW(const std::string &filename)
if (sequences[0].length() == 1) Error("Zero-length sequence read.");

// initialize empty secondary structure
mapping.resize(sequences[0].length(), UNKNOWN);
mapping.resize(sequences[0].length(), UnKnown);
}

//////////////////////////////////////////////////////////////////////
Expand All @@ -247,7 +247,7 @@ void SStruct::LoadBPSEQ(const std::string &filename)
// initialize
names.push_back(filename);
sequences.push_back("@");
mapping.push_back(UNKNOWN);
mapping.push_back(UnKnown);

// open file
std::ifstream data(filename.c_str());
Expand Down Expand Up @@ -388,7 +388,7 @@ std::string SStruct::FilterParens(std::string sequence) const

std::vector<int> SStruct::ConvertParensToMapping(const std::string &parens) const
{
std::vector<int> mapping(parens.length(), UNKNOWN);
std::vector<int> mapping(parens.length(), UnKnown);
std::vector<int> stack;

Assert(parens[0] == '@', "Invalid parenthesized string.");
Expand Down Expand Up @@ -428,7 +428,7 @@ std::string SStruct::ConvertMappingToParens(const std::vector<int> &mapping) con

for (int i = 1; i < int(mapping.size()); i++)
{
if (mapping[i] == UNKNOWN)
if (mapping[i] == UnKnown)
parens += "?";
else if (mapping[i] == UNPAIRED)
parens += ".";
Expand All @@ -452,10 +452,10 @@ std::string SStruct::ConvertMappingToParens(const std::vector<int> &mapping) con

void SStruct::ValidateMapping(const std::vector<int> &mapping) const
{
if (mapping.size() == 0 || mapping[0] != UNKNOWN) Error("Invalid mapping.");
if (mapping.size() == 0 || mapping[0] != UnKnown) Error("Invalid mapping.");
for (int i = 1; i < int(mapping.size()); i++)
{
if (mapping[i] == UNPAIRED || mapping[i] == UNKNOWN)
if (mapping[i] == UNPAIRED || mapping[i] == UnKnown)
continue;
if (mapping[i] < 1 || mapping[i] >= int(mapping.size()))
Error("Position %d of sequence maps to invalid position.", i);
Expand All @@ -478,7 +478,7 @@ bool SStruct::ContainsPseudoknots() const

for (int i = 1; i < int(mapping.size()); i++)
{
if (mapping[i] == UNPAIRED || mapping[i] == UNKNOWN)
if (mapping[i] == UNPAIRED || mapping[i] == UnKnown)
continue;
if (mapping[i] > i)
stack.push_back(i);
Expand Down
2 changes: 1 addition & 1 deletion src/contralign/SStruct.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ class SStruct
// integer constants used to identify nucleotides which are either
// unpaired or whose pairing is not known
static const int UNPAIRED;
static const int UNKNOWN;
static const int UnKnown;

// constructor and destructor
SStruct();
Expand Down
4 changes: 2 additions & 2 deletions src/contralign/Sequence.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
#include "Sequence.hpp"

namespace CONTRALIGN {
const int Sequence::UNKNOWN = -1;
const int Sequence::UNALIGNED = 0;
const int Sequence::UnKnown = -1;
const int Sequence::UnAligned = 0;

/////////////////////////////////////////////////////////////////
// Sequence::Sequence()
Expand Down
4 changes: 2 additions & 2 deletions src/contralign/Sequence.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ class Sequence {
enum CompressGaps { COMPRESS_GAPS };
enum InsertGaps { INSERT_GAPS };

static const int UNKNOWN;
static const int UNALIGNED;
static const int UnKnown;
static const int UnAligned;

Sequence(const std::string &data, const std::string &name, int id);
Sequence(const Sequence &rhs);
Expand Down
Loading

0 comments on commit 1dc41c4

Please sign in to comment.