void TransferFunctionControlPointConnection::updateShape() { if (left_ == nullptr && right_ == nullptr) { path_ = QPainterPath(); } path_ = QPainterPath(getStart()); path_.lineTo(getStop()); rect_ = path_.boundingRect(); QPainterPathStroker pathStrocker; pathStrocker.setWidth(10.0); shape_ = pathStrocker.createStroke(path_); prepareGeometryChange(); update(); }
void testNextStart() const { char const * e = getStart(); while ( e ) { std::cerr << std::string(80,'-') << std::endl; std::cerr << std::string(e,static_cast<char const *>(pc)); FastQEntryStats entry; computeEntryStats(e,entry); std::cerr << "namelen=" << entry.namelen << ",seqlen=" << entry.seqlen << ",pluslen=" << entry.pluslen << std::endl; e = nextStart(e); } }
bool TimeBase::isRunning() { if (_paused && _pausedRate != 0) return true; Common::Rational rate = getRate(); if (rate == 0) return false; if (getFlags() & kLoopTimeBase) return true; if (rate > 0) return getTime() != getStop(); return getTime() != getStart(); }
static void notifyParent( HWND hwnd, UINT code = 0 ) { // NM_ code TODO NMRANGESLIDER nm = { { 0 } }; nm.hdr.hwndFrom = hwnd; nm.hdr.idFrom = GetWindowID( hwnd ); nm.hdr.code = code; nm.rsInfo._lower = getLower ( hwnd ); nm.rsInfo._upper = getUpper ( hwnd ); nm.rsInfo._start = getStart ( hwnd ); nm.rsInfo._end = getEnd ( hwnd ); nm.rsInfo._minRange = getMinRange ( hwnd ); nm.rsInfo._granularity = getGranularity( hwnd ); FORWARD_WM_NOTIFY( GetParent( hwnd ), nm.hdr.idFrom, &nm, SNDMSG ); }
void magic(int start, int end){ if (differences[start]){ update(start, 1); update(end+1, -1); } else { int rangeStart = getStart(start); int rangeEnd = getEnd(start); int sizeofChunk = rangeEnd - start + 1; update(rangeStart, 1); update(rangeStart + sizeofChunk, -1); if (rangeEnd+1 <= maxIndex){ update(rangeEnd+1, 1); update(maxIndex+1, -1); } } }
void SymbolicList::evalDollar(GVN & gvn, const GVN::Value * dollarVal) { if (GVN::Value * const dollar = gvn.getExistingValue(symbol::Symbol(L"$"))) { if (GVN::Value * v = evalDollar(gvn, getStart(), dollar, dollarVal)) { setStart(v); } if (GVN::Value * v = evalDollar(gvn, getStep(), dollar, dollarVal)) { setStep(v); } if (GVN::Value * v = evalDollar(gvn, getEnd(), dollar, dollarVal)) { setEnd(v); } } }
void Transfer::getParams(const UserConnection& aSource, StringMap& params) { params["userCID"] = aSource.getUser()->getCID().toBase32(); params["userNI"] = Util::toString(ClientManager::getInstance()->getNicks(aSource.getUser()->getCID(), aSource.getHubUrl())); params["userI4"] = aSource.getRemoteIp(); StringList hubNames = ClientManager::getInstance()->getHubNames(aSource.getUser()->getCID(), aSource.getHubUrl()); if(hubNames.empty()) hubNames.push_back(_("Offline")); params["hub"] = Util::toString(hubNames); StringList hubs = ClientManager::getInstance()->getHubs(aSource.getUser()->getCID(), aSource.getHubUrl()); if(hubs.empty()) hubs.push_back(_("Offline")); params["hubURL"] = Util::toString(hubs); params["fileSI"] = Util::toString(getSize()); params["fileSIshort"] = Util::formatBytes(getSize()); params["fileSIactual"] = Util::toString(getActual()); params["fileSIactualshort"] = Util::formatBytes(getActual()); params["speed"] = str(F_("%1%/s") % Util::formatBytes(getAverageSpeed())); params["time"] = Util::formatSeconds((GET_TICK() - getStart()) / 1000); params["fileTR"] = getTTH().toBase32(); }
void SubString::executePlanOperation() { auto in = std::const_pointer_cast<storage::AbstractTable>(input.getTable(0)); storage::TableBuilder::param_list list; for (unsigned i = 0; i < _field_definition.size(); ++i) { list.append().set_type("STRING").set_name(getColName(i)); } auto resultTable = storage::TableBuilder::build(list); resultTable->resize(in->size()); for (size_t row = 0; row < in->size(); row++) { for (size_t col = 0; col < _field_definition.size(); col++) { resultTable->setValue<hyrise_string_t>( col, row, (in->getValue<std::string>(_field_definition[col], row)).substr(getStart(col), getCount(col))); } } addResult(std::make_shared<storage::MutableVerticalTable>(std::vector<storage::atable_ptr_t>{in, resultTable})); }
PoolAllocator<T>::PoolAllocator(std::size_t numOf) : BaseAllocator(sizeof(T) * numOf) { std::size_t newSize = sizeof(T) * numOf; *freeList = std::align(alignof(T), sizeof(T), *freeList, newSize); if(!freeList || !*freeList) { throw std::bad_alloc(); } // gather all blocks into freeList for(std::size_t i = 0; i < numOf; i++) { *freeList = freeList + sizeof(T); freeList = static_cast<void**>(*freeList); } *freeList = nullptr; freeList = static_cast<void**>(getStart()); }
//单击“添加旅客”按钮,开始运行 void Widget::addTravelerButtonClicked() { //添加旅客,初始化旅客信息 qDebug() << "Add new traveler, reset all elements in widget"; std::vector<bool> temp(12, false); throughcity = temp; qDebug() << "throughcity creat success."; travelers.push_back(Traveler(addtravelertimes-1, getStartTime(), getDeadline(), getStrategy(), getStart(), getDestination(), ui->ThroughCityCheckBox->isChecked(), throughcity)); qDebug() << "travelers.pushback..."; startclicked.push_back(false); addtravelertimes += 1; startclickedtimes = 0; //将界面右侧各栏初始化显示 ui->TravelerComboBox->addItem(QString::number(addtravelertimes)); ui->TravelerComboBox->setCurrentText(QString::number(addtravelertimes)); ui->StartButton->setText(QString::fromWCharArray(L"开始")); ui->TravelerComboBox->setEnabled(true); ui->StartComboBox->setEnabled(true); ui->StrategyComboBox->setEnabled(true); ui->DestinationComboBox->setEnabled(true); ui->StrategyComboBox->setCurrentIndex(0); ui->StartComboBox->setCurrentIndex(0); ui->DestinationComboBox->setCurrentIndex(1); ui->ThroughCityCheckBox->setEnabled(true); ui->DeadlineDateTimeEdit->setEnabled(false); ui->StartDateTimeEdit->setEnabled(true); ui->StartButton->setEnabled(true); ui->StartDateTimeEdit->setDateTime(QDateTime::currentDateTime()); int deaDay = QDateTime::currentDateTime().date().day(); deaDay += 1; QDateTime deadlineDateTime; deadlineDateTime.setDate(QDate(QDateTime::currentDateTime().date().year(), QDateTime::currentDateTime().date().month(), deaDay)); deadlineDateTime.setTime(QTime(QDateTime::currentDateTime().time())); ui->DeadlineDateTimeEdit->setDateTime(deadlineDateTime); }
void Transfer::getParams(const UserConnection& aSource, StringMap& params) const { params["userCID"] = aSource.getUser()->getCID().toBase32(); params["userNI"] = Util::toString(ClientManager::getInstance()->getNicks(aSource.getUser()->getCID(), aSource.getHubUrl())); params["userI4"] = aSource.getRemoteIp(); StringList hubNames = ClientManager::getInstance()->getHubNames(aSource.getUser()->getCID(), aSource.getHubUrl()); if(hubNames.empty()) hubNames.push_back(STRING(OFFLINE)); params["hub"] = Util::toString(hubNames); StringList hubs = ClientManager::getInstance()->getHubs(aSource.getUser()->getCID(), aSource.getHubUrl()); if(hubs.empty()) hubs.push_back(STRING(OFFLINE)); params["hubURL"] = Util::toString(hubs); params["fileSI"] = Util::toString(getSize()); params["fileSIshort"] = Util::formatBytes(getSize()); params["fileSIchunk"] = Util::toString(getPos()); params["fileSIchunkshort"] = Util::formatBytes(getPos()); params["fileSIactual"] = Util::toString(getActual()); params["fileSIactualshort"] = Util::formatBytes(getActual()); params["speed"] = Util::formatBytes(static_cast<int64_t>(getAverageSpeed())) + "/s"; params["time"] = Text::fromT(Util::formatSeconds((GET_TICK() - getStart()) / 1000)); params["fileTR"] = getTTH().toBase32(); }
void Transfer::updateRunningAverage() { time_t tick = GET_TICK(); // Update 4 times/sec at most if(tick > (lastTick + 250)) { time_t diff = tick - lastTick; int64_t tot = getTotal(); if( ((tick - getStart()) < AVG_PERIOD) ) { runningAverage = getAverageSpeed(); } else { int64_t bdiff = tot - last; int64_t avg = bdiff * (int64_t)1000 / diff; if(diff > AVG_PERIOD) { runningAverage = avg; } else { // Weighted average... runningAverage = ((avg * diff) + (runningAverage*(AVG_PERIOD-diff)))/AVG_PERIOD; } } last = tot; } lastTick = tick; }
void diffTime(const char *str) { std::chrono::system_clock::time_point start = getStart(str); std::chrono::system_clock::time_point now = std::chrono::system_clock::now(); std::chrono::microseconds delay = std::chrono::duration_cast<std::chrono::microseconds>(now - start); div_t res; if(mapDelay[str].count() > 0) { long a = delay.count() + mapDelay[str].count(); res = div(a, 2); delay = std::chrono::microseconds(res.quot); } mapDelay[str] = delay; typedef std::chrono::duration<int, std::milli> milliseconds_type; std::chrono::time_point<std::chrono::system_clock, milliseconds_type> Start = std::chrono::time_point_cast<milliseconds_type>(start); std::chrono::time_point<std::chrono::system_clock, milliseconds_type> End = std::chrono::time_point_cast<milliseconds_type>(now); fs << str; fs << ", " << Start.time_since_epoch().count(); fs << ", " << End.time_since_epoch().count(); fs << std::endl; }
// Gets start and end points in dictionary for a certain wordlength // Gets a pointer to a new dictionary with only the specified wordlength // Creates new int64_t* array containing ciphertext for subroutine // Decrypts using map, which returns the decryption key // Prints the key and the plaintext // Frees all malloc'd resources created in block int64_t* executeSubroutine(char** words, char* ciphertextchars, int ciphertextlength, int wordlength, int keylength, int64_t* tm, int mapnum){ int start=0, end=0, wordcount=0, i=0; // Get a new short dictionary int64_t** wordlengthOnly = getShortDictionary(words, wordlength); int64_t* foundkey = Cache_Aligned_Allocate(keylength * sizeof(int64_t)); start = getStart(words, wordlength); end = getEnd(words, wordlength); wordcount = end - start + 1; int64_t* ciphertext = malloc(sizeof(int64_t) * (ciphertextlength+1)); // Extra for null char for(i = 0; i < ciphertextlength; i++){ ciphertext[i] = (int64_t)ciphertextchars[i]; } // Decrypt on MAP subr (&wordlengthOnly[0][0], ciphertext, ciphertextlength, foundkey, wordcount, wordlength, keylength, &tm, mapnum); char *key = malloc(sizeof(char) * (keylength+1)); key[keylength] = '\0'; printf("MAP subroutine found key '"); for(i = 0; i < keylength; i++){ printf("%c", (char)(foundkey[i]) ); key[i] = (char)foundkey[i]; } printf("' and plaintext %s \n", decrypt( ciphertextchars, ciphertextlength, key, keylength )); printf ("MAP completed in %lld clocks.\n", tm); free(foundkey); freeShortDictionary(wordlengthOnly, wordcount); free(ciphertext); free(key); return tm; }
// To evaluate a binary operation is to evaluate the two operands and apply the // operator to them. ValueAST *BinaryOp::eval(Environment &env) const { std::unique_ptr<ValueAST> left{lhs->eval(env)}; std::unique_ptr<ValueAST> right{rhs->eval(env)}; if (!left || !right) return nullptr; BinaryOpFunction func = findWithDefault(binaryFunctionMap, op, nullptr); assert(func); ValueAST *result = (*left.*func)(right.get(), env); if (result == (ValueAST *) -1) { env.errorContext.printMessage("invalid operands to binary expression", getStart(), left->getStart(), left->getEnd(), right->getStart(), right->getEnd()); result = nullptr; } // No need to adjust bounds; the implementation function returns an // expression with the LHS's start and RHS's end. return result; }
bool FogChunk::operator == (const StateChunk &other) const { FogChunk const *tother = dynamic_cast<FogChunk const *>(&other); if(tother == NULL) return false; if(getMode() != tother->getMode()) return false; if(getDensity() != tother->getDensity()) return false; if(getStart() != tother->getStart()) return false; if(getEnd() != tother->getEnd()) return false; if(getColor() != tother->getColor()) return false; return true; }
bool parallelPlanning(bool output, enum SPACE_TYPE space, std::vector<enum PLANNER_TYPE> &planners, unsigned int links, unsigned int chains, struct ConstrainedOptions &c_opt, struct AtlasOptions &a_opt, bool bench) { // Create a shared pointer to our constraint. auto constraint = std::make_shared<ParallelConstraint>(links, chains); ConstrainedProblem cp(space, constraint->createSpace(), constraint); cp.setConstrainedOptions(c_opt); cp.setAtlasOptions(a_opt); cp.css->registerProjection("parallel", constraint->getProjection(cp.css)); Eigen::VectorXd start, goal; constraint->getStart(start); constraint->getGoal(goal); cp.setStartAndGoalStates(start, goal); cp.ss->setStateValidityChecker(std::bind(&ParallelConstraint::isValid, constraint, std::placeholders::_1)); if (!bench) return parallelPlanningOnce(cp, planners[0], output); else return parallelPlanningBench(cp, planners); }
bool Interval::operator<(const Interval & b) const { if(getStart() == b.getStart()){ return (getStop() < b.getStop()); } return (getStart() < b.getStart()); }
bool Interval::overlaps(const Interval & b, bool strand_specific){ if(getStrand() == b.getStrand() || getStrand() == BOTH || b.getStrand() == BOTH || !strand_specific){ return (getStart() < b.getStop() && b.getStart() < getStop()); } return false; }
QString WaySubline::toString() const { return "start: " + getStart().toString() + " end: " + getEnd().toString(); }
bool WaySubline::contains(const WaySubline& other) const { return getStart().getWay() == other.getStart().getWay() && other.getStart() >= getStart() && other.getEnd() <= getEnd(); }
double Clock::getElapsedTime() { return static_cast<double>(clock()-getStart())/CLOCKS_PER_SEC ; }
/* * addEntry: Adds an entry to a fcb. * * @start: Integer Pointer location of the starting block * @fcBlockID: Integer the target fcb id * @name: String name of the entry * @type: Integer type of the entry * * return 0: successful execution * return -1: file already exists in directory * return -2: error retrieving the parent file control block * return -3: error looking for a free block * return -4: error finding entry in the file control block * return -5: error creating file control block */ int addEntry(int* start, int fcBlockID, char* name, int type) { /* best case: * block: [1, a, b, c, d, e, f, ... ] * average case: * block: [1, a, b, c, 0, 0, 0, ... ] * worst case: * block: [1, 0, 0, 0, 0, 0, 0, ... ] * * Therefore, 7 chars must be skipped before any useful data is reached. */ if (getStart(malloc(1), fcBlockID, name) != -2) { fprintf(stderr, "File already exists in directory.\n"); return -1; } char* fcb = malloc(BLOCK_SIZE); if (get_block(fcBlockID, fcb)) { fprintf(stderr, "Error retrieving the parent file control block.\n"); return -2; } if (getFreeBlock(start)) { fprintf(stderr, "Error looking for a free block.\n"); return -3; } // Position in the file control block int position; if (getEntryPoint(&position, fcb)) { fprintf(stderr, "Error finding entry in the file control block.\n"); return -4; } /* * order of file attributes: * type name start */ fcb[position++] = type; for (unsigned int i = 0; i < strlen(name); i++) { fcb[i + position] = name[i]; } position += MAX_DIRNAME - 1; char* _start = encode_int(*start); for (int i = 0; i < START; i++) { fcb[i + position] = _start[i]; } position += START; if (fcb[position + 1] == '\0') { fcb[position] = ENTRY_END; } if (put_block(fcBlockID, fcb)) { fprintf(stderr, "Error creating file control block.\n"); return -5; } return 0; }
void TuringMachine::whileLoop(char haltChar){ while (*head != haltChar){ setCurrent(getStart()); startMachine(); } }
void TuringMachine::startMachine(){ setCurrent(getStart()); while (!(&getCurrent() == &getHaltTrue() || &getCurrent() == &getHaltFalse())){ this->operator()(*head); } }
/** problem reading method of reader */ static SCIP_DECL_READERREAD(readerReadCip) { /*lint --e{715}*/ CIPINPUT cipinput; SCIP_Real objscale; SCIP_Real objoffset; SCIP_Bool initialconss; SCIP_Bool dynamicconss; SCIP_Bool dynamiccols; SCIP_Bool dynamicrows; SCIP_Bool initialvar; SCIP_Bool removablevar; SCIP_RETCODE retcode; if( NULL == (cipinput.file = SCIPfopen(filename, "r")) ) { SCIPerrorMessage("cannot open file <%s> for reading\n", filename); SCIPprintSysError(filename); return SCIP_NOFILE; } cipinput.len = 131071; SCIP_CALL( SCIPallocBufferArray(scip, &(cipinput.strbuf), cipinput.len) ); cipinput.linenumber = 0; cipinput.section = CIP_START; cipinput.haserror = FALSE; cipinput.endfile = FALSE; cipinput.readingsize = 65535; SCIP_CALL( SCIPcreateProb(scip, filename, NULL, NULL, NULL, NULL, NULL, NULL, NULL) ); SCIP_CALL( SCIPgetBoolParam(scip, "reading/initialconss", &initialconss) ); SCIP_CALL( SCIPgetBoolParam(scip, "reading/dynamiccols", &dynamiccols) ); SCIP_CALL( SCIPgetBoolParam(scip, "reading/dynamicconss", &dynamicconss) ); SCIP_CALL( SCIPgetBoolParam(scip, "reading/dynamicrows", &dynamicrows) ); initialvar = !dynamiccols; removablevar = dynamiccols; objscale = 1.0; objoffset = 0.0; while( cipinput.section != CIP_END && !cipinput.haserror ) { /* get next input string */ SCIP_CALL( getInputString(scip, &cipinput) ); if( cipinput.endfile ) break; switch( cipinput.section ) { case CIP_START: getStart(scip, &cipinput); break; case CIP_STATISTIC: SCIP_CALL( getStatistics(scip, &cipinput) ); break; case CIP_OBJECTIVE: SCIP_CALL( getObjective(scip, &cipinput, &objscale, &objoffset) ); break; case CIP_VARS: retcode = getVariable(scip, &cipinput, initialvar, removablevar, objscale); if( retcode == SCIP_READERROR ) { cipinput.haserror = TRUE; goto TERMINATE; } SCIP_CALL(retcode); break; case CIP_FIXEDVARS: retcode = getFixedVariable(scip, &cipinput); if( retcode == SCIP_READERROR ) { cipinput.haserror = TRUE; goto TERMINATE; } SCIP_CALL(retcode); break; case CIP_CONSTRAINTS: retcode = getConstraint(scip, &cipinput, initialconss, dynamicconss, dynamicrows); if( retcode == SCIP_READERROR ) { cipinput.haserror = TRUE; goto TERMINATE; } SCIP_CALL(retcode); break; default: SCIPerrorMessage("invalid CIP state\n"); SCIPABORT(); return SCIP_INVALIDDATA; /*lint !e527*/ } /*lint !e788*/ } if( !SCIPisZero(scip, objoffset) && !cipinput.haserror ) { SCIP_VAR* objoffsetvar; objoffset *= objscale; SCIP_CALL( SCIPcreateVar(scip, &objoffsetvar, "objoffset", objoffset, objoffset, 1.0, SCIP_VARTYPE_CONTINUOUS, TRUE, TRUE, NULL, NULL, NULL, NULL, NULL) ); SCIP_CALL( SCIPaddVar(scip, objoffsetvar) ); SCIP_CALL( SCIPreleaseVar(scip, &objoffsetvar) ); SCIPdebugMessage("added variables <objoffset> for objective offset of <%g>\n", objoffset); } if( cipinput.section != CIP_END && !cipinput.haserror ) { SCIPerrorMessage("unexpected EOF\n"); } TERMINATE: /* close file stream */ SCIPfclose(cipinput.file); SCIPfreeBufferArray(scip, &cipinput.strbuf); if( cipinput.haserror ) return SCIP_READERROR; /* successfully parsed cip format */ *result = SCIP_SUCCESS; return SCIP_OKAY; }
float JUCE_get_max_val(const float *array, const int num_elements){ auto both = FloatVectorOperations::findMinAndMax(array,num_elements); float a = -both.getStart(); float b = both.getEnd(); return R_MAX(a,b); }
static void threadSequenceThroughGraph(TightString * tString, KmerOccurenceTable * kmerTable, Graph * graph, IDnum seqID, Category category, boolean readTracking, boolean double_strand, ReferenceMapping * referenceMappings, Coordinate referenceMappingCount, IDnum refCount, Annotation * annotations, IDnum annotationCount, boolean second_in_pair) { Kmer word; Kmer antiWord; Coordinate readNucleotideIndex; Coordinate kmerIndex; KmerOccurence *kmerOccurence; int wordLength = getWordLength(graph); PassageMarkerI marker = NULL_IDX; PassageMarkerI previousMarker = NULL_IDX; Node *node = NULL; Node *previousNode = NULL; Coordinate coord = 0; Coordinate previousCoord = 0; Nucleotide nucleotide; boolean reversed; IDnum refID; Coordinate refCoord = 0; ReferenceMapping * refMap; Annotation * annotation = annotations; Coordinate index = 0; Coordinate uniqueIndex = 0; Coordinate annotIndex = 0; IDnum annotCount = 0; SmallNodeList * nodePile = NULL; // Neglect any string shorter than WORDLENGTH : if (getLength(tString) < wordLength) return; clearKmer(&word); clearKmer(&antiWord); // Fill in the initial word : for (readNucleotideIndex = 0; readNucleotideIndex < wordLength - 1; readNucleotideIndex++) { nucleotide = getNucleotide(readNucleotideIndex, tString); pushNucleotide(&word, nucleotide); if (double_strand || second_in_pair) { #ifdef COLOR reversePushNucleotide(&antiWord, nucleotide); #else reversePushNucleotide(&antiWord, 3 - nucleotide); #endif } } // Go through sequence while (readNucleotideIndex < getLength(tString)) { nucleotide = getNucleotide(readNucleotideIndex++, tString); pushNucleotide(&word, nucleotide); if (double_strand || second_in_pair) { #ifdef COLOR reversePushNucleotide(&antiWord, nucleotide); #else reversePushNucleotide(&antiWord, 3 - nucleotide); #endif } // Update annotation if necessary if (annotCount < annotationCount && annotIndex == getAnnotationLength(annotation)) { annotation = getNextAnnotation(annotation); annotCount++; annotIndex = 0; } // Search for reference mapping if (category == REFERENCE) { if (referenceMappings) refMap = findReferenceMapping(seqID, index, referenceMappings, referenceMappingCount); else refMap = NULL; if (refMap) { node = getNodeInGraph(graph, refMap->nodeID); if (refMap->nodeID > 0) { coord = refMap->nodeStart + (index - refMap->referenceStart); } else { coord = getNodeLength(node) - refMap->nodeStart - refMap->length + (index - refMap->referenceStart); } } else { node = NULL; if (previousNode) break; } } // Search for reference-based mapping else if (annotCount < annotationCount && uniqueIndex >= getPosition(annotation) && getAnnotSequenceID(annotation) <= refCount && getAnnotSequenceID(annotation) >= -refCount) { refID = getAnnotSequenceID(annotation); if (refID > 0) refCoord = getStart(annotation) + annotIndex; else refCoord = getStart(annotation) - annotIndex; refMap = findReferenceMapping(refID, refCoord, referenceMappings, referenceMappingCount); // If success if (refMap) { if (refID > 0) { node = getNodeInGraph(graph, refMap->nodeID); if (refMap->nodeID > 0) { coord = refMap->nodeStart + (refCoord - refMap->referenceStart); } else { coord = getNodeLength(node) - refMap->nodeStart - refMap->length + (refCoord - refMap->referenceStart); } } else { node = getNodeInGraph(graph, -refMap->nodeID); if (refMap->nodeID > 0) { coord = getNodeLength(node) - refMap->nodeStart - (refCoord - refMap->referenceStart) - 1; } else { coord = refMap->nodeStart + refMap->length - (refCoord - refMap->referenceStart) - 1; } } } else { node = NULL; if (previousNode) break; } } // Search in table else { reversed = false; if (double_strand) { if (compareKmers(&word, &antiWord) <= 0) { kmerOccurence = findKmerInKmerOccurenceTable(&word, kmerTable); } else { kmerOccurence = findKmerInKmerOccurenceTable(&antiWord, kmerTable); reversed = true; } } else { if (!second_in_pair) { kmerOccurence = findKmerInKmerOccurenceTable(&word, kmerTable); } else { kmerOccurence = findKmerInKmerOccurenceTable(&antiWord, kmerTable); reversed = true; } } if (kmerOccurence) { if (!reversed) { node = getNodeInGraph(graph, getKmerOccurenceNodeID(kmerOccurence)); coord = getKmerOccurencePosition(kmerOccurence); } else { node = getNodeInGraph(graph, -getKmerOccurenceNodeID(kmerOccurence)); coord = getNodeLength(node) - getKmerOccurencePosition(kmerOccurence) - 1; } } else { node = NULL; if (previousNode) break; } } // Increment positions if (annotCount < annotationCount && uniqueIndex >= getPosition(annotation)) annotIndex++; else uniqueIndex++; // Fill in graph if (node) { #ifdef OPENMP lockNode(node); #endif kmerIndex = readNucleotideIndex - wordLength; if (previousNode == node && previousCoord == coord - 1) { if (category / 2 >= CATEGORIES) { setPassageMarkerFinish(marker, kmerIndex + 1); setFinishOffset(marker, getNodeLength(node) - coord - 1); } else { #ifndef SINGLE_COV_CAT incrementVirtualCoverage(node, category / 2, 1); incrementOriginalVirtualCoverage(node, category / 2, 1); #else incrementVirtualCoverage(node, 1); #endif } #ifdef OPENMP unLockNode(node); #endif } else { if (category / 2 >= CATEGORIES) { marker = newPassageMarker(seqID, kmerIndex, kmerIndex + 1, coord, getNodeLength (node) - coord - 1); transposePassageMarker(marker, node); connectPassageMarkers (previousMarker, marker, graph); previousMarker = marker; } else { if (readTracking) { if (!isNodeMemorized(node, nodePile)) { addReadStart(node, seqID, coord, graph, kmerIndex); memorizeNode(node, &nodePile); } else { blurLastShortReadMarker (node, graph); } } #ifndef SINGLE_COV_CAT incrementVirtualCoverage(node, category / 2, 1); incrementOriginalVirtualCoverage(node, category / 2, 1); #else incrementVirtualCoverage(node, 1); #endif } #ifdef OPENMP lockTwoNodes(node, previousNode); #endif createArc(previousNode, node, graph); #ifdef OPENMP unLockTwoNodes(node, previousNode); #endif } previousNode = node; previousCoord = coord; } index++; } if (readTracking && category / 2 < CATEGORIES) unMemorizeNodes(&nodePile); }
static void onKey( HWND hwnd, UINT vk, BOOL fDown, int cRepeat, UINT flags ) { long start = getStart( hwnd ); long end = getEnd( hwnd ); const BOOL controlKey = GetAsyncKeyState( VK_CONTROL ) < 0; if ( VK_ESCAPE == vk ) { if ( htNone != getHTCode( hwnd ) ) { setHTCode( hwnd, htNone ); const LONG oldStart = getSaveStart( hwnd ); const LONG oldEnd = getSaveEnd ( hwnd ); setStart( hwnd, oldStart ); setEnd ( hwnd, oldEnd ); invalidateRect( hwnd ); //onLButtonUp( hwnd, 0, 0, 0 ); // TODO retain capture anyway? // TODO notify parent return; //** FUNCTION EXIT POINT } } const UINT left_key = isVertical( hwnd ) ? VK_UP : VK_LEFT ; const UINT right_key = isVertical( hwnd ) ? VK_DOWN : VK_RIGHT; long granularity = getGranularity( hwnd ); if ( granularity <= 0 ) { granularity = 1; } if ( left_key == vk ) { if ( controlKey ) { if ( getMinRange( hwnd ) < end - start ) { end -= granularity; } } else if ( getLower( hwnd ) < start ) { start -= granularity; end -= granularity; } } else if ( right_key == vk ) { if ( end < getUpper( hwnd ) ) { end += granularity; if ( !controlKey ) { start += granularity; } } } else if ( VK_PRIOR == vk ) { scroll( hwnd, -1, 0 ); return; //*** FUNCTION EXIT POINT } else if ( VK_NEXT == vk ) { scroll( hwnd, 1, 0 ); return; //*** FUNCTION EXIT POINT } else if ( VK_HOME == vk ) { const long range = abs( getLower( hwnd ) - start ); start -= range; end -= range; } else if ( VK_END == vk ) { const long range = abs( getUpper( hwnd ) - end ); start += range; end += range; } start = adjust( hwnd, start ); end = adjust( hwnd, end ); if ( start != getStart( hwnd ) || end != getEnd( hwnd ) ) { setStart( hwnd, start ); setEnd ( hwnd, end ); invalidateRect( hwnd ); invalidateCursor(); notifyParent( hwnd ); } }
static void ghostThreadSequenceThroughGraph(TightString * tString, KmerOccurenceTable * kmerTable, Graph * graph, IDnum seqID, Category category, boolean readTracking, boolean double_strand, ReferenceMapping * referenceMappings, Coordinate referenceMappingCount, IDnum refCount, Annotation * annotations, IDnum annotationCount, boolean second_in_pair) { Kmer word; Kmer antiWord; Coordinate readNucleotideIndex; KmerOccurence *kmerOccurence; int wordLength = getWordLength(graph); Nucleotide nucleotide; IDnum refID; Coordinate refCoord; ReferenceMapping * refMap = NULL; Coordinate uniqueIndex = 0; Coordinate annotIndex = 0; IDnum annotCount = 0; boolean reversed; SmallNodeList * nodePile = NULL; Annotation * annotation = annotations; Node *node; Node *previousNode = NULL; // Neglect any read which will not be short paired if ((!readTracking && category % 2 == 0) || category / 2 >= CATEGORIES) return; // Neglect any string shorter than WORDLENGTH : if (getLength(tString) < wordLength) return; // Verify that all short reads are reasonnably short if (getLength(tString) > USHRT_MAX) { velvetLog("Short read of length %lli, longer than limit %i\n", (long long) getLength(tString), SHRT_MAX); velvetLog("You should better declare this sequence as long, because it genuinely is!\n"); exit(1); } clearKmer(&word); clearKmer(&antiWord); // Fill in the initial word : for (readNucleotideIndex = 0; readNucleotideIndex < wordLength - 1; readNucleotideIndex++) { nucleotide = getNucleotide(readNucleotideIndex, tString); pushNucleotide(&word, nucleotide); if (double_strand || second_in_pair) { #ifdef COLOR reversePushNucleotide(&antiWord, nucleotide); #else reversePushNucleotide(&antiWord, 3 - nucleotide); #endif } } // Go through sequence while (readNucleotideIndex < getLength(tString)) { // Shift word: nucleotide = getNucleotide(readNucleotideIndex++, tString); pushNucleotide(&word, nucleotide); if (double_strand || second_in_pair) { #ifdef COLOR reversePushNucleotide(&antiWord, nucleotide); #else reversePushNucleotide(&antiWord, 3 - nucleotide); #endif } // Update annotation if necessary if (annotCount < annotationCount && annotIndex == getAnnotationLength(annotation)) { annotation = getNextAnnotation(annotation); annotCount++; annotIndex = 0; } // Search for reference mapping if (annotCount < annotationCount && uniqueIndex >= getPosition(annotation) && getAnnotSequenceID(annotation) <= refCount && getAnnotSequenceID(annotation) >= -refCount) { refID = getAnnotSequenceID(annotation); if (refID > 0) refCoord = getStart(annotation) + annotIndex; else refCoord = getStart(annotation) - annotIndex; refMap = findReferenceMapping(refID, refCoord, referenceMappings, referenceMappingCount); // If success if (refMap) { if (refID > 0) node = getNodeInGraph(graph, refMap->nodeID); else node = getNodeInGraph(graph, -refMap->nodeID); } else { node = NULL; if (previousNode) break; } } // if not.. look in table else { reversed = false; if (double_strand) { if (compareKmers(&word, &antiWord) <= 0) { kmerOccurence = findKmerInKmerOccurenceTable(&word, kmerTable); } else { kmerOccurence = findKmerInKmerOccurenceTable(&antiWord, kmerTable); reversed = true; } } else { if (!second_in_pair) { kmerOccurence = findKmerInKmerOccurenceTable(&word, kmerTable); } else { kmerOccurence = findKmerInKmerOccurenceTable(&antiWord, kmerTable); reversed = true; } } if (kmerOccurence) { if (!reversed) node = getNodeInGraph(graph, getKmerOccurenceNodeID(kmerOccurence)); else node = getNodeInGraph(graph, -getKmerOccurenceNodeID(kmerOccurence)); } else { node = NULL; if (previousNode) break; } } if (annotCount < annotationCount && uniqueIndex >= getPosition(annotation)) annotIndex++; else uniqueIndex++; previousNode = node; // Fill in graph if (node && !isNodeMemorized(node, nodePile)) { #ifdef OPENMP lockNode(node); #endif incrementReadStartCount(node, graph); #ifdef OPENMP unLockNode(node); #endif memorizeNode(node, &nodePile); } } unMemorizeNodes(&nodePile); }