-
Notifications
You must be signed in to change notification settings - Fork 1
/
Kronik.cpp
159 lines (141 loc) · 6.08 KB
/
Kronik.cpp
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
/*
Copyright 2007-2015, Michael R. Hoopmann, University of Washington
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.
*/
#include "CKronik.h"
void usage();
int main(int argc, char* argv[]){
cout << "\nKrönik version 2.20, Nov 12 2012\nApp: kronik\nAuthor: Michael Hoopmann\nCopyright 2007-2012\n" << endl;
cout << "\nDescription: Finds peptide isotope distributions (PIDs) that" << endl;
cout << " persist in at least 3 of 4 consecutive scans from" << endl;
cout << " Hardklör results.\n" << endl;
if(argc<3){
usage();
exit(0);
}
CKronik k;
int i;
double mass1=600.0;
double mass2=8000.0;
double ppmTol=10.0;
float contam=5.0;
int gapTol=1;
int matchTol=3;
bool gaussFit=false;
if(argc>3){
for(i=1;i<argc-2;i+=2){
if(argv[i][0]!='-') {
cout << "Invalid flag!\n" << endl;
usage();
exit(0);
}
switch(argv[i][1]){
case 'p': ppmTol=atof(argv[i+1]); break;
case 'c': contam=(float)atof(argv[i+1]); break;
case 'd': matchTol=atoi(argv[i+1]); break;
case 'f': gaussFit=true; i--; break;
case 'g': gapTol=atoi(argv[i+1]); break;
case 'm': mass2=atof(argv[i+1]); break;
case 'n': mass1=atof(argv[i+1]); break;
default:
cout << "Invalid flag!\n" << endl;
usage();
exit(0);
break;
}
}
}
cout << "Input file:\t" << argv[argc-2] << endl;
cout << "Output file:\t" << argv[argc-1] << endl;
cout << "Parameters:" << endl;
cout << " Persistence set to " << matchTol << " with " << gapTol << " gaps allowed." << endl;
cout << " Mass Tolerance: " << ppmTol << " ppm." << endl;
cout << " Contaminants set at " << contam << " minutes persistent." << endl;
cout << " Maxmimum peptide size allowed: " << mass2 << " daltons." << endl;
cout << " Minimum peptide size allowed: " << mass1 << " daltons." << endl;
cout << "\n" << endl;
k.setGapTol(gapTol);
k.setMatchTol(matchTol);
k.setPPMTol(ppmTol);
k.setGaussFit(gaussFit);
k.processHK(argv[argc-2]);
cout << "Total Persistent Peptide Isotope Distributions (PID): " << k.size() << endl;
k.removeContaminants(contam);
cout << "PIDs after removing contaminants: " << k.size() << endl;
k.removeMass(mass1,mass2);
cout << "PIDs within mass range: " << k.size() << endl;
FILE* f;
f=fopen(argv[argc-1],"wt");
//Heading line
fprintf(f,"First Scan\tLast Scan\tNum of Scans\tCharge\tMonoisotopic Mass\tBase Isotope Peak\t");
fprintf(f,"Best Intensity\tSummed Intensity\tFirst RTime\tLast RTime\tBest RTime\tBest Correlation\tModifications");
if(gaussFit) fprintf(f,"\tFWHM\t4sigma\tr2");
fprintf(f,"\n");
for(i=0;i<k.size();i++){
fprintf(f,"%d\t%d\t%d\t%d\t%lf\t%lf\t%f\t%f\t%f\t%f\t%f\t%.4lf\t%s",
k[i].lowScan,
k[i].highScan,
k[i].datapoints,
k[i].charge,
k[i].monoMass,
k[i].basePeak,
k[i].intensity,
k[i].sumIntensity,
k[i].firstRTime,
k[i].lastRTime,
k[i].rTime,
k[i].xCorr,
&k.vMods[k[i].mods][0]);
if(gaussFit){
if(k[i].gaussR2<0.00000001){
fprintf(f,"\t0\t0\t0");
} else {
double sigma=1/(SQRTTWO*sqrt(-k[i].gaussian[2]));
fprintf(f,"\t%lf\t%lf\t%.6lf",FWHMCONST*sigma,
4*sigma,
k[i].gaussR2);
}
}
fprintf(f,"\n");
}
fclose(f);
return 0;
}
void usage(){
cout << "Usage: kronik [flags] [input file] [output file]" << endl;
cout << "\nInput files are Hardklör generated results files." << endl;
cout << "Output files are in tab-delimited ASCII text format." << endl;
cout << "\nAll flags must be followed by a positive integer." << endl;
cout << "Example: kronik -p 5 inputfile.txt outputfile.txt" << endl;
cout << "\nFlags:" << endl;
cout << " -c\tSets the threshold for contaminants. If a peptide isotope\n"
<< " \tdistribution persists greater than this number of minutes, it\n"
<< " \tis excluded from further analysis. Default: 5.0\n" << endl;
cout << " -d\tSets the match tolerance. This number specifies the minimum\n"
<< " \tconsecutive scans (allowing for gaps) that a peptide is\n"
<< " \tobserved across to be considered persistent. Default: 3\n" << endl;
cout << " -f\tPerforms a Gaussian fit to the peptide chromatographic profiles.\n"
<< " \tFWHM, 4*sigma, and r^2 are reported in the output.\n"
<< " \tDefault: off\n" << endl;
cout << " -g\tSets the gap tolerance. Sets the number of scans a peptide\n"
<< " \tcan skip and still be considered if seen again in the folloing\n"
<< " \tscan. Default: 1\n" << endl;
cout << " -m\tSets the maxmimum mass allowed in daltons. If a peptide isotope\n"
<< " \tdistribution's mass is greater than this number, it is\n"
<< " \texcluded from further analysis. Default: 8000.0\n" << endl;
cout << " -n\tSets the minimum mass allowed in daltons. If a peptide isotope\n"
<< " \tdistribution's mass is less than this number, it is excluded\n"
<< " \tfrom further analysis. Default: 600.0\n" << endl;
cout << " -p\tSets the mass accuracy in parts per million (ppm). Peptides in\n"
<< " \tadjacent scans must differ in mass by less than this amount to\n"
<< " \tbe called the same. Default: 10.0\n" << endl;
cout << "\nPlease read the README.txt file for more information on Persistent." << endl;
}