Newer
Older
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
/**
* \file /input/mascot/mascotdatparser.h
* \date 17/2/2018
* \author Olivier Langella
* \brief MASCOT dat file parser
*/
/*******************************************************************************
* Copyright (c) 2018 Olivier Langella <olivier.langella@u-psud.fr>.
*
* This file is part of XTPcpp.
*
* XTPcpp is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* XTPcpp is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with XTPcpp. If not, see <http://www.gnu.org/licenses/>.
*
* Contributors:
* Olivier Langella <olivier.langella@u-psud.fr> - initial API and implementation
******************************************************************************/
#include "mascotdatparser.h"
#include "mimeparser.h"
#include <QDebug>
MascotDatParser::MascotDatParser(Project * p_project, IdentificationGroup * p_identification_group,
IdentificationDataSource * p_identification_data_source) {
_p_project = p_project;
_p_identification_group = p_identification_group;
_p_identification_data_source = p_identification_data_source;
}
MascotDatParser::~MascotDatParser() {
}
void MascotDatParser::parse(QIODevice * in_stream) {
qDebug() << "MascotDatParser::parse begin";
MimeParser mime_parser(in_stream);
mime_parser.open();
for(bool more=mime_parser.goToFirstFile(); more; more=mime_parser.goToNextFile()) {
qDebug() << "MascotDatParser::parse mimetype=" << mime_parser.getCurrentMimeType() << " filename=" << mime_parser.getCurrentFileName();
if (mime_parser.getCurrentFileName() == "proteins") {
while(!mime_parser.getCurrentTextStream().atEnd()) {
parseProteinLine( mime_parser.getCurrentTextStream().readLine());
}
}
else if (mime_parser.getCurrentFileName() == "header") {
while(!mime_parser.getCurrentTextStream().atEnd()) {
parseHeaderLine( mime_parser.getCurrentTextStream().readLine());
}
}
else if (mime_parser.getCurrentFileName() == "peptides") {
while(!mime_parser.getCurrentTextStream().atEnd()) {
parsePeptidesLine( mime_parser.getCurrentTextStream().readLine());
}
}
}
mime_parser.close();
qDebug() << "MascotDatParser::parse end";
}
void MascotDatParser::parseProteinLine(const QString & protein_line) {
//02::"tr|A0A0D9SF80|A0A0D9SF80_HUMAN"=55120.88,"General transcription factor II-I repeat domain-containing protein 2A OS=Homo sapiens GN=GTF2IRD2B PE=4 SV=1"
QRegExp regexp_protein("^(.*)::\"(.*)\"=([0-9]+\\.[0-9]+),\"(.*)\"$");
if (regexp_protein.exactMatch(protein_line)) {
QStringList protein_list = regexp_protein.capturedTexts();
_current_protein.setAccession(protein_list[2]);
_current_protein.setDescription(protein_list[4]);
sp_xtp_protein = _current_protein.makeProteinXtpSp();
sp_xtp_protein = _p_project->getProteinStore().getInstance(sp_xtp_protein);
}
else {
QRegExp regexp_proteinb("^\"(.*)\"=([0-9]+\\.[0-9]+),\"(.*)\"$");
if (regexp_proteinb.exactMatch(protein_line)) {
QStringList protein_list = regexp_proteinb.capturedTexts();
_current_protein.setAccession(protein_list[1]);
_current_protein.setDescription(protein_list[3]);
sp_xtp_protein = _current_protein.makeProteinXtpSp();
sp_xtp_protein = _p_project->getProteinStore().getInstance(sp_xtp_protein);
}
else {
qDebug() << "MascotDatParser::parseProteinLine error " << protein_line;
}
}
}
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
136
137
void MascotDatParser::parseHeaderLine(const QString & header_line) {
QRegExp regexp_header_line("^([a-z,0-9,_]+)=(.*)$");
if (regexp_header_line.exactMatch(header_line)) {
QStringList header_list = regexp_header_line.capturedTexts();
//sequences=73998
//sequences_after_tax=73998
//residues=24900901
//distribution=64847,0,1,576,2254,1934,1417,984,683,419,238,192,113,89,74,46,23,32,28,21,11,3,2,3,3,2,1,1,0,0,0,0,0,0,1
//decoy_type=1
//distribution_decoy=65162,0,1,552,2259,1891,1422,957,601,376,192,159,126,73,56,64,26,27,22,14,6,4,1,1,3,2,1
//exec_time=484
//date=1517587671
//time=17:07:51
//queries=54084
//min_peaks_for_homology=6
//max_hits=50
//version=2.5.0
if (header_list[1] == "version") {
_p_identification_data_source->setIdentificationEngineVersion(header_list[2]);
}
//fastafile=C:/inetpub/mascot/sequence/ECOLI_INRA/current/ECOLI_INRA_1.fasta
else if (header_list[1].startsWith("fastafile")) {
qDebug() << "fastafile=" << header_list[2];
_fasta_file_list.push_back( _p_project->getFastaFileStore().getInstance(FastaFile(header_list[2])));
_p_identification_data_source->addFastaFile(_fasta_file_list.back());
}
//release=ECOLI_INRA_1.fasta
//sequences1=4305
//sequences_after_tax1=4305
//residues1=1356026
//fastafile2=C:/inetpub/mascot/sequence/HUMAN_INRA/current/HUMAN_INRA_1.fasta
//release2=HUMAN_INRA_1.fasta
//sequences2=69693
//sequences_after_tax2=69693
//residues2=23544875
//taskid=151758718701
}
}
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
void MascotDatParser::parsePeptidesLine(const QString & peptide_line) {
QRegExp regexp_header_line("^([a-z,0-9,_]+)=(.*)$");
if (regexp_header_line.exactMatch(peptide_line)) {
QStringList header_list = regexp_header_line.capturedTexts();
QString index = header_list[1];
QString value = header_list[2];
QStringList index_list = index.split("_");
if (index_list.size() == 3) {
if (index_list[2] == "db") {
_peptides_fasta_file_list.clear();
while(value.size() > 0) {
_peptides_fasta_file_list.push_back( _fasta_file_list[value.left(2).toInt()-1]);
value = value.mid(2);
}
}
}
else if (index_list.size() == 2) {
QString query = index_list[0];
QString peptide = index_list[1];
}
/*
q1_p1_db=02
q1_p1=0,597.302322,0.997884,2,GAWHK,9,0000000,7.97,0000012000000000000,0,0;"sp|O95006|OR2F2_HUMAN":0:299:303:1
q1_p1_terms=K,L
q1_p2_db=02
q1_p2=1,598.296219,0.003987,2,KEEPP,11,0000000,1.32,0002000000000000000,0,0;"tr|E9PNM8|E9PNM8_HUMAN":0:134:138:1
q1_p2_terms=R,-
q2_p1_db=02
q2_p1=1,598.380234,-0.000316,3,KAGVPK,13,00000000,17.13,0002011000000000000,0,0;"tr|H7C1P9|H7C1P9_HUMAN":0:945:950:2
q2_p1_terms=K,K
q2_p2_db=0202
q2_p2=1,598.380234,-0.000316,2,KQPVK,9,0000000,9.54,0002011000000000000,0,0;"sp|P33527|MRP1_HUMAN":0:270:274:1,"tr|I3L4X2|I3L4X2_HUMAN":0:169:173:1
q2_p2_terms=R,V:R,V
q2_p3_db=02
q2_p3=1,598.380234,-0.000316,2,KAVPGK,13,00000000,7.03,0002001000000000000,0,0;"sp|Q13061|TRDN_HUMAN":0:440:445:2
q2_p3_terms=K,K
q2_p4_db=0202
q2_p4=1,598.380234,-0.000316,2,IPGGKK,14,00000000,1.26,0002001000000000000,0,0;"sp|Q9Y2I7|FYV1_HUMAN":0:670:675:2,"tr|E9PDH4|E9PDH4_HUMAN":0:614:619:2
q2_p4_terms=K,F:K,F
*/
}
}