-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathHybrid_allele_analysis_script
359 lines (278 loc) · 17.6 KB
/
Hybrid_allele_analysis_script
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
#!/usr/bin/perl
# This line is needed to include the min and max functions
use List::Util qw(min max);
# This program identifies parental fixed SNPs
# This program then identifies allele contributions to hybrid genomes
### Change output files? ###
open (DATAFILE, "Bd_49_SNPs.4X_GPLvsNovel_UMformat.txt");
open (FIXEDMAT, ">results_fixedmatrix.txt");
open ($BrazilGPLdiffs, ">GPL_VS_Brazilfixed.txt");
open ($CapeGPLdiffs, ">Cape_VS_GPLfixed.txt");
open ($BrazilCapediffs, ">Brazil_VS_Capefixed.txt");
open ($GPLBrazilshared, ">GPL_and_Brazilshared.txt");
open ($GPLCapeshared, ">Cape_and_GPLshared.txt");
open ($BrazilCapeshared, ">Brazil_and_Capeshared.txt");
open ($hybrid, ">Hybrid.txt");
print $BrazilGPLdiffs "Contig\t Position\t GPL\t BRAZIL\n";
print $CapeGPLdiffs "Contig\t Position\t GPL\t CAPE\n";
print $BrazilCapediffs "Contig\t Position\t BRAZIL\t CAPE\n";
print $GPLBrazilshared "Contig\t Position\t GPL\t BRAZIL\t CAPE\n";
print $GPLCapeshared "Contig\t Position\t GPL\t BRAZIL\t CAPE\n";
print $BrazilCapeshared "Contig\t Position\t GPL\t BRAZIL\t CAPE\n";
print $hybrid "Contig\t Position\t Hybrid\n";
# First and second and third ines are the number of strains followed by number of SNPs followed by number of contigs.
$strainline = <DATAFILE>;
chomp ($strainline);
$numstrains= $strainline;
$lastGPL = 42;
$lastBRAZIL = 44;
$lastCAPE = 47; # Number of Contigs
$SNPline = <DATAFILE>;
chomp ($SNPline);
$numsnps = $SNPline;
$contigline = <DATAFILE>;
chomp ($contigline);
$numcontigs = $contigline;
# This value is the maximum reported supercontig cutoff due to size.
$threshold=68;
# Read in third line to have the strains names
$listofnames = <DATAFILE>;
chomp ($listofnames);
@names = split(/\t/, $listofnames);
for ($a=0;$a<$numstrains;$a++)
{
print "names[$a]=$names[$a]\n";
}
# Next we will read the data into the array of strains x snps ($dataset). There are two other arrays ($contig & $position) that index the location of the SNPs.
$snp=0;
while ($snp < $numsnps)
{
$nextline = <DATAFILE>;
chomp ($nextline);
@genos = split(/\t/, $nextline);
# This following line removes the whitespace at the end of the line.
$genos[$numstrains+1] =~ s/\s+$//;
$contig[$snp] = $genos[0];
$position[$snp] = $genos[1];
for ($a=0;$a<$numstrains;$a++)
{
$dataset[$snp][$a] = $genos[$a+2];
}
$snp++;
}
### Start sub 1 to find fixed difference ###
for ($a=0;$a<$numsnps;$a++)
{
print FIXEDMAT "$contig[$a]\t$position[$a]\t";
$countAs=0;
$countCs=0;
$countGs=0;
$countTs=0;
$countNs=0;
for ($b=0;$b<$lastGPL;$b++)
{
if ($dataset[$a][$b] eq 'A') {$countAs++;}
if ($dataset[$a][$b] eq 'C') {$countCs++;}
if ($dataset[$a][$b] eq 'G') {$countGs++;}
if ($dataset[$a][$b] eq 'T') {$countTs++;}
if ($dataset[$a][$b] eq 'N') {$countNs++;}
}
if($countNs==$lastGPL) {$fixedmatrix[$a][0]=N;}
if($countNs>=$lastGPL*0.25) {$fixedmatrix[$a][0]=N;}
elsif($countAs+$countNs==$lastGPL) {$fixedmatrix[$a][0]=A;}
elsif($countCs+$countNs==$lastGPL) {$fixedmatrix[$a][0]=C;}
elsif($countGs+$countNs==$lastGPL) {$fixedmatrix[$a][0]=G;}
elsif($countTs+$countNs==$lastGPL) {$fixedmatrix[$a][0]=T;}
else {$fixedmatrix[$a][0]=P;}
#print "$contig[$a]\t$position[$a]\tN=$countNs\tA=$countAs\tC=$countCs\n";
print FIXEDMAT "$fixedmatrix[$a][0]\t";
$countAs=0;
$countCs=0;
$countGs=0;
$countTs=0;
$countNs=0;
for ($b=$lastGPL;$b<$lastBRAZIL;$b++)
{
if ($dataset[$a][$b] eq 'A') {$countAs++;}
if ($dataset[$a][$b] eq 'C') {$countCs++;}
if ($dataset[$a][$b] eq 'G') {$countGs++;}
if ($dataset[$a][$b] eq 'T') {$countTs++;}
if ($dataset[$a][$b] eq 'N') {$countNs++;}
}
if($countNs==$lastBRAZIL-$lastGPL) {$fixedmatrix[$a][1]=N;}
if($countNs>=($lastBRAZIL-$lastGPL)*0.25) {$fixedmatrix[$a][1]=N;}
elsif($countAs+$countNs==$lastBRAZIL-$lastGPL) {$fixedmatrix[$a][1]=A;}
elsif($countCs+$countNs==$lastBRAZIL-$lastGPL) {$fixedmatrix[$a][1]=C;}
elsif($countGs+$countNs==$lastBRAZIL-$lastGPL) {$fixedmatrix[$a][1]=G;}
elsif($countTs+$countNs==$lastBRAZIL-$lastGPL) {$fixedmatrix[$a][1]=T;}
else {$fixedmatrix[$a][1]=P;}
print FIXEDMAT "$fixedmatrix[$a][1]\t";
$countAs=0;
$countCs=0;
$countGs=0;
$countTs=0;
$countNs=0;
for ($b=$lastBRAZIL;$b<$lastCAPE;$b++)
{
if ($dataset[$a][$b] eq 'A') {$countAs++;}
if ($dataset[$a][$b] eq 'C') {$countCs++;}
if ($dataset[$a][$b] eq 'G') {$countGs++;}
if ($dataset[$a][$b] eq 'T') {$countTs++;}
if ($dataset[$a][$b] eq 'N') {$countNs++;}
}
if($countNs==$lastCAPE-$lastBRAZIL) {$fixedmatrix[$a][2]=N;}
if($countNs>=($lastCAPE-$lastBRAZIL)*0.25) {$fixedmatrix[$a][2]=N;}
elsif($countAs+$countNs==$lastCAPE-$lastBRAZIL) {$fixedmatrix[$a][2]=A;}
elsif($countCs+$countNs==$lastCAPE-$lastBRAZIL) {$fixedmatrix[$a][2]=C;}
elsif($countGs+$countNs==$lastCAPE-$lastBRAZIL) {$fixedmatrix[$a][2]=G;}
elsif($countTs+$countNs==$lastCAPE-$lastBRAZIL) {$fixedmatrix[$a][2]=T;}
else {$fixedmatrix[$a][2]=P;}
print FIXEDMAT "$fixedmatrix[$a][2]\n";
}
### sub 2 find informative SNPS ###
$fixeddiffsGPLBrazil=0;
for ($a=0;$a<$numsnps;$a++)
{
if (($fixedmatrix[$a][0] eq 'A') && ($fixedmatrix[$a][1] eq 'T')) {printtofile($BrazilGPLdiffs,$a,0,1); $fixeddiffsGPLBrazil++;}
elsif (($fixedmatrix[$a][0] eq 'A') && ($fixedmatrix[$a][1] eq 'G')) {printtofile($BrazilGPLdiffs,$a,0,1); $fixeddiffsGPLBrazil++;}
elsif (($fixedmatrix[$a][0] eq 'A') && ($fixedmatrix[$a][1] eq 'C')) {printtofile($BrazilGPLdiffs,$a,0,1); $fixeddiffsGPLBrazil++;}
elsif (($fixedmatrix[$a][0] eq 'T') && ($fixedmatrix[$a][1] eq 'A')) {printtofile($BrazilGPLdiffs,$a,0,1); $fixeddiffsGPLBrazil++;}
elsif (($fixedmatrix[$a][0] eq 'T') && ($fixedmatrix[$a][1] eq 'G')) {printtofile($BrazilGPLdiffs,$a,0,1); $fixeddiffsGPLBrazil++;}
elsif (($fixedmatrix[$a][0] eq 'T') && ($fixedmatrix[$a][1] eq 'C')) {printtofile($BrazilGPLdiffs,$a,0,1); $fixeddiffsGPLBrazil++;}
elsif (($fixedmatrix[$a][0] eq 'G') && ($fixedmatrix[$a][1] eq 'A')) {printtofile($BrazilGPLdiffs,$a,0,1); $fixeddiffsGPLBrazil++;}
elsif (($fixedmatrix[$a][0] eq 'G') && ($fixedmatrix[$a][1] eq 'T')) {printtofile($BrazilGPLdiffs,$a,0,1); $fixeddiffsGPLBrazil++;}
elsif (($fixedmatrix[$a][0] eq 'G') && ($fixedmatrix[$a][1] eq 'C')) {printtofile($BrazilGPLdiffs,$a,0,1); $fixeddiffsGPLBrazil++;}
elsif (($fixedmatrix[$a][0] eq 'C') && ($fixedmatrix[$a][1] eq 'G')) {printtofile($BrazilGPLdiffs,$a,0,1); $fixeddiffsGPLBrazil++;}
elsif (($fixedmatrix[$a][0] eq 'C') && ($fixedmatrix[$a][1] eq 'A')) {printtofile($BrazilGPLdiffs,$a,0,1); $fixeddiffsGPLBrazil++;}
elsif (($fixedmatrix[$a][0] eq 'C') && ($fixedmatrix[$a][1] eq 'T')) {printtofile($BrazilGPLdiffs,$a,0,1); $fixeddiffsGPLBrazil++;}
}
$fixeddiffsCapeGPL=0;
for ($a=0;$a<$numsnps;$a++)
{
if (($fixedmatrix[$a][0] eq 'A') && ($fixedmatrix[$a][2] eq 'T')) {printtofile($CapeGPLdiffs,$a,0,2); $fixeddiffsCapeGPL++;}
elsif (($fixedmatrix[$a][0] eq 'A') && ($fixedmatrix[$a][2] eq 'G')) {printtofile($CapeGPLdiffs,$a,0,2); $fixeddiffsCapeGPL++;}
elsif (($fixedmatrix[$a][0] eq 'A') && ($fixedmatrix[$a][2] eq 'C')) {printtofile($CapeGPLdiffs,$a,0,2); $fixeddiffsCapeGPL++;}
elsif (($fixedmatrix[$a][0] eq 'T') && ($fixedmatrix[$a][2] eq 'A')) {printtofile($CapeGPLdiffs,$a,0,2); $fixeddiffsCapeGPL++;}
elsif (($fixedmatrix[$a][0] eq 'T') && ($fixedmatrix[$a][2] eq 'G')) {printtofile($CapeGPLdiffs,$a,0,2); $fixeddiffsCapeGPL++;}
elsif (($fixedmatrix[$a][0] eq 'T') && ($fixedmatrix[$a][2] eq 'C')) {printtofile($CapeGPLdiffs,$a,0,2); $fixeddiffsCapeGPL++;}
elsif (($fixedmatrix[$a][0] eq 'G') && ($fixedmatrix[$a][2] eq 'A')) {printtofile($CapeGPLdiffs,$a,0,2); $fixeddiffsCapeGPL++;}
elsif (($fixedmatrix[$a][0] eq 'G') && ($fixedmatrix[$a][2] eq 'T')) {printtofile($CapeGPLdiffs,$a,0,2); $fixeddiffsCapeGPL++;}
elsif (($fixedmatrix[$a][0] eq 'G') && ($fixedmatrix[$a][2] eq 'C')) {printtofile($CapeGPLdiffs,$a,0,2); $fixeddiffsCapeGPL++;}
elsif (($fixedmatrix[$a][0] eq 'C') && ($fixedmatrix[$a][2] eq 'G')) {printtofile($CapeGPLdiffs,$a,0,2); $fixeddiffsCapeGPL++;}
elsif (($fixedmatrix[$a][0] eq 'C') && ($fixedmatrix[$a][2] eq 'A')) {printtofile($CapeGPLdiffs,$a,0,2); $fixeddiffsCapeGPL++;}
elsif (($fixedmatrix[$a][0] eq 'C') && ($fixedmatrix[$a][2] eq 'T')) {printtofile($CapeGPLdiffs,$a,0,2); $fixeddiffsCapeGPL++;}
}
$fixeddiffsCapeBrazil=0;
for ($a=0;$a<$numsnps;$a++)
{
if (($fixedmatrix[$a][1] eq 'A') && ($fixedmatrix[$a][2] eq 'T')) {printtofile($BrazilCapediffs,$a,1,2); $fixeddiffsCapeBrazil++;}
elsif (($fixedmatrix[$a][1] eq 'A') && ($fixedmatrix[$a][2] eq 'G')) {printtofile($BrazilCapediffs,$a,1,2); $fixeddiffsCapeBrazil++;}
elsif (($fixedmatrix[$a][1] eq 'A') && ($fixedmatrix[$a][2] eq 'C')) {printtofile($BrazilCapediffs,$a,1,2); $fixeddiffsCapeBrazil++;}
elsif (($fixedmatrix[$a][1] eq 'T') && ($fixedmatrix[$a][2] eq 'A')) {printtofile($BrazilCapediffs,$a,1,2); $fixeddiffsCapeBrazil++;}
elsif (($fixedmatrix[$a][1] eq 'T') && ($fixedmatrix[$a][2] eq 'G')) {printtofile($BrazilCapediffs,$a,1,2); $fixeddiffsCapeBrazil++;}
elsif (($fixedmatrix[$a][1] eq 'T') && ($fixedmatrix[$a][2] eq 'C')) {printtofile($BrazilCapediffs,$a,1,2); $fixeddiffsCapeBrazil++;}
elsif (($fixedmatrix[$a][1] eq 'G') && ($fixedmatrix[$a][2] eq 'A')) {printtofile($BrazilCapediffs,$a,1,2); $fixeddiffsCapeBrazil++;}
elsif (($fixedmatrix[$a][1] eq 'G') && ($fixedmatrix[$a][2] eq 'T')) {printtofile($BrazilCapediffs,$a,1,2); $fixeddiffsCapeBrazil++;}
elsif (($fixedmatrix[$a][1] eq 'G') && ($fixedmatrix[$a][2] eq 'C')) {printtofile($BrazilCapediffs,$a,1,2); $fixeddiffsCapeBrazil++;}
elsif (($fixedmatrix[$a][1] eq 'C') && ($fixedmatrix[$a][2] eq 'G')) {printtofile($BrazilCapediffs,$a,1,2); $fixeddiffsCapeBrazil++;}
elsif (($fixedmatrix[$a][1] eq 'C') && ($fixedmatrix[$a][2] eq 'A')) {printtofile($BrazilCapediffs,$a,1,2); $fixeddiffsCapeBrazil++;}
elsif (($fixedmatrix[$a][1] eq 'C') && ($fixedmatrix[$a][2] eq 'T')) {printtofile($BrazilCapediffs,$a,1,2); $fixeddiffsCapeBrazil++;}
}
sub printtofile {
my ($filename, $snpnumber, $group1, $group2) = @_;
print $filename "$contig[$snpnumber]\t $position[$snpnumber]\t $fixedmatrix[$a][$group1]\t $fixedmatrix[$a][$group2]\n"
}
### Identify SNPs fixed in all three strains ###
$sharedGPLBrazil=0;
$sharedGPLCape=0;
$sharedBrazilCape=0;
$missedSNPs=0;
for ($a=0;$a<$numsnps;$a++)
{
if (($fixedmatrix[$a][0] =~ /N|P/) | ($fixedmatrix[$a][1] =~ /N|P/) | ($fixedmatrix[$a][2] =~ /N|P/)) {next;}
elsif (($fixedmatrix[$a][0] eq $fixedmatrix[$a][1]) && ($fixedmatrix[$a][0] ne $fixedmatrix[$a][2]))
{print $GPLBrazilshared "$contig[$a]\t $position[$a]\t $fixedmatrix[$a][0]\t $fixedmatrix[$a][1]\t $fixedmatrix[$a][2]\n"; $sharedGPLBrazil++;}
elsif (($fixedmatrix[$a][0] eq $fixedmatrix[$a][2]) && ($fixedmatrix[$a][0] ne $fixedmatrix[$a][1]))
{print $GPLCapeshared "$contig[$a]\t $position[$a]\t $fixedmatrix[$a][0]\t $fixedmatrix[$a][1]\t $fixedmatrix[$a][2]\n"; $sharedGPLCape++;}
elsif (($fixedmatrix[$a][1] eq $fixedmatrix[$a][2]) && ($fixedmatrix[$a][1] ne $fixedmatrix[$a][0]))
{print $BrazilCapeshared "$contig[$a]\t $position[$a]\t $fixedmatrix[$a][0]\t $fixedmatrix[$a][1]\t $fixedmatrix[$a][2]\n"; $sharedBrazilCape++;}
else {$missedSNPs++;} #print "$contig[$a]\t $position[$a]\t $fixedmatrix[$a][0]\t $fixedmatrix[$a][1]\t $fixedmatrix[$a][2]\n";}
}
print "GPL&BrazilSNPs\t $sharedGPLBrazil\n";
print "GPL&CapeSNPs\t $sharedGPLCape\n";
print "Brazil&CapeSNPs\t $sharedBrazilCape\n";
print "Missing\t $missedSNPs\n";
$sharedpolymorphGPLBrazil=0;
$sharedpolymorphGPLCape=0;
$sharedpolymorphBrazilCape=0;
$sharedGPLBrazilvsP=0;
$sharedGPLCapevsP=0;
$sharedBrazilCapevsP=0;
$allpolymorphic=0;
$polymorphmissedSNPs=0;
$missingdata=0;
for ($a=0;$a<$numsnps;$a++)
{
if (($fixedmatrix[$a][0] =~ /N/) | ($fixedmatrix[$a][1] =~ /N/) | ($fixedmatrix[$a][2] =~ /N/)) {$missingdata++;}
elsif (($fixedmatrix[$a][0] eq 'A') && ($fixedmatrix[$a][1] eq 'P') && ($fixedmatrix[$a][2] eq 'P')) {$sharedpolymorphBrazilCape++;}
elsif (($fixedmatrix[$a][0] eq 'P') && ($fixedmatrix[$a][1] eq 'A') && ($fixedmatrix[$a][2] eq 'P')) {$sharedpolymorphGPLCape++;}
elsif (($fixedmatrix[$a][0] eq 'P') && ($fixedmatrix[$a][1] eq 'P') && ($fixedmatrix[$a][2] eq 'A')) {$sharedpolymorphGPLBrazil++;}
elsif (($fixedmatrix[$a][0] eq 'A') && ($fixedmatrix[$a][1] eq 'A') && ($fixedmatrix[$a][2] eq 'P')) {$sharedGPLBrazilvsP++;}
elsif (($fixedmatrix[$a][0] eq 'A') && ($fixedmatrix[$a][1] eq 'P') && ($fixedmatrix[$a][2] eq 'A')) {$sharedGPLCapevsP++;}
elsif (($fixedmatrix[$a][0] eq 'P') && ($fixedmatrix[$a][1] eq 'A') && ($fixedmatrix[$a][2] eq 'A')) {$sharedBrazilCapevsP++;}
elsif (($fixedmatrix[$a][0] eq 'T') && ($fixedmatrix[$a][1] eq 'P') && ($fixedmatrix[$a][2] eq 'P')) {$sharedpolymorphBrazilCape++;}
elsif (($fixedmatrix[$a][0] eq 'P') && ($fixedmatrix[$a][1] eq 'T') && ($fixedmatrix[$a][2] eq 'P')) {$sharedpolymorphGPLCape++;}
elsif (($fixedmatrix[$a][0] eq 'P') && ($fixedmatrix[$a][1] eq 'P') && ($fixedmatrix[$a][2] eq 'T')) {$sharedpolymorphGPLBrazil++;}
elsif (($fixedmatrix[$a][0] eq 'T') && ($fixedmatrix[$a][1] eq 'T') && ($fixedmatrix[$a][2] eq 'P')) {$sharedGPLBrazilvsP++;}
elsif (($fixedmatrix[$a][0] eq 'T') && ($fixedmatrix[$a][1] eq 'P') && ($fixedmatrix[$a][2] eq 'T')) {$sharedGPLCapevsP++;}
elsif (($fixedmatrix[$a][0] eq 'P') && ($fixedmatrix[$a][1] eq 'A') && ($fixedmatrix[$a][2] eq 'A')) {$sharedBrazilCapevsP++;}
elsif (($fixedmatrix[$a][0] eq 'G') && ($fixedmatrix[$a][1] eq 'P') && ($fixedmatrix[$a][2] eq 'P')) {$sharedpolymorphBrazilCape++;}
elsif (($fixedmatrix[$a][0] eq 'P') && ($fixedmatrix[$a][1] eq 'G') && ($fixedmatrix[$a][2] eq 'P')) {$sharedpolymorphGPLCape++;}
elsif (($fixedmatrix[$a][0] eq 'P') && ($fixedmatrix[$a][1] eq 'P') && ($fixedmatrix[$a][2] eq 'G')) {$sharedpolymorphGPLBrazil++;}
elsif (($fixedmatrix[$a][0] eq 'G') && ($fixedmatrix[$a][1] eq 'G') && ($fixedmatrix[$a][2] eq 'P')) {$sharedGPLBrazilvsP++;}
elsif (($fixedmatrix[$a][0] eq 'G') && ($fixedmatrix[$a][1] eq 'P') && ($fixedmatrix[$a][2] eq 'G')) {$sharedGPLCapevsP++;}
elsif (($fixedmatrix[$a][0] eq 'P') && ($fixedmatrix[$a][1] eq 'G') && ($fixedmatrix[$a][2] eq 'G')) {$sharedBrazilCapevsP++;}
elsif (($fixedmatrix[$a][0] eq 'C') && ($fixedmatrix[$a][1] eq 'P') && ($fixedmatrix[$a][2] eq 'P')) {$sharedpolymorphBrazilCape++;}
elsif (($fixedmatrix[$a][0] eq 'P') && ($fixedmatrix[$a][1] eq 'C') && ($fixedmatrix[$a][2] eq 'P')) {$sharedpolymorphGPLCape++;}
elsif (($fixedmatrix[$a][0] eq 'P') && ($fixedmatrix[$a][1] eq 'P') && ($fixedmatrix[$a][2] eq 'C')) {$sharedpolymorphGPLBrazil++;}
elsif (($fixedmatrix[$a][0] eq 'C') && ($fixedmatrix[$a][1] eq 'C') && ($fixedmatrix[$a][2] eq 'P')) {$sharedGPLBrazilvsP++;}
elsif (($fixedmatrix[$a][0] eq 'C') && ($fixedmatrix[$a][1] eq 'P') && ($fixedmatrix[$a][2] eq 'C')) {$sharedGPLCapevsP++;}
elsif (($fixedmatrix[$a][0] eq 'P') && ($fixedmatrix[$a][1] eq 'C') && ($fixedmatrix[$a][2] eq 'C')) {$sharedBrazilCapevsP++;}
elsif (($fixedmatrix[$a][0] eq 'P') && ($fixedmatrix[$a][1] eq 'P') && ($fixedmatrix[$a][2] eq 'P')) {$allpolymorphic++;}
else {$polymorphmissedSNPs++; print "$contig[$a]\t $position[$a]\t $fixedmatrix[$a][0]\t $fixedmatrix[$a][1]\t $fixedmatrix[$a][2]\n";}
}
print "\n";
print "Missing Data\t $missingdata\n";
print "GPL&BrazilvsP\t $sharedGPLBrazilvsP\n";
print "GPL&CapevsP\t $sharedGPLCapevsP\n";
print "Brazil&CapevsP\t $sharedBrazilCapevsP\n\n";
print "GPL=P & Brazil=P\t $sharedpolymorphGPLBrazil\n";
print "GPL=P & Cape=P\t\t $sharedpolymorphGPLCape\n";
print "BRazil=P & Cape=P\t $sharedpolymorphBrazilCape\n\n";
print "All Polymorphic\t $allpolymorphic\n";
print "missed SNPs polymorphic $polymorphmissedSNPs\n";
#APT
#ATP
#PAT
### Identify parental contribution of Hybrid SNPS ###
# Build a negative control
$uninf=0;
$noinfo=0;
$homozygousGPL=0;
$homozygousBrazil=0;
$heterozygousGPLBrazil=0;
for ($a=0;$a<$numsnps;$a++)
{
if (($fixedmatrix[$a][0] =~ /N|P/) | ($fixedmatrix[$a][1] =~ /N|P/) | ($dataset[$a][47] =~ /N/)) {$noinfo++; next;}
elsif ($fixedmatrix[$a][0] eq $fixedmatrix[$a][1]) {$uninf++; next;}
elsif ($dataset[$a][47] eq $fixedmatrix[$a][0]) {print $hybrid "$contig[$a]\t $position[$a]\t 1\t $fixedmatrix[$a][0]\t $fixedmatrix[$a][1]\t $dataset[$a][47]\n"; $homozygousGPL++;}
elsif ($dataset[$a][47] eq $fixedmatrix[$a][1]) {print $hybrid "$contig[$a]\t $position[$a]\t -1\t $fixedmatrix[$a][0]\t $fixedmatrix[$a][1]\t $dataset[$a][47]\n"; $homozygousBrazil++;}
elsif ($dataset[$a][47] ne $fixedmatrix[$a][1]) {print $hybrid "$contig[$a]\t $position[$a]\t 0\t $fixedmatrix[$a][0]\t $fixedmatrix[$a][1]\t $dataset[$a][47]\n"; $heterozygousGPLBrazil++;}
}
print "\n";
print "Uninformative\t $uninf\n";
print "No Info\t $noinfo\n";
print "homozygousGPL\t $homozygousGPL\n";
print "homozygousBrazil\t $homozygousBrazil\n";
print "heterozygous\t $heterozygousGPLBrazil\n";
exit;