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

Draft: display of Hi-C links and results of taxonomic analysis #113

Open
wants to merge 13 commits into
base: main
Choose a base branch
from
54 changes: 54 additions & 0 deletions blast/BlastFeaturesNodesMatcher.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
#include "BlastFeaturesNodesMatcher.h"
#include "BuildBlastDatabaseWorker.h"
#include "RunBlastSearchWorker.h"
#include "../blast/blastsearch.h"
#include "../blast/blasthit.h"
#include "../blast/blastquery.h"
#include "../program/globals.h"
#include "../program/settings.h"

BlastFeaturesNodesMatcher::BlastFeaturesNodesMatcher() {
m_makeblastdbCommand = "makeblastdb";
m_blastnCommand = "blastn";
m_tblastnCommand = "tblastn";
}

void BlastFeaturesNodesMatcher::matchFeaturesNode(RandomForestNode* selectedNode) {
std::vector<QString> querySequences = selectedNode->getQuerySequences();
if ((querySequences.size()!= 0) && (selectedNode->getBlastColourInd() == - 1)) {
//build blast db
if (!g_blastSearch->findProgram("makeblastdb", &m_makeblastdbCommand)) {
return;
}

BuildBlastDatabaseWorker buildBlastDatabaseWorker(m_makeblastdbCommand);
buildBlastDatabaseWorker.buildBlastDatabase();

//add blast query
//g_blastSearch->cleanUp();
QString featureNodeName = selectedNode->getName() + "_";
int indexColour = g_blastSearch->m_blastQueries.m_queries.size();
for (size_t i = 0; i < querySequences.size(); ++i)
{
QString queryName = featureNodeName + QString::number(i);
g_blastSearch->m_blastQueries.addQuery(new BlastQuery(queryName, querySequences[i]), indexColour, selectedNode->getClassInd());

}
//run blast search

if (!g_blastSearch->findProgram("blastn", &m_blastnCommand))
{
return;
}
if (!g_blastSearch->findProgram("tblastn", &m_tblastnCommand))
{
return;
}

g_blastSearch->clearBlastHits();

RunBlastSearchWorker runBlastSearchWorker(m_blastnCommand, m_tblastnCommand, "");
runBlastSearchWorker.runBlastSearch();
selectedNode->setBlastColourInd(indexColour);
}
}
18 changes: 18 additions & 0 deletions blast/BlastFeaturesNodesMatcher.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#ifndef BLASTFEATURESNODESMATCHER_H
#define BLASTFEATURESNODESMATCHER_H

#include <vector>
#include "../random_forest/RandomForestNode.h"

class BlastFeaturesNodesMatcher
{
public:
BlastFeaturesNodesMatcher();
void matchFeaturesNode(RandomForestNode* selectedNode);
private:
QString m_makeblastdbCommand;
QString m_blastnCommand;
QString m_tblastnCommand;
};

#endif //BLASTFEATURESNODESMATCHER_H
8 changes: 6 additions & 2 deletions blast/blasthit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,12 @@ std::vector<BlastHitPart> BlastHit::getBlastHitParts(bool reverse, double scaled
queryFraction += querySpacing;
}
}

else if (g_settings->nodeColourScheme == BLAST_HITS_CLASS_COLOURS) {
if (reverse)
returnVector.push_back(BlastHitPart(m_query->getFeatureClassColour(), 1.0 - m_nodeStartFraction, 1.0 - m_nodeEndFraction));
else
returnVector.push_back(BlastHitPart(m_query->getFeatureClassColour(), m_nodeStartFraction, m_nodeEndFraction));
}
//If the colour scheme is Blast solid, then this function generates only one
//BlastHitPart with a colour dependent on the Blast query.
else
Expand All @@ -96,7 +101,6 @@ std::vector<BlastHitPart> BlastHit::getBlastHitParts(bool reverse, double scaled
else
returnVector.push_back(BlastHitPart(m_query->getColour(), m_nodeStartFraction, m_nodeEndFraction));
}

return returnVector;
}

Expand Down
22 changes: 22 additions & 0 deletions blast/blastqueries.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,28 @@ void BlastQueries::addQuery(BlastQuery * newQuery)
updateTempFiles();
}

void BlastQueries::addQuery(BlastQuery* newQuery, int colourIndex)
{
newQuery->setName(getUniqueName(newQuery->getName()));

colourIndex %= m_presetColours.size();
newQuery->setColour(m_presetColours[colourIndex]);
m_queries.push_back(newQuery);
updateTempFiles();
}

void BlastQueries::addQuery(BlastQuery* newQuery, int colourIndex, int featureClassColour)
{
newQuery->setName(getUniqueName(newQuery->getName()));

colourIndex %= m_presetColours.size();
newQuery->setColour(m_presetColours[colourIndex]);
featureClassColour %= m_presetColours.size();
newQuery->setFeatureClassColour(m_presetColours[featureClassColour]);
m_queries.push_back(newQuery);
updateTempFiles();
}


//This function renames the query. It returns the name given, because that
//might not be exactly the same as the name passed to the function if it
Expand Down
2 changes: 2 additions & 0 deletions blast/blastqueries.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ class BlastQueries
int getQueryCount(SequenceType sequenceType);
bool isQueryPresent(BlastQuery * query);
void findQueryPaths();
void addQuery(BlastQuery* newQuery, int colourIndex);
void addQuery(BlastQuery* newQuery, int colourIndex, int featureClassColour);

std::vector<QColor> m_presetColours;

Expand Down
3 changes: 3 additions & 0 deletions blast/blastquery.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ class BlastQuery : public QObject
QList< QSharedPointer<BlastHit> > getHits() const {return m_hits;}
bool wasSearchedFor() const {return m_searchedFor;}
QColor getColour() const {return m_colour;}
QColor getFeatureClassColour() const {return m_featureClassColour;}
SequenceType getSequenceType() const {return m_sequenceType;}
QList<BlastQueryPath> getPaths() const {return m_paths;}
int getPathCount() const {return m_paths.size();}
Expand All @@ -63,6 +64,7 @@ class BlastQuery : public QObject

public slots:
void setColour(QColor newColour) {m_colour = newColour;}
void setFeatureClassColour(QColor newColour) { m_featureClassColour = newColour; }
void setShown(bool newShown) {m_shown = newShown;}

private:
Expand All @@ -71,6 +73,7 @@ public slots:
QList< QSharedPointer<BlastHit> > m_hits;
bool m_searchedFor;
QColor m_colour;
QColor m_featureClassColour;
SequenceType m_sequenceType;
QList<BlastQueryPath> m_paths;
bool m_shown;
Expand Down
2 changes: 1 addition & 1 deletion build_scripts/bandage_build_windows.bat
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,4 @@ call "%QT_PATH%\%MSVC_VERSION%\bin\windeployqt.exe" Bandage\Bandage.exe

rem Zip Bandage with the sample graph and clean up.
call "%ZIP_PATH%" a -tzip Bandage_Windows_v%VERSION%.zip Bandage\ sample_LastGraph installation.txt
call rmdir Bandage\ /S /Q
call rmdir Bandage\ /S /Q
Loading