Skip to content

Commit

Permalink
Move the read following portion of class mode3::Tangle to mode3::Tang…
Browse files Browse the repository at this point in the history
…leGraph.
  • Loading branch information
paoloshasta committed Dec 2, 2024
1 parent 3dcc3fb commit b720c14
Show file tree
Hide file tree
Showing 4 changed files with 483 additions and 8 deletions.
96 changes: 90 additions & 6 deletions src/mode3-Tangle.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// Shasta.
#include "mode3-Tangle.hpp"
#include "mode3-TangleGraph.hpp"
#include "deduplicate.hpp"
using namespace shasta;
using namespace mode3;
Expand All @@ -8,6 +9,55 @@ using namespace mode3;
#include <boost/graph/iteration_macros.hpp>


Tangle::Tangle(
bool debug,
AssemblyGraph& assemblyGraph,
uint64_t maxOffset,
const vector<AssemblyGraph::vertex_descriptor>& tangleVerticesArgument) :
debug(debug),
assemblyGraph(assemblyGraph),
tangleVertices(tangleVerticesArgument)
{
if(debug) {
cout << "Working on a tangle with " << tangleVertices.size() << " vertices." << endl;
}

// Sort the tangleVertices so we can do binary searches in them
// in isTangleVertex.
sort(tangleVertices.begin(), tangleVertices.end());
if(debug) {
writeTangleVertices();
}

findTangleEdges(maxOffset);
if(debug) {
writeTangleEdges();
}

findEntrances();
findExits();
if(debug) {
writeEntrances();
writeExits();
}

// Create the TangleGraph.
vector<AnchorId> entranceAnchorIds;
for(const Entrance& entrance: entrances) {
entranceAnchorIds.push_back(entrance.anchorId);
}
vector<AnchorId> exitAnchorIds;
for(const Exit& exit: exits) {
exitAnchorIds.push_back(exit.anchorId);
}
const bool bidirectional = true;
TangleGraph tangleGraph(debug, assemblyGraph.anchors,
entranceAnchorIds, exitAnchorIds, bidirectional);
}


#if 0
// Old code that does not use the TangleGraph.
Tangle::Tangle(
bool debug,
AssemblyGraph& assemblyGraph,
Expand Down Expand Up @@ -65,7 +115,7 @@ Tangle::Tangle(
}

}

#endif


bool Tangle::isTangleVertex(AssemblyGraph::vertex_descriptor v) const
Expand Down Expand Up @@ -139,16 +189,30 @@ void Tangle::writeTangleEdges() const

Tangle::EntranceOrExit::EntranceOrExit(
AssemblyGraph::edge_descriptor e,
AnchorId anchorId,
const Anchor& anchor) :
AnchorId anchorId) :
e(e),
anchorId(anchorId)
{
copy(anchor.begin(), anchor.end(), back_inserter(anchorMarkerIntervals));
}



// The entrances are AssemblyGraph edges that are not in the Tangle
// but whose target vertex is in the Tangle.
void Tangle::findEntrances()
{
for(const AssemblyGraph::vertex_descriptor v: tangleVertices) {
BGL_FORALL_INEDGES(v, e, assemblyGraph, AssemblyGraph) {
if(not isTangleEdge(e)) {
const Chain& chain = assemblyGraph[e].getOnlyChain();
const AnchorId anchorId = chain.secondToLast();
entrances.push_back(Entrance(e, anchorId));
}
}
}
}

#if 0
// The entrances are AssemblyGraph edges that are not in the Tangle
// but whose target vertex is in the Tangle.
void Tangle::findEntrances()
Expand Down Expand Up @@ -203,9 +267,26 @@ void Tangle::findEntrances()
}
}
}
#endif


// The exits are AssemblyGraph edges that are not in the Tangle
// but whose source vertex is in the Tangle.
void Tangle::findExits()
{
for(const AssemblyGraph::vertex_descriptor v: tangleVertices) {
BGL_FORALL_OUTEDGES(v, e, assemblyGraph, AssemblyGraph) {
if(not isTangleEdge(e)) {
const Chain& chain = assemblyGraph[e].getOnlyChain();
const AnchorId anchorId = chain.second();
exits.push_back(Exit(e, anchorId));
}
}
}
}


#if 0
// The exits are AssemblyGraph edges that are not in the Tangle
// but whose source vertex is in the Tangle.
void Tangle::findExits()
Expand Down Expand Up @@ -284,7 +365,7 @@ bool Tangle::isExit(AssemblyGraph::edge_descriptor e) const
}
return false;
}

#endif


void Tangle::writeEntrances() const
Expand All @@ -308,7 +389,7 @@ void Tangle::writeExits() const
}



#if 0
void Tangle::readFollowingFromEntrances()
{
for(Entrance& entrance: entrances) {
Expand Down Expand Up @@ -426,3 +507,6 @@ void Tangle::readFollowingFromExit(Exit& exit)
cout << "After deduplication, read following found " << exit.journeyAnchorIds.size() << " anchors." << endl;
}
}

#endif

5 changes: 3 additions & 2 deletions src/mode3-Tangle.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ class shasta::mode3::Tangle {
AssemblyGraph::edge_descriptor e;
AnchorId anchorId;

#if 0
// The AnchorMarkerIntervals on that AnchorId.
// These are initially copies from class Anchors.
// But later, for entrances we remove AnchorMarkerIntervals
Expand All @@ -76,11 +77,11 @@ class shasta::mode3::Tangle {
// The AnchorIds encountered during read following starting from this Entrance
// and no other entrance.
vector<AnchorId> uniqueJourneyAnchorIds;
#endif

EntranceOrExit(
AssemblyGraph::edge_descriptor,
AnchorId,
const Anchor&);
AnchorId);
};
class Entrance : public EntranceOrExit {using EntranceOrExit::EntranceOrExit;};
class Exit : public EntranceOrExit {using EntranceOrExit::EntranceOrExit;};
Expand Down
Loading

0 comments on commit b720c14

Please sign in to comment.