Skip to content

Commit

Permalink
support output directories in TOPPAS
Browse files Browse the repository at this point in the history
  • Loading branch information
cbielow committed May 31, 2024
1 parent 20d6e71 commit 2a5b34e
Show file tree
Hide file tree
Showing 18 changed files with 730 additions and 283 deletions.
161 changes: 90 additions & 71 deletions share/OpenMS/examples/TOPPAS/QualityControl.toppas

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,6 @@ public slots:
/// The edge we are configuring
TOPPASEdge * edge_;

/// Vector storing the mapping of the target input combobox indices to param indices of edges
QVector<int> target_input_param_indices_;

protected slots:

/// Called when OK is pressed; checks if the selected parameters are valid
Expand Down
28 changes: 2 additions & 26 deletions src/openms_gui/include/OpenMS/VISUAL/TOPPASOutputFileListVertex.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,21 +21,12 @@ namespace OpenMS
@ingroup TOPPAS_elements
*/
class OPENMS_GUI_DLLAPI TOPPASOutputFileListVertex :
public TOPPASVertex
public TOPPASOutputVertex
{
Q_OBJECT

public:

/// Default constructor
TOPPASOutputFileListVertex() = default;
/// Copy constructor
TOPPASOutputFileListVertex(const TOPPASOutputFileListVertex & rhs);
/// Destructor
~TOPPASOutputFileListVertex() override = default;
/// Assignment operator
TOPPASOutputFileListVertex & operator=(const TOPPASOutputFileListVertex & rhs);
/// returns "OutputVertex"
/// returns "OutputFileVertex"
String getName() const override;
// documented in base class
void paint(QPainter * painter, const QStyleOptionGraphicsItem * option, QWidget * widget) override;
Expand Down Expand Up @@ -66,21 +57,6 @@ namespace OpenMS
public slots:
//documented in base class
void inEdgeHasChanged() override;

signals:
/// Emitted when an output file was written
void outputFileWritten(const String& file);

/// Emitted when user has changed the output folder name (i.e. output dir needs to be newly created and packages updates)
void outputFolderNameChanged();

protected:
/// custom output folder name
QString output_folder_name_;

// convenience members, not required for operation, but for progress during copying
int files_written_ = 0; ///< files that were already written
int files_total_ = 0; ///< total number of files from upstream
};
}

63 changes: 63 additions & 0 deletions src/openms_gui/include/OpenMS/VISUAL/TOPPASOutputFolderVertex.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
// Copyright (c) 2002-present, The OpenMS Team -- EKU Tuebingen, ETH Zurich, and FU Berlin
// SPDX-License-Identifier: BSD-3-Clause
//
// --------------------------------------------------------------------------
// $Maintainer: Chris Bielow $
// $Authors: Chris Bielow $
// --------------------------------------------------------------------------

#pragma once

// OpenMS_GUI config
#include <OpenMS/VISUAL/OpenMS_GUIConfig.h>

#include <OpenMS/VISUAL/TOPPASVertex.h>

namespace OpenMS
{
/**
@brief A vertex representing an output folder
@ingroup TOPPAS_elements
*/
class OPENMS_GUI_DLLAPI TOPPASOutputFolderVertex :
public TOPPASOutputVertex
{
Q_OBJECT

public:
/// returns "OutputFolderVertex"
String getName() const override;
// documented in base class
void paint(QPainter * painter, const QStyleOptionGraphicsItem * option, QWidget * widget) override;
// documented in base class
QRectF boundingRect() const override;
// documented in base class
void reset(bool reset_all_files = false) override;
/// opens the folder containing the output data
void mouseDoubleClickEvent(QGraphicsSceneMouseEvent*) override;
/// Called when the parent node has finished execution
void run() override;
/// Returns the full directory (including preceding output path as selected by user)
String getFullOutputDirectory() const;
/// Returns the directory where the output files are stored
String getOutputDir() const;
/// Creates the output directory for this node
String createOutputDir() const;
/// Sets the topological sort number and removes invalidated tmp files
void setTopoNr(UInt nr) override;
/// Opens the folders of the output files
void openContainingFolder() const;
/// Sets a custom output folder name, which will be integrated into 'getOutputDir()' and 'getFullOutputDirectory()' calls.
/// @note The string is not checked for validity (avoid characters which are not allowed in directories, e.g. '{')
void setOutputFolderName(const QString& name);
/// return the output folder where results are written
const QString& getOutputFolderName() const;

public slots:
//documented in base class
void inEdgeHasChanged() override;

};
}

