35 #ifndef OPENMS_APPLICATIONS_MAPALIGNERBASE_H 36 #define OPENMS_APPLICATIONS_MAPALIGNERBASE_H 72 class TOPPMapAlignerBase :
77 TOPPMapAlignerBase(String name, String description,
bool official =
true) :
78 TOPPBase(name, description, official), ref_params_(REF_NONE)
83 static Param getModelDefaults(
const String& default_model)
86 params.setValue(
"type", default_model,
"Type of model");
88 StringList model_types = ListUtils::create<String>(
"linear,b_spline,lowess,interpolated");
91 model_types.insert(model_types.begin(), default_model);
93 params.setValidStrings(
"type", model_types);
97 params.insert(
"linear:", model_params);
98 params.setSectionDescription(
"linear",
"Parameters for 'linear' model");
101 params.insert(
"b_spline:", model_params);
102 params.setSectionDescription(
"b_spline",
"Parameters for 'b_spline' model");
105 params.insert(
"lowess:", model_params);
106 params.setSectionDescription(
"lowess",
"Parameters for 'lowess' model");
109 params.insert(
"interpolated:", model_params);
110 params.setSectionDescription(
"interpolated",
111 "Parameters for 'interpolated' model");
121 enum ReferenceParameterKind { REF_NONE, REF_RESTRICTED, REF_FLEXIBLE }
124 void registerOptionsAndFlags_(
const String& file_formats,
125 enum ReferenceParameterKind ref_params)
127 registerInputFileList_(
"in",
"<files>",
StringList(),
"Input files to align (all must have the same file type)",
true);
128 setValidFormats_(
"in", ListUtils::create<String>(file_formats));
129 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);
130 setValidFormats_(
"out", ListUtils::create<String>(file_formats));
131 registerOutputFileList_(
"trafo_out",
"<files>",
StringList(),
"Transformation output files. Either this option or 'out' has to be provided; they can be used together.",
false);
132 setValidFormats_(
"trafo_out", ListUtils::create<String>(
"trafoXML"));
134 if (ref_params != REF_NONE)
136 registerTOPPSubsection_(
"reference",
"Options to define a reference file (use either 'file' or 'index', not both)");
137 String description =
"File to use as reference";
138 if (ref_params == REF_RESTRICTED)
140 description +=
" (same file format as input files required)";
142 registerInputFile_(
"reference:file",
"<file>",
"", description,
false);
143 setValidFormats_(
"reference:file", ListUtils::create<String>(file_formats));
144 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);
145 setMinInt_(
"reference:index", 0);
147 ref_params_ = ref_params;
150 ExitCodes checkParameters_()
157 StringList trafos = getStringList_(
"trafo_out");
163 if (outs.empty() && trafos.empty())
165 writeLog_(
"Error: Either data output or transformation output files have to be provided (parameters 'out'/'trafo_out')");
166 return ILLEGAL_PARAMETERS;
169 if (!outs.empty() && (ins.size() != outs.size()))
171 writeLog_(
"Error: The number of data input and output files has to be equal (parameters 'in'/'out')");
172 return ILLEGAL_PARAMETERS;
174 if (!trafos.empty() && (ins.size() != trafos.size()))
176 writeLog_(
"Error: The number of data input and transformation output files has to be equal (parameters 'in'/'trafo_out')");
177 return ILLEGAL_PARAMETERS;
181 for (
Size i = 1; i < ins.size(); ++i)
185 writeLog_(
"Error: All input files (parameter 'in') must have the same format!");
186 return ILLEGAL_PARAMETERS;
190 if (ref_params_ != REF_NONE)
192 Size reference_index = getIntOption_(
"reference:index");
193 String reference_file = getStringOption_(
"reference:file");
194 if (reference_index > ins.size())
196 writeLog_(
"Error: Value of parameter 'reference:index' must not be higher than the number of input files");
197 return ILLEGAL_PARAMETERS;
199 if (reference_index && !reference_file.empty())
201 writeLog_(
"Error: Parameters 'reference:index' and 'reference:file' cannot be used together");
202 return ILLEGAL_PARAMETERS;
205 if ((ref_params_ == REF_RESTRICTED) && !reference_file.empty() &&
208 writeLog_(
"Error: Reference file must have the same format as other input files (parameters 'reference:file'/'in')");
209 return ILLEGAL_PARAMETERS;
222 #endif // OPENMS_APPLICATIONS_MAPALIGNERBASE_H Type
Actual file types enum.
Definition: FileTypes.h:59
static FileTypes::Type getType(const String &filename)
Tries to determine the file type (by name or content)
Main OpenMS namespace.
Definition: FeatureDeconvolution.h:47
std::vector< String > StringList
Vector of String.
Definition: ListUtils.h:74
size_t Size
Size type e.g. used as variable which can hold result of size()
Definition: Types.h:128
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:150