Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gfa paths #103

Open
wants to merge 36 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
53a7917
Add posibility to colors node in cli image generation
natir Feb 3, 2017
d9c665a
Fix crash when adding new BLAST queries but not immediately running s…
rrwick Mar 10, 2017
2db0b0c
Refuse to load GFA/FASTG with duplicate node names
rrwick Mar 17, 2017
109c3cb
Remove unnecessary lines in project file
rrwick Mar 17, 2017
bf1d2ae
Merge pull request #35 from natir/master
rrwick Mar 18, 2017
d1b59ff
Add select nodes with dead ends
rrwick Apr 7, 2017
1c5050d
Merge branch 'development' of https://github.com/rrwick/Bandage into …
rrwick Apr 7, 2017
9acfcf3
Allow FASTQ files for BLAST search
rrwick May 8, 2017
c774cc5
Small fix for CSV parsing
rrwick May 26, 2017
3cbd21b
Fix Bandage info tab-delimited output
rrwick Jul 13, 2017
4f14171
Added dotplot.cpp and dotplot.h to calculate k-mer seed hits. Also, u…
isovic Oct 17, 2017
a18aaca
Added the placeholder for the dotplot, and removed the vertical space…
isovic Oct 17, 2017
a8622dd
Added a shared pointer to hold the dotplot scene, and the method whic…
isovic Oct 17, 2017
821dd3f
Added the signal handling and plotting of the dotplot between two sel…
isovic Oct 17, 2017
8439ab1
Added declarations to dotplot.h.
isovic Oct 18, 2017
9bccb54
Allowed self-dotplots.
isovic Oct 18, 2017
8870cb9
Added unit tests for the new methods.
isovic Oct 19, 2017
7899b41
Fixed the dotplot.cpp and dotplot.h according to the results discover…
isovic Oct 19, 2017
6246fd3
Changed the upper limit to k-mer size as checked by the Main window.
isovic Oct 19, 2017
7ed3e9f
Minor aesthetic changes.
isovic Oct 19, 2017
aafde88
Merge pull request #52 from isovic/dotplot
rrwick Oct 20, 2017
ccad4b8
Adjust UI layout of dotplot
rrwick Oct 20, 2017
cd243f9
Tweaks to dotplot
rrwick Oct 20, 2017
e0aec11
Use a spinbox for k-mer size input
rrwick Oct 20, 2017
76d98ba
Fix issues with tab order
rrwick Oct 24, 2017
542d69e
Added a failing test case for the dotplot.
isovic Oct 31, 2017
5348448
Fixed the bug in findHits (dotplot). Previously, only the first hit w…
isovic Oct 31, 2017
a94af64
Merge pull request #54 from isovic/dotplot
rrwick Nov 1, 2017
1eefc1a
Parse and store GFA paths
asl May 2, 2018
ed86881
Show loaded GFA paths
asl May 2, 2018
3f733e6
Allow path selection via GUI
asl May 2, 2018
dc211a9
Allow select nodes along GFA path
asl May 2, 2018
a0b9608
Implement recoloring
asl May 2, 2018
863b3d7
Properly recolor paths in double-stranded mode
asl May 2, 2018
9ea4047
Merge branch 'development' of https://github.com/rrwick/Bandage into …
ekg Jun 15, 2021
80ea6f2
correct merge
ekg Jun 15, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions Bandage.pro
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ INCLUDEPATH += ui

SOURCES += \
program/main.cpp\
program/dotplot.cpp \
program/settings.cpp \
program/globals.cpp \
program/graphlayoutworker.cpp \
Expand Down Expand Up @@ -119,6 +120,7 @@ SOURCES += \

