bool TableRowElement::moveCursor(FormulaCursor& newcursor, FormulaCursor& oldcursor) { //TODO: Moving the cursor vertically in the tableelement is a little bit fragile if ( (newcursor.isHome() && newcursor.direction()==MoveLeft) || (newcursor.isEnd() && newcursor.direction()==MoveRight) ) { return false; } int rowpos=parentElement()->positionOfChild(this); int colpos=(newcursor.position()!=endPosition() ? newcursor.position() : newcursor.position()-1); if (newcursor.isSelecting()) { switch(newcursor.direction()) { case MoveLeft: newcursor.moveTo(this,newcursor.position()-1); break; case MoveRight: newcursor.moveTo(this,newcursor.position()+1); break; case MoveUp: case MoveDown: return false; default: break; } } else { switch(newcursor.direction()) { case MoveLeft: newcursor.setCurrentElement(m_data[newcursor.position()-1]); newcursor.moveEnd(); break; case MoveRight: newcursor.setCurrentElement(m_data[newcursor.position()]); newcursor.moveHome(); break; case MoveUp: if ( rowpos>1 ) { BasicElement* b=parentElement()->childElements()[rowpos/2-1]->childElements()[colpos]; return newcursor.moveCloseTo(b, oldcursor); } else { return false; } case MoveDown: if ( rowpos<endPosition()-1 ) { BasicElement* b=parentElement()->childElements()[rowpos/2+1]->childElements()[colpos]; return newcursor.moveCloseTo(b, oldcursor); } else { return false; } default: break; } } return true; }
// This avoids the expense of a full fledged delete operation, and avoids a layout that typically results // from text removal. bool InsertTextCommand::performTrivialReplace(const String& text, bool selectInsertedText) { if (!endingSelection().isRange()) return false; if (text.contains('\t') || text.contains(' ') || text.contains('\n')) return false; Position start = endingSelection().start(); Position end = endingSelection().end(); if (start.node() != end.node() || !start.node()->isTextNode() || isTabSpanTextNode(start.node())) return false; replaceTextInNode(static_cast<Text*>(start.node()), start.offset(), end.offset() - start.offset(), text); Position endPosition(start.node(), start.offset() + text.length()); // We could have inserted a part of composed character sequence, // so we are basically treating ending selection as a range to avoid validation. // <http://bugs.webkit.org/show_bug.cgi?id=15781> Selection forcedEndingSelection; forcedEndingSelection.setWithoutValidation(start, endPosition); setEndingSelection(forcedEndingSelection); if (!selectInsertedText) setEndingSelection(Selection(endingSelection().visibleEnd())); return true; }
vector<Pixel> Line::getPixels() const{ int x1 = mBeginPoint.x; int x0 = mEndPoint.x; int y1 = mBeginPoint.y; int y0 = mEndPoint.y; int dx = abs(x1-x0), sx = x0<x1 ? 1 : -1; int dy = -abs(y1-y0), sy = y0<y1 ? 1 : -1; int err = dx+dy, e2; /* error value e_xy */ vector<Pixel> pixels; for(;;){ /* loop */ Point position(x0,y0); Pixel pixel(position,mColor); pixels.push_back(pixel); if (x0==x1 && y0==y1) break; e2 = 2*err; if (e2 >= dy) { err += dy; x0 += sx; } /* e_xy+e_x > 0 */ if (e2 <= dx) { err += dx; y0 += sy; } /* e_xy+e_y < 0 */ } for (int i=0;i<pixels.size();i++) { Point initialPosition = pixels[i].getPosition(); Point endPosition(initialPosition.x+mPositionX,initialPosition.y+mPositionY); pixels[i].setPosition(endPosition); } return pixels; }
vector<Pixel> ClipDrawable::getPixels() const{ vector<Pixel> pixels; Point viewPortStart(mPositionX,mPositionY); Point viewPortEnd(mPositionX+mWidth,mPositionY+mHeight); Rectangle border(viewPortStart,mWidth,mHeight,Color(255,0,0,0)); vector<Pixel> borderPixel = border.getPixels(); pixels.insert(pixels.end(),borderPixel.begin(),borderPixel.end()); vector<Line> lines = mWorldMap.getLines(); for (int i=0;i<lines.size();i++) { Line lineInView = CohenShutterlandAlgorithm::getLineInView(scaleLineToView(lines[i]),viewPortStart,viewPortEnd); vector<Pixel> linePixels = lineInView.getPixels(); pixels.insert(pixels.end(),linePixels.begin(),linePixels.end()); } for (int i=0;i<pixels.size();i++) { Point initialPosition = pixels[i].getPosition(); Point endPosition(initialPosition.x+mPositionX,initialPosition.y+mPositionY); pixels[i].setPosition(endPosition); } return pixels; }
void Segment::rotateAll(vec3 rotation) { rotate(rotation); for(int i = 0; i < nextSegments.size(); i++) { nextSegments[i]->movePosition(vec3(endPosition())); nextSegments[i]->rotateAll(rotation); } }
void PositionInterpolatorTests::testExtremes( TestReporter& reporter ) { NEW_TEST_FUNCTION( reporter ); PositionInterpolator interpolator; PositionInterpolatorTester tester( interpolator ); interpolator.disableMC2Conversion(); /** * * No data. No correct calculations or assumptions could be made, * so the position 0, 0 is returned. * */ CHECK( !tester.getPosition( 1000 ).isValid(), reporter ); InterpolationHintConsumer& pathConsumer = interpolator; pathConsumer.prepareNewData( 1000 ); MC2Coordinate checkPosition( 1337, 1337 ); static const int MPSToCmPS = 100; pathConsumer.addDataPoint( checkPosition, 10 * MPSToCmPS ); pathConsumer.finalizeNewData(); /** * Only single point, should return point itself. */ CHECK( tester.getPosition( 0 ) == checkPosition, reporter ); CHECK( tester.getPosition( 1000 ) == checkPosition, reporter ); CHECK( tester.getPosition( 2000 ) == checkPosition, reporter ); /** * Two points, test outside scope on both sides of the interval. * Should be clamped to endpoints. */ MC2Coordinate endPosition( 1338, 1338 ); pathConsumer.addDataPoint( endPosition, 10 * MPSToCmPS ); pathConsumer.finalizeNewData(); /** * Seconds to millisecond conversion unit. */ static const int sToMs = 1000; CHECK( tester.getPosition( 0 ) == checkPosition, reporter ); CHECK( tester.getPosition( 500000 * sToMs ) == endPosition, reporter ); }
void DocumentMarkerControllerTest::markNodeContentsWithComposition(Node* node) { // Force layoutObjects to be created; TextIterator, which is used in // DocumentMarkerControllerTest::addMarker(), needs them. document().updateStyleAndLayout(); auto range = EphemeralRange::rangeOfContents(*node); markerController().addCompositionMarker(range.startPosition(), range.endPosition(), Color::black, false, Color::black); }
void Segment::getEndEffectors(vector<vec3> &endEffectors) { int segs = nextSegments.size(); if(segs == 0) endEffectors.push_back(vec3(endPosition())); for(int i = 0; i < segs; i++) { nextSegments[i]->getEndEffectors(endEffectors); } }
void DocumentMarkerControllerTest::markNodeContents(PassRefPtrWillBeRawPtr<Node> node) { // Force layoutObjects to be created; TextIterator, which is used in // DocumentMarkerControllerTest::addMarker(), needs them. document().updateLayout(); auto range = EphemeralRange::rangeOfContents(*node); markerController().addMarker(range.startPosition(), range.endPosition(), DocumentMarker::Spelling); }
EphemeralRangeTemplate<Strategy> CharacterIteratorAlgorithm<Strategy>::calculateCharacterSubrange(int offset, int length) { advance(offset); const PositionAlgorithm<Strategy> startPos = startPosition(); if (length > 1) advance(length - 1); return EphemeralRangeTemplate<Strategy>(startPos, endPosition()); }
PreviewBoard::PreviewBoard(DockPreviewBoard* dockPreviewBoard, QWidget *parent) : QWidget(parent), dockPreviewBoard_(dockPreviewBoard) { srand ( time(NULL) ); for (int x = 0; x < 19; x++) { for (int y = 0; y < 19; y++) { whiteStoneType_[x][y] = rand()%35; // between 0 and 35 board_[x][y] = 0; } } // boards.clear(); // resize(400, 400); // setMinimumSize ( 200, 200 ); //int minw, int minh // setMaximumSize ( 600, 600 ); // setSizeIncrement ( 0, 0 ); setMouseTracking (true); QString boardDir = Resources::path(); origBoardImage = QPixmap(boardDir + "Beige1.png"); QPalette palette; palette.setBrush(backgroundRole(), QBrush(origBoardImage)); setPalette(palette); setAutoFillBackground ( true ); //connect(this, SIGNAL(click()), this, SLOT(makeFocus())); previewBoardMenu = new QMenu("Preview board menu", this); // boardMenu->setTitle ("Preview board menu"); positionActions_ = new QActionGroup(this); positionActions_->setExclusive(true); currentPositionAct = new QAction(tr("&Current board position"), this); currentPositionAct->setCheckable(true); nextPositionAct = new QAction(tr("&Board next move"), this); nextPositionAct->setCheckable(true); endPositionAct = new QAction(tr("&End position"), this); endPositionAct->setCheckable(true); positionActions_->addAction (currentPositionAct); positionActions_->addAction (nextPositionAct); positionActions_->addAction (endPositionAct); previewBoardMenu->addActions(positionActions_->actions()); connect(currentPositionAct, SIGNAL(triggered()), this, SLOT(currentPosition())); connect(nextPositionAct, SIGNAL(triggered()), this, SLOT(nextPosition())); connect(endPositionAct, SIGNAL(triggered()), this, SLOT(endPosition())); }
void check_cutted_frags(CharString frag, std::vector<table_entry*> &links, map<unsigned long long, string> &chains, unsigned int min_length){ if(length(frag) > min_length){ std::queue<int> l_link; std::queue<int> r_link; Pattern<CharString, ShiftOr > pattern(frag); for(unsigned int i=0; i<links.size(); ++i){ CharString text = links[i]->get_short_read()->get_RNA_seq_sequence(); Finder<CharString> finder(text); find(finder,pattern); if(beginPosition(finder) < min_length){ //std::cout << "L link " << i << ::std::endl; l_link.push(i); } if(endPosition(finder) > length(text) - min_length){ //std::cout << "R link" << ::std::endl; r_link.push(i); } } if(l_link.size() != 0 && r_link.size() != 0){ string head; assign(head,frag); for(unsigned int z=0; z<min_length*2 - length(frag);++z){ head.append("A"); } if(chains.find(fingerprint(head)) == chains.end()){ chains[fingerprint(head)] = toCString(frag); //std::cerr << "CUT: " << frag << " " << length(frag) << std::endl; }else{ //std::cerr << "Problem:" << std::endl; //std::cerr << chains[fingerprint(head)] << std::endl; //std::cerr << toCString(frag) << std::endl; } //::std::cout << toCString(frag) << ::std::endl; while(!l_link.empty()){ links[l_link.front()]->push_D_link(fingerprint(head)); l_link.pop(); } while(!r_link.empty()){ links[r_link.front()]->push_A_link(fingerprint(head)); r_link.pop(); } } } }
TEST_F(OsgScreenSpaceQuadRenderTests, InitTest) { std::shared_ptr<OsgScreenSpaceQuadRepresentation> quad = std::make_shared<OsgScreenSpaceQuadRepresentation>("Screen Quad"); viewElement->addComponent(quad); /// Run the thread runtime->start(); EXPECT_TRUE(graphicsManager->isInitialized()); EXPECT_TRUE(viewElement->isInitialized()); quad->setSize(100, 100); boost::this_thread::sleep(boost::posix_time::milliseconds(1000)); auto dimensions = viewElement->getView()->getDimensions(); SurgSim::Math::Vector3d startPosition(0.0, 0.0, 0.0); SurgSim::Math::Vector3d endPosition(dimensions[0], dimensions[1], 0.0); SurgSim::Math::Vector2d startSize(0.0, 0.0); SurgSim::Math::Vector2d endSize(200, 200); int numSteps = 100; for (int i = 0; i < numSteps; ++i) { /// Calculate t in [0.0, 1.0] double t = static_cast<double>(i) / numSteps; RigidTransform3d currentPose = SurgSim::Testing::interpolatePose( Vector3d::Identity(), Vector3d::Identity(), startPosition, endPosition, t); quad->setLocalPose(currentPose); SurgSim::Math::Vector2d size = SurgSim::Testing::interpolate(startSize, endSize, t); quad->setSize(size.x(), size.y()); boost::this_thread::sleep(boost::posix_time::milliseconds(1000 / numSteps)); } }
bool TableRowElement::setCursorTo(FormulaCursor& cursor, QPointF point) { if (cursor.isSelecting()) { if (m_data.isEmpty() || point.x()<0.0) { cursor.setCurrentElement(this); cursor.setPosition(0); return true; } //check if the point is behind all child elements if (point.x() >= width()) { cursor.setCurrentElement(this); cursor.setPosition(endPosition()); return true; } } int i=0; qreal x=0.0; TableElement* parentTable = static_cast<TableElement*>( parentElement() ); for (; i<m_data.count()-1; ++i) { //Find the child element the point is in x+=parentTable->columnWidth( i ); if (x>=point.x()) { break; } } if (cursor.isSelecting()) { //we don't need to change current element because we are already in this element if (cursor.mark()<=i) { cursor.setPosition(i+1); } else { cursor.setPosition(i); } return true; } else { point-=m_data[i]->origin(); return m_data[i]->setCursorTo(cursor,point); } }
void linking_refinement(::std::vector<table_entry*> & links, map<unsigned long long, string> & chains, unsigned int len, ::std::map<unsigned long long, unsigned long long> & mapping){ for(unsigned int i=0; i<links.size(); ++i){ //Linkato solo a dx if(links[i]->size_D_link() == 0 && links[i]->size_A_link() != 0){ //::std::cout << "D link" << ::std::endl; CharString p = ::seqan::prefix(links[i]->get_short_read()->get_RNA_seq_sequence(),len); Pattern<CharString, ShiftOr > pattern(p); ::std::map<unsigned long long, string>::iterator chain_it; ::std::set<unsigned long long> modif_chains; for(chain_it = chains.begin(); chain_it != chains.end(); ++chain_it){ CharString text = chain_it->second; Finder<CharString> finder(text); if(modif_chains.find(chain_it->first) == modif_chains.end() && find(finder,pattern)){ links[i]->push_D_link(chain_it->first); if(chain_it->second.length()- endPosition(finder) > len){ //::std::cout << "D " << (i+1) << " " << beginPosition(finder) << ::std::endl; CharString pre = ::seqan::prefix(chain_it->second, beginPosition(finder) + len); string str_pre = ::seqan::toCString(pre); CharString suf = ::seqan::suffix(chain_it->second, beginPosition(finder) + len); string str_suf = ::seqan::toCString(suf); //::std::cout << chain_it->second << " - " << chain_it->second.length() << ::std::endl; //Sono sicuro che sia > len dato che la estraggo da un prefisso //di lunghezza len... chains[chain_it->first] = str_pre; //::std::cout << str_pre << " - " << str_pre.length() << ::std::endl; modif_chains.insert(chain_it->first); //...ma il suffissopotrebbe essere piu' corto di len string head; if(str_suf.length() >= len){ head = ::seqan::toCString(::seqan::prefix(suf,len)); chains[fingerprint(head)] = str_suf; mapping[fingerprint(head)] = fingerprint(head); }else{ head = str_suf; for(unsigned int z=0; z<len-str_suf.length();++z){ head.append("A"); } chains[fingerprint(head)] = str_suf; mapping[fingerprint(head)] = fingerprint(head); } //::std::cout << str_suf << " - " << str_suf.length() << ::std::endl << ::std::endl; modif_chains.insert(fingerprint(head)); for(unsigned int z=0; z<links.size();++z){ for(int k=0; k<links[z]->size_D_link();++k){ if(links[z]->at_D_link(k) == chain_it->first){ links[z]->at_D_link(k) = fingerprint(head); } } } //Aggiungere un link tra le due catene create CharString l_part = chains[chain_it->first]; string new_link = ::seqan::toCString(::seqan::suffix(l_part,length(l_part) - len)); unsigned long long f_l = fingerprint(new_link); new_link.append(head); table_entry* t_new = new table_entry(new_link,f_l,fingerprint(head)); t_new->push_D_link(chain_it->first); t_new->push_A_link(fingerprint(head)); links.push_back(t_new); } } } } //Linkato solo a sx if(links[i]->size_A_link() == 0 && links[i]->size_D_link() != 0){ //::std::cout << "A link" << ::std::endl; CharString p = ::seqan::suffix(links[i]->get_short_read()->get_RNA_seq_sequence(),len); Pattern<CharString, ShiftOr > pattern(p); ::std::map<unsigned long long, string>::iterator chain_it; ::std::set<unsigned long long> modif_chains; for(chain_it = chains.begin(); chain_it != chains.end(); ++chain_it){ CharString text = chain_it->second; Finder<CharString> finder(text); if(modif_chains.find(chain_it->first) == modif_chains.end() && find(finder,pattern)){ //if(find(finder,pattern)){ //::std::cout << "1 - if " << beginPosition(finder) << " " << endPosition(finder) << ::std::endl; if(beginPosition(finder) == 0){ links[i]->push_A_link(chain_it->first); } if(endPosition(finder) > len){ //::std::cout << "A " << (i+1) << " " << beginPosition(finder) << ::std::endl; CharString pre = ::seqan::prefix(chain_it->second, beginPosition(finder) + len); string str_pre = ::seqan::toCString(pre); CharString suf = ::seqan::suffix(chain_it->second, beginPosition(finder) + len); string str_suf = ::seqan::toCString(suf); chains[chain_it->first] = str_pre; //::std::cout << str_pre << " - " << str_pre.length() << ::std::endl; modif_chains.insert(chain_it->first); string head; if(str_suf.length() >= len){ head = ::seqan::toCString(::seqan::prefix(suf,len)); chains[fingerprint(head)] = str_suf; mapping[fingerprint(head)] = fingerprint(head); }else{ head = str_suf; for(unsigned int z=0; z<len-str_suf.length();++z){ head.append("A"); } chains[fingerprint(head)] = str_suf; mapping[fingerprint(head)] = fingerprint(head); } //::std::cout << str_suf << " - " << str_suf.length() << ::std::endl << ::std::endl; modif_chains.insert(fingerprint(head)); for(unsigned int z=0; z<links.size();++z){ for(int k=0; k<links[z]->size_D_link();++k){ if(links[z]->at_D_link(k) == chain_it->first){ links[z]->at_D_link(k) = fingerprint(head); } } } //Aggiungere un link tra le due catene create CharString l_part = chains[chain_it->first]; string new_link = ::seqan::toCString(::seqan::suffix(l_part,length(l_part) - len)); unsigned long long f_l = fingerprint(new_link); new_link.append(head); table_entry* t_new = new table_entry(new_link,f_l,fingerprint(head)); t_new->push_D_link(chain_it->first); t_new->push_A_link(fingerprint(head)); links.push_back(t_new); links[i]->push_A_link(fingerprint(head)); } } } } } //::std::cout << chains.size() << ::std::endl; }
iterator& end() const { iterator it(this, endPosition()); itend = it; return itend; }
EphemeralRange PlainTextRange::createRangeFor(const ContainerNode& scope, GetRangeFor getRangeFor) const { ASSERT(isNotNull()); size_t docTextPosition = 0; bool startRangeFound = false; Position textRunStartPosition; Position textRunEndPosition; TextIteratorBehaviorFlags behaviorFlags = TextIteratorEmitsObjectReplacementCharacter; if (getRangeFor == ForSelection) behaviorFlags |= TextIteratorEmitsCharactersBetweenAllVisiblePositions; auto range = EphemeralRange::rangeOfContents(scope); TextIterator it(range.startPosition(), range.endPosition(), behaviorFlags); // FIXME: the atEnd() check shouldn't be necessary, workaround for // <http://bugs.webkit.org/show_bug.cgi?id=6289>. if (!start() && !length() && it.atEnd()) return EphemeralRange(Position(it.currentContainer(), 0)); Position resultStart = Position(&scope.document(), 0); Position resultEnd = resultStart; for (; !it.atEnd(); it.advance()) { int len = it.length(); textRunStartPosition = it.startPositionInCurrentContainer(); textRunEndPosition = it.endPositionInCurrentContainer(); bool foundStart = start() >= docTextPosition && start() <= docTextPosition + len; bool foundEnd = end() >= docTextPosition && end() <= docTextPosition + len; // Fix textRunRange->endPosition(), but only if foundStart || foundEnd, because it is only // in those cases that textRunRange is used. if (foundEnd) { // FIXME: This is a workaround for the fact that the end of a run // is often at the wrong position for emitted '\n's or if the // layoutObject of the current node is a replaced element. if (len == 1 && (it.characterAt(0) == '\n' || it.isInsideAtomicInlineElement())) { it.advance(); if (!it.atEnd()) { textRunEndPosition = it.startPositionInCurrentContainer(); } else { Position runEnd = nextPositionOf(createVisiblePosition(textRunStartPosition)).deepEquivalent(); if (runEnd.isNotNull()) textRunEndPosition = runEnd; } } } if (foundStart) { startRangeFound = true; if (textRunStartPosition.computeContainerNode()->isTextNode()) { int offset = start() - docTextPosition; resultStart = Position(textRunStartPosition.computeContainerNode(), offset + textRunStartPosition.offsetInContainerNode()); } else { if (start() == docTextPosition) resultStart = textRunStartPosition; else resultStart = textRunEndPosition; } } if (foundEnd) { if (textRunStartPosition.computeContainerNode()->isTextNode()) { int offset = end() - docTextPosition; resultEnd = Position(textRunStartPosition.computeContainerNode(), offset + textRunStartPosition.offsetInContainerNode()); } else { if (end() == docTextPosition) resultEnd = textRunStartPosition; else resultEnd = textRunEndPosition; } docTextPosition += len; break; } docTextPosition += len; } if (!startRangeFound) return EphemeralRange(); if (length() && end() > docTextPosition) { // end() is out of bounds resultEnd = textRunEndPosition; } return EphemeralRange(resultStart.toOffsetInAnchor(), resultEnd.toOffsetInAnchor()); }
void check_overlapping_nodes(::std::vector<table_entry*> & links, map<unsigned long long, string> & chains, int len, ::std::map<unsigned long long, unsigned long long>& mapping, unsigned int min_overlap, int ov_perc){ ::std::map<unsigned long long, string>::iterator chain_it; ::std::map<unsigned long long, string>::iterator chain_it_2; ::std::vector<small_frag> short_blocks; stack<unsigned int> s; queue<unsigned long long> q; for(chain_it = chains.begin(); chain_it != chains.end(); ++chain_it){ for(chain_it_2 = chains.begin(); chain_it_2 != chains.end(); ++chain_it_2){ unsigned int ov = overlappedStringLength(chain_it->second,chain_it_2->second); if(chain_it != chain_it_2 && ov < (ov_perc*chain_it->second.length())/100 && (ov_perc*ov < chain_it_2->second.length())/100 && ov > min_overlap){ bool new_node = false; CharString pat_text=prefix(chain_it_2->second,ov); //::std::cout << chain_it->second << ::std::endl; //::std::cout << chain_it_2->second << ::std::endl; //::std::cout << ov << ::std::endl; Pattern<CharString, ShiftAnd> pattern(pat_text); for(unsigned int i=0; i<links.size();++i){ CharString link_read = links[i]->get_short_read()->get_RNA_seq_sequence(); Finder<CharString> finder(link_read); if(find(finder,pattern) && ( prefix(link_read,beginPosition(finder)) == infix(chain_it->second,chain_it->second.length()-ov-beginPosition(finder),chain_it->second.length()-ov) || suffix(link_read,length(link_read) - endPosition(finder)) == infix(chain_it_2->second,ov,ov+endPosition(finder)))){ //::std::cout << link_read << ::std::endl; //::std::cout << prefix(link_read,beginPosition(finder)) << ::std::endl; //::std::cout << infix(chain_it->second,chain_it->second.length()-ov-beginPosition(finder),chain_it->second.length()-ov) << ::std::endl; //::std::cout << suffix(link_read,length(link_read) - endPosition(finder)) << ::std::endl; //::std::cout << infix(chain_it_2->second,ov,ov+endPosition(finder)) << ::std::endl; new_node = true; } } if(new_node){ small_frag f; f.frag_links.D_chain = chain_it->first; f.frag_links.A_chain = chain_it_2->first; f.frag = prefix(chain_it_2->second,ov); short_blocks.push_back(f); } }else{ if(chain_it != chain_it_2 && ov>=(ov_perc*chain_it->second.length())/100){ //::std::cout << "Chain_it sub-node of Chain_it_2" << ::std::endl; //::std::cout << "Chain_it " << chain_it->second << ::std::endl; //::std::cout << "Chain_it_2 " << chain_it_2->second << ::std::endl; //::std::cout << ov << ::std::endl; q.push(chain_it->first); }else{ if(chain_it != chain_it_2 && ov>=(ov_perc*chain_it_2->second.length())/100){ //::std::cout << "Chain_it_2 sub-node of Chain_it" << ::std::endl; //::std::cout << "Chain_it " << chain_it->second << ::std::endl; //::std::cout << "Chain_it_2 " <<chain_it_2->second << ::std::endl; //::std::cout << ov << ::std::endl; q.push(chain_it_2->first); } } } } } for(unsigned int i=0; i<short_blocks.size(); ++i){ bool sub_seq = false; for(unsigned int k=0; k<short_blocks.size(); ++k){ if(short_blocks[i].frag == short_blocks[k].frag && i<k){ links_pair erased_links; erased_links.D_chain = short_blocks[i].frag_links.D_chain; erased_links.A_chain = short_blocks[i].frag_links.A_chain; short_blocks[k].other_links.push_back(erased_links); sub_seq = true; } if(i!=k && (::seqan::length(short_blocks[i].frag)) < (::seqan::length(short_blocks[k].frag))){ Finder<CharString> finder(short_blocks[k].frag); Pattern<CharString, ShiftAnd> pattern(short_blocks[i].frag); if(find(finder,pattern)){ links_pair erased_links; erased_links.D_chain = short_blocks[i].frag_links.D_chain; erased_links.A_chain = short_blocks[i].frag_links.A_chain; //::std::cout << i << k << " - " << beginPosition(finder) << " " << endPosition(finder) << ::std::endl; short_blocks[k].other_links.push_back(erased_links); sub_seq = true; } } } if(sub_seq){ s.push(i); } } while(!s.empty()){ short_blocks.erase(short_blocks.begin()+s.top()); s.pop(); } while(!q.empty()){ chains.erase(q.front()); q.pop(); } for(unsigned int i=0; i<short_blocks.size(); ++i){ //::std::cout << short_blocks[i].frag << " " << length(short_blocks[i].frag) << ::std::endl; string ch = ""; for(unsigned int z = 0; z<len-length(short_blocks[i].frag); ++z){ ch.append("A"); } ch.append(toCString(short_blocks[i].frag)); //if(chains.find(fingerprint(ch)) == chains.end()){//Start_If_5 //chains[fingerprint(ch)] = ::seqan::toCString(short_blocks[i].frag); //::std::cout << ::seqan::toCString(short_blocks[i].frag) <<" "<< length(short_blocks[i].frag)<<::std::endl; //mapping[fingerprint(ch)] = fingerprint(ch); //Add the first link string first_half; assign(first_half,prefix(chains[short_blocks[i].frag_links.D_chain],len)); string new_link_1 = first_half; new_link_1.append(ch); table_entry* link_1 = new table_entry(new_link_1,fingerprint(first_half),fingerprint(ch)); link_1->push_D_link(short_blocks[i].frag_links.D_chain); link_1->push_A_link(short_blocks[i].frag_links.A_chain); links.push_back(link_1); /* //Add the second link string second_half; assign(second_half,prefix(chains[short_blocks[i].frag_links.A_chain],len)); string new_link_2 = ch; new_link_2.append(second_half); table_entry* link_2 = new table_entry(new_link_2,fingerprint(ch),fingerprint(second_half)); link_2->push_D_link(short_blocks[i].frag_links.D_chain); link_2->push_A_link(short_blocks[i].frag_links.A_chain); links.push_back(link_2); */ //::std::cout<<links[short_blocks[i].frag_links.D_chain]->get_short_read()->get_RNA_seq_sequence()<<::std::endl; //::std::cout<<links[short_blocks[i].frag_links.A_chain]->get_short_read()->get_RNA_seq_sequence()<<::std::endl; for(unsigned int j=0; j<short_blocks[i].other_links.size(); ++j){//Start_For_6 string second_half; assign(first_half,prefix(chains[short_blocks[i].other_links[j].D_chain],len)); string new_link_2 = second_half; new_link_2.append(ch); table_entry* link_2 = new table_entry(new_link_2,fingerprint(second_half),fingerprint(ch)); link_2->push_D_link(short_blocks[i].other_links[j].D_chain); link_2->push_A_link(short_blocks[i].other_links[j].A_chain); links.push_back(link_1); }//End_For_6 //}//End_If_5 } }
PassRefPtrWillBeRawPtr<Range> PlainTextRange::createRangeFor(const ContainerNode& scope, GetRangeFor getRangeFor) const { ASSERT(isNotNull()); RefPtrWillBeRawPtr<Range> resultRange = scope.document().createRange(); size_t docTextPosition = 0; bool startRangeFound = false; Position textRunStartPosition; Position textRunEndPosition; TextIteratorBehaviorFlags behaviorFlags = TextIteratorEmitsObjectReplacementCharacter; if (getRangeFor == ForSelection) behaviorFlags |= TextIteratorEmitsCharactersBetweenAllVisiblePositions; auto range = rangeOfContents(const_cast<ContainerNode*>(&scope)); TextIterator it(range->startPosition(), range->endPosition(), behaviorFlags); // FIXME: the atEnd() check shouldn't be necessary, workaround for <http://bugs.webkit.org/show_bug.cgi?id=6289>. if (!start() && !length() && it.atEnd()) { resultRange->setStart(it.currentContainer(), 0, ASSERT_NO_EXCEPTION); resultRange->setEnd(it.currentContainer(), 0, ASSERT_NO_EXCEPTION); return resultRange.release(); } for (; !it.atEnd(); it.advance()) { int len = it.length(); textRunStartPosition = it.startPositionInCurrentContainer(); textRunEndPosition = it.endPositionInCurrentContainer(); bool foundStart = start() >= docTextPosition && start() <= docTextPosition + len; bool foundEnd = end() >= docTextPosition && end() <= docTextPosition + len; // Fix textRunRange->endPosition(), but only if foundStart || foundEnd, because it is only // in those cases that textRunRange is used. if (foundEnd) { // FIXME: This is a workaround for the fact that the end of a run // is often at the wrong position for emitted '\n's or if the // renderer of the current node is a replaced element. if (len == 1 && (it.characterAt(0) == '\n' || it.isInsideReplacedElement())) { it.advance(); if (!it.atEnd()) { textRunEndPosition = it.startPositionInCurrentContainer(); } else { Position runEnd = VisiblePosition(textRunStartPosition).next().deepEquivalent(); if (runEnd.isNotNull()) textRunEndPosition = createLegacyEditingPosition(runEnd.containerNode(), runEnd.computeOffsetInContainerNode()); } } } if (foundStart) { startRangeFound = true; if (textRunStartPosition.containerNode()->isTextNode()) { int offset = start() - docTextPosition; resultRange->setStart(textRunStartPosition.containerNode(), offset + textRunStartPosition.offsetInContainerNode(), IGNORE_EXCEPTION); } else { if (start() == docTextPosition) resultRange->setStart(textRunStartPosition.containerNode(), textRunStartPosition.offsetInContainerNode(), IGNORE_EXCEPTION); else resultRange->setStart(textRunEndPosition.containerNode(), textRunEndPosition.offsetInContainerNode(), IGNORE_EXCEPTION); } } if (foundEnd) { if (textRunStartPosition.containerNode()->isTextNode()) { int offset = end() - docTextPosition; resultRange->setEnd(textRunStartPosition.containerNode(), offset + textRunStartPosition.offsetInContainerNode(), IGNORE_EXCEPTION); } else { if (end() == docTextPosition) resultRange->setEnd(textRunStartPosition.containerNode(), textRunStartPosition.offsetInContainerNode(), IGNORE_EXCEPTION); else resultRange->setEnd(textRunEndPosition.containerNode(), textRunEndPosition.offsetInContainerNode(), IGNORE_EXCEPTION); } docTextPosition += len; break; } docTextPosition += len; } if (!startRangeFound) return nullptr; if (length() && end() > docTextPosition) { // end() is out of bounds resultRange->setEnd(textRunEndPosition.containerNode(), textRunEndPosition.offsetInContainerNode(), IGNORE_EXCEPTION); } return resultRange.release(); }