ProteoWizard
TextWriter.hpp
Go to the documentation of this file.
1//
2// $Id$
3//
4//
5// Original author: Robert Burke <robert.burke@proteowizard.org>
6//
7// Copyright 2009 Spielberg Family Center for Applied Proteomics
8// University of Southern California, Los Angeles, California 90033
9//
10// Licensed under the Apache License, Version 2.0 (the "License");
11// you may not use this file except in compliance with the License.
12// You may obtain a copy of the License at
13//
14// http://www.apache.org/licenses/LICENSE-2.0
15//
16// Unless required by applicable law or agreed to in writing, software
17// distributed under the License is distributed on an "AS IS" BASIS,
18// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19// See the License for the specific language governing permissions and
20// limitations under the License.
21//
22
23
24#ifndef _IDENTDATA_TEXTWRITER_HPP_
25#define _IDENTDATA_TEXTWRITER_HPP_
26
27
30#include "IdentData.hpp"
31#include <boost/foreach.hpp>
32#include <iostream>
33#include <string>
34#include <vector>
35
36
37namespace pwiz {
38namespace identdata {
39
40using namespace pwiz::cv;
41using namespace pwiz::data;
42using namespace boost::logic;
43
45{
46 public:
47
48 TextWriter(std::ostream& os, int depth = 0)
49 : os_(os), depth_(depth), indent_(depth*2, ' ')
50 {
51 os_.precision(14);
52 }
53
54
55 TextWriter child() {return TextWriter(os_, depth_+1);}
56
57
58 TextWriter& operator()(const std::string& text)
59 {
60 os_ << indent_ << text << std::endl;
61 return *this;
62 }
63
64
65 TextWriter& operator()(const float value)
66 {
67 os_ << indent_ << value << std::endl;
68 return *this;
69 }
70
71
72 TextWriter& operator()(const CVParam& cvParam)
73 {
74 os_ << indent_ << "cvParam: " << cvTermInfo(cvParam.cvid).name;
75 if (!cvParam.value.empty())
76 os_ << ", " << cvParam.value;
77 if (cvParam.units != CVID_Unknown)
78 os_ << ", " << cvParam.unitsName();
79 os_ << std::endl;
80 return *this;
81 }
82
83
84 TextWriter& operator()(const std::string& label, const float& v)
85 {
86 os_ << indent_ << label << v << std::endl;
87 return *this;
88 }
89
90
91 TextWriter& operator()(const std::string& label, const double& v)
92 {
93 os_ << indent_ << label << v << std::endl;
94 return *this;
95 }
96
97
98 TextWriter& operator()(const std::string& label, const bool& v)
99 {
100 os_ << indent_ << label << std::boolalpha << v << std::endl;
101 return *this;
102 }
103
104
105 TextWriter& operator()(const UserParam& userParam)
106 {
107 os_ << indent_ << "userParam: " << userParam.name;
108 if (!userParam.value.empty()) os_ << ", " << userParam.value;
109 if (!userParam.type.empty()) os_ << ", " << userParam.type;
110 if (userParam.units != CVID_Unknown) os_ << ", " << cvTermInfo(userParam.units).name;
111 os_ << std::endl;
112 return *this;
113 }
114
115
116 template<typename object_type>
117 TextWriter& operator()(const std::string& label, const std::vector<object_type>& v)
118 {
119 (*this)(label);
120 for_each(v.begin(), v.end(), child());
121 return *this;
122 }
123
124
125 template<typename object_type>
126 TextWriter& operator()(const std::vector<object_type>& v)
127 {
128 for_each(v.begin(), v.end(), child());
129 return *this;
130 }
131
132
133 template<typename object_type>
134 TextWriter& operator()(const std::string& label, const object_type& v)
135 {
136 (*this)(label + boost::lexical_cast<std::string>(v));
137 return *this;
138 }
139
140
141 TextWriter& operator()(const std::string& label, const ParamContainer& paramContainer)
142 {
143 (*this)(label); // + ":"
144 for_each(paramContainer.cvParams.begin(), paramContainer.cvParams.end(), child());
145 for_each(paramContainer.userParams.begin(), paramContainer.userParams.end(), child());
146 return *this;
147 }
148
149
150 TextWriter& operator()(const ParamContainer& paramContainer)
151 {
152 for_each(paramContainer.cvParams.begin(), paramContainer.cvParams.end(), *this);
153 for_each(paramContainer.userParams.begin(), paramContainer.userParams.end(), *this);
154 return *this;
155 }
156
157
159 {
160 (*this)("BibliographicReference: ");
161 (*this)((Identifiable)br);
162 if (!br.authors.empty())
163 child()("authors: "+br.authors);
164 if (!br.publication.empty())
165 child()("publication: "+br.publication);
166 if (!br.publisher.empty())
167 child()(br.publisher);
168 if (!br.editor.empty())
169 child()("editor: "+br.editor);
170 if (br.year != 0)
171 child()("year: ", br.year);
172 if (!br.volume.empty())
173 child()("volume: "+br.volume);
174 if (!br.issue.empty())
175 child()("issue: "+br.issue);
176 if (!br.pages.empty())
177 child()("pages: "+br.pages);
178 if (!br.title.empty())
179 child()("title: "+br.title);
180
181 return *this;
182 }
183
184
186 {
187 (*this)("TranslationTable:");
188 (*this)((const IdentifiableParamContainer&)tt);
189 return *this;
190 }
191
192
194 {
195 (*this)("DatabaseTranslation:");
196 if (!dt.frames.empty())
197 child()("frames: ", dt.frames);
198 if (!dt.translationTable.empty())
199 child()("translationTable: ", dt.translationTable);
200 return *this;
201 }
202
203
205 {
206 (*this)("SpectrumIdentificationProtocol:");
207 (*this)((Identifiable&)si);
208 if (si.analysisSoftwarePtr.get() &&
209 !si.analysisSoftwarePtr->empty())
210 child()("analysisSoftware_ref: "+si.analysisSoftwarePtr->id);
211 if (!si.searchType.empty())
212 child()("SearchType: ", si.searchType);
214 child()("AdditionalSearchParams", si.additionalSearchParams);
215 if (!si.modificationParams.empty())
216 child()("ModificationParams", si.modificationParams);
217 if (!si.enzymes.empty())
218 child()(si.enzymes);
219 if (!si.massTable.empty())
220 child()(si.massTable);
221 if (!si.fragmentTolerance.empty())
222 child()("FragmentTolerance", si.fragmentTolerance);
223 if (!si.parentTolerance.empty())
224 child()("ParentTolerance", si.parentTolerance);
225 if (!si.threshold.empty())
226 child()("Threshold", si.threshold);
227 if (!si.databaseFilters.empty())
228 child()("DatabaseFilters", si.databaseFilters);
229 if (si.databaseTranslation.get() && !si.databaseTranslation->empty())
230 child()("DatabaseTranslation", si.databaseTranslation);
231
232 return *this;
233 }
234
235
237 {
238 (*this)("DBSequence: ");
239 (*this)((const IdentifiableParamContainer&)ds);
240 if (ds.length!=0)
241 child()("length: ", ds.length);
242 if (!ds.accession.empty())
243 child()("accession: "+ds.accession);
244 if (ds.searchDatabasePtr.get() && !ds.searchDatabasePtr->empty())
245 child()("searchDatabase_ref: "+ds.searchDatabasePtr->id);
246 if (!ds.seq.empty())
247 child()("Seq: "+ds.seq);
248
249 return *this;
250 }
251
252
254 {
255 (*this)("SubstitutionModification: ");
256 if (ds.originalResidue != 0)
257 child()("originalResidue: ", ds.originalResidue);
258 if (ds.replacementResidue != 0)
259 child()("replacementResidue: ", ds.replacementResidue);
260 if (ds.location != 0)
261 child()("location: ", ds.location);
262 child()("avgMassDelta: ", ds.avgMassDelta);
263 child()("monoisotopicMassDelta: ", ds.monoisotopicMassDelta);
264
265 return *this;
266 }
267
268
270 {
271 (*this)("IonType: ");
272 if (!it.index.empty())
273 child()("index: " + makeDelimitedListString(it.index));
274 if (it.charge != 0)
275 child()("charge: ", it.charge);
276 if (!it.fragmentArray.empty())
277 (*this)(it.fragmentArray);
278 (*this)((const CVParam&)it);
279 return *this;
280 }
281
282
284 {
285 (*this)("Measure: ");
286 (*this)((const ParamContainer&)m);
287
288 return *this;
289 }
290
291
293 {
294 (*this)("SearchDatabase: ");
295 (*this)((const IdentifiableParamContainer&)sd);
296 if (!sd.location.empty())
297 child()("location: " + sd.location);
298 if (!sd.version.empty())
299 child()("version: " + sd.version);
300 if (!sd.releaseDate.empty())
301 child()("releaseDate: " + sd.releaseDate);
302 if (sd.numDatabaseSequences != 0)
303 child()("numDatabaseSequences: ", sd.numDatabaseSequences);
304 if (sd.numResidues != 0)
305 child()("numResidues: ", sd.numResidues);
306 if (!sd.fileFormat.empty())
307 child()("FileFormat: ", sd.fileFormat);
308 if (!sd.databaseName.empty())
309 child()("DatabaseName: ", sd.databaseName);
310 return *this;
311 }
312
313
315 {
316 (*this)("SpectraData: ");
317 if (!sd.location.empty())
318 child()("location: " + sd.location);
319 if (!sd.externalFormatDocumentation.empty())
320 child()("ExternalFormatDocumentation: ", sd.externalFormatDocumentation);
321 if (!sd.fileFormat.empty())
322 child()("FileFormat: ", sd.fileFormat);
323 if (!sd.spectrumIDFormat.empty())
324 child()("SpectrumIDFormat: ", sd.spectrumIDFormat);
325 return *this;
326 }
327
328
330 {
331 (*this)("SpectrumIdentificationItem:");
332 if (!sii.id.empty())
333 child()("id: ", sii.id);
334 if (!sii.name.empty())
335 child()("name: ", sii.name);
336 if (!sii.empty())
337 {
338 child()("rank: ", sii.rank);
339 child()("chargeState: ", sii.chargeState);
340 child()("experimentalMassToCharge: ", sii.experimentalMassToCharge);
341 child()("calculatedMassToCharge: ", sii.calculatedMassToCharge);
342 child()("calculatedPI: ", sii.calculatedPI);
343 child()("passThreshold: ", sii.passThreshold);
344 }
345 if (sii.peptidePtr.get() && !sii.peptidePtr->empty())
346 child()("peptide_ref: ", sii.peptidePtr->id);
347 if (sii.massTablePtr.get() && !sii.massTablePtr->empty())
348 child()("massTable_ref: ", sii.massTablePtr->id);
349 if (sii.samplePtr.get() && !sii.samplePtr->empty())
350 child()("sample_ref: ", sii.samplePtr->id);
351
352 BOOST_FOREACH(const PeptideEvidencePtr& pe, sii.peptideEvidencePtr)
353 if (pe.get() && !pe->empty())
354 child()("peptideEvidence_ref: ", pe->id);
355
356 if (!sii.fragmentation.empty())
357 child()("fragmentation", sii.fragmentation);
358
359 child()((const ParamContainer&)sii);
360
361 return *this;
362 }
363
364
366 {
367 (*this)("SpectrumIdentificationResult: ");
368 (*this)((const IdentifiableParamContainer&)sir);
369 if (!sir.spectrumID.empty())
370 child()("spectrumID: "+sir.spectrumID);
371 if (sir.spectraDataPtr.get() && !sir.spectraDataPtr->empty())
372 child()("spectraData_ref: "+sir.spectraDataPtr->id);
373 if (!sir.spectrumIdentificationItem.empty())
374 (*this)(sir.spectrumIdentificationItem);
375
376 return *this;
377 }
378
379
381 {
382 (*this)("SpectrumIdentificationList: ");
383 (*this)((const IdentifiableParamContainer&)sil);
384 if (!sil.empty())
385 child()("numSequencesSearched: ", sil.numSequencesSearched);
386 if (!sil.fragmentationTable.empty())
387 child()("FragmentationTable", sil.fragmentationTable);
388 if (!sil.spectrumIdentificationResult.empty())
389 (*this)(sil.spectrumIdentificationResult);
390 return *this;
391 }
392
393
395 {
396 (*this)("ProteinDetectionList: ");
397 if (!pdl.proteinAmbiguityGroup.empty())
398 (*this)(pdl.proteinAmbiguityGroup);
399 (*this)((const ParamContainer&)pdl);
400 return *this;
401 }
402
403
405 {
406 (*this)("AnalysisData: ");
407
408 if (!ad.spectrumIdentificationList.empty())
409 (*this)(ad.spectrumIdentificationList);
410 if (ad.proteinDetectionListPtr.get() &&
411 !ad.proteinDetectionListPtr->empty())
412 (*this)(*ad.proteinDetectionListPtr);
413
414 return *this;
415 }
416
417
419 {
420 (*this)("FragmentArray: ");
421
422 if (fa.measurePtr.get() && !fa.measurePtr->empty())
423 child()("measure_ref: " + fa.measurePtr->id);
424 if (!fa.values.empty())
425 child()("values: " + makeDelimitedListString(fa.values));
426
427 return *this;
428 }
429
430
432 {
433 //(*this)("sourceFile: ");
434
435 (*this)((const IdentifiableParamContainer&)sf);
436 if (!sf.location.empty())
437 child()("location: " + sf.location);
438 if (!sf.fileFormat.empty())
439 child()(sf.fileFormat);
440 if (!sf.externalFormatDocumentation.empty())
441 child()("externalFormatDocumentation: ",
443
444 return *this;
445 }
446
447
449 {
450 (*this)("Inputs: ");
451
452 if (!inputs.sourceFile.empty())
453 child()("sourceFile: ", inputs.sourceFile);
454 if (!inputs.searchDatabase.empty())
455 child()("searchDatabase: ", inputs.searchDatabase);
456 if (!inputs.spectraData.empty())
457 child()("spectraData: ", inputs.spectraData);
458
459 return *this;
460 }
461
462
464 {
465 (*this)("DataCollection: ");
466
467 if (!dc.inputs.empty())
468 child()(dc.inputs);
469 if (!dc.analysisData.empty())
470 child()(dc.analysisData);
471
472 return *this;
473 }
474
475
477 {
478 (*this)("Filter: ");
479 if (!f.filterType.empty())
480 child()("filterType: ", f.filterType);
481 if (!f.include.empty())
482 child()("include: ", f.include);
483 if (!f.exclude.empty())
484 child()("exclude: ", f.exclude);
485 return *this;
486 }
487
488
490 {
491 (*this)("SearchModification: ");
492 if (sm.fixedMod != 0)
493 child()("fixedMod: ", sm.fixedMod);
494 if (sm.massDelta != 0)
495 child()("massDelta: ", sm.massDelta);
496 if (!sm.residues.empty())
497 child()("residues: " + makeDelimitedListString(sm.residues));
498 if (!sm.specificityRules.empty())
499 child()("specificityRules: ", sm.specificityRules);
500 child()((const ParamContainer&)sm);
501 return *this;
502 }
503
504
506 {
507 (*this)("Enzymes: ");
508 if (!indeterminate(ezs.independent))
509 child()("independent: ", (bool) ezs.independent);
510 if (!ezs.enzymes.empty())
511 child()("enzymes: ", ezs.enzymes);
512 return *this;
513 }
514
515
517 {
518 (*this)("MassTable: ");
519 if (!mt.id.empty())
520 child()("id: " + mt.id);
521 if (!mt.msLevel.empty())
522 child()("msLevel: ", mt.msLevel);
523 if (!mt.residues.empty())
524 child()("residues: ", mt.residues);
525 if (!mt.ambiguousResidue.empty())
526 child()("ambiguousResidue: ", mt.residues);
527 return *this;
528 }
529
530
532 {
533 (*this)("AnalysisProtocolCollection: ");
534 if (!apc.spectrumIdentificationProtocol.empty())
535 child()("spectrumIdentificationProtocol: ",
537 if (!apc.proteinDetectionProtocol.empty())
538 child()("proteinDetectionProtocol: ",
540 return *this;
541 }
542
543
545 {
546 (*this)("PeptideHypothesis: ");
547
548 if (ph.peptideEvidencePtr.get())
549 child()("peptideEvidence: ", ph.peptideEvidencePtr->id);
550 child()("spectrumIdentificationItem: " + makeDelimitedRefListString(ph.spectrumIdentificationItemPtr));
551 return *this;
552 }
553
554
556 {
557 (*this)("ProteinDetectionHypothesis: ");
558 if (pdh.dbSequencePtr.get() && !pdh.dbSequencePtr->empty())
559 child()("DBSequence_ref: " + pdh.dbSequencePtr->id);
560 // TODO: Resolve if (!pdh.passThreshold.empty())
561 // child()("passThreshold: " + boost::lexical_cast<std::string>(pdh.passThreshold));
562 if (!pdh.peptideHypothesis.empty())
563 (*this)(pdh.peptideHypothesis);
564
565 child()((const ParamContainer&)pdh);
566 return *this;
567 }
568
569
571 {
572 (*this)("ProteinAmbiguityGroup: ");
573 if (!pag.proteinDetectionHypothesis.empty())
574 (*this)(pag.proteinDetectionHypothesis);
575 (*this)((const ParamContainer&)pag);
576
577 return *this;
578 }
579
580
582 {
583 (*this)("ProteinDetection: ");
584 if (pd.proteinDetectionProtocolPtr.get() &&
585 !pd.proteinDetectionProtocolPtr->empty())
586 child()("proteinDetectionProtocol_ref: "+pd.proteinDetectionProtocolPtr->id);
587 if (pd.proteinDetectionListPtr.get() &&
588 !pd.proteinDetectionListPtr->empty())
589 child()("proteinDetectionList_ref: "+pd.proteinDetectionListPtr->id);
590 if (!pd.activityDate.empty())
591 child()("activityDate: "+pd.activityDate);
592 child()("inputSpectrumIdentifications: " + makeDelimitedRefListString(pd.inputSpectrumIdentifications));
593 return *this;
594 }
595
596
598 {
599 (*this)("SpectrumIdentification: ");
602 child()("spectrumIdentificationProtocol_ref: "+si.spectrumIdentificationProtocolPtr->id);
603 if (si.spectrumIdentificationListPtr.get() &&
605 child()("spectrumIdentificationList_ref: "+si.spectrumIdentificationListPtr->id);
606 if (!si.activityDate.empty())
607 child()("activityDate: "+si.activityDate);
608 if (!si.inputSpectra.empty())
609 child()("inputSpectra: " + makeDelimitedRefListString(si.inputSpectra));
610 if (!si.searchDatabase.empty())
611 child()("searchDatabase: " + makeDelimitedRefListString(si.searchDatabase));
612
613 return *this;
614 }
615
616
618 {
619 (*this)("AnalysisCollection: ", ac.spectrumIdentification);
620 if (!ac.proteinDetection.empty())
621 child()(ac.proteinDetection);
622 return *this;
623 }
624
625
627 {
628 (*this)("SequenceCollection: ");
629 if (!sc.dbSequences.empty())
630 child()("dbSequences: ", sc.dbSequences);
631 if (!sc.peptides.empty())
632 child()("peptides: ", sc.peptides);
633 if (!sc.peptideEvidence.empty())
634 child()("peptideEvidence: ", sc.peptideEvidence);
635 return *this;
636 }
637
638
640 {
641 (*this)((const IdentifiableParamContainer&)cont);
642
643 return *this;
644 }
645
646
648 {
649 (*this)("Person: ");
650 (*this)((const Contact&)per);
651 if (!per.lastName.empty())
652 child()("lastName: "+per.lastName);
653 if (!per.firstName.empty())
654 child()("firstName: "+per.firstName);
655 if (!per.midInitials.empty())
656 child()("midInitials: "+per.midInitials);
657 if (!per.affiliations.empty())
658 child()("affiliations: ", per.affiliations);
659
660 return *this;
661 }
662
663
665 {
666 (*this)("Organization: ");
667 (*this)((const Contact&)org);
668 if (org.parent.get())
669 child()("Parent: ", org.parent->id);
670
671 return *this;
672 }
673
674
675 TextWriter& operator()(const ContactPtr cont)
676 {
677 if (dynamic_cast<Person*>(cont.get()))
678 (*this)((const Person&)(*cont));
679 else if (dynamic_cast<Organization*>(cont.get()))
680 (*this)((const Organization&)(*cont));
681 else
682 (*this)(*cont);
683
684 return *this;
685 }
686
687
688 TextWriter& operator()(const std::string& label, const ContactPtr cont)
689 {
690 (*this)(label);
691 (*this)(cont);
692
693 return *this;
694 }
695
696
698 {
699 (*this)("ContactRole: ");
700 if (cr.contactPtr.get() && !cr.contactPtr->empty())
701 child()("contact_ref: ", cr.contactPtr->id);
702 if (!cr.CVParam::empty())
703 child()("Role: ", (const CVParam&)cr);
704 return (*this);
705 }
706
707
709 {
710 (*this)("Provider: ");
711 (*this)((Identifiable&)provider);
712 if (provider.contactRolePtr.get() && !provider.contactRolePtr->empty())
713 child()(provider.contactRolePtr);
714 return *this;
715 }
716
717
719 {
720 (*this)("Sample: ");
721 (*this)((const IdentifiableParamContainer&)sample);
722 (*this)(sample.contactRole);
723 child()(sample.cvParams);
724 child()("SubSamples:", sample.subSamples);
725
726 return *this;
727 }
728
729
731 {
732 (*this)("AnalysisSampleCollection: ", asc.samples);
733
734 return *this;
735 }
736
737
738 TextWriter& operator()(const AnalysisSoftwarePtr& asp)
739 {
740 (*this)("analysisSoftware:");
741 (*this)((Identifiable)*asp);
742 if (!asp->version.empty())
743 child()("version: "+asp->version);
744 if (asp->contactRolePtr.get() && asp->contactRolePtr->empty())
745 child()(*asp->contactRolePtr);
746 if (!asp->softwareName.empty())
747 child()("softwareName: ", asp->softwareName);
748 if (!asp->URI.empty())
749 child()("uri: "+asp->URI);
750 if (!asp->customizations.empty())
751 child()("customizations: "+asp->customizations);
752 return *this;
753 }
754
755
757 {
758 (*this)("Enzyme: ");
759 if (!enzyme.id.empty())
760 child()("id: "+enzyme.id);
761 if (!enzyme.nTermGain.empty())
762 child()("nTermGain: "+enzyme.nTermGain);
763 if (!enzyme.cTermGain.empty())
764 child()("cTermGain: "+enzyme.cTermGain);
765 child()("semiSpecific: ", (enzyme.terminalSpecificity != proteome::Digestion::FullySpecific ? "true": "false"));
766 if (enzyme.missedCleavages != 0)
767 child()("missedCleavages: ", enzyme.missedCleavages);
768 if (enzyme.minDistance != 0)
769 child()("minDistance: ", enzyme.minDistance);
770 if (!enzyme.siteRegexp.empty())
771 child()("SiteRegexp: "+enzyme.siteRegexp);
772 if (!enzyme.enzymeName.empty())
773 child()("EnzymeName: ", enzyme.enzymeName);
774
775 return *this;
776 }
777
778
780 {
781 if (!id.id.empty())
782 child()("id: "+id.id);
783 if (!id.name.empty())
784 child()("name: "+id.name);
785
786 return *this;
787 }
788
789
791 {
792 if (!id.id.empty())
793 child()("id: "+id.id);
794 if (!id.name.empty())
795 child()("name: "+id.name);
796
797 child()((const ParamContainer&)id);
798
799 return *this;
800 }
801
802
804 {
805 (*this)("Residue: ");
806 if (res.code != 0)
807 child()("code: ", res.code);
808 if (res.mass != 0)
809 child()("mass: ", res.mass);
810 return *this;
811 }
812
813
815 {
816 (*this)("AmbiguousResidue: ");
817 if (res.code != 0)
818 child()("code: ", res.code);
819 (*this)((const ParamContainer&)res);
820
821 return *this;
822 }
823
824
826 {
827 (*this)("Modification: ");
828 if (mod.location != 0)
829 child()("location: ", mod.location);
830 if (!mod.residues.empty())
831 child()("residues: " + makeDelimitedListString(mod.residues));
832 if (mod.avgMassDelta != 0)
833 child()("avgMassDelta: ", mod.avgMassDelta);
834 if (mod.monoisotopicMassDelta != 0)
835 child()("monoisotopicMassDelta: ", mod.monoisotopicMassDelta);
836 child()((const ParamContainer&)mod);
837
838 return *this;
839 }
840
841
843 {
844 (*this)("Peptide: ");
845 (*this)((const IdentifiableParamContainer&)pep);
846 if (!pep.peptideSequence.empty())
847 child()("peptideSequence: "+pep.peptideSequence);
848 if (!pep.modification.empty())
849 child()("modification", pep.modification);
850 if (!pep.substitutionModification.empty())
851 child()(pep.substitutionModification);
852
853 return *this;
854 }
855
856
858 {
859 (*this)("PeptideEvidence: ");
860 (*this)((const IdentifiableParamContainer&)pe);
861 if (pe.peptidePtr.get() && !pe.peptidePtr->empty())
862 child()("peptide_ref: "+pe.peptidePtr->id);
863 if (pe.dbSequencePtr.get() && !pe.dbSequencePtr->empty())
864 child()("dBSequence_ref: "+pe.dbSequencePtr->id);
865 if (pe.start != 0)
866 child()("start: ", pe.start);
867 if (pe.end != 0)
868 child()("end: ", pe.end);
869 if (pe.pre != 0)
870 child()("pre: ", pe.pre);
871 if (pe.post != 0)
872 child()("post: ", pe.post);
873 if (pe.translationTablePtr.get() && !pe.translationTablePtr->empty())
874 child()("translationTable_ref: "+pe.translationTablePtr->id);
875 if (pe.frame != 0)
876 child()("frame: ", pe.frame);
877 child()("isDecoy: ", pe.isDecoy);
878
879 return *this;
880 }
881
882
884 {
885 (*this)("mzid:");
886 child()((Identifiable)mzid);
887 ("version: " + mzid.version());
888 if (!mzid.cvs.empty())
889 child()("cvList: ", mzid.cvs);
890 if (!mzid.analysisSoftwareList.empty())
891 child()("analysisSoftwareList: ", mzid.analysisSoftwareList);
892 if (!mzid.provider.empty())
893 child()(mzid.provider);
894 if (!mzid.auditCollection.empty())
895 child()("auditCollection: ", mzid.auditCollection);
897 child()(mzid.analysisSampleCollection);
898 if (!mzid.sequenceCollection.empty())
899 child()(mzid.sequenceCollection);
900 if (!mzid.analysisCollection.empty())
901 child()(mzid.analysisCollection);
903 child()(mzid.analysisProtocolCollection);
904 if (!mzid.dataCollection.empty())
905 child()(mzid.dataCollection);
906 if (!mzid.bibliographicReference.empty())
907 child()(mzid.bibliographicReference);
908 return *this;
909 }
910
911
913 {
914 (*this)("cv:");
915 child()
916 ("id: " + cv.id)
917 ("fullName: " + cv.fullName)
918 ("version: " + cv.version)
919 ("URI: " + cv.URI);
920 return *this;
921 }
922
923
924 // if no other overload matches, assume the object is a shared_ptr of a valid overloaded type
925 template<typename object_type>
926 TextWriter& operator()(const boost::shared_ptr<object_type>& p)
927 {
928 return p.get() ? (*this)(*p) : *this;
929 }
930
931 private:
932 std::ostream& os_;
934 std::string indent_;
935
936 template <typename object_type>
937 std::string makeDelimitedRefListString(const std::vector<boost::shared_ptr<object_type> >& objects, const char* delimiter = " ")
938 {
939 std::ostringstream oss;
940 for (size_t i=0; i < objects.size(); ++i)
941 {
942 if (i > 0) oss << delimiter;
943 oss << objects[i]->id;
944 }
945 return oss.str();
946 }
947
948 template <typename object_type>
949 std::string makeDelimitedListString(const std::vector<object_type>& objects, const char* delimiter = " ")
950 {
951 std::ostringstream oss;
952 oss.precision(9);
953 for (size_t i=0; i < objects.size(); ++i)
954 {
955 if (i > 0) oss << delimiter;
956 oss << objects[i];
957 }
958 return oss.str();
959 }
960};
961
962
963} // namespace identdata
964} // namespace pwiz
965
966
967#endif // _IDENTDATA_TEXTWRITER_HPP_
968
#define PWIZ_API_DECL
Definition Export.hpp:32
TextWriter & operator()(const Enzymes &ezs)
TextWriter & operator()(const CV &cv)
TextWriter & operator()(const std::string &label, const float &v)
TextWriter & operator()(const SubstitutionModification &ds)
TextWriter & operator()(const AnalysisProtocolCollection &apc)
TextWriter & operator()(const SpectraData &sd)
TextWriter & operator()(const IdentifiableParamContainer &id)
std::string makeDelimitedRefListString(const std::vector< boost::shared_ptr< object_type > > &objects, const char *delimiter=" ")
TextWriter & operator()(const PeptideHypothesis &ph)
TextWriter & operator()(const BibliographicReference &br)
TextWriter & operator()(const ProteinDetectionList &pdl)
TextWriter & operator()(const DataCollection &dc)
TextWriter & operator()(const Person &per)
TextWriter & operator()(const SpectrumIdentificationItem &sii)
TextWriter & operator()(const Sample &sample)
TextWriter & operator()(const SequenceCollection &sc)
TextWriter & operator()(const std::string &label, const object_type &v)
TextWriter & operator()(const PeptideEvidence &pe)
TextWriter & operator()(const IdentData &mzid)
std::string makeDelimitedListString(const std::vector< object_type > &objects, const char *delimiter=" ")
TextWriter & operator()(const TranslationTable &tt)
TextWriter & operator()(const SearchModification &sm)
TextWriter & operator()(const SearchDatabase &sd)
TextWriter & operator()(const MassTable &mt)
TextWriter & operator()(const Provider &provider)
TextWriter & operator()(const Contact &cont)
TextWriter & operator()(const FragmentArray &fa)
TextWriter & operator()(const Organization &org)
TextWriter & operator()(const AnalysisSampleCollection &asc)
TextWriter & operator()(const CVParam &cvParam)
TextWriter & operator()(const std::string &label, const std::vector< object_type > &v)
TextWriter & operator()(const Peptide &pep)
TextWriter & operator()(const std::string &label, const ContactPtr cont)
TextWriter & operator()(const ContactRole &cr)
TextWriter & operator()(const Residue &res)
TextWriter & operator()(const UserParam &userParam)
TextWriter & operator()(const std::string &text)
TextWriter & operator()(const ProteinAmbiguityGroup &pag)
TextWriter & operator()(const Modification &mod)
TextWriter & operator()(const AmbiguousResidue &res)
TextWriter & operator()(const SourceFile &sf)
TextWriter & operator()(const SpectrumIdentificationProtocol &si)
TextWriter & operator()(const Filter &f)
TextWriter & operator()(const Enzyme &enzyme)
TextWriter & operator()(const AnalysisData &ad)
TextWriter(std::ostream &os, int depth=0)
TextWriter & operator()(const std::string &label, const ParamContainer &paramContainer)
TextWriter & operator()(const std::string &label, const bool &v)
TextWriter & operator()(const ParamContainer &paramContainer)
TextWriter & operator()(const ContactPtr cont)
TextWriter & operator()(const SpectrumIdentification &si)
TextWriter & operator()(const Identifiable &id)
TextWriter & operator()(const DBSequence &ds)
TextWriter & operator()(const std::string &label, const double &v)
TextWriter & operator()(const float value)
TextWriter & operator()(const Inputs &inputs)
TextWriter & operator()(const std::vector< object_type > &v)
TextWriter & operator()(const SpectrumIdentificationResult &sir)
TextWriter & operator()(const Measure &m)
TextWriter & operator()(const DatabaseTranslation &dt)
TextWriter & operator()(const ProteinDetectionHypothesis &pdh)
TextWriter & operator()(const ProteinDetection &pd)
TextWriter & operator()(const AnalysisSoftwarePtr &asp)
TextWriter & operator()(const boost::shared_ptr< object_type > &p)
TextWriter & operator()(const AnalysisCollection &ac)
TextWriter & operator()(const SpectrumIdentificationList &sil)
TextWriter & operator()(const IonType &it)
CVID_Unknown
Definition cv.hpp:114
PWIZ_API_DECL const CVTermInfo & cvTermInfo(CVID cvid)
returns CV term info for the specified CVID
PWIZ_API_DECL const CV & cv(const std::string &prefix)
returns a CV object for the specified namespace (prefix); currently supported namespaces are: MS UO
Information about an ontology or CV source and a short 'lookup' tag to refer to.
Definition cv.hpp:14916
std::string id
the short label to be used as a reference tag with which to refer to this particular Controlled Vocab...
Definition cv.hpp:14918
std::string fullName
the usual name for the resource (e.g. The PSI-MS Controlled Vocabulary).
Definition cv.hpp:14924
std::string URI
the URI for the resource.
Definition cv.hpp:14921
std::string version
the version of the CV from which the referred-to terms are drawn.
Definition cv.hpp:14927
std::string name
Definition cv.hpp:14947
represents a tag-value pair, where the tag comes from the controlled vocabulary
std::string unitsName() const
convenience function to return string for the units
The base class for elements that may contain cvParams, userParams, or paramGroup references.
bool empty() const
returns true iff the element contains no params or param groups
std::vector< CVParam > cvParams
a collection of controlled vocabulary terms
std::vector< UserParam > userParams
a collection of uncontrolled user terms
Uncontrolled user parameters (essentially allowing free text). Before using these,...
CVID units
an optional CV parameter for the unit term associated with the value, if any (e.g....
std::string value
the value for the parameter, where appropriate.
std::string name
the name for the parameter.
std::string type
the datatype of the parameter, where appropriate (e.g.: xsd:float).
Implementation of AmbiguousResidueType from the mzIdentML schema.
Implementation of AnalysisCollectionType from the mzIdentML schema.
std::vector< SpectrumIdentificationPtr > spectrumIdentification
Implementation of AnalysisDataType from the mzIdentML schema.
std::vector< SpectrumIdentificationListPtr > spectrumIdentificationList
ProteinDetectionListPtr proteinDetectionListPtr
Implementation of AnalysisProtocolCollectionType from the mzIdentML schema.
std::vector< ProteinDetectionProtocolPtr > proteinDetectionProtocol
std::vector< SpectrumIdentificationProtocolPtr > spectrumIdentificationProtocol
Implementation of AnalysisSampleCollectionType from mzIdentML schema.
Implementation for the BibliographicReferenceType tag in the mzIdentML schema.
Definition IdentData.hpp:96
Implementation of ContactType from mzIdentML.
Implementation of ContactRoleType from the mzIdentML schema.
Implementation of DBSequenceType from the mzIdentML schema.
SearchDatabasePtr searchDatabasePtr
Implementation of DataCollectionType from the mzIdentML schema.
Implementation of DatabaseTranslationType from the mzIdentML schema.
std::vector< TranslationTablePtr > translationTable
Implementation of EnzymeType from the mzIdentML schema.
proteome::Digestion::Specificity terminalSpecificity
ParamContainer enzymeName
Implementation of EnzymesType from the mzIdentML schema.
std::vector< EnzymePtr > enzymes
boost::logic::tribool independent
Implementation of FilterType from the mzIdentML schema.
ParamContainer exclude
ParamContainer filterType
ParamContainer include
Implementation of FragmentArrayType from the mzIdentML schema.
std::vector< double > values
Implementation of the MzIdentMLType from the mzIdentML schema.
SequenceCollection sequenceCollection
DataCollection dataCollection
AnalysisProtocolCollection analysisProtocolCollection
std::vector< AnalysisSoftwarePtr > analysisSoftwareList
std::vector< ContactPtr > auditCollection
const std::string & version() const
returns the version of this mzIdentML document; for a document created programmatically,...
std::vector< BibliographicReferencePtr > bibliographicReference
AnalysisSampleCollection analysisSampleCollection
AnalysisCollection analysisCollection
Parent class representing extensions of the IdentifiableType from the mzIdentML schema.
Definition IdentData.hpp:65
Parent class of all Identifiable objects that have ParamGroups.
Definition IdentData.hpp:80
Implementation of the InputsType from the mzIdentML schema.
std::vector< SourceFilePtr > sourceFile
std::vector< SearchDatabasePtr > searchDatabase
std::vector< SpectraDataPtr > spectraData
Implementation of IonTypeType from the mzIdentML schema.
std::vector< int > index
std::vector< FragmentArrayPtr > fragmentArray
Implementation of MassTableType from the mzIdentML schema.
std::vector< ResiduePtr > residues
std::vector< AmbiguousResiduePtr > ambiguousResidue
std::vector< int > msLevel
Implementation of MeasureType from the mzIdentML schema.
Implementation of ModificationType from the mzIdentML schema.
std::vector< char > residues
Implementation of AbstractOrganizationType from the mzIdentML schema.
boost::shared_ptr< Organization > parent
Implementation of PeptideEvidenceType from the mzIdentML schema.
TranslationTablePtr translationTablePtr
Implementation of PeptideType from the mzIdentML schema.
std::vector< ModificationPtr > modification
std::vector< SubstitutionModificationPtr > substitutionModification
Implementation of PeptideHypothesisType from the mzIdentML schema.
PeptideEvidencePtr peptideEvidencePtr
std::vector< SpectrumIdentificationItemPtr > spectrumIdentificationItemPtr
Implementation of PersonType from the mzIdentML schema.
std::vector< OrganizationPtr > affiliations
Implementation of ProteinAmbiguityGroupType from the mzIdentML schema.
std::vector< ProteinDetectionHypothesisPtr > proteinDetectionHypothesis
Implementation of ProteinDetectionType from the mzIdentML schema.
std::vector< SpectrumIdentificationListPtr > inputSpectrumIdentifications
ProteinDetectionProtocolPtr proteinDetectionProtocolPtr
ProteinDetectionListPtr proteinDetectionListPtr
Implementation of ProteinDetectionHypothesisType from the mzIdentML schema.
std::vector< PeptideHypothesis > peptideHypothesis
Implementation of ProteinDetectionListType from the mzIdentML schema.
std::vector< ProteinAmbiguityGroupPtr > proteinAmbiguityGroup
Implementation of ProviderType from the mzIdentML schema.
ContactRolePtr contactRolePtr
Implementation of ResidueType from the mzIdentML schema.
Implementation of the SampleType from the mzIdentML schema.
std::vector< boost::shared_ptr< Sample > > subSamples
std::vector< ContactRolePtr > contactRole
Implementation of SearchDatabaseType from the mzIdentML schema.
Implementation of SearchModificationType from the mzIdentML schema.
Implementation of SequenceCollectionType from the mzIdentML schema.
std::vector< DBSequencePtr > dbSequences
std::vector< PeptideEvidencePtr > peptideEvidence
std::vector< PeptidePtr > peptides
Implementation of SourceFileType from the mzIdentML schema.
std::vector< std::string > externalFormatDocumentation
Implementation of SpectraDataType from the mzIdentML schema.
std::vector< std::string > externalFormatDocumentation
Implementation of SpectrumIdentificationType from the mzIdentML schema.
std::vector< SpectraDataPtr > inputSpectra
SpectrumIdentificationListPtr spectrumIdentificationListPtr
std::vector< SearchDatabasePtr > searchDatabase
SpectrumIdentificationProtocolPtr spectrumIdentificationProtocolPtr
Implementation of SpectrumIdentificationItemType from the mzIdentML schema.
std::vector< PeptideEvidencePtr > peptideEvidencePtr
std::vector< IonTypePtr > fragmentation
Implementation of SpectrumIdentificationListType from the mzIdentML schema.
std::vector< SpectrumIdentificationResultPtr > spectrumIdentificationResult
std::vector< MeasurePtr > fragmentationTable
Implementation of SpectrumIdentificationProtocolType from the mzIdentML schema.
std::vector< SearchModificationPtr > modificationParams
Implementation of SpectrumIdentificationResultType from the mzIdentML schema.
std::vector< SpectrumIdentificationItemPtr > spectrumIdentificationItem
Implementation of SubstitutionModificationType from the mzIdentML schema.
Implementation of TranslationTableType from the mzIdentML schema.