static boolean isPreviousToNode(Node * previous, Node * target) { Node *currentNode = target; Node *previousNode = NULL; Time targetTime = getNodeTime(target); //velvetLog("Testing if %li is previous to %li\n", getNodeID(previous), getNodeID(target)); while (true) { //velvetLog("CCC %li %f\n", getNodeID(currentNode), getNodeTime(currentNode)); if (currentNode == previous) return true; if (currentNode == previousNode) return false; if (getNodeID(currentNode) > nodeCount(graph) || getNodeID(currentNode) < -nodeCount(graph)) { velvetLog("Node ID??? %li %li\n", (long) getNodeID(currentNode), (long) getNodeID(previousNode)); } if (getNodeTime(currentNode) != targetTime) return false; previousNode = currentNode; currentNode = getNodePrevious(currentNode); } }
void prepareGraphForLocalCorrections(Graph * argGraph) { IDnum nodes = nodeCount(argGraph); IDnum index; //Setting global params graph = argGraph; WORDLENGTH = getWordLength(graph);; // Done with global params velvetLog("Preparing to correct graph with cutoff %f\n", MAXDIVERGENCE); // Allocating memory times = mallocOrExit(2 * nodes + 1, Time); previous = mallocOrExit(2 * nodes + 1, Node *); dheapNodes = mallocOrExit(2 * nodes + 1, DFibHeapNode *); dheap = newDFibHeap(); fastSequence = newTightString(MAXREADLENGTH); slowSequence = newTightString(MAXREADLENGTH); for (index = 0; index < (2 * nodeCount(graph) + 1); index++) { times[index] = -1; dheapNodes[index] = NULL; previous[index] = NULL; } Fmatrix = callocOrExit(MAXREADLENGTH + 1, double *); for (index = 0; index < MAXREADLENGTH + 1; index++) Fmatrix[index] = callocOrExit(MAXREADLENGTH + 1, double); //Done with memory }
static void markInterestingNodes(Node * node) { Connection *connect; Node *destination; MiniConnection *localConnect; Coordinate min_distance = getNodeLength(node) / 2 - BACKTRACK_CUTOFF; // Mark own node setEmptyMiniConnection(node); // Loop thru primary scaffold for (connect = getConnection(node); connect != NULL; connect = getNextConnection(connect)) { destination = getTwinNode(getConnectionDestination(connect)); localConnect = &localScaffold[getNodeID(destination) + nodeCount(graph)]; if (getNodeStatus(destination)) { readjustMiniConnection(destination, localConnect, getConnectionDistance(connect), min_distance, getConnectionVariance(connect), connect, NULL); localConnect->backReference = NULL; } else { resetMiniConnection(destination, localConnect, getConnectionDistance(connect), getConnectionVariance(connect), connect, NULL, true); } integrateDerivativeDistances(connect, min_distance, true); } // Loop thru twin's primary scaffold for (connect = getConnection(getTwinNode(node)); connect != NULL; connect = getNextConnection(connect)) { destination = getConnectionDestination(connect); localConnect = &localScaffold[getNodeID(destination) + nodeCount(graph)]; if (getNodeStatus(destination)) readjustMiniConnection(destination, localConnect, -getConnectionDistance(connect), min_distance, getConnectionVariance(connect), NULL, connect); else resetMiniConnection(destination, localConnect, -getConnectionDistance(connect), getConnectionVariance(connect), NULL, connect, -1); integrateDerivativeDistances(connect, min_distance, false); } }
void destroyConnection(Connection * connect, IDnum nodeID) { Connection *previous, *next; //printf("Destroying connection from %li to %li\n", (long) nodeID, (long) getNodeID(connect->destination)); if (connect == NULL) return; previous = connect->previous; next = connect->next; if (previous != NULL) previous->next = next; if (next != NULL) next->previous = previous; if (scaffold[nodeID + nodeCount(graph)] == connect) scaffold[nodeID + nodeCount(graph)] = next; if (connect->twin != NULL) { connect->twin->twin = NULL; destroyConnection(connect->twin, getNodeID(connect->destination)); } deallocateConnection(connect); }
int nodeCount (TNODE_p_t root) { if (root == NULL) return 1; int leftCount = nodeCount(root->left); int rightCount = nodeCount(root->right); return (leftCount + rightCount); }
IndexArray MeshEntity::ids() const { IndexArray idVec(nodeCount()); for (uint i = 0; i < nodeCount(); i ++) { idVec[i] = node(i).id(); } return idVec; }
static IDnum *computeReadToNodeCounts() { IDnum readIndex, nodeIndex; IDnum maxNodeIndex = 2 * nodeCount(graph) + 1; IDnum maxReadIndex = sequenceCount(graph) + 1; IDnum *readNodeCounts = callocOrExit(maxReadIndex, IDnum); boolean *readMarker = callocOrExit(maxReadIndex, boolean); ShortReadMarker *nodeArray, *shortMarker; PassageMarkerI marker; Node *node; IDnum nodeReadCount; //puts("Computing read to node mapping array sizes"); for (nodeIndex = 0; nodeIndex < maxNodeIndex; nodeIndex++) { node = getNodeInGraph(graph, nodeIndex - nodeCount(graph)); if (node == NULL) continue; // Short reads if (readStartsAreActivated(graph)) { nodeArray = getNodeReads(node, graph); nodeReadCount = getNodeReadCount(node, graph); for (readIndex = 0; readIndex < nodeReadCount; readIndex++) { shortMarker = getShortReadMarkerAtIndex(nodeArray, readIndex); readNodeCounts[getShortReadMarkerID (shortMarker)]++; } } // Long reads for (marker = getMarker(node); marker != NULL_IDX; marker = getNextInNode(marker)) { readIndex = getPassageMarkerSequenceID(marker); if (readIndex < 0) continue; if (readMarker[readIndex]) continue; readNodeCounts[readIndex]++; readMarker[readIndex] = true; } // Clean up marker array for (marker = getMarker(node); marker != NULL_IDX; marker = getNextInNode(marker)) { readIndex = getPassageMarkerSequenceID(marker); if (readIndex > 0) readMarker[readIndex] = false; } } free(readMarker); return readNodeCounts; }
bool Node::moveLastToNode(Index index) const { if (nodeCount() == 0) return false; unsigned last = nodeCount() - 1; return moveNode(last, index); }
bool Node::moveNodeToLast(Index index) const { if (nodeCount() == 0) return false; unsigned last = nodeCount() - 1; return moveNode(index, last); }
size_t BinTree<T>::nodeCount(Node_T *&p) { size_t count = 0; if(p) { count += nodeCount(p->m_pChildren[0]) + //Nodos por la izquierda nodeCount(p->m_pChildren[1]) + //Nodos por la derecha 1; //Nodo por sí mismo } return count; }
bool Node::moveNodeUp(Index index) const { if (nodeCount() == 0) return false; if (index >= nodeCount()) return false; unsigned count = nodeCount(); unsigned otherIndex = (index - 1 + count) % count; return swapNodes(index, otherIndex); }
void nodeCount(struct node* node) { //assert(isDeleteFlagSet(node)); assert(isPromoteFlagSet(node)); if(isNull(node)) { return; } numOfNodes++; nodeCount(node->lChild); nodeCount(node->rChild); }
void readCoherentGraph(Graph * inGraph, boolean(*isUnique) (Node * node), double coverage, ReadSet * reads) { IDnum nodeIndex; Node *node; IDnum previousNodeCount = 0; graph = inGraph; listMemory = newRecycleBin(sizeof(PassageMarkerList), 100000); expected_coverage = coverage; sequences = reads->tSequences; velvetLog("Read coherency...\n"); resetNodeStatus(graph); identifyUniqueNodes(isUnique); trimLongReadTips(); previousNodeCount = 0; while (previousNodeCount != nodeCount(graph)) { previousNodeCount = nodeCount(graph); for (nodeIndex = 1; nodeIndex <= nodeCount(graph); nodeIndex++) { node = getNodeInGraph(graph, nodeIndex); if (node == NULL || !getUniqueness(node)) continue; while (uniqueNodesConnect(node)) node = bypass(); node = getTwinNode(node); while (uniqueNodesConnect(node)) node = bypass(); } renumberNodes(graph); } destroyRecycleBin(listMemory); destroyRecycleBin(nodeListMemory); velvetLog("Confronted to %li multiple hits and %li null over %li\n", (long) multCounter, (long) nullCounter, (long) dbgCounter); velvetLog("Read coherency over!\n"); }
static IDnum expectedNumberOfConnections(IDnum IDA, Connection * connect, IDnum ** counts, Category cat) { Node *A = getNodeInGraph(graph, IDA); Node *B = connect->destination; IDnum IDB = getNodeID(B); double left, middle, right; Coordinate longLength, shortLength, D; double M, N, O, P; Coordinate mu = getInsertLength(graph, cat); double sigma = sqrt(getInsertLength_var(graph, cat)); double result; double densityA, densityB, minDensity; if (mu <= 0) return 0; if (getNodeLength(A) == 0 || getNodeLength(B) == 0) return 0; if (getNodeLength(A) < getNodeLength(B)) { longLength = getNodeLength(B); shortLength = getNodeLength(A); } else { longLength = getNodeLength(A); shortLength = getNodeLength(B); } densityA = counts[cat][IDA + nodeCount(graph)] / (double) getNodeLength(A); densityB = counts[cat][IDB + nodeCount(graph)] / (double) getNodeLength(B); minDensity = densityA > densityB ? densityB : densityA; D = getConnectionDistance(connect) - (longLength + shortLength) / 2; M = (D - mu) / sigma; N = (D + shortLength - mu) / sigma; O = (D + longLength - mu) / sigma; P = (D + shortLength + longLength - mu) / sigma; left = ((norm(M) - norm(N)) - M * normInt(M, N)) * sigma; middle = shortLength * normInt(N, O); right = ((norm(O) - norm(P)) - P * normInt(O, P)) * (-sigma); result = (minDensity * (left + middle + right)); if (result > 0) return (IDnum) result; else return 0; }
Graph *importPreGraph(char *preGraphFilename, ReadSet * reads, char * roadmapFilename, boolean readTracking, short int accelerationBits) { boolean double_strand = false; Graph *graph = readPreGraphFile(preGraphFilename, &double_strand); Coordinate referenceMappingCount = 0; IDnum referenceCount = 0; if (nodeCount(graph) == 0) return graph; // If necessary compile reference -> node ReferenceMapping * referenceMappings = computeReferenceMappings(preGraphFilename, reads, &referenceMappingCount, &referenceCount); // Node -> reference maps NodeMask * nodeMasks = computeNodeMasks(referenceMappings, referenceMappingCount, graph); // Map k-mers to nodes KmerOccurenceTable *kmerTable = referenceGraphKmers(preGraphFilename, accelerationBits, graph, double_strand, nodeMasks, referenceMappingCount); free(nodeMasks); // Map sequences -> kmers -> nodes fillUpGraph(reads, kmerTable, graph, readTracking, double_strand, referenceMappings, referenceMappingCount, referenceCount, roadmapFilename); free(referenceMappings); return graph; }
ColoredGraph solve(const Graph& gr) { GC_Naive_2 naive; auto result = naive.solve(gr); for (;;) { auto c_gr = result; auto colorCount = result.colorCount()-1; for (auto i = 0; i < c_gr.nodeCount(); ++i) { if (c_gr.color(i) == colorCount) c_gr.unsetColor(i); } for (;;) { auto uncolored = c_gr.uncoloredNodes(); for (auto i : uncolored) { bool success = c_gr.setColor(i); if (success) continue; SetColorUsingKempeChain(c_gr, i); } if (uncolored.size() == c_gr.uncoloredNodeCount()) break; } if (c_gr.uncoloredNodeCount() > 0) break; else { cout << "new sol: " << c_gr.colorCount() << endl; assert(isFeasibleColoring(c_gr)); result = c_gr; } } return result; }
static void findOppositeNode(Node * node, Node ** oppositeNode, Coordinate * distance) { NodeList *nodeList; MiniConnection *localConnect; Node *node2; IDnum node2ID; *oppositeNode = NULL; *distance = 0; for (nodeList = markedNodes; nodeList != NULL; nodeList = nodeList->next) { node2 = nodeList->node; node2ID = getNodeID(node2); localConnect = &localScaffold[node2ID + nodeCount(graph)]; if (node2 == node) continue; if (!getUniqueness(node2)) continue; if (localConnect->distance < 0) continue; if (*oppositeNode == NULL || *distance > localConnect->distance) { *oppositeNode = node2; *distance = localConnect->distance; } } }
static void computeLocalNodeToNodeMappings() { IDnum index; Node *node; puts("Computing local connections"); activateArcLookupTable(graph); for (index = -nodeCount(graph); index <= nodeCount(graph); index++) { node = getNodeInGraph(graph, index); if (node && getUniqueness(node)) computeLocalNodeToNodeMappingsFromNode(node); } deactivateArcLookupTable(graph); }
static Connection *createNewConnection(IDnum nodeID, IDnum node2ID, IDnum direct_count, IDnum paired_count, Coordinate distance, double variance) { Node *destination = getNodeInGraph(graph, node2ID); IDnum nodeIndex = nodeID + nodeCount(graph); Connection *connect = allocateConnection(); // Fill in connect->destination = destination; connect->direct_count = direct_count; connect->paired_count = paired_count; connect->distance = (double) distance; connect->variance = variance; connect->weight = 0; connect->status = false; // Insert in scaffold connect->previous = NULL; connect->next = scaffold[nodeIndex]; if (scaffold[nodeIndex] != NULL) scaffold[nodeIndex]->previous = connect; scaffold[nodeIndex] = connect; if (node2ID != nodeID) createTwinConnection(node2ID, nodeID, connect); else connect->twin = NULL; return connect; }
static void createTwinConnection(IDnum nodeID, IDnum node2ID, Connection * connect) { Connection *newConnection = allocateConnection(); IDnum nodeIndex = nodeID + nodeCount(graph); // Fill in newConnection->distance = connect->distance; newConnection->variance = connect->variance; newConnection->direct_count = connect->direct_count; newConnection->paired_count = connect->paired_count; newConnection->destination = getNodeInGraph(graph, node2ID); newConnection->weight = 0; newConnection->status = false; // Batch to twin newConnection->twin = connect; connect->twin = newConnection; // Insert in scaffold newConnection->previous = NULL; newConnection->next = scaffold[nodeIndex]; if (scaffold[nodeIndex] != NULL) scaffold[nodeIndex]->previous = newConnection; scaffold[nodeIndex] = newConnection; }
static void recenterLocalScaffold(Node * node, Coordinate oldLength) { MiniConnection *localConnect; Coordinate distance_shift = (getNodeLength(node) - oldLength) / 2; Coordinate min_distance = getNodeLength(node) / 2 - BACKTRACK_CUTOFF; NodeList *nodeList, *next; IDnum node2ID; Node *node2; for (nodeList = markedNodes; nodeList != NULL; nodeList = next) { next = nodeList->next; node2 = nodeList->node; if (node2 == node) { setSingleNodeStatus(node2, 1); continue; } node2ID = getNodeID(node2); localConnect = &localScaffold[node2ID + nodeCount(graph)]; localConnect->distance -= distance_shift; if (localConnect->distance < min_distance && localConnect->backReference == NULL && localConnect->frontReference == NULL) unmarkNode(node2, localConnect); else if (getNodeStatus(node2) > 0) setSingleNodeStatus(node2, 1); else if (getNodeStatus(node2) < 0) setSingleNodeStatus(node2, -1); } }
// Sublevel node is unusual, since its Parameters are really the subrange it // operates on. As such, it doesn't have "Params" like most other nodes do. SublevelNode::SublevelNode(QObject *parent) : QObject(parent) { setName(QString("Spectral Range%1").arg(nodeCount())); m_type = FLOAT; addParam<float>("out", 0.0, true); // connect level to rangemeter widget for display CHECKED_CONNECT(Dispatch::Singleton()->getEngine(), SIGNAL(spectrumChanged(const FrequencySpectrum &)), this, SLOT(spectrumChanged(const FrequencySpectrum &))); // Update the spectrograph with selections, so that // it can display selected window, and send changes // back to this node. CHECKED_CONNECT(this, SIGNAL(sublevelSelected(SublevelNode*)), Dispatch::Singleton()->getSpectrograph(), SLOT(submeterSelected(SublevelNode *))); CHECKED_CONNECT(this, SIGNAL(sublevelDeselected(SublevelNode*)), Dispatch::Singleton()->getSpectrograph(), SLOT(submeterDeselected(SublevelNode *))); }
bool Node::moveNodeToNode(Index source, Index destination) const { unsigned count = nodeCount(); if(count < 2) return false; if (source >= count) return false; if (destination >= count) return false; if (source == destination) return false; if (moveNodeToLast(source) == false) return false; if (source < destination) --destination; if (destination == count - 1) --destination; if (popNodeToNode(destination) == false) { moveNodeToLast(source); return false; } return true; }
uint32_t C_DirectedGraph::unusedNodeIndex (void) const { uint32_t result = nodeCount () ; while (isNodeDefined (result)) { result ++ ; } return result ; }
Node::NodePtr Node::node(Index index) const { if (index >= nodeCount()) return nullptr; return clone(nodeKey(index)); }
void computeTranscripts(Graph * argGraph, Locus * loci, IDnum locusCount) { IDnum index; Locus *locus; IDnum distribution[4]; int configuration; double *scores = callocOrExit(2 * nodeCount(argGraph), double); graph = argGraph; resetNodeStatus(graph); prepareGraphForLocalCorrections2(graph); for (index = 0; index < locusCount; index++) { locus = getLocus(loci, index); setLocusStatus(locus, true); getDegreeDistribution(locus, distribution); configuration = hasPlausibleTranscripts(distribution); setLocusStatus(locus, true); addTranscriptToLocus(locus, configuration, scores); setLocusStatus(locus, false); } deactivateLocalCorrectionSettings2(); free(scores); }
const Node & Shape::node(Index i) const { if (i > nodeCount() - 1){ std::cerr << WHERE_AM_I << " requested shape node: " << i << " does not exist." << std::endl; exit(EXIT_MESH_NO_NODE); } return *nodeVector_[i]; }
void Shape::setNode(Index i, Node & n) { if (i > nodeCount() - 1){ std::cerr << WHERE_AM_I << " requested shape node: " << i << " does not exist." << std::endl; exit(EXIT_MESH_NO_NODE); } nodeVector_[i] = &n; this->changed(); }
void StickMan::setDrawSticks(bool on) { m_sticks = on; for (int i=0;i<nodeCount();++i) { Node *node = m_nodes[i]; node->setVisible(on); } }
static void tourBus_local(Node * startingPoint) { Node *currentNode = startingPoint; IDnum nodeID = getNodeID(startingPoint) + nodeCount(graph); //velvetLog("Tour bus from node %li...\n", getNodeID(startingPoint)); times[nodeID] = 0; previous[nodeID] = currentNode; while (currentNode != NULL) { dheapNodes[getNodeID(currentNode) + nodeCount(graph)] = NULL; tourBusNode_local(currentNode); currentNode = removeNextNodeFromDHeap(dheap); } }