OpenMS
TOPPASToolVertex.h
Go to the documentation of this file.
1 // Copyright (c) 2002-present, The OpenMS Team -- EKU Tuebingen, ETH Zurich, and FU Berlin
2 // SPDX-License-Identifier: BSD-3-Clause
3 //
4 // --------------------------------------------------------------------------
5 // $Maintainer: Johannes Veit $
6 // $Authors: Johannes Junker, Chris Bielow $
7 // --------------------------------------------------------------------------
8 
9 #pragma once
10 
11 // OpenMS_GUI config
12 #include <OpenMS/VISUAL/OpenMS_GUIConfig.h>
13 
17 
18 #include <QtCore/QVector>
19 
20 namespace OpenMS
21 {
22  class TOPPASScene;
23 
34  class OPENMS_GUI_DLLAPI TOPPASToolVertex :
35  public TOPPASVertex
36  {
37  Q_OBJECT
38 
39 public:
41  enum TOOLSTATUS {TOOL_READY, TOOL_SCHEDULED, TOOL_RUNNING, TOOL_SUCCESS, TOOL_CRASH, TOOLSTATUS_SIZE};
42 
44  struct IOInfo
45  {
47  IOInfo() :
48  type(IOT_FILE),
49  param_name(),
50  valid_types()
51  {
52  }
53 
55  IOInfo(const IOInfo& rhs) :
56  type(rhs.type),
57  param_name(rhs.param_name),
58  valid_types(rhs.valid_types)
59  {
60  }
61 
63  enum IOType
64  {
66  IOT_LIST
67  };
68 
70  bool operator<(const IOInfo& rhs) const
71  {
72  if (type != rhs.type)
73  {
74  return type == IOT_FILE;
75  }
76  else
77  {
78  return param_name.compare(rhs.param_name) < 0;
79  }
80  }
81 
83  IOInfo& operator=(const IOInfo& rhs)
84  {
85  type = rhs.type;
86  param_name = rhs.param_name;
87  valid_types = rhs.valid_types;
88 
89  return *this;
90  }
91 
93  static bool isAnyList(const QVector<IOInfo>& params)
94  {
95  for (QVector<IOInfo>::const_iterator it = params.begin();
96  it != params.end(); ++it)
97  {
98  if (it->type == IOT_LIST) return true;
99  }
100  return false;
101  }
102 
109  };
110 
114  TOPPASToolVertex(const String& name, const String& type = "");
118  ~TOPPASToolVertex() override = default;
121 
123  String getName() const override;
125  const String& getType() const;
127  void getInputParameters(QVector<IOInfo>& input_infos) const;
129  void getOutputParameters(QVector<IOInfo>& output_infos) const;
130  // documented in base class
131  void paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget) override;
132  // documented in base class
133  QRectF boundingRect() const override;
134  // documented in base class
135  void setTopoNr(UInt nr) override;
136  // documented in base class
137  void reset(bool reset_all_files = false) override;
139  void setParam(const Param& param);
141  const Param& getParam();
143  void run() override;
147  bool updateCurrentOutputFileNames(const RoundPackages& pkg, String& error_message);
151  void editParam();
159  void createDirs();
161  void openContainingFolder() const;
167  bool isToolReady() const;
171  virtual void emitToolStarted();
173  bool invertRecylingMode() override;
174 
175 public slots:
176 
178  void executionFinished(int ec, QProcess::ExitStatus es);
190  virtual void toolScheduledSlot();
192  void inEdgeHasChanged() override;
194  void outEdgeHasChanged() override;
195 
196 signals:
197 
199  void toolStarted();
201  void toolFinished();
203  void toolCrashed();
205  void toolFailed(const QString& message = "");
207  void toppOutputReady(const QString& out);
208 
209 protected:
210 
212 
213  void mouseDoubleClickEvent(QGraphicsSceneMouseEvent* e) override;
215 
216 
219 
225  bool initParam_(const QString& old_ini_file = "");
227  void getParameters_(QVector<IOInfo>& io_infos, bool input_params) const;
229  void writeParam_(const Param& param, const QString& ini_file);
231  QString toolnameWithWhitespacesForFancyWordWrapping_(QPainter* painter, const QString& str);
234  void smartFileNames_(std::vector<QStringList>& filenames);
235 
245  TOOLSTATUS status_{TOOL_READY};
247  bool tool_ready_{true};
249  bool breakpoint_set_{false};
250  };
251 }
252 
Management and storage of parameters / INI files.
Definition: Param.h:44
A more convenient string class.
Definition: String.h:34
Definition: TOPPASScene.h:61
A vertex representing a TOPP tool.
Definition: TOPPASToolVertex.h:36
TOOLSTATUS getStatus() const
return if tool failed or is ready etc.
void toppOutputReady(const QString &out)
Emitted from forwardTOPPOutput() to forward the signal outside.
void setParam(const Param &param)
Sets the Param object of this tool.
void reset(bool reset_all_files=false) override
String type_
The type of the tool, or "" if it does not have a type.
Definition: TOPPASToolVertex.h:239
void toggleBreakpoint()
Toggle breakpoint.
bool renameOutput_()
renames SUFFICES of the output files created by the TOPP tool by inspecting file content
bool initParam_(const QString &old_ini_file="")
Initializes the parameters with standard values (from -write_ini), uses the parameters from the old_i...
Param param_
The parameters of the tool.
Definition: TOPPASToolVertex.h:243
bool isToolReady() const
underlying TOPP tool found and parameters fetched?! (done in C'Tor)
void inEdgeHasChanged() override
Called by an incoming edge when it has changed.
void writeParam_(const Param &param, const QString &ini_file)
Writes param to the ini_file.
String name_
The name of the tool.
Definition: TOPPASToolVertex.h:237
void toolStartedSlot()
Called when the tool is started.
String getFullOutputDirectory() const
Returns the full directory (including preceding tmp path)
void toolFailedSlot()
Called when the tool has failed.
void toolFinished()
Emitted when the tool is finished.
TOPPASToolVertex(const TOPPASToolVertex &rhs)
Copy constructor.
void outEdgeHasChanged() override
Called by an outgoing edge when it has changed.
void openContainingFolder() const
Opens the folder where the file is contained.
bool invertRecylingMode() override
invert status of recycling (overriding base class)
void openInTOPPView()
Opens the files in TOPPView.
void toolCrashedSlot()
Called when the tool has crashed.
void toolFinishedSlot()
Called when the tool has finished.
String getOutputDir() const
Returns the directory where this tool stores its output files.
TOPPASToolVertex()
Default constructor.
virtual void toolScheduledSlot()
Called when the tool was scheduled for running.
TOPPASToolVertex & operator=(const TOPPASToolVertex &rhs)
Assignment operator.
bool updateCurrentOutputFileNames(const RoundPackages &pkg, String &error_message)
void forwardTOPPOutput()
Called when the running TOPP tool produces output.
void getInputParameters(QVector< IOInfo > &input_infos) const
Fills input_infos with the required input file/list parameters together with their valid types.
void editParam()
Lets the user edit the parameters of the tool.
int numIterations()
Returns the number of iterations this tool has to perform.
const String & getType() const
Returns the type of the tool.
String getName() const override
returns the name of the TOPP tool
void smartFileNames_(std::vector< QStringList > &filenames)
void mouseDoubleClickEvent(QGraphicsSceneMouseEvent *e) override
QString toolnameWithWhitespacesForFancyWordWrapping_(QPainter *painter, const QString &str)
Helper method for finding good boundaries for wrapping the tool name. Returns a string with whitespac...
String tmp_path_
The temporary path.
Definition: TOPPASToolVertex.h:241
void getParameters_(QVector< IOInfo > &io_infos, bool input_params) const
Fills io_infos with the required input/output file/list parameters. If input_params is true,...
TOOLSTATUS
current status of the vertex
Definition: TOPPASToolVertex.h:41
@ TOOL_CRASH
Definition: TOPPASToolVertex.h:41
bool refreshParameters()
Refreshes the parameters of this tool, returns if their has been a change.
QRectF boundingRect() const override
Returns the bounding rectangle of this item.
virtual void emitToolStarted()
Called when the QProcess in the queue is called: emits 'toolStarted()'.
void createDirs()
Creates all necessary directories.
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) override
void setTopoNr(UInt nr) override
Sets the topological sort number (overridden in tool and output vertices)
void run() override
Checks if all parent nodes have finished the tool execution and, if so, runs the tool.
TOPPASToolVertex(const String &name, const String &type="")
Constructor.
void toolStarted()
Emitted when the tool is started.
void getOutputParameters(QVector< IOInfo > &output_infos) const
Fills output_infos with the required output file/list parameters together with their valid types.
bool doesParamChangeInvalidate_()
determines if according to current status_, a parameter change would invalidate the pipeline status (...
~TOPPASToolVertex() override=default
Destructor.
void toolFailed(const QString &message="")
Emitted when the tool execution fails.
TOPPASScene * getScene_() const
get parent Scene
void toolCrashed()
Emitted when the tool crashes.
void executionFinished(int ec, QProcess::ExitStatus es)
Called when the execution of this tool has finished.
const Param & getParam()
Returns the Param object of this tool.
The base class of the different vertex classes.
Definition: TOPPASVertex.h:78
std::vector< RoundPackage > RoundPackages
all information a node needs to process all rounds
Definition: TOPPASVertex.h:139
unsigned int UInt
Unsigned integer type.
Definition: Types.h:64
std::vector< String > StringList
Vector of String.
Definition: ListUtils.h:44
Main OpenMS namespace.
Definition: openswathalgo/include/OpenMS/OPENSWATHALGO/DATAACCESS/ISpectrumAccess.h:19
Stores the information for input/output files/lists.
Definition: TOPPASToolVertex.h:45
IOType
The type.
Definition: TOPPASToolVertex.h:64
@ IOT_FILE
Definition: TOPPASToolVertex.h:65
String param_name
The name of the parameter.
Definition: TOPPASToolVertex.h:106
static bool isAnyList(const QVector< IOInfo > &params)
Is any of the input/output parameters a list?
Definition: TOPPASToolVertex.h:93
IOInfo & operator=(const IOInfo &rhs)
Assignment operator.
Definition: TOPPASToolVertex.h:83
StringList valid_types
The valid file types for this parameter.
Definition: TOPPASToolVertex.h:108
IOInfo()
Standard constructor.
Definition: TOPPASToolVertex.h:47
bool operator<(const IOInfo &rhs) const
Comparison operator.
Definition: TOPPASToolVertex.h:70
IOType type
The type of the parameter.
Definition: TOPPASToolVertex.h:104
IOInfo(const IOInfo &rhs)
Copy constructor.
Definition: TOPPASToolVertex.h:55