HEADERS += \
program/settings.h \
program/dotplot.h \
program/globals.h \
program/graphlayoutworker.h \
graph/debruijnnode.h \
Expand Down
2 changes: 2 additions & 0 deletions BandageTests.pro
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ SOURCES += \
program/settings.cpp \
program/globals.cpp \
program/graphlayoutworker.cpp \
program/dotplot.cpp \
graph/debruijnnode.cpp \
graph/debruijnedge.cpp \
graph/graphicsitemnode.cpp \
Expand Down Expand Up @@ -123,6 +124,7 @@ HEADERS += \
program/settings.h \
program/globals.h \
program/graphlayoutworker.h \
program/dotplot.h \
graph/debruijnnode.h \
graph/debruijnedge.h \
graph/graphicsitemnode.h \
Expand Down
2 changes: 1 addition & 1 deletion command_line/image.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ int bandageImage(QStringList arguments)
std::vector<DeBruijnNode *> startingNodes = g_assemblyGraph->getStartingNodes(&errorTitle, &errorMessage,
g_settings->doubleMode,
g_settings->startingNodes,
"all");
"all", "");

QString errormsg;
QStringList columns;
Expand Down
2 changes: 1 addition & 1 deletion command_line/reduce.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ int bandageReduce(QStringList arguments)
std::vector<DeBruijnNode *> startingNodes = g_assemblyGraph->getStartingNodes(&errorTitle, &errorMessage,
g_settings->doubleMode,
g_settings->startingNodes,
"all");
"all", "");

if (errorMessage != "")
{
Expand Down
77 changes: 66 additions & 11 deletions graph/assemblygraph.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,13 +66,26 @@ AssemblyGraph::~AssemblyGraph()

void AssemblyGraph::cleanUp()
{
QMapIterator<QString, DeBruijnNode*> i(m_deBruijnGraphNodes);
while (i.hasNext())
{
i.next();
delete i.value();
QMapIterator<QString, Path*> i(m_deBruijnGraphPaths);
while (i.hasNext())
{
i.next();
delete i.value();
}
m_deBruijnGraphPaths.clear();
}


{
QMapIterator<QString, DeBruijnNode*> i(m_deBruijnGraphNodes);
while (i.hasNext())
{
i.next();
delete i.value();
}
m_deBruijnGraphNodes.clear();
}
m_deBruijnGraphNodes.clear();

QMapIterator<QPair<DeBruijnNode*, DeBruijnNode*>, DeBruijnEdge*> j(m_deBruijnGraphEdges);
while (j.hasNext())
Expand Down Expand Up @@ -396,6 +409,7 @@ void AssemblyGraph::determineGraphInfo()
m_edgeCount = edgeCount;
m_totalLength = totalLength;
m_meanDepth = getMeanDepth();
m_pathCount = m_deBruijnGraphPaths.size();

std::sort(nodeDepths.begin(), nodeDepths.end());

Expand Down Expand Up @@ -579,6 +593,7 @@ void AssemblyGraph::buildDeBruijnGraphFromGfa(QString fullFileName, bool *unsupp

QMap<QString, QColor> colours;
QMap<QString, QString> labels;
QMap<QString, QString> paths;

QTextStream in(&inputFile);
while (!in.atEnd()) {
Expand Down Expand Up @@ -770,6 +785,14 @@ void AssemblyGraph::buildDeBruijnGraphFromGfa(QString fullFileName, bool *unsupp
*unsupportedCigar = true;
}
}

// Load paths
else if (lineParts.at(0) == "P") {
if (lineParts.size() < 4)
continue;

paths.insert(lineParts.at(1), lineParts.at(2));
}
}

//Pair up reverse complements, creating them if necessary.
Expand Down Expand Up @@ -804,6 +827,22 @@ void AssemblyGraph::buildDeBruijnGraphFromGfa(QString fullFileName, bool *unsupp
int overlap = edgeOverlaps[i];
createDeBruijnEdge(node1Name, node2Name, overlap, EXACT_OVERLAP);
}

// Create all the paths.
QMapIterator<QString, QString> p(paths);
while (p.hasNext()) {
p.next();
QString pathName = p.key();

QString pathStringFailure;
Path pp = Path::makeFromString(p.value(), false, &pathStringFailure);

if (pp.isEmpty()) {
std::cout << pathStringFailure.toUtf8().constData() << std::endl;
} else {
m_deBruijnGraphPaths.insert(pathName, new Path(pp));
}
}
}

if (m_deBruijnGraphNodes.size() == 0)
Expand Down Expand Up @@ -2002,7 +2041,7 @@ void AssemblyGraph::addGraphicsItemsToScene(MyGraphicsScene * scene)


std::vector<DeBruijnNode *> AssemblyGraph::getStartingNodes(QString * errorTitle, QString * errorMessage, bool doubleMode,
QString nodesList, QString blastQueryName)
QString nodesList, QString blastQueryName, QString pathName)
{
std::vector<DeBruijnNode *> startingNodes;

Expand Down Expand Up @@ -2062,6 +2101,16 @@ std::vector<DeBruijnNode *> AssemblyGraph::getStartingNodes(QString * errorTitle
}
}

