| OpenMS 2.5.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-2020.
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
40 #include <OpenMS/VISUAL/TOPPASVertex.h>
41 #include <OpenMS/DATASTRUCTURES/Param.h>
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 {
90 IOT_FILE,
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
129 IOType type;
131 String param_name;
133 StringList valid_types;
134 };
135
137 TOPPASToolVertex();
139 TOPPASToolVertex(const String& name, const String& type = "");
141 TOPPASToolVertex(const TOPPASToolVertex& rhs);
143 ~TOPPASToolVertex() override = default;
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 void setTopoNr(UInt nr) override;
161 // documented in base class
162 void reset(bool reset_all_files = false) override;
164 void setParam(const Param& param);
166 const Param& getParam();
168 void run() override;
172 bool updateCurrentOutputFileNames(const RoundPackages& pkg, String& error_message);
174 TOOLSTATUS getStatus() const;
176 void editParam();
178 int numIterations();
180 String getFullOutputDirectory() const;
182 String getOutputDir() const;
184 void createDirs();
186 void openContainingFolder();
188 void openInTOPPView();
190 bool refreshParameters();
192 bool isToolReady() const;
194 void toggleBreakpoint();
196 virtual void emitToolStarted();
198 bool invertRecylingMode() override;
199
200 public slots:
201
203 void executionFinished(int ec, QProcess::ExitStatus es);
205 void forwardTOPPOutput();
207 void toolStartedSlot();
209 void toolFinishedSlot();
211 void toolCrashedSlot();
213 void toolFailedSlot();
215 virtual void toolScheduledSlot();
217 void inEdgeHasChanged() override;
219 void outEdgeHasChanged() override;
220
221 signals:
222
224 void toolStarted();
226 void toolFinished();
228 void toolCrashed();
230 void toolFailed(const QString& message = "");
232 void toppOutputReady(const QString& out);
233
234 protected:
235
237
238 void mouseDoubleClickEvent(QGraphicsSceneMouseEvent* e) override;
240
241
243 TOPPASScene* getScene_() const;
244
246 bool doesParamChangeInvalidate_();
248 bool renameOutput_();
250 bool initParam_(const QString& old_ini_file = "");
252 void getParameters_(QVector<IOInfo>& io_infos, bool input_params) const;
254 void writeParam_(const Param& param, const QString& ini_file);
256 QString toolnameWithWhitespacesForFancyWordWrapping_(QPainter* painter, const QString& str);
259 void smartFileNames_(std::vector<QStringList>& filenames);
260
262 String name_;
264 String type_;
266 String tmp_path_;
268 Param param_;
270 TOOLSTATUS status_{TOOL_READY};
272 bool tool_ready_{true};
274 bool breakpoint_set_{false};
275 };
276 }
277
OpenMS::String
A more convenient string class.
Definition: String.h:58
QWidget
OpenMS::TOPPASToolVertex::IOInfo::isAnyList
static bool isAnyList(const QVector< IOInfo > &params)
Is any of the input/output parameters a list?
Definition: TOPPASToolVertex.h:118
OpenMS::TOPPASToolVertex::IOInfo::type
IOType type
The type of the parameter.
Definition: TOPPASToolVertex.h:129
TOPPASVertex.h
OpenMS::TOPPASToolVertex
A vertex representing a TOPP tool.
Definition: TOPPASToolVertex.h:59
OpenMS::TOPPASToolVertex::IOInfo::valid_types
StringList valid_types
The valid file types for this parameter.
Definition: TOPPASToolVertex.h:133
OpenMS::TOPPASToolVertex::param_
Param param_
The parameters of the tool.
Definition: TOPPASToolVertex.h:268
OpenMS::TOPPASVertex::RoundPackages
std::vector< RoundPackage > RoundPackages
all information a node needs to process all rounds
Definition: TOPPASVertex.h:165
OpenMS::TOPPASToolVertex::IOInfo::IOInfo
IOInfo(const IOInfo &rhs)
Copy constructor.
Definition: TOPPASToolVertex.h:80
OpenMS::TOPPASToolVertex::IOInfo::operator=
IOInfo & operator=(const IOInfo &rhs)
Assignment operator.
Definition: TOPPASToolVertex.h:108
OpenMS::TOPPASToolVertex::IOInfo::operator<
bool operator<(const IOInfo &rhs) const
Comparison operator.
Definition: TOPPASToolVertex.h:95
OpenMS::TOPPASToolVertex::IOInfo::IOT_FILE
Definition: TOPPASToolVertex.h:90
OpenMS::TOPPASToolVertex::IOInfo::IOType
IOType
The type.
Definition: TOPPASToolVertex.h:88
OpenMS
Main OpenMS namespace.
Definition: FeatureDeconvolution.h:46
OpenMS::TOPPASScene
A container for all visual items of a TOPPAS workflow.
Definition: TOPPASScene.h:85
Param.h
OpenMS::TOPPASToolVertex::TOOLSTATUS
TOOLSTATUS
current status of the vertex
Definition: TOPPASToolVertex.h:66
OpenMS::TOPPASToolVertex::IOInfo::IOInfo
IOInfo()
Standard constructor.
Definition: TOPPASToolVertex.h:72
OpenMS::UInt
unsigned int UInt
Unsigned integer type.
Definition: Types.h:94
OpenMS::TOPPASToolVertex::IOInfo
Stores the information for input/output files/lists.
Definition: TOPPASToolVertex.h:69
OpenMS::Param
Management and storage of parameters / INI files.
Definition: Param.h:73
OpenMS::StringList
std::vector< String > StringList
Vector of String.
Definition: ListUtils.h:70
OpenMS::TOPPASToolVertex::name_
String name_
The name of the tool.
Definition: TOPPASToolVertex.h:262
OpenMS::TOPPASToolVertex::IOInfo::param_name
String param_name
The name of the parameter.
Definition: TOPPASToolVertex.h:131
OpenMS::TOPPASVertex
The base class of the different vertex classes.
Definition: TOPPASVertex.h:101
OpenMS::TOPPASToolVertex::type_
String type_
The type of the tool, or "" if it does not have a type.
Definition: TOPPASToolVertex.h:264
OpenMS::TOPPASToolVertex::tmp_path_
String tmp_path_
The temporary path.
Definition: TOPPASToolVertex.h:266