OpenMS  3.0.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-2022.
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;
146  TOPPASToolVertex& operator=(const TOPPASToolVertex& rhs);
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);
175  TOOLSTATUS getStatus() const;
177  void editParam();
179  int numIterations();
181  String getFullOutputDirectory() const;
183  String getOutputDir() const;
185  void createDirs();
187  void openContainingFolder() const;
189  void openInTOPPView();
191  bool refreshParameters();
193  bool isToolReady() const;
195  void toggleBreakpoint();
197  virtual void emitToolStarted();
199  bool invertRecylingMode() override;
200 
201 public slots:
202 
204  void executionFinished(int ec, QProcess::ExitStatus es);
206  void forwardTOPPOutput();
208  void toolStartedSlot();
210  void toolFinishedSlot();
212  void toolCrashedSlot();
214  void toolFailedSlot();
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 
244  TOPPASScene* getScene_() const;
245 
247  bool doesParamChangeInvalidate_();
249  bool renameOutput_();
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 
OpenMS::TOPPASToolVertex::tmp_path_
String tmp_path_
The temporary path.
Definition: TOPPASToolVertex.h:267
OpenMS::TOPPASScene
A container for all visual items of a TOPPAS workflow.
Definition: TOPPASScene.h:85
OpenMS::String
A more convenient string class.
Definition: String.h:58
OpenMS::TOPPASToolVertex
A vertex representing a TOPP tool.
Definition: TOPPASToolVertex.h:60
OpenMS::TOPPASToolVertex::IOInfo::operator=
IOInfo & operator=(const IOInfo &rhs)
Assignment operator.
Definition: TOPPASToolVertex.h:109
OpenMS::TOPPASToolVertex::IOInfo
Stores the information for input/output files/lists.
Definition: TOPPASToolVertex.h:70
QWidget
ListUtils.h
OpenMS::TOPPASToolVertex::param_
Param param_
The parameters of the tool.
Definition: TOPPASToolVertex.h:269
OpenMS::TOPPASToolVertex::IOInfo::type
IOType type
The type of the parameter.
Definition: TOPPASToolVertex.h:130
OpenMS::TOPPASToolVertex::IOInfo::valid_types
StringList valid_types
The valid file types for this parameter.
Definition: TOPPASToolVertex.h:134
OpenMS
Main OpenMS namespace.
Definition: FeatureDeconvolution.h:47
OpenMS::TOPPASToolVertex::type_
String type_
The type of the tool, or "" if it does not have a type.
Definition: TOPPASToolVertex.h:265
OpenMS::TOPPASToolVertex::TOOLSTATUS
TOOLSTATUS
current status of the vertex
Definition: TOPPASToolVertex.h:67
OpenMS::TOPPASToolVertex::IOInfo::IOInfo
IOInfo()
Standard constructor.
Definition: TOPPASToolVertex.h:73
OpenMS::TOPPASToolVertex::IOInfo::IOT_FILE
Definition: TOPPASToolVertex.h:91
Param.h
TOPPASVertex.h
OpenMS::TOPPASToolVertex::IOInfo::IOType
IOType
The type.
Definition: TOPPASToolVertex.h:89
OpenMS::TOPPASToolVertex::IOInfo::param_name
String param_name
The name of the parameter.
Definition: TOPPASToolVertex.h:132
OpenMS::TOPPASVertex
The base class of the different vertex classes.
Definition: TOPPASVertex.h:100
OpenMS::StringList
std::vector< String > StringList
Vector of String.
Definition: ListUtils.h:70
OpenMS::UInt
unsigned int UInt
Unsigned integer type.
Definition: Types.h:94
OpenMS::TOPPASToolVertex::IOInfo::isAnyList
static bool isAnyList(const QVector< IOInfo > &params)
Is any of the input/output parameters a list?
Definition: TOPPASToolVertex.h:119
OpenMS::TOPPASToolVertex::IOInfo::operator<
bool operator<(const IOInfo &rhs) const
Comparison operator.
Definition: TOPPASToolVertex.h:96
OpenMS::Param
Management and storage of parameters / INI files.
Definition: Param.h:69
OpenMS::TOPPASToolVertex::name_
String name_
The name of the tool.
Definition: TOPPASToolVertex.h:263
OpenMS::TOPPASVertex::RoundPackages
std::vector< RoundPackage > RoundPackages
all information a node needs to process all rounds
Definition: TOPPASVertex.h:164
OpenMS::TOPPASToolVertex::IOInfo::IOInfo
IOInfo(const IOInfo &rhs)
Copy constructor.
Definition: TOPPASToolVertex.h:81