ProteoWizard
TextWriter.hpp
Go to the documentation of this file.
1 //
2 // $Id: TextWriter.hpp 8868 2015-09-22 20:51:26Z kaipot $
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 
37 namespace pwiz {
38 namespace identdata {
39 
40 using namespace pwiz::cv;
41 using namespace pwiz::data;
42 using 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);
213  if (!si.additionalSearchParams.empty())
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 
448  TextWriter& operator()(const Inputs& inputs)
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: ", 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: ");
600  if (si.spectrumIdentificationProtocolPtr.get() &&
602  child()("spectrumIdentificationProtocol_ref: "+si.spectrumIdentificationProtocolPtr->id);
603  if (si.spectrumIdentificationListPtr.get() &&
604  !si.spectrumIdentificationListPtr->empty())
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 
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 
708  TextWriter& operator()(const Provider& provider)
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 
718  TextWriter& operator()(const Sample& sample)
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 
756  TextWriter& operator()(const Enzyme& enzyme)
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);
896  if (!mzid.analysisSampleCollection.empty())
897  child()(mzid.analysisSampleCollection);
898  if (!mzid.sequenceCollection.empty())
899  child()(mzid.sequenceCollection);
900  if (!mzid.analysisCollection.empty())
901  child()(mzid.analysisCollection);
902  if (!mzid.analysisProtocolCollection.empty())
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_;
933  int depth_;
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 
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:13356
AnalysisProtocolCollection analysisProtocolCollection
Definition: IdentData.hpp:1018
SpectrumIdentificationProtocolPtr spectrumIdentificationProtocolPtr
Definition: IdentData.hpp:769
TextWriter & operator()(const SpectraData &sd)
Definition: TextWriter.hpp:314
std::vector< OrganizationPtr > affiliations
Definition: IdentData.hpp:161
std::string value
Definition: ParamTypes.hpp:47
TextWriter & operator()(const Inputs &inputs)
Definition: TextWriter.hpp:448
PWIZ_API_DECL const CVTermInfo & cvTermInfo(CVID cvid)
returns CV term info for the specified CVID
Implementation of ContactType from mzIdentML.
Definition: IdentData.hpp:117
TextWriter & operator()(const Measure &m)
Definition: TextWriter.hpp:283
std::vector< SpectrumIdentificationItemPtr > spectrumIdentificationItemPtr
Definition: IdentData.hpp:809
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 ...
TextWriter & operator()(const DBSequence &ds)
Definition: TextWriter.hpp:236
TextWriter & operator()(const std::string &text)
Definition: TextWriter.hpp:58
boost::logic::tribool independent
Definition: IdentData.hpp:433
TextWriter & operator()(const ProteinDetection &pd)
Definition: TextWriter.hpp:581
TextWriter & operator()(const std::string &label, const double &v)
Definition: TextWriter.hpp:91
Implementation of AnalysisCollectionType from the mzIdentML schema.
Definition: IdentData.hpp:895
TextWriter & operator()(const std::string &label, const ParamContainer &paramContainer)
Definition: TextWriter.hpp:141
Implementation of AnalysisSampleCollectionType from mzIdentML schema.
Definition: IdentData.hpp:258
ostream * os_
std::vector< PeptideEvidencePtr > peptideEvidence
Definition: IdentData.hpp:656
ParamContainer exclude
Definition: IdentData.hpp:505
TextWriter & operator()(const FragmentArray &fa)
Definition: TextWriter.hpp:418
Implementation of PeptideEvidenceType from the mzIdentML schema.
Definition: IdentData.hpp:626
Implementation of MeasureType from the mzIdentML schema.
Definition: IdentData.hpp:573
Implementation of TranslationTableType from the mzIdentML schema.
Definition: IdentData.hpp:517
SearchDatabasePtr searchDatabasePtr
Definition: IdentData.hpp:303
TextWriter & operator()(const Modification &mod)
Definition: TextWriter.hpp:825
TextWriter & operator()(const ParamContainer &paramContainer)
Definition: TextWriter.hpp:150
std::vector< PeptideEvidencePtr > peptideEvidencePtr
Definition: IdentData.hpp:684
AnalysisCollection analysisCollection
Definition: IdentData.hpp:1016
TextWriter & operator()(const boost::shared_ptr< object_type > &p)
Definition: TextWriter.hpp:926
TextWriter & operator()(const std::string &label, const std::vector< object_type > &v)
Definition: TextWriter.hpp:117
Implementation of EnzymeType from the mzIdentML schema.
Definition: IdentData.hpp:408
Implementation of AmbiguousResidueType from the mzIdentML schema.
Definition: IdentData.hpp:463
Implementation of SpectraDataType from the mzIdentML schema.
Definition: IdentData.hpp:697
std::string value
the value for the parameter, where appropriate.
Definition: ParamTypes.hpp:191
std::vector< TranslationTablePtr > translationTable
Definition: IdentData.hpp:533
TextWriter & operator()(const Enzymes &ezs)
Definition: TextWriter.hpp:505
std::string unitsName() const
convenience function to return string for the units
std::vector< SpectrumIdentificationResultPtr > spectrumIdentificationResult
Definition: IdentData.hpp:751
TextWriter & operator()(const CV &cv)
Definition: TextWriter.hpp:912
TextWriter & operator()(const SpectrumIdentificationList &sil)
Definition: TextWriter.hpp:380
Parent class representing extensions of the IdentifiableType from the mzIdentML schema.
Definition: IdentData.hpp:64
TextWriter & operator()(const Provider &provider)
Definition: TextWriter.hpp:708
TextWriter & operator()(const AnalysisSampleCollection &asc)
Definition: TextWriter.hpp:730
TextWriter & operator()(const SpectrumIdentificationItem &sii)
Definition: TextWriter.hpp:329
Implementation of DatabaseTranslationType from the mzIdentML schema.
Definition: IdentData.hpp:530
TextWriter & operator()(const Enzyme &enzyme)
Definition: TextWriter.hpp:756
const std::string & version() const
returns the version of this mzIdentML document; for a document created programmatically, the version is the current release version of mzIdentML; for a document created from a file/stream, the version is the schema version read from the file/stream
Implementation of PersonType from the mzIdentML schema.
Definition: IdentData.hpp:152
std::vector< SpectrumIdentificationListPtr > spectrumIdentificationList
Definition: IdentData.hpp:962
std::string peptideSequence
Definition: IdentData.hpp:373
std::vector< IonTypePtr > fragmentation
Definition: IdentData.hpp:685
Implementation of the InputsType from the mzIdentML schema.
Definition: IdentData.hpp:943
Implementation of SpectrumIdentificationResultType from the mzIdentML schema.
Definition: IdentData.hpp:722
Implementation of ProteinDetectionHypothesisType from the mzIdentML schema.
Definition: IdentData.hpp:819
TextWriter & operator()(const Sample &sample)
Definition: TextWriter.hpp:718
std::vector< SpectrumIdentificationProtocolPtr > spectrumIdentificationProtocol
Definition: IdentData.hpp:911
Information about an ontology or CV source and a short &#39;lookup&#39; tag to refer to.
Definition: cv.hpp:13353
std::vector< PeptideHypothesis > peptideHypothesis
Definition: IdentData.hpp:826
TextWriter & operator()(const IdentifiableParamContainer &id)
Definition: TextWriter.hpp:790
TextWriter & operator()(const AnalysisData &ad)
Definition: TextWriter.hpp:404
std::vector< ProteinDetectionProtocolPtr > proteinDetectionProtocol
Definition: IdentData.hpp:912
ParamContainer filterType
Definition: IdentData.hpp:503
TextWriter & operator()(const SubstitutionModification &ds)
Definition: TextWriter.hpp:253
std::vector< ResiduePtr > residues
Definition: IdentData.hpp:487
std::vector< SpectraDataPtr > inputSpectra
Definition: IdentData.hpp:773
TextWriter & operator()(const SearchDatabase &sd)
Definition: TextWriter.hpp:292
Implementation of FilterType from the mzIdentML schema.
Definition: IdentData.hpp:501
Implementation of PeptideType from the mzIdentML schema.
Definition: IdentData.hpp:368
TextWriter & operator()(const Peptide &pep)
Definition: TextWriter.hpp:842
float lexical_cast(const std::string &str)
Implementation of AnalysisDataType from the mzIdentML schema.
Definition: IdentData.hpp:960
TextWriter & operator()(const Organization &org)
Definition: TextWriter.hpp:664
DataCollection dataCollection
Definition: IdentData.hpp:1020
std::vector< EnzymePtr > enzymes
Definition: IdentData.hpp:435
TextWriter & operator()(const std::vector< object_type > &v)
Definition: TextWriter.hpp:126
TranslationTablePtr translationTablePtr
Definition: IdentData.hpp:637
std::vector< double > values
Definition: IdentData.hpp:591
boost::shared_ptr< Organization > parent
Definition: IdentData.hpp:140
TextWriter & operator()(const Filter &f)
Definition: TextWriter.hpp:476
TextWriter & operator()(const IonType &it)
Definition: TextWriter.hpp:269
TextWriter & operator()(const TranslationTable &tt)
Definition: TextWriter.hpp:185
std::string fullName
the usual name for the resource (e.g. The PSI-MS Controlled Vocabulary).
Definition: cv.hpp:13362
ParamContainer include
Definition: IdentData.hpp:504
TextWriter(std::ostream &os, int depth=0)
Definition: TextWriter.hpp:48
std::vector< SearchDatabasePtr > searchDatabase
Definition: IdentData.hpp:774
Implementation of ProviderType from the mzIdentML schema.
Definition: IdentData.hpp:234
std::vector< PeptidePtr > peptides
Definition: IdentData.hpp:655
Uncontrolled user parameters (essentially allowing free text). Before using these, one should verify whether there is an appropriate CV term available, and if so, use the CV term instead.
Definition: ParamTypes.hpp:185
TextWriter & operator()(const ProteinDetectionList &pdl)
Definition: TextWriter.hpp:394
Implementation of ProteinAmbiguityGroupType from the mzIdentML schema.
Definition: IdentData.hpp:839
TextWriter & operator()(const std::string &label, const bool &v)
Definition: TextWriter.hpp:98
std::vector< UserParam > userParams
a collection of uncontrolled user terms
Definition: ParamTypes.hpp:253
TextWriter & operator()(const SourceFile &sf)
Definition: TextWriter.hpp:431
std::string makeDelimitedListString(const std::vector< object_type > &objects, const char *delimiter=" ")
Definition: TextWriter.hpp:949
std::vector< SubstitutionModificationPtr > substitutionModification
Definition: IdentData.hpp:375
std::string type
the datatype of the parameter, where appropriate (e.g.: xsd:float).
Definition: ParamTypes.hpp:194
TextWriter & operator()(const UserParam &userParam)
Definition: TextWriter.hpp:105
Implementation of MassTableType from the mzIdentML schema.
Definition: IdentData.hpp:480
std::vector< std::string > externalFormatDocumentation
Definition: IdentData.hpp:928
TextWriter & operator()(const ContactPtr cont)
Definition: TextWriter.hpp:675
AnalysisSampleCollection analysisSampleCollection
Definition: IdentData.hpp:1012
TextWriter & operator()(const AnalysisCollection &ac)
Definition: TextWriter.hpp:617
std::vector< boost::shared_ptr< Sample > > subSamples
Definition: IdentData.hpp:201
The base class for elements that may contain cvParams, userParams, or paramGroup references.
Definition: ParamTypes.hpp:244
Implementation of SequenceCollectionType from the mzIdentML schema.
Definition: IdentData.hpp:652
boost::shared_ptr< Contact > ContactPtr
Definition: TraData.hpp:57
TextWriter & operator()(const DatabaseTranslation &dt)
Definition: TextWriter.hpp:193
std::string URI
the URI for the resource.
Definition: cv.hpp:13359
Implementation of the MzIdentMLType from the mzIdentML schema.
Definition: IdentData.hpp:993
TextWriter & operator()(const ProteinDetectionHypothesis &pdh)
Definition: TextWriter.hpp:555
std::vector< int > msLevel
Definition: IdentData.hpp:485
bool empty() const
returns true iff the element contains no params or param groups
std::vector< CVParam > cvParams
a collection of controlled vocabulary terms
Definition: ParamTypes.hpp:250
TextWriter & operator()(const Person &per)
Definition: TextWriter.hpp:647
Implementation of EnzymesType from the mzIdentML schema.
Definition: IdentData.hpp:431
Implementation of ProteinDetectionListType from the mzIdentML schema.
Definition: IdentData.hpp:855
TextWriter & operator()(const float value)
Definition: TextWriter.hpp:65
TextWriter & operator()(const SequenceCollection &sc)
Definition: TextWriter.hpp:626
TextWriter & operator()(const SpectrumIdentificationResult &sir)
Definition: TextWriter.hpp:365
#define PWIZ_API_DECL
Definition: Export.hpp:32
std::vector< SearchModificationPtr > modificationParams
Definition: IdentData.hpp:554
std::string name
Definition: cv.hpp:13385
std::string name
the name for the parameter.
Definition: ParamTypes.hpp:188
Implementation of IonTypeType from the mzIdentML schema.
Definition: IdentData.hpp:607
std::vector< int > index
Definition: IdentData.hpp:611
ParamContainer enzymeName
Definition: IdentData.hpp:420
Implementation of SearchModificationType from the mzIdentML schema.
Definition: IdentData.hpp:388
Implementation of the SampleType from the mzIdentML schema.
Definition: IdentData.hpp:195
std::string makeDelimitedRefListString(const std::vector< boost::shared_ptr< object_type > > &objects, const char *delimiter=" ")
Definition: TextWriter.hpp:937
proteome::Digestion::Specificity terminalSpecificity
Definition: IdentData.hpp:415
std::vector< SourceFilePtr > sourceFile
Definition: IdentData.hpp:946
TextWriter & operator()(const PeptideHypothesis &ph)
Definition: TextWriter.hpp:544
Implementation of PeptideHypothesisType from the mzIdentML schema.
Definition: IdentData.hpp:806
TextWriter & operator()(const Identifiable &id)
Definition: TextWriter.hpp:779
std::vector< SpectrumIdentificationPtr > spectrumIdentification
Definition: IdentData.hpp:897
Implementation of AbstractOrganizationType from the mzIdentML schema.
Definition: IdentData.hpp:135
CVID units
an optional CV parameter for the unit term associated with the value, if any (e.g. MS_electron_volt).
Definition: ParamTypes.hpp:197
std::vector< MeasurePtr > fragmentationTable
Definition: IdentData.hpp:750
TextWriter & operator()(const ProteinAmbiguityGroup &pag)
Definition: TextWriter.hpp:570
Implementation of DataCollectionType from the mzIdentML schema.
Definition: IdentData.hpp:974
TextWriter & operator()(const Residue &res)
Definition: TextWriter.hpp:803
TextWriter & operator()(const std::string &label, const float &v)
Definition: TextWriter.hpp:84
std::vector< SpectrumIdentificationListPtr > inputSpectrumIdentifications
Definition: IdentData.hpp:881
Implementation of SourceFileType from the mzIdentML schema.
Definition: IdentData.hpp:923
TextWriter & operator()(const IdentData &mzid)
Definition: TextWriter.hpp:883
std::vector< BibliographicReferencePtr > bibliographicReference
Definition: IdentData.hpp:1022
std::vector< char > residues
Definition: IdentData.hpp:334
Implementation of SpectrumIdentificationProtocolType from the mzIdentML schema.
Definition: IdentData.hpp:545
std::vector< ContactPtr > auditCollection
Definition: IdentData.hpp:1010
std::vector< DBSequencePtr > dbSequences
Definition: IdentData.hpp:654
Implementation of FragmentArrayType from the mzIdentML schema.
Definition: IdentData.hpp:589
SequenceCollection sequenceCollection
Definition: IdentData.hpp:1014
TextWriter & operator()(const Contact &cont)
Definition: TextWriter.hpp:639
Implementation of SubstitutionModificationType from the mzIdentML schema.
Definition: IdentData.hpp:349
CVID_Unknown
Definition: cv.hpp:97
std::vector< std::string > externalFormatDocumentation
Definition: IdentData.hpp:704
std::vector< ModificationPtr > modification
Definition: IdentData.hpp:374
Implementation of ModificationType from the mzIdentML schema.
Definition: IdentData.hpp:329
TextWriter & operator()(const AmbiguousResidue &res)
Definition: TextWriter.hpp:814
TextWriter & operator()(const ContactRole &cr)
Definition: TextWriter.hpp:697
ProteinDetectionProtocolPtr proteinDetectionProtocolPtr
Definition: IdentData.hpp:877
TextWriter & operator()(const SpectrumIdentificationProtocol &si)
Definition: TextWriter.hpp:204
Implementation of SearchDatabaseType from the mzIdentML schema.
Definition: IdentData.hpp:270
TextWriter & operator()(const MassTable &mt)
Definition: TextWriter.hpp:516
ContactRolePtr contactRolePtr
Definition: IdentData.hpp:239
PeptideEvidencePtr peptideEvidencePtr
Definition: IdentData.hpp:808
Implementation of SpectrumIdentificationType from the mzIdentML schema.
Definition: IdentData.hpp:764
TextWriter & operator()(const CVParam &cvParam)
Definition: TextWriter.hpp:72
Implementation of ResidueType from the mzIdentML schema.
Definition: IdentData.hpp:445
PWIZ_API_DECL std::string value(const std::string &id, const std::string &name)
convenience function to extract a named value from an id string
std::vector< SpectraDataPtr > spectraData
Definition: IdentData.hpp:948
TextWriter & operator()(const DataCollection &dc)
Definition: TextWriter.hpp:463
std::vector< AnalysisSoftwarePtr > analysisSoftwareList
Definition: IdentData.hpp:1006
std::vector< ProteinDetectionHypothesisPtr > proteinDetectionHypothesis
Definition: IdentData.hpp:844
std::string version
the version of the CV from which the referred-to terms are drawn.
Definition: cv.hpp:13365
TextWriter & operator()(const AnalysisSoftwarePtr &asp)
Definition: TextWriter.hpp:738
TextWriter & operator()(const std::string &label, const object_type &v)
Definition: TextWriter.hpp:134
TextWriter & operator()(const BibliographicReference &br)
Definition: TextWriter.hpp:158
Implementation of AnalysisProtocolCollectionType from the mzIdentML schema.
Definition: IdentData.hpp:909
std::vector< ProteinAmbiguityGroupPtr > proteinAmbiguityGroup
Definition: IdentData.hpp:860
std::vector< SearchDatabasePtr > searchDatabase
Definition: IdentData.hpp:947
Implementation of DBSequenceType from the mzIdentML schema.
Definition: IdentData.hpp:296
Implementation for the BibliographicReferenceType tag in the mzIdentML schema.
Definition: IdentData.hpp:95
Implementation of ContactRoleType from the mzIdentML schema.
Definition: IdentData.hpp:175
std::vector< FragmentArrayPtr > fragmentArray
Definition: IdentData.hpp:613
SpectrumIdentificationListPtr spectrumIdentificationListPtr
Definition: IdentData.hpp:770
ProteinDetectionListPtr proteinDetectionListPtr
Definition: IdentData.hpp:963
bool empty() const
Definition: ParamTypes.hpp:142
Implementation of SpectrumIdentificationItemType from the mzIdentML schema.
Definition: IdentData.hpp:669
std::vector< AmbiguousResiduePtr > ambiguousResidue
Definition: IdentData.hpp:488
TextWriter & operator()(const SearchModification &sm)
Definition: TextWriter.hpp:489
ProteinDetectionListPtr proteinDetectionListPtr
Definition: IdentData.hpp:878
Implementation of SpectrumIdentificationListType from the mzIdentML schema.
Definition: IdentData.hpp:743
TextWriter & operator()(const AnalysisProtocolCollection &apc)
Definition: TextWriter.hpp:531
Parent class of all Identifiable objects that have ParamGroups.
Definition: IdentData.hpp:79
TextWriter & operator()(const SpectrumIdentification &si)
Definition: TextWriter.hpp:597
std::vector< SpectrumIdentificationItemPtr > spectrumIdentificationItem
Definition: IdentData.hpp:730
Definition: cv.hpp:91
std::vector< ContactRolePtr > contactRole
Definition: IdentData.hpp:200
represents a tag-value pair, where the tag comes from the controlled vocabulary
Definition: ParamTypes.hpp:44
TextWriter & operator()(const std::string &label, const ContactPtr cont)
Definition: TextWriter.hpp:688
std::vector< CV > cvs
Definition: IdentData.hpp:1004
TextWriter & operator()(const PeptideEvidence &pe)
Definition: TextWriter.hpp:857
Implementation of ProteinDetectionType from the mzIdentML schema.
Definition: IdentData.hpp:872