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

Method writeTo

src/openms/source/FORMAT/HANDLERS/MzDataHandler.cpp:578–1075  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

576 }
577
578 void MzDataHandler::writeTo(std::ostream & os)
579 {
580 logger_.startProgress(0, cexp_->size(), "storing mzData file");
581
582 os << "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>\n"
583 << R"(<mzData version="1.05" accessionNumber=")" << cexp_->getIdentifier() << "\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:noNamespaceSchemaLocation=\"http://psidev.sourceforge.net/ms/xml/mzdata/mzdata.xsd\">\n";
584
585 //---------------------------------------------------------------------------------------------------
586 //DESCRIPTION
587 const Sample & sm = cexp_->getSample();
588 os << "\t<description>\n"
589 << "\t\t<admin>\n"
590 << "\t\t\t<sampleName>"
591 << sm.getName()
592 << "</sampleName>\n";
593
594#pragma clang diagnostic push
595#pragma clang diagnostic ignored "-Wconversion"
596 if (!sm.getNumber().empty() || sm.getState() || sm.getMass() || sm.getVolume() || sm.getConcentration() || !sm.isMetaEmpty())
597#pragma clang diagnostic pop
598 {
599 os << "\t\t\t<sampleDescription>\n";
600 writeCVS_(os, sm.getNumber(), "1000001", "SampleNumber");
601 writeCVS_(os, sm.getState(), 0, "1000003", "SampleState");
602 writeCVS_(os, sm.getMass(), "1000004", "SampleMass");
603 writeCVS_(os, sm.getVolume(), "1000005", "SampleVolume");
604 writeCVS_(os, sm.getConcentration(), "1000006", "SampleConcentration");
605 writeUserParam_(os, cexp_->getSample());
606 os << "\t\t\t</sampleDescription>\n";
607 }
608
609 if (!cexp_->getSourceFiles().empty())
610 {
611 os << "\t\t\t<sourceFile>\n"
612 << "\t\t\t\t<nameOfFile>" << cexp_->getSourceFiles()[0].getNameOfFile() << "</nameOfFile>\n"
613 << "\t\t\t\t<pathToFile>" << cexp_->getSourceFiles()[0].getPathToFile() << "</pathToFile>\n";
614 if (!cexp_->getSourceFiles()[0].getFileType().empty())
615 os << "\t\t\t\t<fileType>" << cexp_->getSourceFiles()[0].getFileType() << "</fileType>\n";
616 os << "\t\t\t</sourceFile>\n";
617 }
618 if (cexp_->getSourceFiles().size() > 1)
619 {
620 warning(STORE, "The MzData format can store only one source file. Only the first one is stored!");
621 }
622
623 for (Size i = 0; i < cexp_->getContacts().size(); ++i)
624 {
625 os << "\t\t\t<contact>\n"
626 << "\t\t\t\t<name>" << cexp_->getContacts()[i].getFirstName() << " " << cexp_->getContacts()[i].getLastName() << "</name>\n"
627 << "\t\t\t\t<institution>" << cexp_->getContacts()[i].getInstitution() << "</institution>\n";
628 if (!cexp_->getContacts()[i].getContactInfo().empty())
629 os << "\t\t\t\t<contactInfo>" << cexp_->getContacts()[i].getContactInfo() << "</contactInfo>\n";
630 os << "\t\t\t</contact>\n";
631 }
632 //no contacts given => add empty entry as there must be a contact entry
633 if (cexp_->getContacts().empty())
634 {
635 os << "\t\t\t<contact>\n"

Callers

nothing calls this directly

Calls 15

getSampleMethod · 0.80
getVolumeMethod · 0.80
getConcentrationMethod · 0.80
isMetaEmptyMethod · 0.80
getInletTypeMethod · 0.80
getIonizationMethodMethod · 0.80
getResolutionMethodMethod · 0.80
getResolutionTypeMethod · 0.80
getAccuracyMethod · 0.80
getScanRateMethod · 0.80
getScanTimeMethod · 0.80
getScanDirectionMethod · 0.80

Tested by

no test coverage detected