else if (g_settings->graphScope == AROUND_PATHS)
{
if (m_deBruijnGraphPaths.count(pathName) == 0)
{
*errorTitle = "Invalid path";
*errorMessage = "No path with such name is loaded";
return startingNodes;
}
}

g_settings->doubleMode = doubleMode;
clearOgdfGraphAndResetNodes();

Expand All @@ -2072,6 +2121,12 @@ std::vector<DeBruijnNode *> AssemblyGraph::getStartingNodes(QString * errorTitle
else if (g_settings->graphScope == DEPTH_RANGE)
startingNodes = getNodesInDepthRange(g_settings->minDepthRange,
g_settings->maxDepthRange);
else if (g_settings->graphScope == AROUND_PATHS) {
QList<DeBruijnNode *> nodes = m_deBruijnGraphPaths[pathName]->getNodes();

for (QList<DeBruijnNode *>::iterator i = nodes.begin(); i != nodes.end(); ++i)
startingNodes.push_back(*i);
}

return startingNodes;
}
Expand Down Expand Up @@ -3539,7 +3594,7 @@ void AssemblyGraph::getGraphComponentCountAndLargestComponentSize(int * componen

QSet<DeBruijnNode *> visitedNodes;
QList< QList<DeBruijnNode *> > connectedComponents;

//Loop through all positive nodes.
QMapIterator<QString, DeBruijnNode*> i(m_deBruijnGraphNodes);
while (i.hasNext())
Expand All @@ -3548,12 +3603,12 @@ void AssemblyGraph::getGraphComponentCountAndLargestComponentSize(int * componen
DeBruijnNode * v = i.value();
if (v->isNegativeNode())
continue;

//If the node has not yet been visited, then it must be the start of a new connected component.
if (!visitedNodes.contains(v))
{
QList<DeBruijnNode *> connectedComponent;

QQueue<DeBruijnNode *> q;
q.enqueue(v);
visitedNodes.insert(v);
Expand All @@ -3576,9 +3631,9 @@ void AssemblyGraph::getGraphComponentCountAndLargestComponentSize(int * componen
}

connectedComponents.push_back(connectedComponent);
}
}
}

//Now that the list of connected components is built, we look for the
//largest one (as measured by total node length).
*componentCount = connectedComponents.size();
Expand Down
6 changes: 5 additions & 1 deletion graph/assemblygraph.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,16 @@ class AssemblyGraph : public QObject
//pointers.
QMap<QPair<DeBruijnNode*, DeBruijnNode*>, DeBruijnEdge*> m_deBruijnGraphEdges;

QMap<QString, Path*> m_deBruijnGraphPaths;

ogdf::Graph * m_ogdfGraph;
ogdf::EdgeArray<double> * m_edgeArray;
ogdf::GraphAttributes * m_graphAttributes;

int m_kmer;
int m_nodeCount;
int m_edgeCount;
int m_pathCount;
long long m_totalLength;
long long m_shortestContig;
long long m_longestContig;
Expand Down Expand Up @@ -115,7 +118,8 @@ class AssemblyGraph : public QObject
QString * errorMessage,
bool doubleMode,
QString nodesList,
QString blastQueryName);
QString blastQueryName,
QString pathName);

bool checkIfStringHasNodes(QString nodesString);
QString generateNodesNotFoundErrorMessage(std::vector<QString> nodesNotInGraph,
Expand Down
Loading