-
Notifications
You must be signed in to change notification settings - Fork 3
/
gtc.cpp
145 lines (125 loc) · 4.42 KB
/
gtc.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
//
// gtc.cpp
//
// Program to read the contents of a GTC file
//
// $Id: gtc.cpp 1510 2013-01-21 11:29:16Z js10 $
//
// Copyright (c) 2009 - 2010 Genome Research Ltd.
//
// Author: Jennifer Liddle <[email protected], [email protected]>
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
// 1. Redistributions of source code must retain the above copyright notice,
// this list of conditions and the following disclaimer.
// 2. Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
// 3. Neither the name of Genome Research Ltd nor the names of the
// contributors may be used to endorse or promote products derived from
// software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
// IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
// IN NO EVENT SHALL GENOME RESEARCH LTD. BE LIABLE FOR ANY DIRECT, INDIRECT,
// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
// BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
// USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
// THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
#include <cstring>
#include <iostream>
#include <map>
#include "Gtc.h"
#include "Manifest.h"
#include "win2unix.h"
using namespace std;
int main(int argc, char *argv[])
{
Gtc *gtc = new Gtc();
int json_flag = 0;
string filename;
if (argc>1 && strcmp(argv[1],"-j")==0) {
json_flag = 1;
filename = win2unix(argv[2]);
} else {
filename = win2unix(argv[1]);
}
gtc->open(filename, Gtc::ALL);
if (!gtc->errorMsg.empty()) {
cout << gtc->errorMsg << endl;
exit(1);
}
if (json_flag) {
cout << gtc->json_dump();
exit(0);
}
cout << gtc->dump() << endl;
cout << "Pass Rate: " << gtc->passRate(.15) << endl;
cout << "Corrected Pass Rate: " << gtc->correctedPassRate(.15) << endl;
cout << "Base calls:" << endl;
for (int i=85435; i<85445; i++) {
cout << gtc->baseCalls[i].a << gtc->baseCalls[i].b << " ";
}
cout << endl << endl;
#if 0
cout << "Genotypes:" << endl;
for (int i=0; i<20; i++) {
cout << gtc->genotypes[i] << " ";
}
cout << endl << endl;
#endif
cout << "XForm:" << endl;
cout << "idx\tversion\txOffset\tyOffset\txScale\tyScale\tshear\ttheta" << endl;
int n=0;
vector<XFormClass>::iterator pos;
for (pos = gtc->XForm.begin(); pos < gtc->XForm.end(); pos++) {
cout << n << "\t" << pos->version << "\t" << pos->xOffset << "\t" << pos->yOffset << "\t"
<< pos->xScale << "\t" << pos->yScale << "\t"
<< pos->shear << "\t" << pos->theta
<< endl;
n++;
}
cout << endl;
cout << "Raw Intensities" << endl;
for (int i=0; i<20; i++) {
cout << "Idx = " << i << "\tX = " << gtc->xRawIntensity[i] << "\tY = " << gtc->yRawIntensity[i] << endl;
}
cout << endl;
// Read the manifest
string f = argv[1];
f = f.substr(0,f.find_last_of('/'));
f = f + "/../" + gtc->manifest + ".csv";
Manifest *m = new Manifest();
try {
m->open(f);
}
catch (string s) {
cout << s << endl;
}
// m->dump();
// int n = m->snp2idx(argv[2]);
// snpClass *s = m->findSNP(argv[2]);
// cout << "SNP = " << argv[2] << " n = " << n << " s = " << s << endl;
unsigned int max = 0;
long p = 0;
for (vector<snpClass>::iterator snp = m->snps.begin(); snp != m->snps.end(); snp++) {
if (max < snp->name.length()) max = snp->name.length();
if (p < snp->position) p = snp->position;
}
cout << endl << "Maximum length of SNP name is " << max << endl;
cout << endl << "Maximum position of SNP is " << p << endl;
cout << endl;
cout << " size = " << gtc->xRawIntensity.size() << endl;
cout << "max_size = " << gtc->xRawIntensity.max_size() << endl;
cout << "capacity = " << gtc->xRawIntensity.capacity() << endl;
gtc->xRawIntensity.reserve(0);
cout << " size = " << gtc->xRawIntensity.size() << endl;
cout << "max_size = " << gtc->xRawIntensity.max_size() << endl;
cout << "capacity = " << gtc->xRawIntensity.capacity() << endl;
return 0;
}