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

Method store

src/openms/source/FORMAT/QcMLFile.cpp:1966–2129  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1964
1965
1966 void QcMLFile::store(const String& filename) const
1967 {
1968 //~ startProgress(0, 0, "storing qcML file");
1969 //~ progress_ = 0;
1970 //~ setProgress(++progress_);
1971
1972 //~ file should either contain the complete stylesheet injection (including the stylesheet file preamble, the DOCTYPE definition and the stylesheet itself) or be empty
1973 std::string xslt = "";
1974 std::string xslt_ref = "";
1975 try
1976 {
1977 String xslt_file = File::find("XSL/QcML_report_sheet.xsl"); //TODO make this user defined pt.1
1978 std::ifstream in(xslt_file.c_str());
1979 xslt = std::string((std::istreambuf_iterator<char>(in)), std::istreambuf_iterator<char>());
1980 xslt = xslt.erase(0, xslt.find('\n') + 1);
1981 xslt_ref = "openms-qc-stylesheet"; //TODO make this user defined pt.2
1982 }
1983 catch (Exception::FileNotFound &)
1984 {
1985 warning(STORE, String("No qcml stylesheet found, result will not be viewable in a browser!"));
1986 }
1987
1988
1989 //open stream
1990 ofstream os(filename.c_str());
1991 if (!os)
1992 {
1993 throw Exception::UnableToCreateFile(__FILE__, __LINE__, OPENMS_PRETTY_FUNCTION, filename);
1994 }
1995
1996 os.precision(writtenDigits<double>(0.0));
1997
1998 //~ setProgress(++progress_);
1999 //header & xslt
2000
2001 os << "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>\n";
2002 if (!xslt_ref.empty())
2003 {
2004 os << R"(<?xml-stylesheet type="text/xml" href="#)" << xslt_ref << "\"?>\n";
2005 os << "<!DOCTYPE catelog [\n"
2006 << " <!ATTLIST xsl:stylesheet\n"
2007 << " id ID #REQUIRED>\n"
2008 << " ]>\n";
2009 }
2010 os << "<qcML xmlns=\"https://github.com/qcML/qcml\" >\n"; //TODO creation date into schema!!
2011
2012 //content runs
2013 std::set<String> keys;
2014 for (std::map<String, std::vector<QualityParameter> >::const_iterator it = runQualityQPs_.begin(); it != runQualityQPs_.end(); ++it)
2015 {
2016 keys.insert(it->first);
2017 }
2018 for (std::map<String, std::vector<Attachment> >::const_iterator it = runQualityAts_.begin(); it != runQualityAts_.end(); ++it)
2019 {
2020 keys.insert(it->first);
2021 }
2022
2023 if (!keys.empty())

Callers

nothing calls this directly

Calls 11

stringClass · 0.85
precisionMethod · 0.80
StringClass · 0.50
eraseMethod · 0.45
findMethod · 0.45
emptyMethod · 0.45
beginMethod · 0.45
endMethod · 0.45
insertMethod · 0.45
toXMLStringMethod · 0.45
clearMethod · 0.45

Tested by

no test coverage detected