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

Method writeTo

src/openms/source/FORMAT/HANDLERS/MzXMLHandler.cpp:615–1114  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

613 }
614
615 void MzXMLHandler::writeTo(std::ostream& os)
616 {
617 // determine how many spectra there are (count only those with peaks)
618 UInt count_tmp_ = 0;
619 for (Size s = 0; s < cexp_->size(); s++)
620 {
621 const SpectrumType& spec = (*cexp_)[s];
622 if (!spec.empty())
623 {
624 ++count_tmp_;
625 }
626 }
627 if (count_tmp_ == 0) ++count_tmp_;
628
629 logger_.startProgress(0, cexp_->size(), "storing mzXML file");
630 double min_rt(0), max_rt(0);
631 if (!cexp_->empty())
632 {
633 min_rt = cexp_->begin()->getRT();
634 max_rt = (cexp_->end() - 1)->getRT();
635 }
636 os << "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>\n"
637 << "<mzXML xmlns=\"http://sashimi.sourceforge.net/schema_revision/mzXML_3.1\" \n"
638 << " xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" \n"
639 << " xsi:schemaLocation=\"http://sashimi.sourceforge.net/schema_revision/mzXML_3.1"
640 << " http://sashimi.sourceforge.net/schema_revision/mzXML_3.1/mzXML_idx_3.1.xsd\">\n"
641 << "\t<msRun scanCount=\"" << count_tmp_ << "\" startTime=\"PT" << min_rt << "S\" endTime=\"PT" << max_rt << "S\" >\n";
642
643 //----------------------------------------------------------------------------------------
644 // parent files
645 //----------------------------------------------------------------------------------------
646 if (cexp_->getSourceFiles().empty())
647 {
648 os << "\t\t<parentFile fileName=\"\" fileType=\"processedData\" fileSha1=\"0000000000000000000000000000000000000000\"/>\n";
649 }
650 else
651 {
652 for (Size i = 0; i < cexp_->getSourceFiles().size(); ++i)
653 {
654 const SourceFile& sf = cexp_->getSourceFiles()[i];
655 os << "\t\t<parentFile fileName=\"" << sf.getNameOfFile() << "\" fileType=\"";
656 //file type is an enum in mzXML => search for 'raw' string
657 if (String(sf.getFileType()).toLower().hasSubstring("raw"))
658 {
659 os << "RAWData";
660 }
661 else
662 {
663 os << "processedData";
664 }
665 //Sha1 checksum must have 40 characters => create a fake if it is unknown
666 os << "\" fileSha1=\"";
667 if (sf.getChecksum().size() != 40 || sf.getChecksumType() != SourceFile::SHA1)
668 {
669 os << "0000000000000000000000000000000000000000";
670 }
671 else
672 {

Callers

nothing calls this directly

Calls 15

writeKeyValueFunction · 0.85
encodeFunction · 0.85
hasSubstringMethod · 0.80
toLowerMethod · 0.80
getChecksumTypeMethod · 0.80
getIonizationMethodMethod · 0.80
getResolutionMethodMethod · 0.80
metaValueExistsMethod · 0.80
getMetaValueMethod · 0.80
countMethod · 0.80
getNativeIDMethod · 0.80

Tested by

no test coverage detected