From 072abb046f7f4073441d97c0c6e63ec2a7566070 Mon Sep 17 00:00:00 2001 From: martin-mann Date: Thu, 11 Feb 2021 16:43:21 +0100 Subject: [PATCH] first step... --- src/IntaRNA/Accessibility.cpp | 8 ++++---- src/IntaRNA/AccessibilityDisabled.h | 3 ++- src/IntaRNA/AccessibilityFromStream.cpp | 5 +++-- src/IntaRNA/AccessibilityFromStream.h | 3 ++- src/IntaRNA/AccessibilityVrna.cpp | 12 ++++++++++-- src/IntaRNA/AccessibilityVrna.h | 3 ++- src/bin/CommandLineParsing.cpp | 4 ++-- 7 files changed, 25 insertions(+), 13 deletions(-) diff --git a/src/IntaRNA/Accessibility.cpp b/src/IntaRNA/Accessibility.cpp index 9c15f59f..0685ea2d 100644 --- a/src/IntaRNA/Accessibility.cpp +++ b/src/IntaRNA/Accessibility.cpp @@ -30,7 +30,7 @@ operator<<(std::ostream& out, const Accessibility& acc) // print first (without delimiter) out <=0?" ":"") < omit accessibility diff --git a/src/IntaRNA/AccessibilityFromStream.cpp b/src/IntaRNA/AccessibilityFromStream.cpp index 0f555a7f..208bac51 100644 --- a/src/IntaRNA/AccessibilityFromStream.cpp +++ b/src/IntaRNA/AccessibilityFromStream.cpp @@ -102,7 +102,8 @@ parseRNAplfold_text( std::istream & inStream, const Z_type RT, const bool parseP } // resize data structure to fill - edValues.resize( getSequence().size(), getSequence().size(), 0, getMaxLength() ); + // 1 larger to enable dangling end computation + edValues.resize( getSequence().size(), getSequence().size(), 0, 1+getMaxLength() ); // TODO rewrite to support "nan" and "inf" parsing via boost::spirit::qi // http://stackoverflow.com/questions/11420263/is-it-possible-to-read-infinity-or-nan-values-using-input-streams @@ -136,7 +137,7 @@ parseRNAplfold_text( std::istream & inStream, const Z_type RT, const bool parseP // parse probabilities or EDs for this line and store double curVal; - size_t minI = j - std::min( j, getMaxLength() ); + size_t minI = j - std::min( j, 1+getMaxLength() ); for ( size_t i = j; i>minI; i--) { if ( inStream >>curVal ) { // check if we parse probabilities diff --git a/src/IntaRNA/AccessibilityFromStream.h b/src/IntaRNA/AccessibilityFromStream.h index 7f4e2d39..cdfc82a2 100644 --- a/src/IntaRNA/AccessibilityFromStream.h +++ b/src/IntaRNA/AccessibilityFromStream.h @@ -139,7 +139,8 @@ getED( const size_t from, const size_t to ) const // input range check checkIndices(from,to); - if ((to-from+1) <= getMaxLength()) { + // 1 larger to enable dangling end computation + if ((to-from+1) <= 1+getMaxLength()) { // check for constrained end positions if (!getAccConstraint().isAccessible(from) || !getAccConstraint().isAccessible(to)) { // end position blocked --> omit accessibility diff --git a/src/IntaRNA/AccessibilityVrna.cpp b/src/IntaRNA/AccessibilityVrna.cpp index 100c3396..8105817d 100644 --- a/src/IntaRNA/AccessibilityVrna.cpp +++ b/src/IntaRNA/AccessibilityVrna.cpp @@ -47,8 +47,16 @@ AccessibilityVrna::AccessibilityVrna( ) : Accessibility( seq, maxLength, accConstraint ), - edValues( getSequence().size(), getSequence().size(), 0, getMaxLength() ) + // 1 larger to enable dangling end computation + edValues( getSequence().size(), getSequence().size(), 0, 1+getMaxLength() ) { + +#if INTARNA_IN_DEBUG_MODE + if (plFoldW <= maxLength) { + throw std::runtime_error("AccessibilityVrna::AccessibilityVrna() : plFoldW("+toString(plFoldW)+" <= maxLength"+toString(maxLength)); + } +#endif + // if sequence shows minimal length if (seq.size() > 4) { // window-based accessibility computation @@ -97,7 +105,7 @@ callbackForStorage(FLT_OR_DBL *pr, // copy unpaired data for all available interval lengths // but ensure interval does not contain blocked positions const bool rightEndBlocked = accConstr.isMarkedBlocked(j-1); - for (int l = std::min(j,std::min(pr_size,std::min(max,(int)storageRT.first->getMaxLength()))); l>=1; l--) { + for (int l = std::min(j,std::min(pr_size,std::min(max,1+(int)storageRT.first->getMaxLength()))); l>=1; l--) { // get unpaired probability FLT_OR_DBL prob_unpaired = pr[l]; // TODO: check for [0,1] range and correct if needed (print WARNING) diff --git a/src/IntaRNA/AccessibilityVrna.h b/src/IntaRNA/AccessibilityVrna.h index 9b1c78df..4c386a0b 100644 --- a/src/IntaRNA/AccessibilityVrna.h +++ b/src/IntaRNA/AccessibilityVrna.h @@ -144,7 +144,8 @@ getED( const size_t from, const size_t to ) const // input range check checkIndices(from,to); - if ((to-from+1) <= getMaxLength()) { + // 1 larger to enable dangling end computation + if ((to-from+1) <= (1+getMaxLength()) ) { // check for constrained end positions if (!getAccConstraint().isAccessible(from) || !getAccConstraint().isAccessible(to)) { // end position blocked --> omit accessibility diff --git a/src/bin/CommandLineParsing.cpp b/src/bin/CommandLineParsing.cpp index e73cfee6..3a4d61e2 100644 --- a/src/bin/CommandLineParsing.cpp +++ b/src/bin/CommandLineParsing.cpp @@ -791,7 +791,7 @@ CommandLineParsing::CommandLineParsing( const Personality personality ) , value(&(intLenMax.val)) ->default_value(intLenMax.def) ->notifier(boost::bind(&CommandLineParsing::validate_numberArgument,this,intLenMax,_1)) - , std::string("interaction site : maximal window size to be considered for" + , std::string("interaction site : maximal subsequence length considered for" " interaction" " (arg in range ["+toString(intLenMax.min)+","+toString(intLenMax.max)+"];" " 0 refers to the full sequence length)." @@ -1403,7 +1403,7 @@ parse(int argc, char** argv) throw error("qAccL = " +toString(qAccL.val) + " : has to be <= qAccW (=" +toString(qAccW.val) + ")"); } - // check qAcc upper bound + // check tAcc upper bound if (tAccL.val > tAccW.val && tAccW.val != 0) { throw error("tAccL = " +toString(tAccL.val)+" : has to be <= tAccW (=" +toString(tAccW.val)+")"); }