MCPcopy Create free account
hub / github.com/OpenMS/OpenMS / writeSpectrum_

Method writeSpectrum_

src/openms/source/FORMAT/HANDLERS/MzMLHandler.cpp:5032–5379  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

5030 }
5031
5032 void MzMLHandler::writeSpectrum_(std::ostream& os,
5033 const SpectrumType& spec,
5034 Size s,
5035 const Internal::MzMLValidator& validator,
5036 bool renew_native_ids,
5037 std::vector<std::vector< ConstDataProcessingPtr > >& dps)
5038 {
5039 //native id
5040 String native_id = spec.getNativeID();
5041 if (renew_native_ids)
5042 {
5043 native_id = String("spectrum=") + s;
5044 }
5045
5046 Int64 offset = os.tellp();
5047 spectra_offsets_.emplace_back(native_id, offset + 3);
5048
5049 // IMPORTANT make sure the offset (above) corresponds to the start of the <spectrum tag
5050 os << "\t\t\t<spectrum id=\"" << writeXMLEscape(native_id) << "\" index=\"" << s << "\" defaultArrayLength=\"" << spec.size() << "\"";
5051 if (spec.getSourceFile() != SourceFile())
5052 {
5053 os << " sourceFileRef=\"sf_sp_" << s << "\"";
5054 }
5055 //the data processing info of the first spectrum is the default
5056 //if (s==0 || spec.getDataProcessing()!=exp[0].getDataProcessing())
5057 if (s == 0 || spec.getDataProcessing() != dps[0])
5058 {
5059 Size dp_ref_num = s;
5060 if (s != 0)
5061 {
5062 for (Size i = 0; i < dps.size(); ++i)
5063 {
5064 if (spec.getDataProcessing() == dps[i])
5065 {
5066 dp_ref_num = i;
5067 break;
5068 }
5069 }
5070 }
5071 os << " dataProcessingRef=\"dp_sp_" << dp_ref_num << "\"";
5072 }
5073 os << ">\n";
5074
5075 //spectrum representation
5076 if (spec.getType() == SpectrumSettings::CENTROID)
5077 {
5078 os << "\t\t\t\t<cvParam cvRef=\"MS\" accession=\"MS:1000127\" name=\"centroid spectrum\" />\n";
5079 }
5080 else if (spec.getType() == SpectrumSettings::PROFILE)
5081 {
5082 os << "\t\t\t\t<cvParam cvRef=\"MS\" accession=\"MS:1000128\" name=\"profile spectrum\" />\n";
5083 }
5084 else
5085 {
5086 os << "\t\t\t\t<cvParam cvRef=\"MS\" accession=\"MS:1000525\" name=\"spectrum representation\" />\n";
5087 }
5088
5089 //spectrum attributes

Callers

nothing calls this directly

Calls 15

getNativeIDMethod · 0.80
emplace_backMethod · 0.80
getMSLevelMethod · 0.80
getScanModeMethod · 0.80
getZoomScanMethod · 0.80
getPrecursorsMethod · 0.80
getCompressionMethod · 0.80
StringClass · 0.50
writeXMLEscapeFunction · 0.50
SourceFileFunction · 0.50
sizeMethod · 0.45

Tested by

no test coverage detected