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

Method writeFooter_

src/openms/source/FORMAT/HANDLERS/MzMLHandlerHelper.cpp:81–136  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

79 }
80
81 void MzMLHandlerHelper::writeFooter_(std::ostream& os,
82 const PeakFileOptions& options_,
83 const std::vector< std::pair<std::string, Int64> > & spectra_offsets,
84 const std::vector< std::pair<std::string, Int64> > & chromatograms_offsets)
85 {
86 os << "\t</run>\n";
87 os << "</mzML>";
88
89 if (options_.getWriteIndex())
90 {
91 int indexlists = (int) !spectra_offsets.empty() + (int) !chromatograms_offsets.empty();
92
93 Int64 indexlistoffset = os.tellp();
94 os << "\n";
95 // NOTE: indexList is required, so we need to write one
96 // NOTE: the spectra and chromatogram ids are user-supplied, so better XML-escape them!
97 os << "<indexList count=\"" << indexlists << "\">\n";
98 if (!spectra_offsets.empty())
99 {
100 os << "\t<index name=\"spectrum\">\n";
101 for (Size i = 0; i < spectra_offsets.size(); i++)
102 {
103 os << "\t\t<offset idRef=\"" << XMLHandler::writeXMLEscape(spectra_offsets[i].first) << "\">" << spectra_offsets[i].second << "</offset>\n";
104 }
105 os << "\t</index>\n";
106 }
107 if (!chromatograms_offsets.empty())
108 {
109 os << "\t<index name=\"chromatogram\">\n";
110 for (Size i = 0; i < chromatograms_offsets.size(); i++)
111 {
112 os << "\t\t<offset idRef=\"" << XMLHandler::writeXMLEscape(chromatograms_offsets[i].first) << "\">" << chromatograms_offsets[i].second << "</offset>\n";
113 }
114 os << "\t</index>\n";
115 }
116 if (indexlists == 0)
117 {
118 // dummy: at least one index subelement is required by the standard,
119 // and at least one offset element is required so we need to handle
120 // the case where no spectra/chromatograms are present.
121 os << "\t<index name=\"dummy\">\n";
122 os << "\t\t<offset idRef=\"dummy\">-1</offset>\n";
123 os << "\t</index>\n";
124 }
125 os << "</indexList>\n";
126 os << "<indexListOffset>" << indexlistoffset << "</indexListOffset>\n";
127 os << "<fileChecksum>";
128
129 // TODO calculate checksum here:
130 // SHA-1 checksum from beginning of file to end of 'fileChecksum' open tag.
131 String sha1_checksum = "0";
132 os << sha1_checksum << "</fileChecksum>\n";
133
134 os << "</indexedmzML>";
135 }
136 }
137
138 void MzMLHandlerHelper::decodeBase64Arrays(std::vector<BinaryData>& data, const bool skipXMLCheck)

Callers

nothing calls this directly

Calls 4

getWriteIndexMethod · 0.80
writeXMLEscapeFunction · 0.50
emptyMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected