 |
OpenMS
3.0.0
|
|
Go to the documentation of this file.
75 void updateMembers_()
override;
79 bool compact =
false);
82 void store(std::ostream& os,
const String& filename,
83 const PeakMap& experiment,
bool compact =
false);
92 template <
typename MapType>
102 std::ifstream is(filename.c_str());
104 is.seekg(0, std::ios::end);
105 startProgress(0, is.tellg(),
"loading MGF");
106 is.seekg(0, std::ios::beg);
108 UInt spectrum_number(0);
114 spectrum.
setType(SpectrumSettings::SpectrumType::CENTROID);
115 while (getNextSpectrum_(is, spectrum, line_number, spectrum_number))
118 setProgress(is.tellg());
132 std::pair<String, String> getHTTPPeakListEnclosure(
const String& filename)
const;
135 void writeSpectrum(std::ostream& os,
const PeakSpectrum& spec,
const String& filename,
const String& native_id_type_accession);
146 void writeParameterHeader_(
const String& name, std::ostream& os);
149 void writeModifications_(
const std::vector<String>& mods, std::ostream& os,
150 bool variable_mods =
false);
153 void writeHeader_(std::ostream& os);
156 void writeMSExperiment_(std::ostream& os,
const String& filename,
const PeakMap& experiment);
159 template <
typename SpectrumType>
173 while (getline(is, line,
'\n'))
180 if (line ==
"BEGIN IONS")
182 while (getline(is, line,
'\n'))
187 if (line.empty())
continue;
189 if (isdigit(line[0]))
191 std::vector<String>
split;
210 throw Exception::ParseError(__FILE__, __LINE__, OPENMS_PRETTY_FUNCTION,
"The content '" + line +
"' at line #" +
String(line_number) +
" could not be converted to a number! Expected two (m/z int) or three (m/z int charge) numbers separated by whitespace (space or tab).",
"");
212 spectrum.push_back(p);
216 throw Exception::ParseError(__FILE__, __LINE__, OPENMS_PRETTY_FUNCTION,
"The content '" + line +
"' at line #" +
String(line_number) +
" does not contain m/z and intensity values separated by whitespace (space or tab)!",
"");
219 while (getline(is, line,
'\n') && ++line_number && line.
trim() !=
"END IONS");
221 if (line ==
"END IONS")
227 throw Exception::ParseError(__FILE__, __LINE__, OPENMS_PRETTY_FUNCTION, R
"(Reached end of file. Found "BEGIN IONS" but not the corresponding "END IONS"!)", "");
234 std::vector<String>
split;
236 if (
split.size() == 1)
240 else if (
split.size() == 2)
247 throw Exception::ParseError(__FILE__, __LINE__, OPENMS_PRETTY_FUNCTION,
"Cannot parse PEPMASS in '" + line +
"' at line #" +
String(line_number) +
" (expected 1 or 2 entries, but " +
String(
split.size()) +
" were present)!",
"");
268 std::vector<String>
split;
276 std::vector<String> split2;
277 split[i].trim().split(
' ', split2);
289 std::vector<String>
split;
298 Size firstEqual = line.find(
'=', 4);
299 if (firstEqual != std::string::npos)
Size findByRT(double rt) const
Look up spectrum by retention time (RT).
static bool split(const String &this_s, const char splitter, std::vector< String > &substrings, bool quote_protect)
Definition: StringUtilsSimple.h:360
Class which handles the communication between OpenMS and the Mascot server.
Definition: MascotRemoteQuery.h:56
Base class for TOPP applications.
Definition: TOPPBase.h:147
static bool hasSubstring(const String &this_s, const String &string)
Definition: StringUtilsSimple.h:137
Used to load Mascot XML files.
Definition: MascotXMLFile.h:57
File adapter for MzData files.
Definition: MzDataFile.h:53
void setValue(const std::string &key, const ParamValue &value, const std::string &description="", const std::vector< std::string > &tags=std::vector< std::string >())
Sets a value.
void setQuerySpectra(const String &exp)
sets the query spectra, given in MGF file format
void store(const String &filename, const std::vector< ProteinIdentification > &protein_ids, const std::vector< PeptideIdentification > &peptide_ids, const String &document_id="")
Stores the data in an idXML file.
void reset()
Clear all internal data (spectra, ranges, metadata)
static String basename(const String &file)
String & substitute(char from, char to)
Replaces all occurrences of the character from by the character to.
static QString toQString(const String &this_s)
Definition: StringUtils.h:201
double toDouble() const
Conversion to double.
const double k
Definition: Constants.h:153
void load(const String &filename, std::map< String, std::vector< AASequence > > &peptides)
Loads peptide sequences with modifications out of a PepXML file.
Mascot input file adapter.
Definition: MascotInfile.h:58
A more convenient string class.
Definition: String.h:58
Iterator begin()
Definition: MSExperiment.h:150
File not found exception.
Definition: Exception.h:509
String & trim()
removes whitespaces (space, tab, line feed, carriage return) at the beginning and the end of the stri...
In-Memory representation of a mass spectrometry run.
Definition: MSExperiment.h:70
const std::vector< Precursor > & getPrecursors() const
returns a const reference to the precursors
Invalid conversion exception.
Definition: Exception.h:354
void setInstrument(const String &instrument)
sets the instrument type (Default: Default). Possible instruments: ESI-QUAD-TOF, MALDI-TOF-PSD,...
size_t Size
Size type e.g. used as variable which can hold result of size()
Definition: Types.h:127
Representation of a protein hit.
Definition: ProteinHit.h:58
const double c
Definition: Constants.h:209
void setTaxonomy(const String &taxonomy)
sets the taxonomy (default: All entries). See <mascot path>/config/taxonomy for possible settings.
Used to load Mascot PepXML files.
Definition: PepXMLFileMascot.h:54
void setType(SpectrumType type)
sets the spectrum type
void load(const String &filename, MapType &map)
Loads a map from a MzData file.
void setIntensity(IntensityType intensity)
Mutable access to the data point intensity (height)
Definition: Peak1D.h:110
std::vector< Int > IntList
Vector of signed integers.
Definition: ListUtils.h:55
static String getUniqueName(bool include_hostname=true)
Returns a string, consisting of date, time, hostname, process id, and a incrementing number....
PeakFileOptions & getOptions()
Mutable access to the options for loading/storing.
std::map< String, String > mod_group_map_
mapping of modifications with specificity groups, that have to be treated specially (e....
Definition: MascotGenericFile.h:143
void setModifications(const std::vector< String > &mods)
sets the fixed modifications (default: none). See <mascot path>/config/mod_file for possible setting...
Representation of a protein identification run.
Definition: ProteinIdentification.h:70
bool toBool() const
Conversion to bool.
bool hasPrefix(const String &string) const
true if String begins with string, false otherwise
bool hasSubstring(const String &string) const
true if String contains the string, false otherwise
Size size() const
Definition: MSExperiment.h:120
String getSearchIdentifier() const
returns the search number
A base class for all classes handling default parameters.
Definition: DefaultParamHandler.h:92
String & simplify()
merges subsequent whitespaces to one blank character
static DateTime now()
Returns the current date and time.
static bool writable(const String &file)
Return true if the file is writable.
void setMassType(const String &mass_type)
sets the used mass type "Monoisotopic" or "Average" (default: Monoisotopic)
static bool exists(const String &file)
Method used to test if a file exists.
Main OpenMS namespace.
Definition: FeatureDeconvolution.h:47
void get(UInt &month, UInt &day, UInt &year, UInt &hour, UInt &minute, UInt &second) const
Fills the arguments with the date and the time.
void addSpectrum(const MSSpectrum &spectrum)
adds a spectrum to the list
static String & remove(String &this_s, char what)
Definition: StringUtilsSimple.h:595
Base class for all classes that want to report their progress.
Definition: ProgressLogger.h:52
void load(const String &filename, ProteinIdentification &protein_identification, std::vector< PeptideIdentification > &id_data, const SpectrumMetaDataLookup &lookup)
Loads data from a Mascot XML file.
void setPrimaryMSRunPath(const StringList &s, bool raw=false)
const std::vector< ProteinHit > & getHits() const
Returns the protein hits.
Facilitates file handling by file type recognition.
Definition: FileHandler.h:66
Helper class for looking up spectra based on different attributes.
Definition: SpectrumLookup.h:67
void setVariableModifications(const std::vector< String > &mods)
sets the fixed modifications (default: none). See <mascot path>/config/mod_file for possible setting...
void setDB(const String &db)
sets the DB to use (default: MSDB). See <mascot path>/config/mascot.dat in "Databases" section for po...
bool loadExperiment(const String &filename, MSExperiment &exp, FileTypes::Type force_type=FileTypes::UNKNOWN, ProgressLogger::LogType log=ProgressLogger::NONE, const bool rewrite_source_file=true, const bool compute_hash=true)
Loads a file into an MSExperiment.
const String & getErrorMessage() const
returns the error message, if hasError can be used to check whether an error has occurred
Type
Actual file types enum.
Definition: FileTypes.h:56
void readSpectra(const SpectrumContainer &spectra, const String &scan_regexp=default_scan_regexp)
Read and index spectra for later look-up.
Definition: SpectrumLookup.h:103
void setExportDecoys(const bool b)
request export of decoy summary and decoys (note: internal decoy search must be enabled in the MGF fi...
static FileTypes::Type getType(const String &filename)
Tries to determine the file type (by name or content)
void setCharges(std::vector< Int > &charges)
sets the charges (default: 1+, 2+ and 3+)
bool hasError() const
predicate which returns true if an error occurred during the query
void setHits(const String &hits)
sets the number of hits to report back (default: 20)
void setPeakMassTolerance(float ion_mass_tolerance)
sets the peak mass tolerance in Da (default: 1.0)
void setPosition(PositionType const &position)
Mutable access to the position.
Definition: Peak1D.h:149
Exception base class.
Definition: Exception.h:89
bool split(const char splitter, std::vector< String > &substrings, bool quote_protect=false) const
Splits a string into substrings using splitter as delimiter.
bool exists(const std::string &key) const
Tests if a parameter is set (expecting its fully qualified name, e.g., TextExporter:1:proteins_only)
void setParameters(const Param ¶m)
Sets the parameters.
void setMSLevel(UInt ms_level)
Sets the MS level.
QString toQString() const
Conversion to Qt QString.
Mascot XML file format for peptide identifications (.xml)
Definition: FileTypes.h:83
const Param & getParameters() const
Non-mutable access to the parameters.
Read/write Mascot generic files (MGF).
Definition: MascotGenericFile.h:62
void setCleavage(const String &cleavage)
sets the enzyme used for cleavage (default: Trypsin). See <mascot path>/config/enzymes for possible ...
A 1-dimensional raw data point or peak.
Definition: Peak1D.h:53
std::vector< String > StringList
Vector of String.
Definition: ListUtils.h:70
unsigned int UInt
Unsigned integer type.
Definition: Types.h:94
void resize(Size s)
Definition: MSExperiment.h:125
void setMissedCleavages(UInt missed_cleavages)
sets the number of allowed missed cleavages (default: 1)
Base class for Search Engine Adapters.
Definition: SearchEngineBase.h:54
const String & getNativeID() const
returns the native identifier for the spectrum, used by the acquisition software.
void insertHit(const ProteinHit &input)
Appends a protein hit.
int main(int argc, const char **argv)
Definition: INIFileEditor.cpp:71
const double h
Definition: Constants.h:162
static void initializeLookup(SpectrumMetaDataLookup &lookup, const PeakMap &experiment, const String &scan_regex="")
Initializes a helper object for looking up spectrum meta data (RT, m/z)
void setPrecursorMassTolerance(float precursor_mass_tolerance)
sets the precursor mass tolerance in Da (default: 2.0)
static double toDouble(const String &this_s)
Definition: StringUtils.h:216
#define OPENMS_LOG_ERROR
Macro to be used if non-fatal error are reported (processing continues)
Definition: LogStream.h:455
static String absolutePath(const String &file)
Replaces the relative path in the argument with the absolute path.
Represents the peptide hits for a spectrum.
Definition: PeptideIdentification.h:63
Mascot Generic Format (.mgf)
Definition: FileTypes.h:66
Parse Error exception.
Definition: Exception.h:622
String substr(size_t pos=0, size_t n=npos) const
Wrapper for the STL substr() method. Returns a String object with its contents initialized to a subst...
Param copy(const std::string &prefix, bool remove_prefix=false) const
Returns a new Param object containing all entries that start with prefix.
Iterator end()
Definition: MSExperiment.h:160
bool getNextSpectrum_(std::ifstream &is, SpectrumType &spectrum, Size &line_number, const Size &spectrum_number)
reads a spectrum block, the section between 'BEGIN IONS' and 'END IONS' of a MGF file
Definition: MascotGenericFile.h:160
const std::vector< MSSpectrum > & getSpectra() const
returns the spectrum list
const QByteArray & getMascotXMLResponse() const
returns the Mascot XML response which contains the identifications
static Type nameToType(const String &name)
static String stripExtension(const String &filename)
If filename contains an extension, it will be removed (including the '.'). Special extensions,...
static String & trim(String &this_s)
Definition: StringUtilsSimple.h:229
Management and storage of parameters / INI files.
Definition: Param.h:69
static String getTempDirectory()
String & remove(char what)
Remove all occurrences of the character what.
void store(const String &filename, const PeakSpectrum &spec, double mz, double retention_time, String search_title)
stores the peak list in a MascotInfile that can be used as input for MASCOT shell execution
void clear(bool clear_meta_data)
Clears all data and meta data.
bool store_compact_
use a compact format for storing (no zero-intensity peaks, limited number of decimal places)?
Definition: MascotGenericFile.h:140
const QByteArray & getMascotXMLDecoyResponse() const
returns the Mascot XML response which contains the decoy identifications (note: setExportDecoys must ...
void setMSLevels(const std::vector< Int > &levels)
sets the desired MS levels for peaks to load
void setIdentifier(const String &id)
Sets the identifier.
Element could not be found exception.
Definition: Exception.h:674
The representation of a 1D spectrum.
Definition: MSSpectrum.h:66
const ParamValue & getValue(const std::string &key) const
Returns a value of a parameter.
void setRT(double rt)
Sets the absolute retention time (in seconds)
void remove(const std::string &key)
Remove the entry key or a section key (when suffix is ':')
static void writeParametersToMetaValues(const Param &write_this, MetaInfoInterface &write_here, const String &key_prefix="")
Writes all parameters to meta values.
Int toInt() const
Conversion to int.
DateTime Class.
Definition: DateTime.h:58
void setBoundary(const String &boundary)
sets the boundary used for the MIME format. By default a 22 character random string is used
void setLogType(LogType type) const
Sets the progress log that should be used. The default type is NONE!
void load(const String &filename, MapType &exp)
loads a Mascot Generic File into a PeakMap
Definition: MascotGenericFile.h:93
Used to load and store idXML files.
Definition: IdXMLFile.h:68
void setNativeID(const String &native_id)
sets the native identifier for the spectrum, used by the acquisition software.
Representation of a peptide hit.
Definition: PeptideHit.h:55