MainWindow::MainWindow( QWidget *parent ): QMainWindow( parent ) { this->createParameterInputWindow(); this->createMainWindow(); connect( check_original_fun, SIGNAL( clicked() ), this, SLOT( checkOriginal() ) ); connect( start_evolve, SIGNAL( clicked() ), this, SLOT( startEvolve() ) ); connect(dateback_btn, SIGNAL( clicked() ), this, SLOT( dateBack() ) ); connect( individual_num_input, SIGNAL( valueChanged(int) ), this, SLOT( parameterChange() ) ); connect( generation_num_input, SIGNAL( valueChanged(int) ), this, SLOT( parameterChange() ) ); connect( crossover_rate_input, SIGNAL(valueChanged(double)), this, SLOT( parameterChange() ) ); connect( mutation_rate_input, SIGNAL(valueChanged(double)), this, SLOT( parameterChange() ) ); connect( range_min_input, SIGNAL(valueChanged(double)), this, SLOT(parameterChange()) ); connect( range_max_input, SIGNAL(valueChanged(double)), this, SLOT(parameterChange()) ); connect( min_btn, SIGNAL( clicked() ), this, SLOT( parameterChange() ) ); connect( max_btn, SIGNAL( clicked() ), this, SLOT( parameterChange() ) ); connect(range_min_input, SIGNAL(valueChanged(double)), this, SLOT( originalParaChange()) ); connect(range_max_input, SIGNAL(valueChanged(double)), this, SLOT( originalParaChange()) ); connect(individual_num_input, SIGNAL( valueChanged(int) ), this, SLOT( originalParaChange() ) ); connect( dateback_btn, SIGNAL( clicked() ), this, SLOT( dateBack() ) ); }
void HHGate::setupTau( const Eref& e, vector< double > parms ) { if ( checkOriginal( e.id(), "setupTau" ) ) { if ( parms.size() != 13 ) { cout << "HHGate::setupTau: Error: parms.size() != 13\n"; return; } setupTables( parms, true ); } }
void HHGate::setTableB( const Eref& e, vector< double > v ) { if ( checkOriginal( e.id(), "tableB" ) ) { isDirectTable_ = 1; if ( A_.size() != v.size() ) { cout << "Warning: HHGate::setTableB: size should be same as table A: " << v.size() << " != " << A_.size() << ". Ignoring.\n"; return; } B_ = v; } }
void HHGate::setTableA( const Eref& e, vector< double > v ) { if ( v.size() < 2 ) { cout << "Warning: HHGate::setTableA: size must be >= 2 entries on " << e.id().path() << endl; return; } if ( checkOriginal( e.id(), "tableA" ) ) { isDirectTable_ = 1; A_ = v; unsigned int xdivs = A_.size() - 1; invDx_ = static_cast< double >( xdivs ) / ( xmax_ - xmin_ ); } }
void HHGate::setMinfinity( const Eref& e, vector< double > val ) { if ( val.size() != 5 ) { cout << "Error: HHGate::setMinfinity on " << e.id().path() << ": Number of entries on argument vector should be 5, was " << val.size() << endl; return; } if ( checkOriginal( e.id(), "mInfinity" ) ) { mInfinity_ = val; updateAlphaBeta(); updateTables(); } }
void HHGate::setAlpha( const Eref& e, vector< double > val ) { if ( val.size() != 5 ) { cout << "Error: HHGate::setAlpha on " << e.id().path() << ": Number of entries on argument vector should be 5, was " << val.size() << endl; return; } if ( checkOriginal( e.id(), "alpha" ) ) { alpha_ = val; updateTauMinf(); updateTables(); } }
void HHGate::setMin( const Eref& e, double val ) { if ( checkOriginal( e.id(), "min" ) ) { xmin_ = val; unsigned int xdivs = A_.size() - 1; if ( isDirectTable_ && xdivs > 0 ) { // Stuff here to stretch out table using interpolation. invDx_ = static_cast< double >( xdivs ) / ( xmax_ - val ); tabFill( A_, xdivs, val, xmax_ ); tabFill( B_, xdivs, val, xmax_ ); } else { updateTables(); } } }
void HHGate::setDivs( const Eref& e, unsigned int val ) { if ( checkOriginal( e.id(), "divs" ) ) { if ( isDirectTable_ ) { invDx_ = static_cast< double >( val ) / ( xmax_ - xmin_ ); tabFill( A_, val, xmin_, xmax_ ); tabFill( B_, val, xmin_, xmax_ ); } else { /// Stuff here to redo sizes. A_.resize( val + 1 ); B_.resize( val + 1 ); invDx_ = static_cast< double >( val ) / ( xmax_ - xmin_ ); updateTables(); } } }
void HHGate::setMax( const Eref& e, double val ) { if ( checkOriginal( e.id(), "max" ) ) { xmax_ = val; unsigned int xdivs = A_.size() - 1; if ( isDirectTable_ && xdivs > 0 ) { // Set up using direct assignment of table values. invDx_ = static_cast< double >( xdivs ) / ( val - xmin_ ); tabFill( A_, xdivs, xmin_, val ); tabFill( B_, xdivs, xmin_, val ); } else { // Set up using functional form. here we just recalculate. updateTables(); } } }
void HHGate::setupAlpha( const Eref& e, vector< double > parms ) { if ( checkOriginal( e.id(), "setupAlpha" ) ) { if ( parms.size() != 13 ) { cout << "HHGate::setupAlpha: Error: parms.size() != 13\n"; return; } setupTables( parms, false ); alpha_.resize( 5, 0 ); beta_.resize( 5, 0 ); for ( unsigned int i = 0; i < 5; ++i ) alpha_[i] = parms[i]; for ( unsigned int i = 5; i < 10; ++i ) beta_[i - 5] = parms[i]; } }
void HHChannel2D::destroyGate( const Eref& e, const Qinfo* q, string gateType ) { if ( !checkOriginal( e.id() ) ) { cout << "Warning: HHChannel2D::destroyGate: Not allowed from copied channel:\n" << e.id().path() << "\n"; return; } if ( gateType == "X" ) innerDestroyGate( "xGate", &xGate_, e.id() ); else if ( gateType == "Y" ) innerDestroyGate( "yGate", &yGate_, e.id() ); else if ( gateType == "Z" ) innerDestroyGate( "zGate", &zGate_, e.id() ); else cout << "Warning: HHChannel2D::destroyGate: Unknown gate type '" << gateType << "'. Ignored\n"; }
void HHChannel::vCreateGate( const Eref& e, string gateType ) { if ( !checkOriginal( e.id() ) ) { cout << "Warning: HHChannel::createGate: Not allowed from copied channel:\n" << e.id().path() << "\n"; return; } if ( gateType == "X" ) innerCreateGate( "xGate", &xGate_, e.id(), Id(e.id().value() + 1) ); else if ( gateType == "Y" ) innerCreateGate( "yGate", &yGate_, e.id(), Id(e.id().value() + 2) ); else if ( gateType == "Z" ) innerCreateGate( "zGate", &zGate_, e.id(), Id(e.id().value() + 3) ); else cout << "Warning: HHChannel::createGate: Unknown gate type '" << gateType << "'. Ignored\n"; }
int processBlatQuery( BlatQuery* blQ, int *idxOrig , float cutoff) { int i,j; PslEntry *curr; int sizes[ arrayMax( blQ->entries ) ]; *idxOrig = -1; for( i=0; i<arrayMax(blQ->entries); i++ ) { curr = arrp( blQ->entries, i, PslEntry ); sizes[i]=0; for( j=0; j < arrayMax( curr->blockSizes ); j++) sizes[i] += arru( curr->blockSizes, j, int); sizes[i] -= curr->misMatches; if( checkOriginal ( blQ, curr ) == 1 ) *idxOrig = i; } if( *idxOrig < 0 ) die("Cannot find exact match: %s", blQ->qName); int sizeOrig = sizes[ *idxOrig ]; for( i=0; i< arrayMax( blQ->entries ); i++ ) { curr = arrp( blQ->entries, i, PslEntry ); warn( "%s\t%s\t%d\t%d\t[ %d, %d - %f]\t%d\t--\t%d\t%d\t%d", blQ->qName, curr->tName, curr->tStart, curr->tEnd, sizes[i], sizeOrig, ( (float)sizes[i] / (float)sizeOrig ) ,curr->blockCount, curr->misMatches, curr->qNumInsert, curr->tNumInsert); if( ( (float)sizes[i] / (float)sizeOrig ) > cutoff && (i != *idxOrig) ) return 1; } return 0; }
void HHGate::setupGate( const Eref& e, vector< double > parms ) { // The nine arguments are : // A B C D F size min max isbeta // If size == 0 then we check that the gate has already been allocated. // If isbeta is true then we also have to do the conversion to // HHGate form of alpha, alpha+beta, assuming that the alpha gate // has already been setup. This uses tweakTables. // We may need to resize the tables if they don't match here. if ( !checkOriginal( e.id(), "setupGate" ) ) return; if ( parms.size() != 9 ) { cout << "HHGate::setupGate: Error: parms.size() != 9\n"; return; } double A = parms[0]; double B = parms[1]; double C = parms[2]; double D = parms[3]; double F = parms[4]; int size = static_cast< int > (parms[5] ); double min = parms[6]; double max = parms[7]; bool isBeta = static_cast< bool >( parms[8] ); vector< double >& ip = ( isBeta ) ? B_ : A_; if ( size <= 0 ) { // Look up size, min, max from the interpol size = ip.size() - 1; if ( size <= 0 ) { cout << "Error: setupGate has zero size\n"; return; } } else { ip.resize( size + 1 ); } double dx = ( max - min ) / static_cast< double >( size ); double x = min + dx / 2.0; for ( int i = 0; i <= size; i++ ) { if ( fabs ( F ) < SINGULARITY ) { ip[i] = 0.0; } else { double temp2 = C + exp( ( x + D ) / F ); if ( fabs( temp2 ) < SINGULARITY ) ip[i] = ip[i-1]; else ip[i] = ( A + B * x ) / temp2; } } if ( isBeta ) { assert( A_.size() > 0 ); // Here we ensure that the tables are the same size if ( A_.size() != B_.size() ) { if ( A_.size() > B_.size() ) { // Note that the tabFill expects to allocate the // terminating entry, so we put in size - 1. tabFill( B_, A_.size() - 1, xmin_, xmax_ ); } else { tabFill( A_, B_.size() - 1, xmin_, xmax_ ); } } // Then we do the tweaking to convert to HHChannel form. tweakTables( 0 ); } }
void HHGate::setUseInterpolation( const Eref& e, bool val ) { if ( checkOriginal( e.id(), "useInterpolation" ) ) lookupByInterpolation_ = val; }