2 changes: 1 addition & 1 deletion src/openms_gui/include/OpenMS/VISUAL/TOPPASScene.h
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ namespace OpenMS
///Connects the signals to slots
void connectToolVertexSignals(TOPPASToolVertex * ttv);
///Connects the signals to slots
void connectOutputVertexSignals(TOPPASOutputFileListVertex * oflv);
void connectOutputVertexSignals(TOPPASOutputVertex * oflv);
///Connects the signals to slots
void connectMergerVertexSignals(TOPPASMergerVertex * tmv);
///Connects the signals to slots
Expand Down
17 changes: 10 additions & 7 deletions src/openms_gui/include/OpenMS/VISUAL/TOPPASToolVertex.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,8 @@ namespace OpenMS
enum IOType
{
IOT_FILE,
IOT_LIST
IOT_LIST,
IOT_DIR ///< output directory
};

/// Comparison operator
Expand All @@ -78,6 +79,11 @@ namespace OpenMS
return param_name.compare(rhs.param_name) < 0;
}
}
/// Comparison operator
bool operator==(const IOInfo& rhs) const
{
return type == rhs.type && param_name == rhs.param_name;
}

/// Assignment operator
IOInfo& operator=(const IOInfo& rhs)
Expand All @@ -92,10 +98,9 @@ namespace OpenMS
/// Is any of the input/output parameters a list?
static bool isAnyList(const QVector<IOInfo>& params)
{
for (QVector<IOInfo>::const_iterator it = params.begin();
it != params.end(); ++it)
for (const auto& p : params)
{
if (it->type == IOT_LIST) return true;
if (p.type == IOT_LIST) return true;
}
return false;
}
Expand Down Expand Up @@ -125,10 +130,8 @@ namespace OpenMS
const String& getType() const;
/// Returns input file/list parameters together with their valid types.
QVector<IOInfo> getInputParameters() const;
/// Returns output file/list parameters together with their valid types.
/// Returns output file/list/dir parameters together with their valid types.
QVector<IOInfo> getOutputParameters() const;
/// Returns 'output dir' parameters (if any)
QVector<IOInfo> getOutputDirParameters() const;
// documented in base class
void paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget) override;
// documented in base class
Expand Down
42 changes: 37 additions & 5 deletions src/openms_gui/include/OpenMS/VISUAL/TOPPASVertex.h
Original file line number Diff line number Diff line change
Expand Up @@ -131,12 +131,12 @@ namespace OpenMS
/// indexing via "parameter_index" of adjacent edge (could later be param_name) -> filenames
/// Index for input and output edges is (-1) implicitly, thus we need signed type
/// warning: the index refers to either input OR output (depending on if this structure is used for input files storage or output files storage)
typedef std::map<Int, VertexRoundPackage> RoundPackage;
typedef RoundPackage::const_iterator RoundPackageConstIt;
typedef RoundPackage::iterator RoundPackageIt;
using RoundPackage = std::map<Int, VertexRoundPackage>;
using RoundPackageConstIt = RoundPackage::const_iterator;
using RoundPackageIt = RoundPackage::iterator;

/// all information a node needs to process all rounds
typedef std::vector<RoundPackage> RoundPackages;
using RoundPackages = std::vector<RoundPackage>;

/// The color of a vertex during depth-first search
enum DFS_COLOR
Expand Down Expand Up @@ -346,5 +346,37 @@ public slots:
}

};
}

/**
@brief A vertex representing an output, either folder or files(s)
@ingroup TOPPAS_elements
*/
class OPENMS_GUI_DLLAPI TOPPASOutputVertex : public TOPPASVertex
{
Q_OBJECT
public:
/// Default C'tor
TOPPASOutputVertex() = default;
/// Copy constructor
TOPPASOutputVertex(const TOPPASOutputVertex& rhs);
/// Assignment operator
TOPPASOutputVertex& operator=(const TOPPASOutputVertex& rhs);

signals:
/// Emitted when an output file was written
void outputFileWritten(const String& file);

/// Emitted when user has changed the output folder name (i.e. output dir needs to be newly created and packages updates)
void outputFolderNameChanged();

protected:
/// custom output folder name
QString output_folder_name_;

// convenience members, not required for operation, but for progress during copying
int files_written_ = 0; ///< files that were already written
int files_total_ = 0; ///< total number of files from upstream
};
}

