This file is indexed.

/usr/include/libmstoolkit/pepXMLWriter.h is in libmstoolkit-dev 82-6.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  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
136
137
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
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
/*
Copyright 2005-2016, Michael R. Hoopmann

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 _PEPXMLWRITER_H
#define _PEPXMLWRITER_H

#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <string>
#include <iostream>
#include <vector>

using namespace std;

//Some simple data structures for PepXMLWriter (pxw)
typedef struct pxwBasicXMLTag {
  string name;
  string value;
} pxwBasicXMLTag;

typedef struct pxwModAA{
  int position;
  double mass;
} pxwModAA;

typedef struct pxwMSMSRunSummary {
  string base_name;
  string raw_data_type;
  string raw_data;
  string search_engine;
} pxwMSMSRunSummary;

typedef struct pxwProtein {
  string protein;
  char peptide_next_aa;
  char peptide_prev_aa;
} pxwProtein;

//Use classes for more complicated structures with dynamic arrays
//and additional fuctions.
class PXWModInfo{
public:
  double mod_cterm_mass;
  double mod_nterm_mass;
  string modified_peptide;
  
  PXWModInfo(){
    mod_cterm_mass=0;
    mod_nterm_mass=0;
    modified_peptide.clear();
    mods=new vector<pxwModAA>;
  }
  PXWModInfo(const PXWModInfo& s){
    mod_cterm_mass=s.mod_cterm_mass;
    mod_nterm_mass=s.mod_nterm_mass;
    modified_peptide = s.modified_peptide;
    mods=new vector<pxwModAA>;
    for(size_t i=0;i<s.mods->size();i++) mods->push_back(s.mods->at(i));
  }
  ~PXWModInfo(){
    delete mods;
  }
  PXWModInfo& operator=(const PXWModInfo& s){
    if(this!=&s){
      mod_cterm_mass = s.mod_cterm_mass;
      mod_nterm_mass = s.mod_nterm_mass;
      modified_peptide = s.modified_peptide;
      delete mods;
      mods=new vector<pxwModAA>;
      for(size_t i=0;i<s.mods->size();i++) mods->push_back(s.mods->at(i));
    }
    return *this;
  }

  void addMod(pxwModAA& p){
    mods->push_back(p);
  }
  void addMod(int pos, double mass){
    pxwModAA p;
    p.position=pos;
    p.mass=mass;
    addMod(p);
  }
  void clear(){
    mod_cterm_mass=0;
    mod_nterm_mass=0;
    modified_peptide.clear();
    mods->clear();
  }
  pxwModAA& getMod(int index){
    return mods->at(index);
  }
  pxwModAA& getMod(size_t index){
	  return mods->at(index);
  }
  size_t sizeMods(){
    return mods->size();
  }

private:
  vector<pxwModAA>* mods;
};

class PXWSearchSummary {
public:
  string base_name;
  string search_database;
  string search_engine;
  string search_engine_version;
  int precursor_mass_type; //0=monoisotopic, 1=average
  int fragment_mass_type; //0=monoisotopic, 1=average
  vector<pxwBasicXMLTag>* parameters;

  PXWSearchSummary(){
    base_name.clear();
    search_database.clear();
    search_engine.clear();
    search_engine_version.clear();
    precursor_mass_type=0;
    fragment_mass_type=0;
    parameters=new vector<pxwBasicXMLTag>;
  }
  PXWSearchSummary(const PXWSearchSummary& s){
    base_name=s.base_name;
    search_database=s.search_database;
    search_engine=s.search_engine;
    search_engine_version=s.search_engine_version;
    precursor_mass_type=s.precursor_mass_type;
    fragment_mass_type=s.fragment_mass_type;
    parameters=new vector<pxwBasicXMLTag>;
    for(size_t i=0;i<s.parameters->size();i++) parameters->push_back(s.parameters->at(i));
  }
  ~PXWSearchSummary(){
    delete parameters;
  }
  PXWSearchSummary& operator=(const PXWSearchSummary& s){
    if(this!=&s){
      base_name=s.base_name;
      search_database = s.search_database;
      search_engine=s.search_engine;
      search_engine_version=s.search_engine_version;
      precursor_mass_type=s.precursor_mass_type;
      fragment_mass_type=s.fragment_mass_type;
      delete parameters;
      parameters=new vector<pxwBasicXMLTag>;
      for(size_t i=0;i<s.parameters->size();i++) parameters->push_back(s.parameters->at(i));
    }
    return *this;
  }
};

class PXWSearchHit {
public:
  int hit_rank;
  string peptide;
  int num_tot_proteins;
  double calc_neutral_pep_mass;
  double calc_neutral_xl_mass;
  double massdiff;
  double xl_massdiff;
  PXWModInfo modInfo;
  string xlink_type; //na,loop,xl

  PXWSearchHit(){
    hit_rank=0;
    peptide.clear();
    num_tot_proteins=0;
    calc_neutral_pep_mass=0;
    calc_neutral_xl_mass=0;
    massdiff=0;
    xl_massdiff=0;
    modInfo.clear();
    xlink_type="na";
    proteins=new vector<pxwProtein>;
    searchScores=new vector<pxwBasicXMLTag>;
    xlScores=new vector<pxwBasicXMLTag>;
  }
  PXWSearchHit(const PXWSearchHit& s){
    size_t i;
    hit_rank=s.hit_rank;
    peptide=s.peptide;
    num_tot_proteins=s.num_tot_proteins;
    calc_neutral_pep_mass=s.calc_neutral_pep_mass;
    calc_neutral_xl_mass=s.calc_neutral_xl_mass;
    massdiff=s.massdiff;
    xl_massdiff=s.xl_massdiff;
    modInfo=s.modInfo;
    xlink_type=s.xlink_type;
    proteins=new vector<pxwProtein>;
    searchScores=new vector<pxwBasicXMLTag>;
    xlScores=new vector<pxwBasicXMLTag>;
    for(i=0;i<s.proteins->size();i++) proteins->push_back(s.proteins->at(i));
    for(i=0;i<s.searchScores->size();i++) searchScores->push_back(s.searchScores->at(i));
    for(i=0;i<s.xlScores->size();i++) xlScores->push_back(s.xlScores->at(i));
  }
  ~PXWSearchHit(){
    delete proteins;
    delete searchScores;
    delete xlScores;
  }
  PXWSearchHit& operator=(const PXWSearchHit& s){
    if(this!=&s){
      size_t i;
      hit_rank=s.hit_rank;
      peptide=s.peptide;
      num_tot_proteins=s.num_tot_proteins;
      calc_neutral_pep_mass=s.calc_neutral_pep_mass;
      calc_neutral_xl_mass=s.calc_neutral_xl_mass;
      massdiff=s.massdiff;
      xl_massdiff=s.xl_massdiff;
      modInfo=s.modInfo;
      xlink_type=s.xlink_type;
      delete proteins;
      delete searchScores;
      delete xlScores;
      proteins=new vector<pxwProtein>;
      searchScores=new vector<pxwBasicXMLTag>;
      xlScores=new vector<pxwBasicXMLTag>;
      for(i=0;i<s.proteins->size();i++) proteins->push_back(s.proteins->at(i));
      for(i=0;i<s.searchScores->size();i++) searchScores->push_back(s.searchScores->at(i));
      for(i=0;i<s.xlScores->size();i++) xlScores->push_back(s.xlScores->at(i));
    }
    return *this;
  }

  void addProtein(pxwProtein& p){
    proteins->push_back(p);
  }
  void addProtein(char* protein, char peptide_next_aa, char peptide_prev_aa){
    pxwProtein p;
    p.protein=protein;
    p.peptide_next_aa=peptide_next_aa;
    p.peptide_prev_aa=peptide_prev_aa;
    addProtein(p);
  }
  void addProtein(string& protein, char peptide_next_aa, char peptide_prev_aa){
    pxwProtein p;
    p.protein=protein;
    p.peptide_next_aa=peptide_next_aa;
    p.peptide_prev_aa=peptide_prev_aa;
    addProtein(p);
  }
  void addScore(pxwBasicXMLTag& s){
    searchScores->push_back(s);
  }
  void addScore(const char* name, const char* value){
    pxwBasicXMLTag x;
    x.name=name;
    x.value=value;
    addScore(x);
  }
  void addScore(string& name, string& value){
    pxwBasicXMLTag x;
    x.name=name;
    x.value=value;
    addScore(x);
  }
  void addXLScore(pxwBasicXMLTag& s){
    xlScores->push_back(s);
  }
  void addXLScore(const char* name, const char* value){
    pxwBasicXMLTag x;
    x.name=name;
    x.value=value;
    addXLScore(x);
  }
  void addXLScore(string& name, string& value){
    pxwBasicXMLTag x;
    x.name=name;
    x.value=value;
    addXLScore(x);
  }
  void clear(){
    hit_rank=0;
    peptide.clear();
    num_tot_proteins=0;
    calc_neutral_pep_mass=0;
    calc_neutral_xl_mass=0;
    massdiff=0;
    xl_massdiff=0;
    xlink_type="na";
    modInfo.clear();
    proteins->clear();
    searchScores->clear();
    xlScores->clear();
  }
  pxwProtein& getProtein(int index){
    return proteins->at(index);
  }
  pxwProtein& getProtein(size_t index){
    return proteins->at(index);
  }
  pxwBasicXMLTag& getScore(int index){
    return searchScores->at(index);
  }
  pxwBasicXMLTag& getScore(size_t index){
    return searchScores->at(index);
  }
  pxwBasicXMLTag& getXLScore(int index){
	  return xlScores->at(index);
  }
  pxwBasicXMLTag& getXLScore(size_t index){
    return xlScores->at(index);
  }
  size_t sizeProteins(){
    return proteins->size();
  }
  size_t sizeScores(){
    return searchScores->size();
  }
  size_t sizeXLScores(){
    return xlScores->size();
  }

private:
  vector<pxwProtein>* proteins;
  vector<pxwBasicXMLTag>* searchScores;
  vector<pxwBasicXMLTag>* xlScores;
};

typedef struct pxwSearchHitPair{
  PXWSearchHit* a;
  PXWSearchHit* b;
  string identifier;
  double mass;
  pxwSearchHitPair(){
    a=NULL;
    b=NULL;
    identifier.clear();
    mass=0;
  }
  pxwSearchHitPair(const pxwSearchHitPair& p){
    a=NULL;
    b=NULL;
    identifier=p.identifier;
    mass=p.mass;
    if(p.a!=NULL) {
      a=new PXWSearchHit();
      *a=*p.a;
    }
    if(p.b!=NULL){
      b=new PXWSearchHit();
      *b=*p.b;
    }
  }
  ~pxwSearchHitPair(){
    if(a!=NULL) delete a;
    if(b!=NULL) delete b;
  }
  pxwSearchHitPair& operator=(const pxwSearchHitPair& p){
    if(this!=&p){
      if(a!=NULL) delete a;
      if(b!=NULL) delete b;
      a=NULL;
      b=NULL;
      identifier=p.identifier;
      mass=p.mass;
      if(p.a!=NULL) {
        a=new PXWSearchHit();
        *a=*p.a;
      }
      if(p.b!=NULL){
        b=new PXWSearchHit();
        *b=*p.b;
      }
    }
    return *this;
  }
} pxwSearchHitPair;

typedef struct pxwSampleEnzyme{
  string name;
  string cut;
  string no_cut;
  string sense;
  int maxNumInternalCleavages;
  int minNumTermini;
} pxwSampleEnzyme;

class PXWSpectrumQuery {
public:
  string spectrum;
  int start_scan;
  int end_scan;
  double retention_time_sec;
  double precursor_neutral_mass;
  int assumed_charge;
  
  PXWSpectrumQuery(){
    spectrum.clear();
    start_scan=0;
    end_scan=0;
    retention_time_sec=0;
    precursor_neutral_mass=0;
    assumed_charge=0;
    searchHits=new vector<pxwSearchHitPair>;
  }
  PXWSpectrumQuery(const PXWSpectrumQuery& s){
    spectrum=s.spectrum;
    start_scan=s.start_scan;
    end_scan=s.end_scan;
    retention_time_sec=s.retention_time_sec;
    precursor_neutral_mass=s.precursor_neutral_mass;
    assumed_charge=s.assumed_charge;
    searchHits=new vector<pxwSearchHitPair>;
    for(size_t i=0;i<s.searchHits->size();i++) searchHits->push_back(s.searchHits->at(i));
  }
  ~PXWSpectrumQuery(){
    delete searchHits;
  }
  PXWSpectrumQuery& operator=(const PXWSpectrumQuery& s){
    if(this!=&s){
      spectrum=s.spectrum;
      start_scan=s.start_scan;
      end_scan=s.end_scan;
      retention_time_sec=s.retention_time_sec;
      precursor_neutral_mass=s.precursor_neutral_mass;
      assumed_charge=s.assumed_charge;
      delete searchHits;
      searchHits=new vector<pxwSearchHitPair>;
      for(size_t i=0;i<s.searchHits->size();i++) searchHits->push_back(s.searchHits->at(i));
    }
    return *this;
  }

  void addSearchHit(PXWSearchHit* s, PXWSearchHit* s2=NULL, string* xl=NULL, double* xlMass=NULL){
    pxwSearchHitPair p;
    p.a = new PXWSearchHit(*s);
    if(s2!=NULL) {
      if(xl==NULL || xlMass==NULL){
        printf("PXWSpectrumQuery.addSearchHit(): cross-linked peptides must contain linker and mass. Exiting.\n");
        exit(-4);
      }
      p.b = new PXWSearchHit(*s2);
    }
    if(xl!=NULL) p.identifier=*xl;
    if(xlMass!=NULL) p.mass=*xlMass;
    searchHits->push_back(p);
  }
  void clear(){
    searchHits->clear();
  }
  pxwSearchHitPair& getSearchHit(int index){
    return searchHits->at(index);
  }
  pxwSearchHitPair& getSearchHit(size_t index){
    return searchHits->at(index);
  }
  size_t sizeSearchHits(){
    return searchHits->size();
  }

private:
  vector<pxwSearchHitPair>* searchHits;
};

class PepXMLWriter {
public:

  PepXMLWriter();
  ~PepXMLWriter();

  void  closePepXML         ();
  bool  createPepXML        (char* fn, pxwMSMSRunSummary& run, pxwSampleEnzyme* enzyme=NULL, PXWSearchSummary* search=NULL);
  void  writeSpectrumQuery  (PXWSpectrumQuery& s);

private:

  void addTab               ();
  void deleteTab            ();
  void resetTabs            ();
  void writeAltProtein      (pxwProtein& s);
  void writeModAAMass       (pxwModAA& s);
  void writeModInfo         (PXWModInfo& s);
  void writeLine            (const char* str);
  void writeLinkedPeptide   (PXWSearchHit& s, bool alpha=true);
  void writeSearchHit       (pxwSearchHitPair& s);

  int index;
  int iTabs;
  int spQueryIndex;
  FILE* fptr;

  bool bTabs;
  bool bFileOpen;
  char strTabs[128];

  vector<string> vTagState;

};

#endif