Skip to content

Commit 534ba6c

Browse files
committed
quickNdirty
1 parent 2e70243 commit 534ba6c

1 file changed

Lines changed: 41 additions & 46 deletions

File tree

src/IntaRNA/AccessibilityVrna.cpp

Lines changed: 41 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -60,14 +60,14 @@ AccessibilityVrna::AccessibilityVrna(
6060
// if sequence shows minimal length
6161
if (seq.size() > 4) {
6262
// window-based accessibility computation
63-
if (maxInteriorSpan >= getMaxLength()) {
64-
fillByRNAplfold(vrnaHandler
65-
, (plFoldW==0? getSequence().size() : std::min(plFoldW,getSequence().size()))
66-
, getAccConstraint().getMaxBpSpan()
67-
, &callbackForStorage
68-
, VRNA_PROBS_WINDOW_UP
69-
);
70-
} else {
63+
fillByRNAplfold(vrnaHandler
64+
, (plFoldW==0? getSequence().size() : std::min(plFoldW,getSequence().size()))
65+
, getAccConstraint().getMaxBpSpan()
66+
, &callbackForStorage
67+
, VRNA_PROBS_WINDOW_UP
68+
);
69+
// TODO replace with computations based on one plfold run
70+
if (maxInteriorSpan < getMaxLength()) {
7171
fillByRNAplfold(vrnaHandler
7272
, (plFoldW==0? getSequence().size() : std::min(plFoldW,getSequence().size()))
7373
, getAccConstraint().getMaxBpSpan()
@@ -110,7 +110,7 @@ callbackForStorage(FLT_OR_DBL *pr,
110110
void *data)
111111
{
112112
// check if expected data
113-
if (type & (VRNA_PROBS_WINDOW_UP | VRNA_ANY_LOOP)) {
113+
if ( (type & VRNA_PROBS_WINDOW_UP) && (type & VRNA_ANY_LOOP)) {
114114

115115
// access the storage data
116116
std::pair< AccessibilityVrna*, FLT_OR_DBL > storageRT = *((std::pair< AccessibilityVrna*, FLT_OR_DBL >*)data);
@@ -153,42 +153,39 @@ callbackForStorageExterior(FLT_OR_DBL *pr,
153153
unsigned int type,
154154
void *data)
155155
{
156-
// forward call to store full ED values
157-
AccessibilityVrna::callbackForStorage(pr,pr_size,j,max,type,data);
158-
159-
// check if exterior data
160-
if (type & (VRNA_PROBS_WINDOW_UP | VRNA_EXT_LOOP)) {
161-
162-
163-
LOG(DEBUG)<<"cbExt - ext";
164-
165-
// access the storage data
166-
std::pair< AccessibilityVrna*, FLT_OR_DBL > storageRT = *((std::pair< AccessibilityVrna*, FLT_OR_DBL >*)data);
167-
// direct data access for computation
168-
const FLT_OR_DBL RT = storageRT.second;
169-
EdMatrix & edValues = storageRT.first->edExteriorValues;
170-
const AccessibilityConstraint & accConstr = storageRT.first->getAccConstraint();
171-
172-
// copy unpaired data for all available interval lengths
173-
// but ensure interval does not contain blocked positions
174-
const bool rightEndBlocked = accConstr.isMarkedBlocked(j-1);
175-
for (int l = std::min(j,std::min(pr_size,std::min(max,(int)storageRT.first->getMaxLength()))); l>=1; l--) {
176-
// get unpaired probability
177-
FLT_OR_DBL prob_unpaired = pr[l];
178-
// TODO: check for [0,1] range and correct if needed (print WARNING)
179-
// get left interval boundary index
180-
int i = j - l + 1;
181-
// check if interval ends are blocked positions
182-
// check if zero before computing its log-value
183-
if (rightEndBlocked || accConstr.isMarkedBlocked(i-1) || (prob_unpaired == 0.0) ) {
184-
// ED value = ED_UPPER_BOUND
185-
edValues(i-1,j-1) = ED_UPPER_BOUND;
186-
} else {
187-
// compute ED value = E(unstructured in [i,j]) - E_all
188-
edValues(i-1,j-1) = std::max<E_type>( 0., Z_2_E( -RT*Z_type(std::log(prob_unpaired) )));
156+
if (type & VRNA_PROBS_WINDOW_UP) {
157+
158+
// check if exterior data
159+
if (type & VRNA_EXT_LOOP) {
160+
161+
// access the storage data
162+
std::pair< AccessibilityVrna*, FLT_OR_DBL > storageRT = *((std::pair< AccessibilityVrna*, FLT_OR_DBL >*)data);
163+
// direct data access for computation
164+
const FLT_OR_DBL RT = storageRT.second;
165+
EdMatrix & edValues = storageRT.first->edExteriorValues;
166+
const AccessibilityConstraint & accConstr = storageRT.first->getAccConstraint();
167+
168+
// copy unpaired data for all available interval lengths
169+
// but ensure interval does not contain blocked positions
170+
const bool rightEndBlocked = accConstr.isMarkedBlocked(j-1);
171+
for (int l = std::min(j,std::min(pr_size,std::min(max,(int)storageRT.first->getMaxLength()))); l>=1; l--) {
172+
// get unpaired probability
173+
FLT_OR_DBL prob_unpaired = pr[l];
174+
// TODO: check for [0,1] range and correct if needed (print WARNING)
175+
// get left interval boundary index
176+
int i = j - l + 1;
177+
// check if interval ends are blocked positions
178+
// check if zero before computing its log-value
179+
if (rightEndBlocked || accConstr.isMarkedBlocked(i-1) || (prob_unpaired == 0.0) ) {
180+
// ED value = ED_UPPER_BOUND
181+
edValues(i-1,j-1) = ED_UPPER_BOUND;
182+
} else {
183+
// compute ED value = E(unstructured in [i,j]) - E_all
184+
edValues(i-1,j-1) = std::max<E_type>( 0., Z_2_E( -RT*Z_type(std::log(prob_unpaired) )));
185+
}
189186
}
190-
}
191-
}
187+
}
188+
} // VRNA_PROBS_WINDOW_UP
192189
}
193190

194191
///////////////////////////////////////////////////////////////////////////////
@@ -267,8 +264,6 @@ fillByRNAplfold( const VrnaHandler &vrnaHandler
267264
}
268265
#endif
269266

270-
LOG(DEBUG) <<"fillByRNAplfold upMode = "<<upMode <<" up "<<VRNA_PROBS_WINDOW_UP<<" split "<<VRNA_PROBS_WINDOW_UP_SPLIT<<" both "<<(VRNA_PROBS_WINDOW_UP|VRNA_PROBS_WINDOW_UP_SPLIT)<<" cb = "<<callBackToStore;
271-
272267
// add maximal BP span
273268
vrna_md_t curModel = vrnaHandler.getModel( plFoldL, plFoldW );
274269

0 commit comments

Comments
 (0)