-
Notifications
You must be signed in to change notification settings - Fork 2
/
xmlio.h
135 lines (121 loc) · 4.87 KB
/
xmlio.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
/*******************************************************************************
Copyright 2014 Henric Zazzi <hzazzi@kth.se>
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*******************************************************************************/
#ifndef XMLIO_H
#define XMLIO_H
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <fstream>
#include <stdexcept>
#include <boost/lexical_cast.hpp>
#include <boost/filesystem.hpp>
#include <boost/unordered_map.hpp>
#include <boost/format.hpp>
#include "global.h"
//------------------------------------------------------------------------------
using namespace std;
//------------------------------------------------------------------------------
// Namespaces containing parameters for mzID and percolator out files
// in case future version of MZID, and percolator out parameters change
// Accession and cvRef are kept for future migration of obtained values
// into mzIdentML Controlled Vocabulary
//------------------------------------------------------------------------------
namespace MZID_PARAM {
const char SCHEMA_NAME[]="http://psidev.info/psi/pi/mzIdentML/1.1";
const char SCHEMA[]="mzIdentML1.1.0.xsd";
const char FILE_EXTENSION[]=".mzid";
const char START_INSERT_TAG[]="<SpectrumIdentificationItem ";
const char END_INSERT_TAG[]="</SpectrumIdentificationItem>";
const char PSMID_TAG[]=" id=\"";
const char CVPARAM_TAG[]="%s<cvParam accession=\"%s\" cvref==\"%s\" name=\"%s\" value=\"%s\"/>\n";
const char USERPARAM_TAG[]="%s<userParam name=\"%s\" value=\"%s\"/>\n";
enum ELEMENT_TYPE { USERPARAM,CVPARAM };
namespace ELEMENT_DATA {
const int ELEMENTS[]={
USERPARAM,USERPARAM,USERPARAM,USERPARAM,USERPARAM,USERPARAM
};
const string ACCESSIONS[]={
"","","MS:1002054","MS:1002056","MS:1002055",""
};
const string CVREFS[]={
"","","PSI-PI","PSI-PI","PSI-PI",""
};
const string NAMES[]={
"percolator:score","percolator:psm_p_value","percolator:psm_q_value","percolator:psm_pep","percolator:peptide_q_value","percolator:peptide_pep"
};
}
}
//------------------------------------------------------------------------------
namespace PERCOLATOR_PARAM {
const char SCHEMA_NAME[]="http://per-colator.com/percolator_out/15";
const char HEAD_TAG[]="percolator_output";
const int N_DELIMINATOR_PSM_ID=3;
const char PSMID_START[]="_SII";
enum VALUES { SVM_SCORE,P_VALUE,Q_VALUE,PEP,PEPTIDE_Q_VALUE,PEPTIDE_PEP };
}
//------------------------------------------------------------------------------
class PercolatorOutFeatures {
public:
string filename;
string psmid;
int parameter;
PercolatorOutFeatures();
PercolatorOutFeatures(string filename, string psmid, int parameter);
bool operator==(PercolatorOutFeatures const &p) const;
size_t operator()(PercolatorOutFeatures const &p) const;
};
//------------------------------------------------------------------------------
class XMLIO {
protected:
long validatexml;
public:
XMLIO();
void unsetValidation();
};
//------------------------------------------------------------------------------
class MzIDIO : public XMLIO {
private:
string outputfileending,outputdir;
public:
MzIDIO();
void setOutputFileEnding(string fileending);
bool setOutputDirectory(string outputdir);
string setOutputFileName(string filename);
bool insertMZIDValues(boost::unordered_map<PercolatorOutFeatures, string, PercolatorOutFeatures> &pout_values,
vector <string> &filenames, bool multiplemzidfiles);
};
//------------------------------------------------------------------------------
class PercolatorOutI : public XMLIO {
private:
string filename,inputdir;
bool decoy;
bool warning;
public:
bool multiplemzidfiles;
boost::unordered_map<PercolatorOutFeatures, string, PercolatorOutFeatures> pout_values;
vector<string> mzidfilenames;
PercolatorOutI();
bool setFilename(string filename);
bool noFilename();
bool setInputDirectory(string inputdir);
bool addFilenames(string filename, bool addextension);
void unsetWarningFlag();
void setDecoy();
bool checkDecoy(bool decoy);
bool getPoutValues();
string convertPSMIDFileName(string percolatorid);
static string convertPSMID(string percolatorid);
~PercolatorOutI();
};
//------------------------------------------------------------------------------
#endif // XMLIO_H