| 37 | } |
| 38 | |
| 39 | void ConsensusXMLFile::store(const String& filename, const ConsensusMap& consensus_map) |
| 40 | { |
| 41 | if (!FileHandler::hasValidExtension(filename, FileTypes::CONSENSUSXML)) |
| 42 | { |
| 43 | throw Exception::UnableToCreateFile(__FILE__, __LINE__, OPENMS_PRETTY_FUNCTION, filename, "invalid file extension, expected '" + FileTypes::typeToName(FileTypes::CONSENSUSXML) + "'"); |
| 44 | } |
| 45 | |
| 46 | if (!consensus_map.isMapConsistent(&OpenMS_Log_warn)) |
| 47 | { |
| 48 | // Currently it is possible that FeatureLinkerUnlabeledQT triggers this exception |
| 49 | // throw Exception::MissingInformation(__FILE__, __LINE__, OPENMS_PRETTY_FUNCTION, "The ConsensusXML file contains invalid maps or references thereof. No data was written! Please fix the file or notify the maintainer of this tool if you did not provide a consensusXML file!"); |
| 50 | std::cerr << "The ConsensusXML file contains invalid maps or references thereof. Please fix the file or notify the maintainer of this tool if you did not provide a consensusXML file! Note that this warning will be a fatal error in the next version of OpenMS!" << std::endl; |
| 51 | } |
| 52 | |
| 53 | if (Size invalid_unique_ids = consensus_map.applyMemberFunction(&UniqueIdInterface::hasInvalidUniqueId)) |
| 54 | { |
| 55 | // TODO Take care *outside* that this does not happen. |
| 56 | // We can detect this here but it is too late to fix the problem; |
| 57 | // there is no straightforward action to be taken in all cases. |
| 58 | // Note also that we are given a const reference. |
| 59 | OPENMS_LOG_INFO << String("ConsensusXMLFile::store(): found ") + invalid_unique_ids + " invalid unique ids" << std::endl; |
| 60 | } |
| 61 | |
| 62 | // This will throw if the unique ids are not unique, |
| 63 | // so we never create bad files in this respect. |
| 64 | try |
| 65 | { |
| 66 | consensus_map.updateUniqueIdToIndex(); |
| 67 | } |
| 68 | catch (Exception::Postcondition& e) |
| 69 | { |
| 70 | OPENMS_LOG_FATAL_ERROR << e.getName() << ' ' << e.what() << std::endl; |
| 71 | throw; |
| 72 | } |
| 73 | |
| 74 | |
| 75 | Internal::ConsensusXMLHandler handler(consensus_map, filename); |
| 76 | handler.setOptions(options_); |
| 77 | handler.setLogType(getLogType()); |
| 78 | save_(filename, &handler); |
| 79 | } |
| 80 | |
| 81 | void ConsensusXMLFile::load(const String& filename, ConsensusMap& consensus_map) |
| 82 | { |
nothing calls this directly
no test coverage detected