Skip to content

Commit

Permalink
Merge pull request #177 from BackofenLab/dev
Browse files Browse the repository at this point in the history
v3.1.3
  • Loading branch information
martin-raden authored Nov 4, 2019
2 parents 892dd8b + 722a26c commit 3a31d0b
Show file tree
Hide file tree
Showing 14 changed files with 87 additions and 29 deletions.
18 changes: 18 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,23 @@
################################################################################
################################################################################

################################################################################
### version 3.1.3
################################################################################

# IntaRNA
- bugfix latest changes on traceback

################################################################################

191104 Martin Raden
* PredictorMfe2dSeedExtension::
* traceBack()
* bugfix tracback (reset of k2 iteration)

191031 Martin Raden
* using c++11 raw strings where appropriate

################################################################################
### version 3.1.2
################################################################################
Expand All @@ -27,6 +44,7 @@
- new total energy output `Etotal` = (E+Eall1+Eall2) and
`EallTotal` = (Eall+Eall1+Eall2)
- new `RT` output
- new `bpList` output

# auxiliary R scripts
- plotRegions.py - visualization of sequence regions covered by IntaRNA
Expand Down
2 changes: 1 addition & 1 deletion configure.ac
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

AC_PREREQ([2.65])
# 5 argument version only available with aclocal >= 2.64
AC_INIT([IntaRNA], [3.1.2], [], [intaRNA], [http://www.bioinf.uni-freiburg.de] )
AC_INIT([IntaRNA], [3.1.3], [], [intaRNA], [http://www.bioinf.uni-freiburg.de] )

# minimal required version of the boost library
BOOST_REQUIRED_VERSION=1.50.0
Expand Down
7 changes: 3 additions & 4 deletions src/IntaRNA/AccessibilityConstraint.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,7 @@ const std::string AccessibilityConstraint::dotBracketAlphabet =
;
const std::string AccessibilityConstraint::regionIndexList =
"["+AccessibilityConstraint::dotBracket_constraints+"]:"
+"(-?[123456789]\\d*--?[123456789]\\d*,)*-?[123456789]\\d*--?[123456789]\\d*"
;
+ R"((-?[123456789]\d*--?[123456789]\d*,)*-?[123456789]\d*--?[123456789]\d*)";

const boost::regex AccessibilityConstraint::regex(
"(["
Expand All @@ -41,14 +40,14 @@ const boost::regex AccessibilityConstraint::regex(
// D | Dm1.9 | Db-0.7 | Dm1.9b-0.7
// Z | Zb0.8
// W
const boost::regex AccessibilityConstraint::regexShapeMethod("^((D(m-?(\\d+|\\d+.\\d+))?(b-?(\\d+|\\d+.\\d+))?)|(Z(b(\\d+|\\d+.\\d+))?)|(W))$");
const boost::regex AccessibilityConstraint::regexShapeMethod(R"(^((D(m-?(\d+|\d+.\d+))?(b-?(\d+|\d+.\d+))?)|(Z(b(\d+|\d+.\d+))?)|(W))$)");

// M
// C0.2
// S
// Ls0.5i0.5
// Os0.5i-0.5
const boost::regex AccessibilityConstraint::regexShapeConversion("^((M)|(C(\\d+|\\d+.\\d+)?)|(S)|((L|O)(s-?(\\d+|\\d+.\\d+)i-?(\\d+|\\d+.\\d+))?))$");
const boost::regex AccessibilityConstraint::regexShapeConversion(R"(^((M)|(C(\d+|\d+.\d+)?)|(S)|((L|O)(s-?(\d+|\d+.\d+)i-?(\d+|\d+.\d+))?))$)");


////////////////////////////////////////////////////////////////////////
Expand Down
4 changes: 2 additions & 2 deletions src/IntaRNA/AccessibilityFromStream.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,15 +73,15 @@ parseRNAplfold_text( std::istream & inStream, const Z_type RT, const bool parseP
if ( !std::getline( inStream, line ) ) {
throw std::runtime_error("AccessibilityFromStream::parseRNAplfold_text() : nothing readable");
}
if ( ! boost::regex_match(line,boost::regex("^#[\\w\\s]+$"), boost::match_perl) ) {
if ( ! boost::regex_match(line,boost::regex(R"(^#[\w\s]+$)"), boost::match_perl) ) {
throw std::runtime_error("AccessibilityFromStream::parseRNAplfold_text() : first line != expected header line starting with '#'");
}

// parse second line = available lengths
if ( !std::getline( inStream, line ) ) {
throw std::runtime_error("AccessibilityFromStream::parseRNAplfold_text() : length header (2nd line) not found");
}
if ( ! boost::regex_match(line,boost::regex("^\\s*#i.\\s+l=1(\\s+\\d+)*\\s*$"), boost::match_perl) ) {
if ( ! boost::regex_match(line,boost::regex(R"(^\s*#i.\s+l=1(\s+\d+)*\s*$)"), boost::match_perl) ) {
throw std::runtime_error("AccessibilityFromStream::parseRNAplfold_text() : second line is no proper lengths header");
}
// check if maxLength <= max available length
Expand Down
1 change: 0 additions & 1 deletion src/IntaRNA/IndexRange.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ const size_t IndexRange::LAST_INDEX = IndexRange::NA_INDEX-1;

////////////////////////////////////////////////////////////////

//const std::string IndexRange::regexString("(0|-?[123456789]\\d*)-(0|-?[123456789]\\d*)");
const boost::regex IndexRange::regex("^"+std::string(IndexRange::regexString)+"$");

////////////////////////////////////////////////////////////////
Expand Down
2 changes: 1 addition & 1 deletion src/IntaRNA/IndexRange.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class IndexRange {
size_t to;

//! regular expression that matches valid IndexRange string encodings
static constexpr const char* regexString = "(0|-?[123456789]\\d*)-(0|-?[123456789]\\d*)";
static constexpr const char* regexString = R"((0|-?[123456789]\d*)-(0|-?[123456789]\d*))";

//! regular expression that matches valid IndexRange string encodings
static const boost::regex regex;
Expand Down
4 changes: 2 additions & 2 deletions src/IntaRNA/PredictionTrackerSpotProb.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ namespace IntaRNA {

//////////////////////////////////////////////////////////////////////

const std::string PredictionTrackerSpotProb::str_spot ="(0|-?[123456789]\\d*)&(0|-?[123456789]\\d*)";
const boost::regex PredictionTrackerSpotProb::regexSpotString("\\s*|"+str_spot+"(,"+str_spot+")*");
const std::string PredictionTrackerSpotProb::str_spot = R"((0|-?[123456789]\d*)&(0|-?[123456789]\d*))";
const boost::regex PredictionTrackerSpotProb::regexSpotString(R"(\s*|)"+str_spot+"(,"+str_spot+")*");

//////////////////////////////////////////////////////////////////////

Expand Down
12 changes: 6 additions & 6 deletions src/IntaRNA/PredictorMfe2dSeedExtension.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -392,8 +392,8 @@ traceBack( Interaction & interaction )
// check all combinations of decompositions into (i1,i2)..(k1,k2)-(si1,si2)
const size_t k1max = std::min(si1-1,i1+noLpShift+energy.getMaxInternalLoopSize1()+1);
const size_t k2max = std::min(si2-1,i2+noLpShift+energy.getMaxInternalLoopSize2()+1);
for (k1++; traceNotFound && k1<=k1max; k1++) {
for (k2++; traceNotFound && k2<=k2max; k2++) {
for (k1=i1+noLpShift+1; traceNotFound && k1<=k1max; k1++) {
for (k2=i2+noLpShift+1; traceNotFound && k2<=k2max; k2++) {
// check if (k1,k2) are valid left boundary
if ( E_isNotINF( hybridE_left(si1-k1,si2-k2) ) ) {
if ( E_equal( curE,
Expand All @@ -411,10 +411,10 @@ traceBack( Interaction & interaction )
i1=k1;
i2=k2;
curE = hybridE_left(si1-i1,si2-i2);
}
}
}
}
} // found trace step
} // (k1,k2) complementary
} // k2
} // k1
if (traceNotFound) {
LOG(ERROR) <<"left-not-found: i "<<i1<<","<<i2<<" si "<<si1<<","<<si2;
throw std::runtime_error("trace not found");
Expand Down
2 changes: 1 addition & 1 deletion src/IntaRNA/SeedHandlerExplicit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ checkSeedEncoding( const std::string & seed )
}

// check general encoding
if ( ! boost::regex_match(seed,boost::regex("^-?\\d+[|\\.]+&-?\\d+[|\\.]+$"), boost::match_perl) ) {
if ( ! boost::regex_match(seed,boost::regex(R"(^-?\d+[|\.]+&-?\d+[|\.]+$)"), boost::match_perl) ) {
return "is not of regular expression format start1dotbar1&start2dotbar2, e.g. '3|||.|&6||.||'";
}

Expand Down
4 changes: 2 additions & 2 deletions src/IntaRNA/general.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ std::ostream *
newOutputStream( const std::string & out )
{
// check if empty or whitespace string
if (boost::regex_match( out, boost::regex("^\\s*$"), boost::match_perl)) {
if (boost::regex_match( out, boost::regex(R"(^\s*$)"), boost::match_perl)) {
return NULL;
}
// open according stream
Expand Down Expand Up @@ -87,7 +87,7 @@ std::istream *
newInputStream( const std::string & in )
{
// check if empty or whitespace string
if (boost::regex_match( in, boost::regex("^\\s*$"), boost::match_perl)) {
if (boost::regex_match( in, boost::regex(R"(^\s*$)"), boost::match_perl)) {
return NULL;
}
// open according stream
Expand Down
10 changes: 8 additions & 2 deletions src/bin/CommandLineParsing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#include <cmath>
#include <stdexcept>
#include <fstream>
#include <cstdio>

#if INTARNA_MULITHREADING
#include <omp.h>
Expand Down Expand Up @@ -1099,6 +1100,11 @@ parse(int argc, char** argv)
if (parsingCode == ReturnCode::KEEP_GOING) {
try {


// parsing escape literals
outSep = unescaped_string<std::string::const_iterator>::getUnescaped( outSep );


// open output stream
{
// open according stream
Expand Down Expand Up @@ -2511,15 +2517,15 @@ getPersonality( int argc, char ** argv )
// default : check via call name
std::string value(argv[0]);
// strip path if present
size_t cutPos = value.find_last_of("/\\");
size_t cutPos = value.find_last_of(R"(/\)");
if (cutPos != std::string::npos) {
value = value.substr(cutPos+1);
}

// check if respective parameter provided
// --> overwrites default from call name
const boost::regex paramNameRegex("^--personality.*", boost::regex::icase);
const boost::regex paramRegex("^--personality=\\S+$", boost::regex::icase);
const boost::regex paramRegex(R"(^--personality=\S+$)", boost::regex::icase);
bool setViaParameter = false;
for (int i=1; i<argc; i++) {
std::string argi(argv[i]);
Expand Down
36 changes: 36 additions & 0 deletions src/bin/CommandLineParsing.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include <boost/program_options.hpp>
#include <boost/algorithm/string.hpp>
#include <boost/filesystem.hpp>
#include <boost/spirit/include/qi.hpp>

#include <iostream>
#include <cstdarg>
Expand Down Expand Up @@ -87,6 +88,41 @@ class CommandLineParsing {
}
}

template <typename InputIterator = std::string::const_iterator>
struct unescaped_string
: boost::spirit::qi::grammar<InputIterator, std::string(char const*)>
{
boost::spirit::qi::rule<InputIterator, std::string(char const*)> unesc_str;
boost::spirit::qi::symbols<char const, char const> unesc_char;

unescaped_string()
: unescaped_string::base_type(unesc_str)
{
using namespace boost::spirit;
unesc_char.add(R"(\a)", '\a')(R"(\b)", '\b')(R"(\f)", '\f')(R"(\n)", '\n')
(R"(\r)", '\r')(R"(\t)", '\t')(R"(\v)", '\v')
(R"(\\)", '\\')(R"(\')", '\'')(R"(\")", '\"')
;

unesc_str = qi::lit(qi::_r1)
>> *(unesc_char | qi::graph | qi::space | R"(\x)" >> qi::hex)
>> qi::lit(qi::_r1)
;
}

static
std::string
getUnescaped( const std::string & rawString )
{
using namespace boost::spirit;
std::string parsed;
char const* quote = ""; // leading and trailing quote string to parse
unescaped_string myGrammar;
qi::parse( rawString.begin(), rawString.end(), myGrammar(quote), parsed);
return parsed;
}
};

/**
* Identifies the requested personality from the given call arguments
*/
Expand Down
2 changes: 1 addition & 1 deletion tests/AccessibilityConstraint_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ TEST_CASE( "AccessibilityConstraint", "[AccessibilityConstraint]" ) {
boost::regex regex;

// general test
regex = boost::regex("\\s");
regex = boost::regex(R"(\s)");
REQUIRE_FALSE(boost::regex_match( "", regex, boost::match_perl ));
REQUIRE(boost::regex_match( " ", regex, boost::match_perl ));

Expand Down
12 changes: 6 additions & 6 deletions tests/PredictionTrackerProfileMinE_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ TEST_CASE( "PredictionTrackerProfileMinE", "[PredictionTrackerProfileMinE]" ) {
// LOG(DEBUG)<<"1.s2:\n"<<s2out.str();

// check output
REQUIRE( boost::regex_match(s1out.str(),boost::regex("^idx;"+r1.getId()+";minE(\\s+\\d;\\w;X){"+toString(r1.size())+"}\\s*$"), boost::match_perl) );
REQUIRE( boost::regex_match(s2out.str(),boost::regex("^idx;"+r2.getId()+";minE(\\s+\\d;\\w;X){"+toString(r2.size())+"}\\s*$"), boost::match_perl) );
REQUIRE( boost::regex_match(s1out.str(),boost::regex("^idx;"+r1.getId()+R"(;minE(\s+\d;\w;X){)"+toString(r1.size())+R"(}\s*$)"), boost::match_perl) );
REQUIRE( boost::regex_match(s2out.str(),boost::regex("^idx;"+r2.getId()+R"(;minE(\s+\d;\w;X){)"+toString(r2.size())+R"(}\s*$)"), boost::match_perl) );
}

SECTION("single range") {
Expand All @@ -58,8 +58,8 @@ TEST_CASE( "PredictionTrackerProfileMinE", "[PredictionTrackerProfileMinE]" ) {
// LOG(DEBUG)<<"2.s2:\n"<<s2out.str();

// check output
REQUIRE( boost::regex_match(s1out.str(),boost::regex("^idx;"+r1.getId()+";minE(\\s+\\d;\\w;0\\.02){2}(\\s+\\d;\\w;X){"+toString(r1.size()-2)+"}\\s*$"), boost::match_perl) );
REQUIRE( boost::regex_match(s2out.str(),boost::regex("^idx;"+r2.getId()+";minE(\\s+\\d;\\w;X){"+toString(r2.size()-2-4)+"}(\\s+\\d;\\w;0\\.02){2}(\\s+\\d;\\w;X){4}\\s*$"), boost::match_perl) );
REQUIRE( boost::regex_match(s1out.str(),boost::regex("^idx;"+r1.getId()+R"(;minE(\s+\d;\w;0\.02){2}(\s+\d;\w;X){)"+toString(r1.size()-2)+R"(}\s*$)"), boost::match_perl) );
REQUIRE( boost::regex_match(s2out.str(),boost::regex("^idx;"+r2.getId()+R"(;minE(\s+\d;\w;X){)"+toString(r2.size()-2-4)+R"(}(\s+\d;\w;0\.02){2}(\s+\d;\w;X){4}\s*$)"), boost::match_perl) );
}


Expand All @@ -79,8 +79,8 @@ TEST_CASE( "PredictionTrackerProfileMinE", "[PredictionTrackerProfileMinE]" ) {
// LOG(DEBUG)<<"3.s2:\n"<<s2out.str();

// check output
REQUIRE( boost::regex_match(s1out.str(),boost::regex("^idx;"+r1.getId()+";minE(\\s+\\d;\\w;0\\.02)(\\s+\\d;\\w;0\\.01){2}(\\s+\\d;\\w;X){"+toString(r1.size()-3)+"}\\s*$"), boost::match_perl) );
REQUIRE( boost::regex_match(s2out.str(),boost::regex("^idx;"+r2.getId()+";minE(\\s+\\d;\\w;X){"+toString(r2.size()-3-4)+"}(\\s+\\d;\\w;0\\.01){2}(\\s+\\d;\\w;0\\.02)(\\s+\\d;\\w;X){4}\\s*$"), boost::match_perl) );
REQUIRE( boost::regex_match(s1out.str(),boost::regex("^idx;"+r1.getId()+R"(;minE(\s+\d;\w;0\.02)(\s+\d;\w;0\.01){2}(\s+\d;\w;X){)"+toString(r1.size()-3)+R"(}\s*$)"), boost::match_perl) );
REQUIRE( boost::regex_match(s2out.str(),boost::regex("^idx;"+r2.getId()+R"(;minE(\s+\d;\w;X){)"+toString(r2.size()-3-4)+R"(}(\s+\d;\w;0\.01){2}(\s+\d;\w;0\.02)(\s+\d;\w;X){4}\s*$)"), boost::match_perl) );
}


Expand Down

0 comments on commit 3a31d0b

Please sign in to comment.