1 change: 1 addition & 0 deletions src/openms_gui/include/OpenMS/VISUAL/sources.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ TOPPASEdge.h
TOPPASInputFileListVertex.h
TOPPASMergerVertex.h
TOPPASOutputFileListVertex.h
TOPPASOutputFolderVertex.h
TOPPASResource.h
TOPPASResources.h
TOPPASScene.h
Expand Down
55 changes: 30 additions & 25 deletions src/openms_gui/source/VISUAL/APPLICATIONS/TOPPASBase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@
#include <QtWidgets/QVBoxLayout>
#include <QtWidgets/QWhatsThis>
#include <utility>
#include <OpenMS/VISUAL/TOPPASOutputFolderVertex.h>


using namespace std;
Expand Down Expand Up @@ -439,21 +440,18 @@ namespace OpenMS
header_labels.append(QString("TOPP tools"));
tools_tree_view->setHeaderLabels(header_labels);

QTreeWidgetItem* item = new QTreeWidgetItem((QTreeWidget*)nullptr);
item->setText(0, "<Input files>");
tools_tree_view->addTopLevelItem(item);
item = new QTreeWidgetItem((QTreeWidget*)nullptr);
item->setText(0, "<Output files>");
tools_tree_view->addTopLevelItem(item);
item = new QTreeWidgetItem((QTreeWidget*)nullptr);
item->setText(0, "<Merger>");
tools_tree_view->addTopLevelItem(item);
item = new QTreeWidgetItem((QTreeWidget*)nullptr);
item->setText(0, "<Collector>");
tools_tree_view->addTopLevelItem(item);
item = new QTreeWidgetItem((QTreeWidget*)nullptr);
item->setText(0, "<Splitter>");
tools_tree_view->addTopLevelItem(item);
auto add_list_item = [&tools_tree_view](const QString& node_name)
{
QTreeWidgetItem* item = new QTreeWidgetItem(tools_tree_view);
item->setText(0, node_name);
tools_tree_view->addTopLevelItem(item);
};
add_list_item("<Input files>");
add_list_item("<Output files>");
add_list_item("<Output folder>");
add_list_item("<Merger>");
add_list_item("<Collector>");
add_list_item("<Splitter>");

//Param category_param = param_.copy("tool_categories:", true);

Expand All @@ -477,24 +475,24 @@ namespace OpenMS

std::map<QString, QTreeWidgetItem*> category_map;

foreach(const QString &category, category_list)
for (const QString &category : category_list)
{
item = new QTreeWidgetItem((QTreeWidget*)nullptr);
auto item = new QTreeWidgetItem((QTreeWidget*)nullptr);
item->setText(0, category);
tools_tree_view->addTopLevelItem(item);
category_map[category] = item;
}

for (ToolListType::iterator it = tools_list.begin(); it != tools_list.end(); ++it)
for (const auto& tool : tools_list)
{
item = new QTreeWidgetItem(category_map[it->second.category.toQString()]);
item->setText(0, it->first.toQString());
auto item = new QTreeWidgetItem(category_map[tool.second.category.toQString()]);
item->setText(0, tool.first.toQString());
QTreeWidgetItem* parent_item = item;
StringList types = ToolHandler::getTypes(it->first);
for (StringList::iterator types_it = types.begin(); types_it != types.end(); ++types_it)
StringList types = ToolHandler::getTypes(tool.first);
for (const auto& type : types)
{
item = new QTreeWidgetItem(parent_item);
item->setText(0, types_it->toQString());
item->setText(0, type.toQString());
}
}
tools_tree_view->resizeColumnToContents(0);
Expand Down Expand Up @@ -1208,8 +1206,15 @@ namespace OpenMS
{
tv = new TOPPASOutputFileListVertex();
TOPPASOutputFileListVertex* oflv = dynamic_cast<TOPPASOutputFileListVertex*>(tv);
connect(oflv, SIGNAL(outputFileWritten(const String &)), this, SLOT(outputVertexFinished(const String &)));
scene->connectOutputVertexSignals(oflv);
connect(tv, SIGNAL(outputFileWritten(const String &)), this, SLOT(outputVertexFinished(const String &)));
scene->connectOutputVertexSignals((TOPPASOutputVertex*)oflv);
}
else if (tool_name == "<Output folder>")
{
tv = new TOPPASOutputFolderVertex();
TOPPASOutputFolderVertex* oflv = dynamic_cast<TOPPASOutputFolderVertex*>(tv);
connect(tv, SIGNAL(outputFileWritten(const String&)), this, SLOT(outputVertexFinished(const String&)));
scene->connectOutputVertexSignals((TOPPASOutputVertex*)oflv);
}
else if (tool_name == "<Merger>")
{
Expand Down
Loading

0 comments on commit 2a5b34e

Please sign in to comment.