40class TOPPFeatureLinkerBase :
46 TOPPFeatureLinkerBase(
String name,
String description,
bool official =
true) :
47 TOPPBase(name, description, official)
54 registerInputFileList_(
"in",
"<files>", ListUtils::create<String>(
""),
"input files separated by blanks",
true);
55 setValidFormats_(
"in", ListUtils::create<String>(
"featureXML,consensusXML"));
58 registerInputFile_(
"design",
"<file>",
"",
"input file containing the experimental design",
false);
61 registerFlag_(
"keep_subelements",
"For consensusXML input only: If set, the sub-features of the inputs are transferred to the output.");
86 for (
Size i = 0; i < ins.size(); ++i)
90 writeLogError_(
"Error: All input files must be of the same type!");
99 writeDebug_(
"Used algorithm parameters", algorithm_param, 3);
119 writeLogError_(
"Error: Using fractionated design with consensusXML als input is not supported!");
125 OPENMS_LOG_INFO <<
"Linking " << ins.size() <<
" featureXMLs." << endl;
132 map<unsigned, vector<String>> frac2files;
134 if (!design_file.empty())
147 writeLogError_(
"Error: Number of runs must match for every fraction!");
153 for (
Size i = 0; i != ins.size(); ++i)
159 vector<FeatureMap > maps(ins.size());
171 for (
Size i = 0; i < ins.size(); ++i)
180 if (ms_runs.size() > 1 || ms_runs.empty())
182 OPENMS_LOG_WARN <<
"Exactly one MS run should be associated with a FeatureMap. "
184 <<
" provided." << endl;
194 ms_run_locations.insert(ms_run_locations.end(), ms_runs.begin(), ms_runs.end());
210 ft.getSubordinates().clear();
211 ft.getConvexHulls().clear();
219 ft.setMetaValue(
"Group", group);
237 ms_run_locations.push_back(ms_run_locations[0]);
243 if (frac2files.size() == 1)
245 algorithm->
group(maps, out_map);
250 for (
Size i = 1; i <= frac2files.size(); ++i)
252 vector<FeatureMap> fraction_maps;
255 for (
size_t feature_map_index = 0; feature_map_index != frac2files[i].size(); ++feature_map_index)
257 fraction_maps.push_back(maps[feature_map_index]);
259 algorithm->
group(fraction_maps, out_map);
267 bool keep_subelements =
getFlag_(
"keep_subelements");
268 vector<ConsensusMap> maps(ins.size());
270 for (
Size i = 0; i < ins.size(); ++i)
273 maps[i].updateRanges();
276 maps[i].getPrimaryMSRunPath(ms_runs);
277 ms_run_locations.insert(ms_run_locations.end(), ms_runs.begin(), ms_runs.end());
278 if (keep_subelements)
280 auto saveOldMapIndex =
283 if (p.metaValueExists(
"map_index"))
285 p.setMetaValue(
"old_map_index", p.getMetaValue(
"map_index"));
289 OPENMS_LOG_WARN <<
"Warning: map_index not found in PeptideID. The tool will not be able to assign a"
290 "consistent one. Check the settings of previous tools." << std::endl;
293 maps[i].applyFunctionOnPeptideIDs(saveOldMapIndex,
true);
297 algorithm->
group(maps, out_map);
301 if (!keep_subelements)
303 for (
Size i = 0; i < ins.size(); ++i)
333 map<Size, UInt> num_consfeat_of_size;
336 ++num_consfeat_of_size[cf.size()];
340 for (map<Size, UInt>::reverse_iterator i = num_consfeat_of_size.rbegin();
341 i != num_consfeat_of_size.rend(); ++i)
343 OPENMS_LOG_INFO <<
" of size " << setw(2) << i->first <<
": " << setw(6)
344 << i->second << endl;
#define OPENMS_LOG_WARN
Macro if a warning, a piece of information which should be read by the user, should be logged.
Definition LogStream.h:447
#define OPENMS_LOG_INFO
Macro if a information, e.g. a status should be reported.
Definition LogStream.h:452
A consensus feature spanning multiple LC-MS/MS experiments.
Definition ConsensusFeature.h:45
A container for consensus elements.
Definition ConsensusMap.h:68
Size applyMemberFunction(Size(Type::*member_function)())
Applies a member function of Type to the container itself and all consensus features....
Definition ConsensusMap.h:283
void sortPeptideIdentificationsByMapIndex()
Sorts PeptideIdentifications of consensus features with respect to their map index.
const ColumnHeaders & getColumnHeaders() const
Non-mutable access to the file descriptions.
@ FEATURE_GROUPING
Feature grouping
Definition DataProcessing.h:48
void setParameters(const Param ¶m)
Sets the parameters.
static ExperimentalDesign load(const String &tsv_file, bool require_spectra_files)
Loads an experimental design from a tabular separated file.
Representation of an experimental design in OpenMS. Instances can be loaded with the ExperimentalDesi...
Definition ExperimentalDesign.h:109
unsigned getNumberOfFractions() const
bool sameNrOfMSFilesPerFraction() const
std::map< unsigned int, std::vector< String > > getFractionToMSFilesMapping() const
return fraction index to file paths (ordered by fraction_group)
size_t size() const noexcept
Definition ExposedVector.h:128
Options for loading files containing features.
Definition FeatureFileOptions.h:21
void setLoadConvexHull(bool convex)
void setLoadSubordinates(bool sub)
Base class for all feature grouping algorithms.
Definition FeatureGroupingAlgorithm.h:25
void transferSubelements(const std::vector< ConsensusMap > &maps, ConsensusMap &out) const
Transfers subelements (grouped features) from input consensus maps to the result consensus map.
virtual void group(const std::vector< FeatureMap > &maps, ConsensusMap &out)=0
Applies the algorithm. The features in the input maps are grouped and the output is written to the co...
A container for features.
Definition FeatureMap.h:82
void getPrimaryMSRunPath(StringList &toFill) const
get the file path to the first MS run
void updateRanges() override
An LC-MS feature.
Definition Feature.h:46
Facilitates file handling by file type recognition.
Definition FileHandler.h:46
void loadConsensusFeatures(const String &filename, ConsensusMap &map, const std::vector< FileTypes::Type > allowed_types={}, ProgressLogger::LogType log=ProgressLogger::NONE)
Loads a file into a ConsensusMap.
static FileTypes::Type getType(const String &filename)
Tries to determine the file type (by name or content)
FeatureFileOptions & getFeatOptions()
Mutable access to the feature file options for loading/storing.
void storeConsensusFeatures(const String &filename, const ConsensusMap &map, const std::vector< FileTypes::Type > allowed_types={}, ProgressLogger::LogType log=ProgressLogger::NONE)
Store a ConsensusFeatureMap.
void loadFeatures(const String &filename, FeatureMap &map, const std::vector< FileTypes::Type > allowed_types={}, ProgressLogger::LogType log=ProgressLogger::NONE)
Loads a file into a FeatureMap.
void setFeatOptions(const FeatureFileOptions &)
set feature file options for loading/storing
Management and storage of parameters / INI files.
Definition Param.h:46
Param copy(const std::string &prefix, bool remove_prefix=false) const
Returns a new Param object containing all entries that start with prefix.
Represents the set of candidates (SpectrumMatches) identified for a single precursor spectrum.
Definition PeptideIdentification.h:64
Base class for all classes that want to report their progress.
Definition ProgressLogger.h:27
void setProgress(SignedSize value) const
Sets the current progress.
void setLogType(LogType type) const
Sets the progress log that should be used. The default type is NONE!
void startProgress(SignedSize begin, SignedSize end, const String &label) const
Initializes the progress display.
void endProgress(UInt64 bytes_processed=0) const
@ CMD
Command line progress.
Definition ProgressLogger.h:44
A more convenient string class.
Definition String.h:34
Base class for TOPP applications.
Definition TOPPBase.h:122
Param const & getParam_() const
Return all parameters relevant to this TOPP tool.
void registerInputFileList_(const String &name, const String &argument, const StringList &default_value, const String &description, bool required=true, bool advanced=false, const StringList &tags=StringList())
Registers a list of input files option.
void addEmptyLine_()
Adds an empty line between registered variables in the documentation.
void registerInputFile_(const String &name, const String &argument, const String &default_value, const String &description, bool required=true, bool advanced=false, const StringList &tags=StringList())
Registers an input file option.
bool getFlag_(const String &name) const
Returns the value of a previously registered flag.
void writeDebug_(const String &text, UInt min_level) const
Writes a string to the log file and to OPENMS_LOG_DEBUG if the debug level is at least min_level.
void setValidFormats_(const String &name, const std::vector< String > &formats, const bool force_OpenMS_format=true)
Sets the formats for a input/output file option or for all members of an input/output file lists.
void registerFlag_(const String &name, const String &description, bool advanced=false)
Registers a flag.
StringList getStringList_(const String &name) const
Returns the value of a previously registered StringList.
String getStringOption_(const String &name) const
Returns the value of a previously registered string option (use getOutputDirOption() for output direc...
virtual void registerOptionsAndFlags_()=0
Sets the valid command line options (with argument) and flags (without argument).
DataProcessing getProcessingInfo_(DataProcessing::ProcessingAction action) const
Returns the data processing information.
void registerOutputFile_(const String &name, const String &argument, const String &default_value, const String &description, bool required=true, bool advanced=false)
Registers an output file option.
@ ILLEGAL_PARAMETERS
Definition TOPPBase.h:140
@ EXECUTION_OK
Definition TOPPBase.h:134
void addDataProcessing_(ConsensusMap &map, const DataProcessing &dp) const
Data processing setter for consensus maps.
void writeLogError_(const String &text) const
Writes a string to the log file and to OPENMS_LOG_ERROR.
UInt64 getUniqueId() const
Non-mutable access to unique id - returns the unique id.
Definition UniqueIdInterface.h:78
Size setUniqueId()
Assigns a new, valid unique id. Always returns 1.
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
const std::string ADDUCT_GROUP
Definition Constants.h:564
const std::string DC_CHARGE_ADDUCTS
Definition Constants.h:574
Main OpenMS namespace.
Definition openswathalgo/include/OpenMS/OPENSWATHALGO/DATAACCESS/ISpectrumAccess.h:19
Type
Actual file types enum.
Definition FileTypes.h:31
@ CONSENSUSXML
OpenMS consensus map format (.consensusXML)
Definition FileTypes.h:39
@ FEATUREXML
OpenMS feature file (.featureXML)
Definition FileTypes.h:37