OpenMS  2.7.0
TOPPASToolVertex.h
Go to the documentation of this file.
1 // --------------------------------------------------------------------------
2 // OpenMS -- Open-Source Mass Spectrometry
3 // --------------------------------------------------------------------------
4 // Copyright The OpenMS Team -- Eberhard Karls University Tuebingen,
5 // ETH Zurich, and Freie Universitaet Berlin 2002-2021.
6 //
7 // This software is released under a three-clause BSD license:
8 // * Redistributions of source code must retain the above copyright
9 // notice, this list of conditions and the following disclaimer.
10 // * Redistributions in binary form must reproduce the above copyright
11 // notice, this list of conditions and the following disclaimer in the
12 // documentation and/or other materials provided with the distribution.
13 // * Neither the name of any author or any participating institution
14 // may be used to endorse or promote products derived from this software
15 // without specific prior written permission.
16 // For a full list of authors, refer to the file AUTHORS.
17 // --------------------------------------------------------------------------
18 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
19 // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21 // ARE DISCLAIMED. IN NO EVENT SHALL ANY OF THE AUTHORS OR THE CONTRIBUTING
22 // INSTITUTIONS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
23 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
24 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
25 // OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
26 // WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
27 // OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
28 // ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 //
30 // --------------------------------------------------------------------------
31 // $Maintainer: Johannes Veit $
32 // $Authors: Johannes Junker, Chris Bielow $
33 // --------------------------------------------------------------------------
34 
35 #pragma once
36 
37 // OpenMS_GUI config
38 #include <OpenMS/VISUAL/OpenMS_GUIConfig.h>
39 
43 
44 #include <QtCore/QVector>
45 
46 namespace OpenMS
47 {
48  class TOPPASScene;
49 
60  class OPENMS_GUI_DLLAPI TOPPASToolVertex :
61  public TOPPASVertex
62  {
63  Q_OBJECT
64 
65 public:
67  enum TOOLSTATUS {TOOL_READY, TOOL_SCHEDULED, TOOL_RUNNING, TOOL_SUCCESS, TOOL_CRASH, TOOLSTATUS_SIZE};
68 
70  struct IOInfo
71  {
73  IOInfo() :
74  type(IOT_FILE),
75  param_name(),
76  valid_types()
77  {
78  }
79 
81  IOInfo(const IOInfo& rhs) :
82  type(rhs.type),
83  param_name(rhs.param_name),
84  valid_types(rhs.valid_types)
85  {
86  }
87 
89  enum IOType
90  {
92  IOT_LIST
93  };
94 
96  bool operator<(const IOInfo& rhs) const
97  {
98  if (type != rhs.type)
99  {
100  return type == IOT_FILE;
101  }
102  else
103  {
104  return param_name.compare(rhs.param_name) < 0;
105  }
106  }
107 
109  IOInfo& operator=(const IOInfo& rhs)
110  {
111  type = rhs.type;
112  param_name = rhs.param_name;
113  valid_types = rhs.valid_types;
114 
115  return *this;
116  }
117 
119  static bool isAnyList(const QVector<IOInfo>& params)
120  {
121  for (QVector<IOInfo>::const_iterator it = params.begin();
122  it != params.end(); ++it)
123  {
124  if (it->type == IOT_LIST) return true;
125  }
126  return false;
127  }
128 
135  };
136 
140  TOPPASToolVertex(const String& name, const String& type = "");
144  ~TOPPASToolVertex() override = default;
147 
149  String getName() const override;
151  const String& getType() const;
153  void getInputParameters(QVector<IOInfo>& input_infos) const;
155  void getOutputParameters(QVector<IOInfo>& output_infos) const;
156  // documented in base class
157  void paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget) override;
158  // documented in base class
159  QRectF boundingRect() const override;
160  // documented in base class
161  void setTopoNr(UInt nr) override;
162  // documented in base class
163  void reset(bool reset_all_files = false) override;
165  void setParam(const Param& param);
167  const Param& getParam();
169  void run() override;
173  bool updateCurrentOutputFileNames(const RoundPackages& pkg, String& error_message);
177  void editParam();
185  void createDirs();
193  bool isToolReady() const;
197  virtual void emitToolStarted();
199  bool invertRecylingMode() override;
200 
201 public slots:
202 
204  void executionFinished(int ec, QProcess::ExitStatus es);
216  virtual void toolScheduledSlot();
218  void inEdgeHasChanged() override;
220  void outEdgeHasChanged() override;
221 
222 signals:
223 
225  void toolStarted();
227  void toolFinished();
229  void toolCrashed();
231  void toolFailed(const QString& message = "");
233  void toppOutputReady(const QString& out);
234 
235 protected:
236 
238 
239  void mouseDoubleClickEvent(QGraphicsSceneMouseEvent* e) override;
241 
242 
245 
251  bool initParam_(const QString& old_ini_file = "");
253  void getParameters_(QVector<IOInfo>& io_infos, bool input_params) const;
255  void writeParam_(const Param& param, const QString& ini_file);
257  QString toolnameWithWhitespacesForFancyWordWrapping_(QPainter* painter, const QString& str);
260  void smartFileNames_(std::vector<QStringList>& filenames);
261 
271  TOOLSTATUS status_{TOOL_READY};
273  bool tool_ready_{true};
275  bool breakpoint_set_{false};
276  };
277 }
278 
Management and storage of parameters / INI files.
Definition: Param.h:70
A more convenient string class.
Definition: String.h:61
A container for all visual items of a TOPPAS workflow.
Definition: TOPPASScene.h:87
A vertex representing a TOPP tool.
Definition: TOPPASToolVertex.h:62
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:265
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:269
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:263
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.
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 openContainingFolder()
Opens the folder where the file is contained.
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:267
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:67
@ TOOL_CRASH
Definition: TOPPASToolVertex.h:67
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:104
std::vector< RoundPackage > RoundPackages
all information a node needs to process all rounds
Definition: TOPPASVertex.h:165
unsigned int UInt
Unsigned integer type.
Definition: Types.h:94
std::vector< String > StringList
Vector of String.
Definition: ListUtils.h:70
Main OpenMS namespace.
Definition: FeatureDeconvolution.h:47
Stores the information for input/output files/lists.
Definition: TOPPASToolVertex.h:71
IOType
The type.
Definition: TOPPASToolVertex.h:90
@ IOT_FILE
Definition: TOPPASToolVertex.h:91
String param_name
The name of the parameter.
Definition: TOPPASToolVertex.h:132
static bool isAnyList(const QVector< IOInfo > &params)
Is any of the input/output parameters a list?
Definition: TOPPASToolVertex.h:119
IOInfo & operator=(const IOInfo &rhs)
Assignment operator.
Definition: TOPPASToolVertex.h:109
StringList valid_types
The valid file types for this parameter.
Definition: TOPPASToolVertex.h:134
IOInfo()
Standard constructor.
Definition: TOPPASToolVertex.h:73
bool operator<(const IOInfo &rhs) const
Comparison operator.
Definition: TOPPASToolVertex.h:96
IOType type
The type of the parameter.
Definition: TOPPASToolVertex.h:130
IOInfo(const IOInfo &rhs)
Copy constructor.
Definition: TOPPASToolVertex.h:81