|
OpenMS
2.5.0
|
Go to the documentation of this file.
74 void updateMembers_()
override;
78 bool compact =
false);
81 void store(std::ostream& os,
const String& filename,
82 const PeakMap& experiment,
bool compact =
false);
91 template <
typename MapType>
101 std::ifstream is(filename.c_str());
103 is.seekg(0, std::ios::end);
104 startProgress(0, is.tellg(),
"loading MGF");
105 is.seekg(0, std::ios::beg);
107 UInt spectrum_number(0);
113 while (getNextSpectrum_(is, spectrum, line_number, spectrum_number))
116 setProgress(is.tellg());
131 std::pair<String, String> getHTTPPeakListEnclosure(
const String& filename)
const;
142 void writeParameterHeader_(
const String& name, std::ostream& os);
145 void writeModifications_(
const std::vector<String>& mods, std::ostream& os,
146 bool variable_mods =
false);
149 void writeHeader_(std::ostream& os);
152 void writeSpectrum_(std::ostream& os,
const PeakSpectrum& spec,
const String& filename,
const String& native_id_type_accession);
155 void writeMSExperiment_(std::ostream& os,
const String& filename,
const PeakMap& experiment);
158 template <
typename SpectrumType>
172 while (getline(is, line,
'\n'))
179 if (line ==
"BEGIN IONS")
181 while (getline(is, line,
'\n'))
186 if (line.empty())
continue;
188 if (isdigit(line[0]))
190 std::vector<String> split;
200 if (line.
split(
' ', split,
false))
209 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).",
"");
211 spectrum.push_back(p);
215 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)!",
"");
218 while (getline(is, line,
'\n') && ++line_number && line.
trim() !=
"END IONS");
220 if (line ==
"END IONS")
226 throw Exception::ParseError(__FILE__, __LINE__, OPENMS_PRETTY_FUNCTION,
"Reached end of file. Found \"BEGIN IONS\" but not the corresponding \"END IONS\"!",
"");
233 std::vector<String> split;
234 tmp.
split(
' ', split);
235 if (split.size() == 1)
237 spectrum.
getPrecursors()[0].setMZ(split[0].trim().toDouble());
239 else if (split.size() == 2)
241 spectrum.
getPrecursors()[0].setMZ(split[0].trim().toDouble());
242 spectrum.
getPrecursors()[0].setIntensity(split[1].trim().toDouble());
246 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)!",
"");
267 std::vector<String> split;
268 line.
split(
',', split);
271 for (
Size i = 0; i != split.size(); ++i)
273 if (split[i].hasSubstring(
"min"))
275 std::vector<String> split2;
276 split[i].trim().split(
' ', split2);
279 spectrum.
setRT(split2[0].trim().toDouble() * 60.0);
288 std::vector<String> split;
289 if (line.
split(
'=', split))
291 if (split[1] !=
"") spectrum.
setMetaValue(
"TITLE", split[1]);
297 Size firstEqual = line.find(
'=', 4);
298 if (firstEqual != std::string::npos)
static DateTime now()
Returns the current date and time.
void addMSLevel(int level)
adds a desired MS level for peaks to load
void setVariableModifications(const std::vector< String > &mods)
sets the fixed modifications (default: none). See <mascot path>/config/mod_file for possible setting...
Management and storage of parameters / INI files.
Definition: Param.h:73
void setValue(const String &key, const DataValue &value, const String &description="", const StringList &tags=StringList())
Sets a value.
Read/write Mascot generic files (MGF).
Definition: MascotGenericFile.h:61
static String absolutePath(const String &file)
Replaces the relative path in the argument with the absolute path.
const Param & getParameters() const
Non-mutable access to the parameters.
size_t Size
Size type e.g. used as variable which can hold result of size()
Definition: Types.h:127
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)
A method or algorithm argument contains illegal values.
Definition: Exception.h:648
void setModifications(const std::vector< String > &mods)
sets the fixed modifications (default: none). See <mascot path>/config/mod_file for possible setting...
bool exists(const String &key) const
Tests if a parameter is set (expecting its fully qualified name, e.g., TextExporter:1:proteins_only)
void setPeakMassTolerance(float ion_mass_tolerance)
sets the peak mass tolerance in Da (default: 1.0)
Representation of a protein identification run.
Definition: ProteinIdentification.h:71
Size size() const
Definition: MSExperiment.h:127
void load(const String &filename, MapType &map)
Loads a map from a MzData file.
bool metaValueExists(const String &name) const
Returns whether an entry with the given name exists.
void setCleavage(const String &cleavage)
sets the enzyme used for cleavage (default: Trypsin). See <mascot path>/config/enzymes for possible ...
const DataValue & getMetaValue(const String &name, const DataValue &default_value=DataValue::EMPTY) const
Returns the value corresponding to a string, or a default value (default: DataValue::EMPTY) if not fo...
std::map< String, String > mod_group_map_
mapping of modifications with specificity groups, that have to be treated specially (e....
Definition: MascotGenericFile.h:139
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:159
void reset()
Resets all internal values.
void setMissedCleavages(UInt missed_cleavages)
sets the number of allowed missed cleavages (default: 1)
void setNativeID(const String &native_id)
sets the native identifier for the spectrum, used by the acquisition software.
void setPrimaryMSRunPath(const StringList &s, bool raw=false)
void setIntensity(IntensityType intensity)
Mutable access to the data point intensity (height)
Definition: Peak1D.h:112
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...
const String & getErrorMessage() const
returns the error message, if hasError can be used to check whether an error has occurred
void setMSLevel(UInt ms_level)
Sets the MS level.
const std::vector< Precursor > & getPrecursors() const
returns a const reference to the precursors
Base class for TOPP applications.
Definition: TOPPBase.h:144
std::vector< String > StringList
Vector of String.
Definition: ListUtils.h:70
void setHits(const String &hits)
sets the number of hits to report back (default: 20)
void setBoundary(const String &boundary)
sets the boundary used for the MIME format. By default a 22 character random string is used
const DataValue & getValue(const String &key) const
Returns a value of a parameter.
Base class for all classes that want to report their progress.
Definition: ProgressLogger.h:54
bool hasPrefix(const String &string) const
true if String begins with string, false otherwise
DateTime Class.
Definition: DateTime.h:54
Class which handles the communication between OpenMS and the Mascot server.
Definition: MascotRemoteQuery.h:56
void load(const String &filename, std::map< String, std::vector< AASequence > > &peptides)
Loads peptide sequences with modifications out of a PepXML file.
void setMetaValue(const String &name, const DataValue &value)
Sets the DataValue corresponding to a name.
void setQuerySpectra(const String &exp)
sets the query spectra, given in MGF file format
void setLogType(LogType type) const
Sets the progress log that should be used. The default type is NONE!
PeakFileOptions & getOptions()
Mutable access to the options for loading/storing.
void removeMetaValue(const String &name)
Removes the DataValue corresponding to name if it exists.
const std::vector< MSSpectrum > & getSpectra() const
returns the spectrum list
void setPrecursorMassTolerance(float precursor_mass_tolerance)
sets the precursor mass tolerance in Da (default: 2.0)
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 setParameters(const Param ¶m)
Sets the parameters.
SpectrumType
Spectrum peak type.
Definition: SpectrumSettings.h:70
void setDB(const String &db)
sets the DB to use (default: MSDB). See <mascot path>/config/mascot.dat in "Databases" section for po...
static FileTypes::Type getType(const String &filename)
Tries to determine the file type (by name or content)
In-Memory representation of a mass spectrometry experiment.
Definition: MSExperiment.h:77
Int toInt() const
Conversion to int.
void setTaxonomy(const String &taxonomy)
sets the taxonomy (default: All entries). See <mascot path>/config/taxonomy for possible settings.
const String & getNativeID() const
returns the native identifier for the spectrum, used by the acquisition software.
void remove(const String &key)
Remove the entry key or a section key (when suffix is ':')
Param copy(const String &prefix, bool remove_prefix=false) const
Returns a new Param object containing all entries that start with prefix.
Used to load Mascot PepXML files.
Definition: PepXMLFileMascot.h:54
bool hasSubstring(const String &string) const
true if String contains the string, false otherwise
A 1-dimensional raw data point or peak.
Definition: Peak1D.h:54
void load(const String &filename, ProteinIdentification &protein_identification, std::vector< PeptideIdentification > &id_data, const SpectrumMetaDataLookup &lookup)
Loads data from a Mascot XML file.
bool toBool() const
Conversion to bool.
static bool exists(const String &file)
Method used to test if a file exists.
A base class for all classes handling default parameters.
Definition: DefaultParamHandler.h:91
void setMassType(const String &mass_type)
sets the used mass type "Monoisotopic" or "Average" (default: Monoisotopic)
Type
Actual file types enum.
Definition: FileTypes.h:58
const std::vector< ProteinHit > & getHits() const
Returns the protein hits.
QString toQString() const
Conversion to Qt QString.
Used to load and store idXML files.
Definition: IdXMLFile.h:63
void load(const String &filename, MapType &exp)
loads a Mascot Generic File into a PeakMap
Definition: MascotGenericFile.h:92
bool store_compact_
use a compact format for storing (no zero-intensity peaks, limited number of decimal places)?
Definition: MascotGenericFile.h:136
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.
profile data
Definition: SpectrumSettings.h:74
void setCharges(std::vector< Int > &charges)
sets the charges (default: 1+, 2+ and 3+)
void setPosition(PositionType const &position)
Mutable access to the position.
Definition: Peak1D.h:151
Exception base class.
Definition: Exception.h:89
String getSearchIdentifier() const
returns the search number
A more convenient string class.
Definition: String.h:58
void store(const String &filename, const PeakMap &experiment, bool compact=false)
stores the experiment data in a MascotGenericFile that can be used as input for MASCOT shell executio...
Helper class for looking up spectrum meta data.
Definition: SpectrumMetaDataLookup.h:142
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.
static String removeExtension(const String &file)
const QByteArray & getMascotXMLResponse() const
returns the Mascot XML response which contains the identifications
File is empty.
Definition: Exception.h:594
String & remove(char what)
Remove all occurrences of the character what.
Used to load Mascot XML files.
Definition: MascotXMLFile.h:57
void addSpectrum(const MSSpectrum &spectrum)
adds a spectrum to the list
Main OpenMS namespace.
Definition: FeatureDeconvolution.h:46
static bool writable(const String &file)
Return true if the file is writable.
void setInstrument(const String &instrument)
sets the instrument type (Default: Default). Possible instruments: ESI-QUAD-TOF, MALDI-TOF-PSD,...
String & substitute(char from, char to)
Replaces all occurrences of the character from by the character to.
The representation of a 1D spectrum.
Definition: MSSpectrum.h:67
std::vector< Int > IntList
Vector of signed integers.
Definition: ListUtils.h:55
unsigned int UInt
Unsigned integer type.
Definition: Types.h:94
void get(UInt &month, UInt &day, UInt &year, UInt &hour, UInt &minute, UInt &second) const
Fills the arguments with the date and the time.
File adapter for MzData files.
Definition: MzDataFile.h:53
Mascot input file adapter.
Definition: MascotInfile.h:58
static String getUniqueName(bool include_hostname=true)
Returns a string, consisting of date, time, hostname, process id, and a incrementing number....
Facilitates file handling by file type recognition.
Definition: FileHandler.h:62
static String basename(const String &file)
Returns the basename of the file (without the path).
File not found exception.
Definition: Exception.h:523
double toDouble() const
Conversion to double.
static String getTempDirectory()
The current OpenMS temporary data path (for temporary files)
int main(int argc, const char **argv)
Definition: INIFileEditor.cpp:73
String & simplify()
merges subsequent whitespaces to one blank character
Parse Error exception.
Definition: Exception.h:622
String & trim()
removes whitespaces (space, tab, line feed, carriage return) at the beginning and the end of the stri...
void setRT(double rt)
Sets the absolute retention time (in seconds)
bool split(const char splitter, std::vector< String > &substrings, bool quote_protect=false) const
Splits a string into substrings using splitter as delimiter.
bool hasError() const
predicate which returns true if an error occurred during the query
Invalid conversion exception.
Definition: Exception.h:362