OpenMS  2.4.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-2018.
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 
42 
43 #include <QtCore/QVector>
44 
45 namespace OpenMS
46 {
47  class TOPPASScene;
48 
59  class OPENMS_GUI_DLLAPI TOPPASToolVertex :
60  public TOPPASVertex
61  {
62  Q_OBJECT
63 
64 public:
66  enum TOOLSTATUS {TOOL_READY, TOOL_SCHEDULED, TOOL_RUNNING, TOOL_SUCCESS, TOOL_CRASH, TOOLSTATUS_SIZE};
67 
69  struct IOInfo
70  {
72  IOInfo() :
73  type(IOT_FILE),
74  param_name(),
75  valid_types()
76  {
77  }
78 
80  IOInfo(const IOInfo& rhs) :
81  type(rhs.type),
82  param_name(rhs.param_name),
83  valid_types(rhs.valid_types)
84  {
85  }
86 
88  enum IOType
89  {
91  IOT_LIST
92  };
93 
95  bool operator<(const IOInfo& rhs) const
96  {
97  if (type != rhs.type)
98  {
99  return type == IOT_FILE;
100  }
101  else
102  {
103  return param_name.compare(rhs.param_name) < 0;
104  }
105  }
106 
108  IOInfo& operator=(const IOInfo& rhs)
109  {
110  type = rhs.type;
111  param_name = rhs.param_name;
112  valid_types = rhs.valid_types;
113 
114  return *this;
115  }
116 
118  static bool isAnyList(const QVector<IOInfo>& params)
119  {
120  for (QVector<IOInfo>::const_iterator it = params.begin();
121  it != params.end(); ++it)
122  {
123  if (it->type == IOT_LIST) return true;
124  }
125  return false;
126  }
127 
134  };
135 
139  TOPPASToolVertex(const String& name, const String& type = "");
143  ~TOPPASToolVertex() override;
145  TOPPASToolVertex& operator=(const TOPPASToolVertex& rhs);
146 
148  String getName() const override;
150  const String& getType() const;
152  void getInputParameters(QVector<IOInfo>& input_infos) const;
154  void getOutputParameters(QVector<IOInfo>& output_infos) const;
155  // documented in base class
156  void paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget) override;
157  // documented in base class
158  QRectF boundingRect() const override;
159  // documented in base class
160  QPainterPath shape() const override;
161  // documented in base class
162  void setTopoNr(UInt nr) override;
163  // documented in base class
164  void reset(bool reset_all_files = false) override;
166  void setParam(const Param& param);
168  const Param& getParam();
170  void run() override;
174  bool updateCurrentOutputFileNames(const RoundPackages& pkg, String& error_message);
176  TOOLSTATUS getStatus() const;
178  void editParam();
180  int numIterations();
182  String getFullOutputDirectory() const;
184  String getOutputDir() const;
186  void createDirs();
188  void openContainingFolder();
190  void openInTOPPView();
192  bool refreshParameters();
194  bool isToolReady() const;
196  void toggleBreakpoint();
198  virtual void emitToolStarted();
200  bool invertRecylingMode() override;
201 
202 public slots:
203 
205  void executionFinished(int ec, QProcess::ExitStatus es);
207  void forwardTOPPOutput();
209  void toolStartedSlot();
211  void toolFinishedSlot();
213  void toolCrashedSlot();
215  void toolFailedSlot();
217  virtual void toolScheduledSlot();
219  void inEdgeHasChanged() override;
221  void outEdgeHasChanged() override;
222 
223 signals:
224 
226  void toolStarted();
228  void toolFinished();
230  void toolCrashed();
232  void toolFailed(const QString& message = "");
234  void toppOutputReady(const QString& out);
235 
236 protected:
237 
239 
240  void mouseDoubleClickEvent(QGraphicsSceneMouseEvent* e) override;
242 
243 
245  TOPPASScene* getScene_() const;
246 
248  bool doesParamChangeInvalidate_();
250  bool renameOutput_();
252  bool initParam_(const QString& old_ini_file = "");
254  void getParameters_(QVector<IOInfo>& io_infos, bool input_params) const;
256  void writeParam_(const Param& param, const QString& ini_file);
258  QString toolnameWithWhitespacesForFancyWordWrapping_(QPainter* painter, const QString& str);
259 
272 
275 
278  void smartFileNames_(std::vector<QStringList>& filenames);
279 
280  };
281 }
282 
A container for all visual items of a TOPPAS workflow.
Definition: TOPPASScene.h:85
A more convenient string class.
Definition: String.h:57
A vertex representing a TOPP tool.
Definition: TOPPASToolVertex.h:59
Stores the information for input/output files/lists.
Definition: TOPPASToolVertex.h:69
The base class of the different vertex classes.
Definition: TOPPASVertex.h:100
Param param_
The parameters of the tool.
Definition: TOPPASToolVertex.h:267
unsigned int UInt
Unsigned integer type.
Definition: Types.h:94
Main OpenMS namespace.
Definition: FeatureDeconvolution.h:46
String tmp_path_
The temporary path.
Definition: TOPPASToolVertex.h:265
static bool isAnyList(const QVector< IOInfo > &params)
Is any of the input/output parameters a list?
Definition: TOPPASToolVertex.h:118
bool tool_ready_
tool initialization status: if C&#39;tor was successful in finding the TOPP tool, this is set to &#39;true&#39; ...
Definition: TOPPASToolVertex.h:271
Definition: TOPPASToolVertex.h:90
String type_
The type of the tool, or "" if it does not have a type.
Definition: TOPPASToolVertex.h:263
std::vector< RoundPackage > RoundPackages
all information a node needs to process all rounds
Definition: TOPPASVertex.h:172
IOInfo & operator=(const IOInfo &rhs)
Assignment operator.
Definition: TOPPASToolVertex.h:108
IOInfo(const IOInfo &rhs)
Copy constructor.
Definition: TOPPASToolVertex.h:80
IOInfo()
Standard constructor.
Definition: TOPPASToolVertex.h:72
bool breakpoint_set_
Breakpoint set?
Definition: TOPPASToolVertex.h:274
std::vector< String > StringList
Vector of String.
Definition: ListUtils.h:73
Management and storage of parameters / INI files.
Definition: Param.h:74
String param_name
The name of the parameter.
Definition: TOPPASToolVertex.h:131
IOType
The type.
Definition: TOPPASToolVertex.h:88
IOType type
The type of the parameter.
Definition: TOPPASToolVertex.h:129
TOOLSTATUS
current status of the vertex
Definition: TOPPASToolVertex.h:66
TOOLSTATUS status_
current status of the tool
Definition: TOPPASToolVertex.h:269
bool operator<(const IOInfo &rhs) const
Comparison operator.
Definition: TOPPASToolVertex.h:95
String name_
The name of the tool.
Definition: TOPPASToolVertex.h:261
StringList valid_types
The valid file types for this parameter.
Definition: TOPPASToolVertex.h:133