43 static Param getModelDefaults(
const String& default_model)
46 params.setValue(
"type", default_model,
"Type of model");
48 std::vector<std::string> model_types = {
"linear",
"b_spline",
"lowess",
"interpolated"};
51 model_types.insert(model_types.begin(), default_model);
53 params.setValidStrings(
"type", model_types);
57 params.insert(
"linear:", model_params);
58 params.setSectionDescription(
"linear",
"Parameters for 'linear' model");
61 params.insert(
"b_spline:", model_params);
62 params.setSectionDescription(
"b_spline",
"Parameters for 'b_spline' model");
65 params.insert(
"lowess:", model_params);
66 params.setSectionDescription(
"lowess",
"Parameters for 'lowess' model");
69 params.insert(
"interpolated:", model_params);
70 params.setSectionDescription(
"interpolated",
71 "Parameters for 'interpolated' model");
77 class TOPPMapAlignerBase :
78 public TOPPBase,
public MapAlignerBase
82 TOPPMapAlignerBase(String name, String description,
bool official =
true) :
83 TOPPBase(name, description, official), ref_params_(REF_NONE)
93 enum ReferenceParameterKind { REF_NONE, REF_RESTRICTED, REF_FLEXIBLE }
96 void registerOptionsAndFlagsMapAligners_(
const String& file_formats,
97 enum ReferenceParameterKind ref_params)
99 registerInputFileList_(
"in",
"<files>",
StringList(),
"Input files to align (all must have the same file type)",
true);
100 setValidFormats_(
"in", ListUtils::create<String>(file_formats));
101 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);
102 setValidFormats_(
"out", ListUtils::create<String>(file_formats));
103 registerOutputFileList_(
"trafo_out",
"<files>",
StringList(),
"Transformation output files. This option or 'out' has to be provided; they can be used together.",
false);
104 setValidFormats_(
"trafo_out", ListUtils::create<String>(
"trafoXML"));
106 if (ref_params != REF_NONE)
108 registerTOPPSubsection_(
"reference",
"Options to define a reference file (use either 'file' or 'index', not both)");
109 String description =
"File to use as reference";
110 if (ref_params == REF_RESTRICTED)
112 description +=
" (same file format as input files required)";
114 registerInputFile_(
"reference:file",
"<file>",
"", description,
false);
115 setValidFormats_(
"reference:file", ListUtils::create<String>(file_formats));
116 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);
117 setMinInt_(
"reference:index", 0);
119 ref_params_ = ref_params;
122 ExitCodes checkParameters_()
129 StringList trafos = getStringList_(
"trafo_out");
135 if (outs.empty() && trafos.empty())
137 writeLogError_(
"Error: Data output or transformation output files have to be provided (parameters 'out'/'trafo_out')");
138 return ILLEGAL_PARAMETERS;
141 if (!outs.empty() && (ins.size() != outs.size()))
143 writeLogError_(
"Error: The number of data input and output files has to be equal (parameters 'in'/'out')");
144 return ILLEGAL_PARAMETERS;
146 if (!trafos.empty() && (ins.size() != trafos.size()))
148 writeLogError_(
"Error: The number of data input and transformation output files has to be equal (parameters 'in'/'trafo_out')");
149 return ILLEGAL_PARAMETERS;
153 for (
Size i = 1; i < ins.size(); ++i)
157 writeLogError_(
"Error: All input files (parameter 'in') must have the same format!");
158 return ILLEGAL_PARAMETERS;
162 if (ref_params_ != REF_NONE)
164 Size reference_index = getIntOption_(
"reference:index");
165 String reference_file = getStringOption_(
"reference:file");
166 if (reference_index > ins.size())
168 writeLogError_(
"Error: Value of parameter 'reference:index' must not be higher than the number of input files");
169 return ILLEGAL_PARAMETERS;
171 if (reference_index && !reference_file.empty())
173 writeLogError_(
"Error: Parameters 'reference:index' and 'reference:file' cannot be used together");
174 return ILLEGAL_PARAMETERS;
177 if ((ref_params_ == REF_RESTRICTED) && !reference_file.empty() &&
180 writeLogError_(
"Error: Reference file must have the same format as other input files (parameters 'reference:file'/'in')");
181 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:137
size_t Size
Size type e.g. used as variable which can hold result of size()
Definition: Types.h:97
std::vector< String > StringList
Vector of String.
Definition: ListUtils.h:44
Main OpenMS namespace.
Definition: openswathalgo/include/OpenMS/OPENSWATHALGO/DATAACCESS/ISpectrumAccess.h:19
Type
Actual file types enum.
Definition: FileTypes.h:31