void picPunto::drawLine() { QPointF prevP, nextP; int i; for (i = 0; i < dataList.size(); ++i) { pointData *pd = dataList.at(i); if (!pd->x.isEmpty() && !pd->y.isEmpty()){ prevP.setX(getPValue(pd->x)); prevP.setY(getPValue(pd->y)); i++; break; } else { QMessageBox::information(this, "Info", QString(tr("picPunto drawLine: first point is empty %1")).arg(i)); } } for (; i < dataList.size(); ++i) { pointData *pd = dataList.at(i); if (!pd->x.isEmpty() && !pd->y.isEmpty()){ nextP.setX(getPValue(pd->x)); nextP.setY(getPValue(pd->y)); currDoc->addLine(&prevP, &nextP); // QMessageBox::information(this, "Info", QString(tr("picPunto drawLine: addLine %1 %2,%3 %4,%5")).arg(i).arg(prevP.x()).arg(prevP.y()).arg(nextP.x()).arg(nextP.y())); prevP = nextP; cnt++; } else { QMessageBox::information(this, "Info", QString(tr("picPunto drawLine: next point is empty %1")).arg(i)); } } while (!dataList.isEmpty()) delete dataList.takeFirst(); }
void picPunto::drawCircle(QString x, QString y, QString radius) { QPointF center; qreal rad; center.setX(getPValue(x)); center.setY(getPValue(y)); rad = getPValue(radius); currDoc->addCircle(¢er, rad); cnt++; }
void picPunto::drawText(QString x, QString y, QString txt, QString align) { DPI::VAlign va = DPI::VAlignBottom; DPI::HAlign ha; QString sty = "txt"; double height = 0.05 * scale; ha = (align == "ljust") ? DPI::HAlignLeft : (align == "rjust") ? DPI::HAlignRight : DPI::HAlignCenter; QPointF pt(getPValue(x), getPValue(y)); currDoc->addText(txt, sty, &pt, height, 0.0, ha, va); cnt++; }
JsonObject* SamiUnitConversion::asJsonObject() { JsonObject *pJsonObject = new JsonObject(); pJsonObject->Construct(); JsonString *pUnit_idKey = new JsonString(L"unit_id"); pJsonObject->Add(pUnit_idKey, toJson(getPUnitId(), "Integer", "")); JsonString *pStep_numberKey = new JsonString(L"step_number"); pJsonObject->Add(pStep_numberKey, toJson(getPStepNumber(), "Boolean", "")); JsonString *pOperationKey = new JsonString(L"operation"); pJsonObject->Add(pOperationKey, toJson(getPOperation(), "Boolean", "")); JsonString *pValueKey = new JsonString(L"value"); pJsonObject->Add(pValueKey, toJson(getPValue(), "Float", "")); JsonString *pCreated_atKey = new JsonString(L"created_at"); pJsonObject->Add(pCreated_atKey, toJson(getPCreatedAt(), "DateTime", "")); JsonString *pUpdated_atKey = new JsonString(L"updated_at"); pJsonObject->Add(pUpdated_atKey, toJson(getPUpdatedAt(), "DateTime", "")); return pJsonObject; }
vector_t LinearModel::getPVals() { int tmp = testParameter; vector_t res; for (testParameter = 1; testParameter < np; testParameter++) res.push_back( getPValue() ); testParameter = tmp; return res; }
JsonObject* SamiMeasurementValue::asJsonObject() { JsonObject *pJsonObject = new JsonObject(); pJsonObject->Construct(); JsonString *pStart_timeKey = new JsonString(L"start_time"); pJsonObject->Add(pStart_timeKey, toJson(getPStartTime(), "Long", "")); JsonString *pValueKey = new JsonString(L"value"); pJsonObject->Add(pValueKey, toJson(getPValue(), "Float", "")); return pJsonObject; }
JsonObject* SamiNAMeasureBodyElem::asJsonObject() { JsonObject *pJsonObject = new JsonObject(); pJsonObject->Construct(); JsonString *pBeg_timeKey = new JsonString(L"beg_time"); pJsonObject->Add(pBeg_timeKey, toJson(getPBegTime(), "Integer", "")); JsonString *pStep_timeKey = new JsonString(L"step_time"); pJsonObject->Add(pStep_timeKey, toJson(getPStepTime(), "Integer", "")); JsonString *pValueKey = new JsonString(L"value"); pJsonObject->Add(pValueKey, toJson(getPValue(), "IList", "array")); return pJsonObject; }
void picPunto::drawBox(QString posx, QString posy, QString width, QString height) { QPointF prevP, nextP; prevP.setX(getPValue(posx)); prevP.setY(getPValue(posy)); nextP.setX(getPValue(posx)+getPValue(width)); nextP.setY(prevP.y()); currDoc->addLine(&prevP, &nextP); prevP=nextP; nextP.setY(prevP.y()+getPValue(height)); currDoc->addLine(&prevP, &nextP); prevP=nextP; nextP.setX(getPValue(posx)); currDoc->addLine(&prevP, &nextP); prevP=nextP; nextP.setY(getPValue(posy)); currDoc->addLine(&prevP, &nextP); cnt++; }
SEXP getExceptional( int *G_edges, int G_nnodes, int M_Min_nnodes, int M_Max_nnodes, int *NodeToClass, double *Pi, int NbrClasses, double PValue, int Directed, int &n_prot) { // // Get all occurrences of size k = M_nnodes // // // Find all motif with size k // FindMotif find( StoreMode, 0); FindMotif f( CountMode, 0); vector<int*> *list; SparseAdjacency G( G_edges, G_nnodes, true ); // G.print( "G"); SparseAdjacency H( G_edges, G_nnodes, ! Directed ); // H.print( "H"); SEXP S_ReturnList; // All components are store even if they are NULL PROTECT( S_ReturnList = allocVector( VECSXP, M_Max_nnodes - M_Min_nnodes + 1)); n_prot++; // Index in the Returned list int i_k = 0; /// Previous non NULL value of k index int prev_k_index = -1; for ( int k= M_Min_nnodes; k <= M_Max_nnodes; k++, i_k++) { // To optimize the motifs // int perm_0[k-1]; int *perm_0 = new int[k]; int *perm_1 = new int[k]; SEXP S_Result; // Occurence list 'list' must be deallocated" // Doesn't belong to 'find' // TODO To improve find.clearFoundList(); list = find.findAllMotifs( G, k ); S_Result = sort_m_mp_u( H, G_nnodes, k, list, Pi, NodeToClass, NbrClasses, 0, -1, PValue, n_prot, false ); if ( S_Result != R_NilValue ) { // Store k value SEXP S_k; PROTECT( S_k = allocVector( INTSXP, 1) ); n_prot++; int *p_k = INTEGER_POINTER( S_k ); p_k[0] = k; SEXP S_Struct; PROTECT( S_Struct = allocVector( VECSXP, 2 )); n_prot++;; SET_VECTOR_ELT( S_Struct, 0, S_k ); SET_VECTOR_ELT( S_Struct, 1, S_Result ); SET_VECTOR_ELT( S_ReturnList, i_k, S_Struct ); SEXP S_Adj_1 = VECTOR_ELT( S_Result, 0 ); int MotifNbr_1 = LENGTH( S_Adj_1 ); // Skip First motif // if ( prev_k_index != -1 ) { for ( int k_index = 0; k_index <= (prev_k_index); k_index++ ) { SEXP S_k_value = VECTOR_ELT( VECTOR_ELT( S_ReturnList, k_index ), 0 ); int prev_k_value = INTEGER_POINTER( S_k_value ) [0]; // Get Adjacency matrix with i-1 nodes SEXP S_Adj_0 = VECTOR_ELT( VECTOR_ELT( VECTOR_ELT( S_ReturnList, k_index ), 1 ), 0); // Get M_list SEXP S_m_0 = VECTOR_ELT( VECTOR_ELT( VECTOR_ELT( S_ReturnList, k_index ), 1 ), 1); int MotifNbr_0 = LENGTH( S_Adj_0 ); for(int m = 0; m < MotifNbr_0; m++ ) { // Test NULL SEXP if( VECTOR_ELT(S_Adj_0, m) != R_NilValue ) { // int debug = LENGTH( VECTOR_ELT(S_Adj_0, m) ); int *adj_0 = INTEGER_POINTER( VECTOR_ELT(S_Adj_0, m) ); // printList( "canonic ", adj_0, adj_0+ (k-1)*(k-1), " ", true); SparseAdjacency motif0( adj_0, prev_k_value, "dense", (Directed == 0) ); SparseAdjacency motif0_canon( motif0 ); motif0.optimizeConnexity( perm_0 ); // motif0.print( "motif opt 0" ); // printList( " perm 0 ", perm_0, perm_0 + (k-1), true ); // Number of Del class SEXP S_m_mp_0 = VECTOR_ELT( S_m_0, m ); int m_mp_len_0 = LENGTH( S_m_mp_0 ); int *del_class_0 = new int[ m_mp_len_0 ]; // get the first node ID of the del class getDelClassNode( S_m_mp_0, m_mp_len_0, del_class_0 ); // printList( "Del class 0 ", del_class_0, // del_class_0 + m_mp_len_0, " ", true); // Get Degree of delete node // int deg_in_0 = 0; // int deg_out_0 = 0; for(int p = 0; p < MotifNbr_1; p++ ) { // Test NULL SEXP if( VECTOR_ELT(S_Adj_1, p) != R_NilValue ) { // int debug_1 = LENGTH( VECTOR_ELT(S_Adj_1, p) ); int *adj_1 = INTEGER_POINTER( VECTOR_ELT(S_Adj_1, p) ); #if ( MSG > 0 ) printList( "canonic 1 ", adj_1, adj_1 + (k)*(k), " ", true); #endif SparseAdjacency motif1( adj_1, k, "dense", (Directed == 0) ); SparseAdjacency motif1_canonic( motif1 ); motif1.optimizeConnexity( perm_1 ); // get M List SEXP S_m_1 = VECTOR_ELT( VECTOR_ELT( VECTOR_ELT( S_ReturnList, i_k ), 1 ), 1); // Number of Del class SEXP S_m_mp_1 = VECTOR_ELT( S_m_1, p ); int m_mp_len_1 = LENGTH( S_m_mp_1 ) ; int *del_class_1 = new int [ m_mp_len_1 ]; // get the first node ID of the del class getDelClassNode( S_m_mp_1, m_mp_len_1, del_class_1 ); // printList( "Del class 1 ", del_class_1, // del_class_1 + m_mp_len_1, " ", true); // printList( "canonic ", adj_0, adj_0 + (k-1)*(k-1), " ", true); // printList( "canonic ", adj_1, adj_1 + (k)*(k), " ", true); for( int del_0 = 0; del_0 < m_mp_len_0; del_0++) { if( del_class_0[del_0] >= 0 ) { // Get Degree of delete node int deg_in_0 = 0; int deg_out_0 = 0; if ( Directed ) { deg_in_0 = motif0_canon.getRowSize( del_class_0[ del_0 ] ); deg_out_0 = motif0_canon.getColSize( del_class_0[ del_0] ); } else { deg_in_0 = motif0_canon.getAllRowSize( del_class_0[ del_0 ] ); } for( int del_1 = 0; del_1 < m_mp_len_1; del_1++) { if( del_class_1[ del_1 ] >= 0 ) { if( getPValue( S_m_mp_1, del_1 ) <= PValue ) { if( getPValue( S_m_mp_0, del_0 ) <= PValue ) { // Get Degree of delete node int deg_in_1 = 0; int deg_out_1 = 0; if ( Directed ) { deg_in_1 = motif1_canonic.getRowSize( del_class_1[ del_1 ] ); deg_out_1 = motif1_canonic.getColSize( del_class_1[ del_1 ] ); } else { deg_in_1 = motif1_canonic.getAllRowSize( del_class_1[ del_1 ] ); } // cout << "del_0 :" << del_0 << ", del_1 :" << del_1 << endl; if ( ( deg_in_0 == deg_in_1 ) && (deg_out_0 == deg_out_1 ) ) { int *color_0 = new int [ prev_k_value ]; int *color_1 = new int [ k ]; for( int *ptr=color_0, *ptr_end= color_0 + (prev_k_value); ptr != ptr_end; ptr++ ) { *ptr=0; } for( int *ptr=color_1, *ptr_end= color_1 + (k); ptr != ptr_end; ptr++ ) { *ptr=0; } color_0[ perm_0[ del_class_0[ del_0 ] ]] = 1; color_1[ perm_1[ del_class_1[ del_1 ] ]] = 1; // printList( " color_0 ", color_0,color_0+ (k-1), true); // printList( " color_1 ", color_1,color_1+ (k), true); bool incl = f.isExactlyIncluded( motif0, motif1, color_0, color_1 ); if( incl ) { setMotifFilter( S_m_mp_1, del_1, 0, 1, m, del_class_0[ del_0 ] ); } else { setMotifFilter( S_m_mp_1, del_1, 1, 0, 0, 0 ); } // cout << "( k=" << k-1 << ", motif=" << m << ", del=" // << del_class_0[ del_0 ] << ") "; // cout << "( k=" << k << ", motif=" << p << ", del=" // << del_class_1[ del_1 ] << ") : " << incl << endl ; delete [] color_0; delete [] color_1; } else { // Different degrees => over-represented setMotifFilter( S_m_mp_1, del_1, 1, 0, 0, 0); } } else { // Parent motif not over-represented setMotifFilter( S_m_mp_1, del_1, 1, 0, 0, 0); } } else { // motif not over-represented setMotifFilter( S_m_mp_1, del_1, 0, 0, 0, 0); } } // Valid DelClass - if( del_class_1[del_1] >= 0 ) } // for( int del_1 = 0; ... } // Valid DelClass - if( del_class_0[del_0] >= 0 ) } // for( int del_0 = 0; ... delete [] del_class_1; } // if( VECTOR_ELT(S_Adj_1, p) != R_NilValue ) { } // for(int p = 0; p < MotifNbr_1; p++ ) delete [] del_class_0; } // if( VECTOR_ELT(S_Adj_0, m) != R_NilValue ) { } // for(int m = 0; m < MotifNbr_0; m++ ) { } if ( prev_k_index == -1 ) { // First value of k SEXP S_m_0 = VECTOR_ELT( VECTOR_ELT( VECTOR_ELT( S_ReturnList, i_k ), 1 ), 1); int MotifNbr_0 = LENGTH( S_m_0 ); for(int m = 0; m < MotifNbr_0; m++ ) { SEXP S_m_mp_0 = VECTOR_ELT( S_m_0, m ); if ( S_m_mp_0 != R_NilValue ) { int m_mp_len_0 = LENGTH( S_m_mp_0 ); for( int del_0 = 0; del_0 < m_mp_len_0; del_0++) { if ( VECTOR_ELT( S_m_mp_0, del_0) != R_NilValue ) { if( getPValue( S_m_mp_0, del_0 ) < PValue ) { setMotifFilter( S_m_mp_0, del_0, 1, 0, 0, 0); } else { setMotifFilter( S_m_mp_0, del_0, 0, 0, 0, 0); } } } } } // for(int m = 0; m < MotifNbr_0; m++ ) } prev_k_index = i_k; } else { // S_Result NULL } // for ( vector<int*>::iterator it = list->begin(), // it_end=list->end();it != it_end; it++ ) { // delete [] *it; // } FindMotif::deallocateFoundList( list ); delete [] perm_0; delete [] perm_1; } return S_ReturnList; }