69 static Param getModelDefaults(
const String& default_model)
72 params.setValue(
"type", default_model,
"Type of model");
74 std::vector<std::string> model_types = {
"linear",
"b_spline",
"lowess",
"interpolated"};
77 model_types.insert(model_types.begin(), default_model);
79 params.setValidStrings(
"type", model_types);
83 params.insert(
"linear:", model_params);
84 params.setSectionDescription(
"linear",
"Parameters for 'linear' model");
87 params.insert(
"b_spline:", model_params);
88 params.setSectionDescription(
"b_spline",
"Parameters for 'b_spline' model");
91 params.insert(
"lowess:", model_params);
92 params.setSectionDescription(
"lowess",
"Parameters for 'lowess' model");
95 params.insert(
"interpolated:", model_params);
96 params.setSectionDescription(
"interpolated",
97 "Parameters for 'interpolated' model");
103 class TOPPMapAlignerBase :
104 public TOPPBase,
public MapAlignerBase
108 TOPPMapAlignerBase(String name, String description,
bool official =
true) :
109 TOPPBase(name, description, official), ref_params_(REF_NONE)
119 enum ReferenceParameterKind { REF_NONE, REF_RESTRICTED, REF_FLEXIBLE }
122 void registerOptionsAndFlagsMapAligners_(
const String& file_formats,
123 enum ReferenceParameterKind ref_params)
125 registerInputFileList_(
"in",
"<files>",
StringList(),
"Input files to align (all must have the same file type)",
true);
126 setValidFormats_(
"in", ListUtils::create<String>(file_formats));
127 registerOutputFileList_(
"out",
"<files>",
StringList(),
"Output files (same file type as 'in'). This option or 'trafo_out' has to be provided; they can be used together.",
false);
128 setValidFormats_(
"out", ListUtils::create<String>(file_formats));
129 registerOutputFileList_(
"trafo_out",
"<files>",
StringList(),
"Transformation output files. This option or 'out' has to be provided; they can be used together.",
false);
130 setValidFormats_(
"trafo_out", ListUtils::create<String>(
"trafoXML"));
132 if (ref_params != REF_NONE)
134 registerTOPPSubsection_(
"reference",
"Options to define a reference file (use either 'file' or 'index', not both)");
135 String description =
"File to use as reference";
136 if (ref_params == REF_RESTRICTED)
138 description +=
" (same file format as input files required)";
140 registerInputFile_(
"reference:file",
"<file>",
"", description,
false);
141 setValidFormats_(
"reference:file", ListUtils::create<String>(file_formats));
142 registerIntOption_(
"reference:index",
"<number>", 0,
"Use one of the input files as reference ('1' for the first file, etc.).\nIf '0', no explicit reference is set - the algorithm will select a reference.",
false);
143 setMinInt_(
"reference:index", 0);
145 ref_params_ = ref_params;
148 ExitCodes checkParameters_()
155 StringList trafos = getStringList_(
"trafo_out");
161 if (outs.empty() && trafos.empty())
163 writeLog_(
"Error: Data output or transformation output files have to be provided (parameters 'out'/'trafo_out')");
164 return ILLEGAL_PARAMETERS;
167 if (!outs.empty() && (ins.size() != outs.size()))
169 writeLog_(
"Error: The number of data input and output files has to be equal (parameters 'in'/'out')");
170 return ILLEGAL_PARAMETERS;
172 if (!trafos.empty() && (ins.size() != trafos.size()))
174 writeLog_(
"Error: The number of data input and transformation output files has to be equal (parameters 'in'/'trafo_out')");
175 return ILLEGAL_PARAMETERS;
179 for (
Size i = 1; i < ins.size(); ++i)
183 writeLog_(
"Error: All input files (parameter 'in') must have the same format!");
184 return ILLEGAL_PARAMETERS;
188 if (ref_params_ != REF_NONE)
190 Size reference_index = getIntOption_(
"reference:index");
191 String reference_file = getStringOption_(
"reference:file");
192 if (reference_index > ins.size())
194 writeLog_(
"Error: Value of parameter 'reference:index' must not be higher than the number of input files");
195 return ILLEGAL_PARAMETERS;
197 if (reference_index && !reference_file.empty())
199 writeLog_(
"Error: Parameters 'reference:index' and 'reference:file' cannot be used together");
200 return ILLEGAL_PARAMETERS;
203 if ((ref_params_ == REF_RESTRICTED) && !reference_file.empty() &&
206 writeLog_(
"Error: Reference file must have the same format as other input files (parameters 'reference:file'/'in')");
207 return ILLEGAL_PARAMETERS;
static FileTypes::Type getType(const String &filename)
Tries to determine the file type (by name or content)
static bool contains(const std::vector< T > &container, const E &elem)
Checks whether the element elem is contained in the given container.
Definition: ListUtils.h:162
size_t Size
Size type e.g. used as variable which can hold result of size()
Definition: Types.h:127
std::vector< String > StringList
Vector of String.
Definition: ListUtils.h:70
Main OpenMS namespace.
Definition: FeatureDeconvolution.h:47
Type
Actual file types enum.
Definition: FileTypes.h:57