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

Method loadInputFile_

src/topp/XFDR.cpp:196–248  ·  view source on GitHub ↗

* Loads the input file depending on the type. Returns 0 if the loading of the input was successful, error * code otherwise * @return 0 if the loading of the input was successful, error code otherwise */

Source from the content-addressed store, hash-verified

194 * @return 0 if the loading of the input was successful, error code otherwise
195 */
196 ExitCodes loadInputFile_(std::vector<PeptideIdentification>& peptide_ids, ProteinIdentification& protein_id)
197 {
198 //------------------------------------------------------------
199 // Determine type of input file
200 //-------------------------------------------------------------
201 // const String arg_in_type = getStringOption_(TOPPXFDR::param_in_type);
202 const FileTypes::Type in_type = arg_in_type_.empty() ?
203 FileHandler::getType(this->arg_in_) : FileTypes::nameToType(arg_in_type_);
204
205 std::vector<ProteinIdentification> protein_ids;
206 if (in_type == FileTypes::XQUESTXML)
207 {
208 XQuestResultXMLFile xquest_file;
209 xquest_file.load(arg_in_, peptide_ids, protein_ids);
210
211 writeLogInfo_("\nTotal number of hits in xQuest input: " + String(xquest_file.getNumberOfHits()));
212 }
213 else if (in_type == FileTypes::MZIDENTML)
214 {
215 MzIdentMLFile().load(arg_in_, protein_ids, peptide_ids);
216 }
217 else if (in_type == FileTypes::IDXML)
218 {
219 IdXMLFile().load(arg_in_, protein_ids, peptide_ids);
220 }
221 else
222 {
223 logFatal("Input file type not recognized.");
224 return ILLEGAL_PARAMETERS;
225 }
226 const Size n_pep_ids = peptide_ids.size();
227 const Size n_prot_ids = protein_ids.size();
228
229 writeLogInfo_("Number of Peptide IDs in input file: " + String(n_pep_ids));
230 writeLogInfo_("Number of Protein IDs in input file: " + String(n_prot_ids));
231
232 // Terminate if no hits could be found
233 if (n_pep_ids == 0)
234 {
235 logFatal("Input file does not contain any identifications.");
236 return INPUT_FILE_EMPTY;
237 }
238
239 // Terminate if do not exactly encounter one protein id
240 if (n_prot_ids != 1)
241 {
242 logFatal("There is not exactly one protein identification in the input file. This is unsupported!");
243 return INPUT_FILE_CORRUPT;
244 }
245 protein_id = protein_ids[0];
246
247 return EXECUTION_OK;
248 }
249
250 void logFatal(const String &message) const
251 {

Callers

nothing calls this directly

Calls 6

getTypeFunction · 0.85
StringClass · 0.50
emptyMethod · 0.45
loadMethod · 0.45
getNumberOfHitsMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected