71 class TOPPMapAlignerBase :
76 TOPPMapAlignerBase(String name, String description,
bool official =
true) :
77 TOPPBase(name, description, official), ref_params_(REF_NONE)
82 static Param getModelDefaults(
const String& default_model)
85 params.setValue(
"type", default_model,
"Type of model");
87 StringList model_types = ListUtils::create<String>(
"linear,b_spline,lowess,interpolated");
90 model_types.insert(model_types.begin(), default_model);
92 params.setValidStrings(
"type", model_types);
96 params.insert(
"linear:", model_params);
97 params.setSectionDescription(
"linear",
"Parameters for 'linear' model");
100 params.insert(
"b_spline:", model_params);
101 params.setSectionDescription(
"b_spline",
"Parameters for 'b_spline' model");
104 params.insert(
"lowess:", model_params);
105 params.setSectionDescription(
"lowess",
"Parameters for 'lowess' model");
108 params.insert(
"interpolated:", model_params);
109 params.setSectionDescription(
"interpolated",
110 "Parameters for 'interpolated' model");
120 enum ReferenceParameterKind { REF_NONE, REF_RESTRICTED, REF_FLEXIBLE }
123 void registerOptionsAndFlags_(
const String& file_formats,
124 enum ReferenceParameterKind ref_params)
126 registerInputFileList_(
"in",
"<files>",
StringList(),
"Input files to align (all must have the same file type)",
true);
127 setValidFormats_(
"in", ListUtils::create<String>(file_formats));
128 registerOutputFileList_(
"out",
"<files>",
StringList(),
"Output files (same file type as 'in'). Either this option or 'trafo_out' has to be provided; they can be used together.",
false);
129 setValidFormats_(
"out", ListUtils::create<String>(file_formats));
130 registerOutputFileList_(
"trafo_out",
"<files>",
StringList(),
"Transformation output files. Either this option or 'out' has to be provided; they can be used together.",
false);
131 setValidFormats_(
"trafo_out", ListUtils::create<String>(
"trafoXML"));
133 if (ref_params != REF_NONE)
135 registerTOPPSubsection_(
"reference",
"Options to define a reference file (use either 'file' or 'index', not both)");
136 String description =
"File to use as reference";
137 if (ref_params == REF_RESTRICTED)
139 description +=
" (same file format as input files required)";
141 registerInputFile_(
"reference:file",
"<file>",
"", description,
false);
142 setValidFormats_(
"reference:file", ListUtils::create<String>(file_formats));
143 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);
144 setMinInt_(
"reference:index", 0);
146 ref_params_ = ref_params;
149 ExitCodes checkParameters_()
156 StringList trafos = getStringList_(
"trafo_out");
162 if (outs.empty() && trafos.empty())
164 writeLog_(
"Error: Either data output or transformation output files have to be provided (parameters 'out'/'trafo_out')");
165 return ILLEGAL_PARAMETERS;
168 if (!outs.empty() && (ins.size() != outs.size()))
170 writeLog_(
"Error: The number of data input and output files has to be equal (parameters 'in'/'out')");
171 return ILLEGAL_PARAMETERS;
173 if (!trafos.empty() && (ins.size() != trafos.size()))
175 writeLog_(
"Error: The number of data input and transformation output files has to be equal (parameters 'in'/'trafo_out')");
176 return ILLEGAL_PARAMETERS;
180 for (
Size i = 1; i < ins.size(); ++i)
184 writeLog_(
"Error: All input files (parameter 'in') must have the same format!");
185 return ILLEGAL_PARAMETERS;
189 if (ref_params_ != REF_NONE)
191 Size reference_index = getIntOption_(
"reference:index");
192 String reference_file = getStringOption_(
"reference:file");
193 if (reference_index > ins.size())
195 writeLog_(
"Error: Value of parameter 'reference:index' must not be higher than the number of input files");
196 return ILLEGAL_PARAMETERS;
198 if (reference_index && !reference_file.empty())
200 writeLog_(
"Error: Parameters 'reference:index' and 'reference:file' cannot be used together");
201 return ILLEGAL_PARAMETERS;
204 if ((ref_params_ == REF_RESTRICTED) && !reference_file.empty() &&
207 writeLog_(
"Error: Reference file must have the same format as other input files (parameters 'reference:file'/'in')");
208 return ILLEGAL_PARAMETERS;
Type
Actual file types enum.
Definition: FileTypes.h:58
static FileTypes::Type getType(const String &filename)
Tries to determine the file type (by name or content)
Main OpenMS namespace.
Definition: FeatureDeconvolution.h:46
std::vector< String > StringList
Vector of String.
Definition: ListUtils.h:73
size_t Size
Size type e.g. used as variable which can hold result of size()
Definition: Types.h:127
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:149