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

Method readMzIdentMLFile

src/openms/source/FORMAT/HANDLERS/MzIdentMLDOMHandler.cpp:134–303  ·  view source on GitHub ↗

* reads a mzid file into handlers pro_id_ & pep_id_ members */

Source from the content-addressed store, hash-verified

132 * reads a mzid file into handlers pro_id_ & pep_id_ members
133 */
134 void MzIdentMLDOMHandler::readMzIdentMLFile(const std::string& mzid_file)
135 {
136 // Test to see if the file is ok.
137 struct stat fileStatus;
138
139 errno = 0;
140 if (stat(mzid_file.c_str(), &fileStatus) == -1) // ==0 ok; ==-1 error
141 {
142 if (errno == ENOENT) // errno declared by include file errno.h
143 {
144 throw (runtime_error("Path file_name does not exist, or path is an empty string."));
145 }
146 else if (errno == ENOTDIR)
147 {
148 throw (runtime_error("A component of the path is not a directory."));
149 }
150 // On MSVC 2008, the ELOOP constant is not declared and thus introduces a compile error
151 //else if (errno == ELOOP)
152 // throw (runtime_error("Too many symbolic links encountered while traversing the path."));
153 else if (errno == EACCES)
154 {
155 throw (runtime_error("Permission denied."));
156 }
157 else if (errno == ENAMETOOLONG)
158 {
159 throw (runtime_error("File can not be read."));
160 }
161 }
162
163 // Configure DOM parser.
164 mzid_parser_.setValidationScheme(XercesDOMParser::Val_Never);
165 mzid_parser_.setDoNamespaces(false);
166 mzid_parser_.setDoSchema(false);
167 mzid_parser_.setLoadExternalDTD(false);
168
169 try
170 {
171 mzid_parser_.parse(mzid_file.c_str());
172 }
173 catch (xercesc::XMLException& e)
174 {
175 char* message = xercesc::XMLString::transcode(e.getMessage());
176 // ostringstream errBuf;
177 // errBuf << "Error parsing file: " << message << flush;
178 OPENMS_LOG_ERROR << "XERCES error parsing file: " << message << flush << endl;
179 XMLString::release(&message);
180 }
181
182 // we adopt/own the document so we can free it in case this DOMHandler is reused on another file.
183 xercesc::DOMDocument* xmlDoc = mzid_parser_.adoptDocument();
184
185 try
186 {
187 // Catch special case: Cross-Linking MS
188 DOMNodeList* additionalSearchParams = xmlDoc->getElementsByTagName(CONST_XMLCH("AdditionalSearchParams"));
189 const XMLSize_t as_node_count = additionalSearchParams->getLength();
190
191 for (XMLSize_t i = 0; i < as_node_count; ++i)

Callers 1

loadMethod · 0.80

Calls 7

statClass · 0.70
convertFunction · 0.50
parseMethod · 0.45
getMessageMethod · 0.45
beginMethod · 0.45
endMethod · 0.45
sortMethod · 0.45

Tested by

no test coverage detected