![]() |
OpenMS
|
Facilitates file handling by file type recognition. More...
#include <OpenMS/FORMAT/FileHandler.h>
Public Member Functions | |
| PeakFileOptions & | getOptions () |
| Mutable access to the options for loading/storing. | |
| const PeakFileOptions & | getOptions () const |
| Non-mutable access to the options for loading/storing. | |
| FeatureFileOptions & | getFeatOptions () |
| Mutable access to the feature file options for loading/storing. | |
| const FeatureFileOptions & | getFeatOptions () const |
| Non-mutable access to the feature file options for loading/storing. | |
| void | setOptions (const PeakFileOptions &) |
| set options for loading/storing | |
| void | setFeatOptions (const FeatureFileOptions &) |
| set feature file options for loading/storing | |
| void | loadExperiment (const std::string &filename, PeakMap &exp, const std::vector< FileTypes::Type > allowed_types=std::vector< FileTypes::Type >(), ProgressLogger::LogType log=ProgressLogger::NONE, const bool rewrite_source_file=false, const bool compute_hash=false) |
| Loads a file into an MSExperiment. | |
| void | transformExperiment (const std::string &filename, Interfaces::IMSDataConsumer *consumer, const std::vector< FileTypes::Type > allowed_types=std::vector< FileTypes::Type >(), ProgressLogger::LogType log=ProgressLogger::NONE, const bool rewrite_source_file=false, const bool compute_hash=false) |
| Streams a file into a consumer, spectrum by spectrum, without holding the whole experiment in memory. | |
| void | loadImagingExperiment (const std::string &filename, MSImagingExperiment &exp, const std::vector< FileTypes::Type > allowed_types=std::vector< FileTypes::Type >(), ProgressLogger::LogType log=ProgressLogger::NONE) |
| Loads a mass spectrometry imaging file into an MSImagingExperiment. | |
| void | storeExperiment (const std::string &filename, const PeakMap &exp, const std::vector< FileTypes::Type > allowed_types={}, ProgressLogger::LogType log=ProgressLogger::NONE) |
| Stores an MSExperiment to a file. | |
| void | loadSpectrum (const std::string &filename, MSSpectrum &spec, const std::vector< FileTypes::Type > allowed_types={}) |
| Loads a single MSSpectrum from a file. | |
| void | storeSpectrum (const std::string &filename, MSSpectrum &spec, const std::vector< FileTypes::Type > allowed_types={}) |
| Stores a single MSSpectrum to a file. | |
| void | loadFeatures (const std::string &filename, FeatureMap &map, const std::vector< FileTypes::Type > allowed_types={}, ProgressLogger::LogType log=ProgressLogger::NONE) |
| Loads a file into a FeatureMap. | |
| void | storeFeatures (const std::string &filename, const FeatureMap &map, const std::vector< FileTypes::Type > allowed_types={}, ProgressLogger::LogType log=ProgressLogger::NONE) |
| Store a FeatureMap. | |
| void | loadConsensusFeatures (const std::string &filename, ConsensusMap &map, const std::vector< FileTypes::Type > allowed_types={}, ProgressLogger::LogType log=ProgressLogger::NONE) |
| Loads a file into a ConsensusMap. | |
| void | storeConsensusFeatures (const std::string &filename, const ConsensusMap &map, const std::vector< FileTypes::Type > allowed_types={}, ProgressLogger::LogType log=ProgressLogger::NONE) |
| Store a ConsensusFeatureMap. | |
| void | loadIdentifications (const std::string &filename, std::vector< ProteinIdentification > &additional_proteins, PeptideIdentificationList &additional_peptides, const std::vector< FileTypes::Type > allowed_types={}, ProgressLogger::LogType log=ProgressLogger::NONE) |
| Loads an identification file into a proteinIdentifications and peptideIdentifications. | |
| void | storeIdentifications (const std::string &filename, const std::vector< ProteinIdentification > &additional_proteins, const PeptideIdentificationList &additional_peptides, const std::vector< FileTypes::Type > allowed_types={}, ProgressLogger::LogType log=ProgressLogger::NONE) |
| Stores proteins and peptides into an Identification File. | |
| void | loadTransitions (const std::string &filename, TargetedExperiment &library, const std::vector< FileTypes::Type > allowed_types={}, ProgressLogger::LogType log=ProgressLogger::NONE) |
| Load transitions of a spectral library. | |
| void | storeTransitions (const std::string &filename, const TargetedExperiment &library, const std::vector< FileTypes::Type > allowed_types={}, ProgressLogger::LogType log=ProgressLogger::NONE) |
| Store transitions of a spectral library. | |
| void | loadTransformations (const std::string &filename, TransformationDescription &map, bool fit_model=true, const std::vector< FileTypes::Type > allowed_types={}) |
| Loads a file into Transformations. | |
| void | storeTransformations (const std::string &filename, const TransformationDescription &map, const std::vector< FileTypes::Type > allowed_types={}) |
| Store Transformations. | |
| void | storeQC (const std::string &input_file, const std::string &filename, const MSExperiment &exp, const FeatureMap &feature_map, std::vector< ProteinIdentification > &prot_ids, PeptideIdentificationList &pep_ids, const ConsensusMap &consensus_map, const std::string &contact_name="", const std::string &contact_address="", const std::string &description="", const std::string &label="label", const bool remove_duplicate_features=false, const std::vector< FileTypes::Type > allowed_types={}) |
| Store QC info. | |
Static Public Member Functions | |
| static FileTypes::Type | getType (const std::string &filename) |
| Tries to determine the file type (by name or content) | |
| static FileTypes::Type | getTypeByFileName (const std::string &filename) |
| Try to get the file type from the filename. | |
| static bool | hasValidExtension (const std::string &filename, const FileTypes::Type type) |
Check if filename has the extension type. | |
| static std::string | stripExtension (const std::string &filename) |
| If filename contains an extension, it will be removed (including the '.'). Special extensions, known to OpenMS, e.g. '.mzML.gz' will be recognized as well. | |
| static std::string | swapExtension (const std::string &filename, const FileTypes::Type new_type) |
| Tries to find and remove a known file extension, and append the new one. | |
| static FileTypes::Type | getConsistentOutputfileType (const std::string &output_filename, const std::string &requested_type) |
Useful function for TOPP tools which have an 'out_type' parameter and want to know what output format to write. This function makes sure that the type derived from output_filename and requested_type are consistent, i.e. are either identical or one of them is UNKNOWN. Upon conflict, an error message is printed and the UNKNOWN type is returned. | |
| static FileTypes::Type | getTypeByContent (const std::string &filename) |
| Determines the file type of a file by parsing the first few lines. | |
| static bool | isSupported (FileTypes::Type type) |
| Returns if the file type is supported in this build of the library. | |
| static std::string | computeFileHash (const std::string &filename) |
| Computes a SHA-1 hash value for the content of the given file. | |
Private Member Functions | |
| void | applyPostLoadOptions_ (MSExperiment &exp) const |
| Applies the current PeakFileOptions filters to an already-loaded experiment. | |
Private Attributes | |
| PeakFileOptions | options_ |
| FeatureFileOptions | f_options_ |
Facilitates file handling by file type recognition.
This class provides file type recognition from the file name and from the file content.
It also offer a common interface to load MSExperiment data and allows querying for supported file types.
|
private |
Applies the current PeakFileOptions filters to an already-loaded experiment.
Used by the vendor-format paths. Bruker .d: loadExperiment() has the reader skip the MS levels, retention times and DDA precursors the options exclude, so that this data is not decoded; the filters here make the result exact (the reader's ranges are inclusive). Thermo .raw: the scan-level filters are passed to ThermoRawFile, only the per-peak filters are applied here. Filters MS level, RT range, precursor m/z range, ion mobility range, per-peak m/z and intensity ranges, and strips peak data when metadata-only is requested or fill-data is off. transformExperiment() applies the same filters to each spectrum. Calls updateRanges() at the end.
|
static |
Computes a SHA-1 hash value for the content of the given file.
|
static |
Useful function for TOPP tools which have an 'out_type' parameter and want to know what output format to write. This function makes sure that the type derived from output_filename and requested_type are consistent, i.e. are either identical or one of them is UNKNOWN. Upon conflict, an error message is printed and the UNKNOWN type is returned.
| [in] | output_filename | A full filename (with none, absolute or relative paths) whose type is determined using FileHandler::getTypeByFileName() internally |
| [in] | requested_type | A type as string, usually obtained from '-out_type', e.g. "FASTA" (case insensitive). The string can be empty (yields UNKNOWN for this type) |
| FeatureFileOptions & getFeatOptions | ( | ) |
Mutable access to the feature file options for loading/storing.
| const FeatureFileOptions & getFeatOptions | ( | ) | const |
Non-mutable access to the feature file options for loading/storing.
| PeakFileOptions & getOptions | ( | ) |
Mutable access to the options for loading/storing.
Referenced by MS1LabeledSpectra::load(), TOPPFLASHDeconv::main_(), and TOPPViewBase::metadataFileDialog().
| const PeakFileOptions & getOptions | ( | ) | const |
Non-mutable access to the options for loading/storing.
|
static |
Tries to determine the file type (by name or content)
First tries to determine the type from the file name. If this fails, the type is determined from the file content.
| [in] | filename | the name of the file to check |
| Exception::FileNotFound | is thrown if the file is not present |
Referenced by TOPPViewBase::addDataFile(), MS1LabeledSpectra::load(), and OpenMS::Internal::ClassTest::validateTmpFiles().
|
static |
Determines the file type of a file by parsing the first few lines.
| [in] | filename | The file to check |
| Exception::FileNotFound | is thrown if the file is not present |
Referenced by InspectOutfile::getExperiment().
|
static |
Try to get the file type from the filename.
| [in] | filename | the name of the file to check |
| Exception::FileNotFound | is thrown if the file is not present |
|
static |
Check if filename has the extension type.
If the extension is not known (e.g. '.tmp') this is also allowed. However, if the extension is another one (neither type nor unknown), false is returned.
| [in] | filename | The filename to check |
| [in] | type | The expected file type |
|
static |
Returns if the file type is supported in this build of the library.
| void loadConsensusFeatures | ( | const std::string & | filename, |
| ConsensusMap & | map, | ||
| const std::vector< FileTypes::Type > | allowed_types = {}, |
||
| ProgressLogger::LogType | log = ProgressLogger::NONE |
||
| ) |
Loads a file into a ConsensusMap.
| [in] | filename | the file name of the file to load. |
| [in] | map | The ConsensusMap to load the data into. |
| [in] | allowed_types | A vector of supported filetypes. If the vector is empty, load from any type that we have a handler for. Otherwise getType() is called internally to check the type |
| [in] | log | Progress logging mode |
| Exception::FileNotFound | is thrown if the file could not be opened |
| Exception::ParseError | is thrown if an error occurs during parsing |
Referenced by TOPPViewBase::addDataFile(), TOPPViewBase::fileChanged_(), and TOPPGNPSExport::main_().
| void loadExperiment | ( | const std::string & | filename, |
| PeakMap & | exp, | ||
| const std::vector< FileTypes::Type > | allowed_types = std::vector< FileTypes::Type >(), |
||
| ProgressLogger::LogType | log = ProgressLogger::NONE, |
||
| const bool | rewrite_source_file = false, |
||
| const bool | compute_hash = false |
||
| ) |
Loads a file into an MSExperiment.
| [out] | filename | The file name of the file to load. |
| [in] | exp | The experiment to load the data into. |
| [in] | allowed_types | A vector of supported filetypes. If the vector is empty, load from any type that we have a handler for. Otherwise getType() is called internally to check the type |
| [in] | log | Progress logging mode |
| [in] | rewrite_source_file | Set's the SourceFile name and path to the current file. Note that this looses the link to the primary MS run the file originated from. |
| [out] | compute_hash | If source files are rewritten, this flag triggers a recomputation of hash values. A SHA1 string gets stored in the checksum member of SourceFile. |
rewrite_source_file and compute_hash are set. Bruker .d directories and .d.zip archives (OpenMS built with WITH_OPENTIMS): the MS levels and the RT and ion mobility ranges are passed to the reader, which selects the spectra by their RT (a DDA MS2 spectrum is built from all of its frames) and skips the DDA precursors isolated outside the ion mobility range, so the frames they exclude are not decoded; all options are then applied to the loaded spectra. The ion mobility range (PeakFileOptions::setIMRange()) is applied to the data of every format here; the format readers themselves ignore it.| Exception::FileNotFound | is thrown if the file could not be opened |
| Exception::ParseError | is thrown if an error occurs during parsing |
Referenced by TOPPViewBase::addDataFile(), CachedSwathFileConsumer::ensureMapsAreFilled_(), TOPPViewBase::fileChanged_(), InspectOutfile::getExperiment(), MS1LabeledSpectra::load(), TOPPFLASHDeconv::main_(), and NucleicAcidSearchEngine::main_().
| void loadFeatures | ( | const std::string & | filename, |
| FeatureMap & | map, | ||
| const std::vector< FileTypes::Type > | allowed_types = {}, |
||
| ProgressLogger::LogType | log = ProgressLogger::NONE |
||
| ) |
Loads a file into a FeatureMap.
| [in] | filename | the file name of the file to load. |
| [out] | map | The FeatureMap to load the data into. |
| [in] | allowed_types | A vector of supported filetypes. If the vector is empty, load from any type that we have a handler for. Otherwise getType() is called internally to check the type |
| [in] | log | Progress logging mode |
| Exception::FileNotFound | is thrown if the file could not be opened |
| Exception::ParseError | is thrown if an error occurs during parsing |
Referenced by TOPPViewBase::addDataFile(), and TOPPViewBase::fileChanged_().
| void loadIdentifications | ( | const std::string & | filename, |
| std::vector< ProteinIdentification > & | additional_proteins, | ||
| PeptideIdentificationList & | additional_peptides, | ||
| const std::vector< FileTypes::Type > | allowed_types = {}, |
||
| ProgressLogger::LogType | log = ProgressLogger::NONE |
||
| ) |
Loads an identification file into a proteinIdentifications and peptideIdentifications.
| [in] | filename | the file name of the file to load. |
| [in] | additional_proteins | The proteinIdentification vector to load the data into. |
| [in] | additional_peptides | The peptideIdentification vector to load the data into. |
| [in] | allowed_types | A vector of supported filetypes. If the vector is empty, load from any type that we have a handler for. Otherwise getType() is called internally to check the type |
| [in] | log | Progress logging mode |
| Exception::FileNotFound | is thrown if the file could not be opened |
| Exception::ParseError | is thrown if an error occurs during parsing |
Referenced by TOPPViewBase::addDataFile().
| void loadImagingExperiment | ( | const std::string & | filename, |
| MSImagingExperiment & | exp, | ||
| const std::vector< FileTypes::Type > | allowed_types = std::vector< FileTypes::Type >(), |
||
| ProgressLogger::LogType | log = ProgressLogger::NONE |
||
| ) |
Loads a mass spectrometry imaging file into an MSImagingExperiment.
Imaging data is always loaded into an MSImagingExperiment. Supported here are imzML (via ImzMLFile) and Bruker timsTOF MALDI imaging .d folders and .d.zip archives (via BrukerTimsImagingFile, OpenMS built with WITH_OPENTIMS).
| [in] | filename | The file name of the file to load. |
| [out] | exp | The imaging experiment to load the data into; replaced (not appended). |
| [in] | allowed_types | A vector of supported filetypes. If the vector is empty, load from any imaging type that we have a handler for. |
| [in] | log | Progress logging mode |
| Exception::InvalidFileType | is thrown if the file is not an imaging format |
| Exception::ParseError | is thrown if the type is not in allowed_types |
| Exception::InvalidValue | is thrown for a .d folder that is not MALDI imaging |
| void loadSpectrum | ( | const std::string & | filename, |
| MSSpectrum & | spec, | ||
| const std::vector< FileTypes::Type > | allowed_types = {} |
||
| ) |
Loads a single MSSpectrum from a file.
| [in] | filename | The file name of the file to load. |
| [out] | spec | The spectrum to load the data into. |
| [in] | allowed_types | A vector of supported filetypes. If the vector is empty, load from any type that we have a handler for. Otherwise getType() is called internally to check the type |
| Exception::FileNotFound | is thrown if the file could not be opened |
| Exception::ParseError | is thrown if an error occurs during parsing |
| void loadTransformations | ( | const std::string & | filename, |
| TransformationDescription & | map, | ||
| bool | fit_model = true, |
||
| const std::vector< FileTypes::Type > | allowed_types = {} |
||
| ) |
Loads a file into Transformations.
| [in] | filename | the file name of the file to load. |
| [out] | map | The Transformations to load the data into. |
| [in] | fit_model | Call fitModel() on the map before returning? |
| [in] | allowed_types | A vector of supported filetypes. If the vector is empty, load from any type that we have a handler for. Otherwise getType() is called internally to check the type |
| Exception::FileNotFound | is thrown if the file could not be opened |
| Exception::ParseError | is thrown if an error occurs during parsing |
| void loadTransitions | ( | const std::string & | filename, |
| TargetedExperiment & | library, | ||
| const std::vector< FileTypes::Type > | allowed_types = {}, |
||
| ProgressLogger::LogType | log = ProgressLogger::NONE |
||
| ) |
Load transitions of a spectral library.
| [in] | filename | the file name of the file to read. |
| [out] | library | The TargetedExperiment to load. |
| [in] | allowed_types | A vector of supported filetypes. If the vector is empty, load from any type that we have a handler for. Otherwise getType() is called internally to check the type |
| [in] | log | Progress logging mode |
| Exception::FileNotFound | is thrown if the file could not be opened |
| Exception::ParseError | is thrown if an error occurs during parsing |
| void setFeatOptions | ( | const FeatureFileOptions & | ) |
set feature file options for loading/storing
| void setOptions | ( | const PeakFileOptions & | ) |
set options for loading/storing
Referenced by TOPPFLASHDeconv::main_(), and NucleicAcidSearchEngine::main_().
| void storeConsensusFeatures | ( | const std::string & | filename, |
| const ConsensusMap & | map, | ||
| const std::vector< FileTypes::Type > | allowed_types = {}, |
||
| ProgressLogger::LogType | log = ProgressLogger::NONE |
||
| ) |
Store a ConsensusFeatureMap.
| [in] | filename | the file name of the file to write. |
| [out] | map | The ConsensusMap to store. |
| [in] | allowed_types | Restricts the set of file formats this call may write.
|
| [in] | log | Progress logging mode |
| Exception::UnableToCreateFile | is thrown if the file could not be written |
| Exception::InvalidFileType | is thrown if the file type cannot be determined or is not allowed |
| void storeExperiment | ( | const std::string & | filename, |
| const PeakMap & | exp, | ||
| const std::vector< FileTypes::Type > | allowed_types = {}, |
||
| ProgressLogger::LogType | log = ProgressLogger::NONE |
||
| ) |
Stores an MSExperiment to a file.
The file type to store the data in is determined by the file name. Supported formats for storing are mzML, mzXML, mzData and DTA2D. If the file format cannot be determined from the file name, the mzML format is used.
| [in] | filename | The name of the file to store the data in. |
| [out] | exp | The experiment to store. |
| [in] | allowed_types | A vector of supported filetypes. If empty we try to guess based on the filename. If that fails we throw UnableToCreateFile. If there is only one allowed type, check whether it agrees with the filename, and throw UnableToCreateFile if they disagree. |
| [in] | log | Progress logging mode |
| Exception::UnableToCreateFile | is thrown if the file could not be written |
Referenced by NucleicAcidSearchEngine::main_().
| void storeFeatures | ( | const std::string & | filename, |
| const FeatureMap & | map, | ||
| const std::vector< FileTypes::Type > | allowed_types = {}, |
||
| ProgressLogger::LogType | log = ProgressLogger::NONE |
||
| ) |
Store a FeatureMap.
| [in] | filename | the file name of the file to write. |
| [out] | map | The FeatureMap to store. |
| [in] | allowed_types | Restricts the set of file formats this call may write.
|
| [in] | log | Progress logging mode |
| Exception::UnableToCreateFile | is thrown if the file could not be written |
| Exception::InvalidFileType | is thrown if the file type cannot be determined or is not allowed |
| void storeIdentifications | ( | const std::string & | filename, |
| const std::vector< ProteinIdentification > & | additional_proteins, | ||
| const PeptideIdentificationList & | additional_peptides, | ||
| const std::vector< FileTypes::Type > | allowed_types = {}, |
||
| ProgressLogger::LogType | log = ProgressLogger::NONE |
||
| ) |
Stores proteins and peptides into an Identification File.
| [in] | filename | the file name of the file to write to. |
| [in] | additional_proteins | The proteinIdentification vector to load the data from. |
| [in] | additional_peptides | The peptideIdentification vector to load the data from. |
| [in] | allowed_types | Restricts the set of file formats this call may write.
|
| [in] | log | Progress logging mode |
| Exception::UnableToCreateFile | is thrown if the file could not be written |
| Exception::InvalidFileType | is thrown if the file type cannot be determined or is not allowed |
Referenced by NucleicAcidSearchEngine::main_().
| void storeQC | ( | const std::string & | input_file, |
| const std::string & | filename, | ||
| const MSExperiment & | exp, | ||
| const FeatureMap & | feature_map, | ||
| std::vector< ProteinIdentification > & | prot_ids, | ||
| PeptideIdentificationList & | pep_ids, | ||
| const ConsensusMap & | consensus_map, | ||
| const std::string & | contact_name = "", |
||
| const std::string & | contact_address = "", |
||
| const std::string & | description = "", |
||
| const std::string & | label = "label", |
||
| const bool | remove_duplicate_features = false, |
||
| const std::vector< FileTypes::Type > | allowed_types = {} |
||
| ) |
Store QC info.
Stores QC data in mzQC file with JSON format
| [in] | input_file | mzML input file name |
| [in] | filename | mzQC output file name |
| [in] | exp | MSExperiment to extract QC data from, prior sortSpectra() and updateRanges() required |
| [in] | feature_map | FeatureMap from feature file (featureXML) |
| [in] | prot_ids | protein identifications from ID file (idXML) |
| [in] | pep_ids | protein identifications from ID file (idXML) |
| [out] | consensus_map | an optional consensus map to store. |
| [in] | contact_name | name of the person creating the mzQC file |
| [in] | contact_address | contact address (mail/e-mail or phone) of the person creating the mzQC file |
| [in] | description | description and comments about the mzQC file contents |
| [in] | label | unique and informative label for the run |
| [in] | remove_duplicate_features | whether to remove duplicate features only for QCML for now |
| [in] | allowed_types | A vector of supported filetypes. If empty we try to guess based on the filename. If that fails we throw UnableToCreateFile. If there is only one allowed type, check whether it agrees with the filename, and throw UnableToCreateFile if they disagree. |
| Exception::UnableToCreateFile | is thrown if the file could not be written |
| void storeSpectrum | ( | const std::string & | filename, |
| MSSpectrum & | spec, | ||
| const std::vector< FileTypes::Type > | allowed_types = {} |
||
| ) |
Stores a single MSSpectrum to a file.
| [in] | filename | The file name of the file to store. |
| [in] | spec | The spectrum to store the data from. |
| [in] | allowed_types | A vector of supported filetypes. If the vector is empty, load from any type that we have a handler for. Otherwise getType() is called internally to check the type |
| Exception::UnableToCreateFile | is thrown if the file could not be written |
| void storeTransformations | ( | const std::string & | filename, |
| const TransformationDescription & | map, | ||
| const std::vector< FileTypes::Type > | allowed_types = {} |
||
| ) |
Store Transformations.
| [out] | filename | the file name of the file to write. |
| [in] | map | The Transformations to store. |
| [in] | allowed_types | A vector of supported filetypes. If empty we try to guess based on the filename. If that fails we throw UnableToCreateFile. If there is only one allowed type, check whether it agrees with the filename, and throw UnableToCreateFile if they disagree. |
| Exception::UnableToCreateFile | is thrown if the file could not be written |
| void storeTransitions | ( | const std::string & | filename, |
| const TargetedExperiment & | library, | ||
| const std::vector< FileTypes::Type > | allowed_types = {}, |
||
| ProgressLogger::LogType | log = ProgressLogger::NONE |
||
| ) |
Store transitions of a spectral library.
| [out] | filename | the file name of the file to write. |
| [out] | library | The TargetedExperiment to store. |
| [in] | allowed_types | A vector of supported filetypes. If empty we try to guess based on the filename. If that fails we throw UnableToCreateFile. If there is only one allowed type, check whether it agrees with the filename, and throw UnableToCreateFile if they disagree. |
| [in] | log | Progress logging mode |
| Exception::UnableToCreateFile | is thrown if the file could not be written |
|
static |
If filename contains an extension, it will be removed (including the '.'). Special extensions, known to OpenMS, e.g. '.mzML.gz' will be recognized as well.
E.g. 'experiment.featureXML' becomes 'experiment' and 'c:\files\data.mzML.gz' becomes 'c:\files\data' If the extension is unknown, the everything in the basename of the file after the last '.' is removed. E.g. 'future.newEnding' becomes 'future' If the filename does not contain '.', but the path (if any) does, nothing is removed, e.g. '/my.dotted.dir/filename' is returned unchanged.
| [in] | filename | the name to strip |
|
static |
Tries to find and remove a known file extension, and append the new one.
Internally calls 'stripExtension()' and adds the new suffix to the result. E.g. 'experiment.featureXML'+ FileTypes::TRANSFORMATIONXML becomes 'experiment.trafoXML' and 'c:\files\data.mzML.gz' + FileTypes::FEATUREXML becomes 'c:\files\data.featureXML' If the existing extension is unknown, the everything after the last '.' is removed, e.g. 'exp.tmp' + FileTypes::IDXML becomes 'exp.idXML'
| [in] | filename | the original filename |
| [in] | new_type | the FileTypes::Types to use to set the new extension |
Referenced by TOPPViewBase::addDataFile().
| void transformExperiment | ( | const std::string & | filename, |
| Interfaces::IMSDataConsumer * | consumer, | ||
| const std::vector< FileTypes::Type > | allowed_types = std::vector< FileTypes::Type >(), |
||
| ProgressLogger::LogType | log = ProgressLogger::NONE, |
||
| const bool | rewrite_source_file = false, |
||
| const bool | compute_hash = false |
||
| ) |
Streams a file into a consumer, spectrum by spectrum, without holding the whole experiment in memory.
The consumer receives IMSDataConsumer::setExpectedSize() and IMSDataConsumer::setExperimentalSettings() first, then the spectra and chromatograms. Supported are mzML (MzMLFile::transform), mzXML (MzXMLFile::transform), Thermo .raw (ThermoRawFile::transform, OpenMS built with WITH_THERMO_RAW) and Bruker timsTOF .d directories and .d.zip archives (BrukerTimsFile::transform, OpenMS built with WITH_OPENTIMS). The PeakFileOptions are applied as by loadExperiment(); .raw files are read centroided and with the scan-level options passed to the reader, as by loadExperiment(). For .d data the reader skips the frames the options exclude, as for loadExperiment(), and every spectrum is then filtered on its way to the consumer. Bruker MALDI imaging data is rejected, as by loadExperiment(). Unlike loadExperiment(), mzML and .raw spectra that hold chromatogram data (SRM) are not converted to chromatograms. For mzML and mzXML the sizes passed to IMSDataConsumer::setExpectedSize() come from the file and ignore the selection; for .raw they are the numbers of selected spectra and chromatograms. For .d data the number of spectra is an upper bound: it is counted before any peak is read (see BrukerTimsFile::transform()), and the spectra the options exclude are not subtracted. Some Bruker configurations are loaded completely before the first spectrum is passed on (see BrukerTimsFile::transform()); the default configuration used here is not one of them.
| [in] | filename | The file to read |
| [in] | consumer | Receives the data (not owned) |
| [in] | allowed_types | Supported file types; if empty, any streamable type |
| [in] | log | Progress logging mode |
| [in] | rewrite_source_file | Set the SourceFile name and path to filename (as loadExperiment()) |
| [in] | compute_hash | If source files are rewritten, store the SHA-1 of filename in the SourceFile |
| Exception::NullPointer | is thrown if consumer is null |
| Exception::FileNotFound | is thrown if the file could not be opened |
| Exception::ParseError | is thrown if an error occurs during parsing or the type is not in allowed_types |
| Exception::InvalidFileType | is thrown if the file type cannot be streamed |
|
private |
|
private |