bool isFileSimilar(const std::string& filename_1, const std::string& filename_2) { fuzzy_message.clear(); FuzzyStringComparator fsc; fsc.setAcceptableAbsolute(absdiff_max_allowed); fsc.setAcceptableRelative(ratio_max_allowed); fsc.setVerboseLevel(2); fsc.setWhitelist(whitelist); std::ostringstream os; fsc.setLogDestination(os); fsc.use_prefix_ = true; bool result = fsc.compareFiles(filename_1, filename_2); fuzzy_message = os.str(); absdiff = fsc.absdiff_max_; ratio = fsc.ratio_max_; line_num_1_max = fsc.line_num_1_max_; line_num_2_max = fsc.line_num_2_max_; return result; }
Param p = test_ffm.getParameters(); p.setValue("mz_scoring_13C", "true"); test_ffm.setParameters(p); test_ffm.run(splitted_mt, test_fm, chromatograms); TEST_EQUAL(test_fm.size(), 93); // run with default settings (from paper using charge+isotope# dependent distances) p.setValue("report_convex_hulls", "true"); p.setValue("mz_scoring_13C", "false"); test_ffm.setParameters(p); test_ffm.run(splitted_mt, test_fm, chromatograms); TEST_EQUAL(test_fm.size(), 91); // --> this gives less features, i.e. more isotope clusters (but the input data is simulated and highly weird -- should be replaced at some point) // test annotation of input String tmp_file; NEW_TMP_FILE(tmp_file); FeatureXMLFile().store(tmp_file, test_fm); TEST_EQUAL(fsc.compareFiles(tmp_file, OPENMS_GET_TEST_DATA_PATH("FeatureFindingMetabo_output1.featureXML")), true); } END_SECTION ///////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////// END_TEST
START_SECTION(void store(String filename, const std::vector<ProteinIdentification>& protein_ids, const std::vector<PeptideIdentification>& peptide_ids, const String& document_id="") ) //store and load data std::vector<ProteinIdentification> protein_ids, protein_ids2; std::vector<PeptideIdentification> peptide_ids, peptide_ids2; String document_id, document_id2; String input_path = OPENMS_GET_TEST_DATA_PATH("IdXMLFile_whole.idXML"); IdXMLFile().load(input_path, protein_ids2, peptide_ids2, document_id2); String filename; NEW_TMP_FILE(filename) IdXMLFile().store(filename, protein_ids2, peptide_ids2, document_id2); FuzzyStringComparator fuzzy; fuzzy.setWhitelist(ListUtils::create<String>("<?xml-stylesheet")); fuzzy.setAcceptableAbsolute(0.0001); bool result = fuzzy.compareFiles(input_path, filename); TEST_EQUAL(result, true); END_SECTION START_SECTION([EXTRA] static bool isValid(const String& filename)) std::vector<ProteinIdentification> protein_ids, protein_ids2; std::vector<PeptideIdentification> peptide_ids, peptide_ids2; String filename; IdXMLFile f; //test if empty file is valid NEW_TMP_FILE(filename) f.store(filename, protein_ids2, peptide_ids2); TEST_EQUAL(f.isValid(filename, std::cerr),true);
// load, store, and reload data std::vector<ProteinIdentification> protein_ids, protein_ids2; std::vector<PeptideIdentification> peptide_ids, peptide_ids2; String document_id, document_id2; String target_file = OPENMS_GET_TEST_DATA_PATH("IdXMLFile_whole.idXML"); IdXMLFile().load(target_file, protein_ids2, peptide_ids2, document_id2); String actual_file; NEW_TMP_FILE(actual_file) IdXMLFile().store(actual_file, protein_ids2, peptide_ids2, document_id2); FuzzyStringComparator fuzzy; fuzzy.setWhitelist(ListUtils::create<String>("<?xml-stylesheet")); fuzzy.setAcceptableAbsolute(0.0001); bool result = fuzzy.compareFiles(actual_file, target_file); TEST_EQUAL(result, true); END_SECTION START_SECTION([EXTRA] static bool isValid(const String& filename)) std::vector<ProteinIdentification> protein_ids, protein_ids2; std::vector<PeptideIdentification> peptide_ids, peptide_ids2; String filename; IdXMLFile f; //test if empty file is valid NEW_TMP_FILE(filename) f.store(filename, protein_ids2, peptide_ids2); TEST_EQUAL(f.isValid(filename, std::cerr),true);