-
Notifications
You must be signed in to change notification settings - Fork 4
/
aligned_fasta_group_diffs.pl
executable file
·641 lines (577 loc) · 21.3 KB
/
aligned_fasta_group_diffs.pl
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
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
#! /usr/bin/perl
# INPUT: takes in all .fa* files in the working directory, which must be aligned to one
# another. Considers each fasta file a meaningful "group" of sequences.
# OUTPUTS: a file describing positions at which the groups differ in their major
# nucleotide. The user may provide the following arguments to control how these sites
# are determined: <to be added>
#########################################################################################
# EXAMPLE CALL:
#########################################################################################
# aligned_fasta_group_diffs.pl
# aligned_fasta_group_diffs.pl --min_variant_maj_nt_freq=.9 --min_site_coverage=8
#########################################################################################
# Copyright (C) 2017 Chase W. Nelson
# Date created: November 15, 2017
# AUTHOR: Chase W. Nelson
# CONTACT1: [email protected]
# AFFILIATION: Sackler Institute for Comparative Genomics, American Museum of Natural History, New York, NY 10024, USA
# ACKNOWLEDGMENTS: written by C.W.N. with support from a Gerstner Scholars Fellowship from
# the Gerstner Family Foundation at the American Museum of Natural History, New York.
use strict;
#use warnings;
use Getopt::Long;
use Data::Dumper;
STDOUT->autoflush(1); # requires Data::Dumper, but needed
#########################################################################################
# INITIALIZE (OPTIONAL) INPUT VARIABLES
my $min_variant_maj_nt_freq;
my $min_site_coverage;
# Get user input, if given. If a Boolean argument is passed, its value is 1; else undef
GetOptions( "min_variant_maj_nt_freq:f" => \$min_variant_maj_nt_freq, # optional floating point parameter
"min_site_coverage:i" => \$min_site_coverage) # optional integer parameter
or die "\n### WARNING: Error in command line arguments. Script terminated.\n\n";
# If an argument is called as a flag, its value is 0; if not called, it's null
if(! $min_variant_maj_nt_freq) { # null or 0
$min_variant_maj_nt_freq = 0.5; # default behavior
} elsif($min_variant_maj_nt_freq < 0.5) {
die "\n### WARNING: The --min_variant_maj_nt_freq option must ≥0.5\n".
"### Script terminated.\n\n";
}
if(! $min_site_coverage) { # null or 0
$min_site_coverage = 5; # default behavior
} elsif($min_site_coverage < 1) {
die "\n### WARNING: The --min_site_coverage option must ≥1\n".
"### Script terminated.\n\n";
}
#########################################################################################
# PREPARE TO STORE FASTA DATA
my @fasta_file_names_arr = &get_fasta_file_names;
my %group2seqs_ha;
#my $filename = $ARGV[0];
#my $coding_start_site = $ARGV[1];
#my $coding_stop_site = $ARGV[2];
my $seq_length = 0;
foreach my $fasta_file_name (@fasta_file_names_arr) {
# Read in the sequence from the file
my $seq = '';
my @seqs_arr;
#my $header = '';
#my @headers_arr;
my $seq_num = 0;
my $last_seq_length;
open(IN, "$fasta_file_name") or die "Could not open file $fasta_file_name\n";
# print "\nGenerating summary nucleotide statistics for $fasta_file_name\...\n";
while(<IN>) {
chomp;
if(/>/) {
if($seq_num == 0) {
#$header = $_;
$seq_num ++;
} else {
push(@seqs_arr,$seq);
#push(@headers_arr,$header);
#$header = $_;
$seq_num ++;
my $this_seq_length = length($seq);
#print "\nseq $seq_num is of length $this_seq_length\n";
if($last_seq_length && ($last_seq_length != $this_seq_length)) {
die "\n\nDIE: The sequences must be aligned, i.e., must be the same length. TERMINATED.\n\n";
} else {
$last_seq_length = $this_seq_length;
#print "\nseq: $seq\n";
$seq = '';
}
}
} else {
$seq .= $_;
}
}
if(@seqs_arr == 0) {
$seq_length = length($seq);
$last_seq_length = $seq_length;
}
push(@seqs_arr,$seq);
#push(@headers_arr,$header);
close IN;
if($seq_length == 0) {
$seq_length = $last_seq_length;
# print "\nseq length is $seq_length\n";
} elsif($seq_length != $last_seq_length) {
die "\n\nDIE: The sequences from $fasta_file_name must be the same length as previous files. TERMINATED.\n\n";
}
# Get name for group from $fasta_file_name
my $group_name;
if($fasta_file_name =~ '.fa') {
$group_name = $`;
} else {
die "\n### NEED A FASTA FILE\n\n";
}
# Add this group of sequences to %group2seqs_ha
$group2seqs_ha{$group_name} = \@seqs_arr;
#push(@{$product_coordinates_harr{$product_name}->{product_coord_arr}},@product_coord_arr);
}
#print "\nSequence length is $seq_length\n";
# Now I want to go site-by-site and (1) determine the number of defined nucleotides at
# each sites; (2) calculate the consensus/majority nucleotide among those defined using
# some threshold like 90%; (3) in cases where majority nucleotides differ between groups,
# make note of the sites, nucleotide identities, and coverage.
my @groups = sort keys %group2seqs_ha;
# Print header to output file
print "site";
foreach my $group (@groups) {
print "\t";
print "$group\_maj_nt\t";
print "$group\_maj_nt_count\t";
print "$group\_defined_count\t";
print "$group\_maj_nt_freq";
}
print "\n";
# For each nucleotide
for(my $i = 0; $i < $seq_length; $i++) {
my %group2maj_nt;
# For each group (FASTA file)
foreach my $group (@groups) {
my @this_group_seqs = @{$group2seqs_ha{$group}};
my %nt_count;
# Count number of each nucleotide (A, C, G, T) at this site in this group
foreach my $this_seq (@this_group_seqs) {
my $this_nt = substr($this_seq,$i,1);
# print "\nNT IS: $this_nt\n";
$nt_count{$this_nt}++;
}
# Determine majority nucleotide
my $maj_nt = 'N';
my $maj_count = 0;
my $defined_count = 0;
# Check if the two highest have the same counts?
# Count the number of nucleotides that are defined, i.e., not 'N' or '-'
foreach my $observed_nt (keys %nt_count) {
if($observed_nt ne 'N' && $observed_nt ne '-') {
$defined_count += $nt_count{$observed_nt};
# If it's got the highest count observed so far, make it the major nucleotide
if($nt_count{$observed_nt} > $maj_count) {
$maj_nt = $observed_nt;
$maj_count = $nt_count{$observed_nt};
# print "\nGroup $group site index $i has major nucleotide $maj_nt\n";
}
}
}
# Define frequency of major nucleotide in this group if there are defined nucleotides
my $maj_nt_freq = 0;
if($defined_count > 0) {
$maj_nt_freq = $maj_count / $defined_count;
}
# If a group was all N's, this will remain N and 0
$group2maj_nt{$group}->{maj_nt} = $maj_nt;
$group2maj_nt{$group}->{maj_count} = $maj_count;
$group2maj_nt{$group}->{defined_count} = $defined_count;
$group2maj_nt{$group}->{maj_nt_freq} = $maj_nt_freq; # use this later to filter
# print "\nsite $i group $group maj_nt $maj_nt with $maj_count / $defined_count = $maj_nt_freq\n";
}
my $prev_group_maj_nt = '';
my $maj_nt_diff_flag = 0;
# Find out if there's a difference, but don't consider if it's an N or gap (-)
foreach my $group (@groups) {
my $this_group_maj_nt = $group2maj_nt{$group}->{maj_nt};
if($this_group_maj_nt ne 'N' && $this_group_maj_nt ne '-') {
my $this_group_defined_count = $group2maj_nt{$group}->{defined_count};
my $this_group_maj_nt_freq = $group2maj_nt{$group}->{maj_nt_freq};
# Make sure it fits our minimum freq and seq coverage criteria
if($this_group_maj_nt_freq >= $min_variant_maj_nt_freq && $this_group_defined_count >= $min_site_coverage) {
if($prev_group_maj_nt eq '') { # haven't seen a defined nt yet
$prev_group_maj_nt = $group2maj_nt{$group}->{maj_nt};
} elsif($prev_group_maj_nt ne $group2maj_nt{$group}->{maj_nt}) {
# print "\nsite index $i has disparate major nucleotides among groups.\n";
$maj_nt_diff_flag = 1;
last;
}
}# else {
# print "\n### excluded a variant in $group index $i because criteria not satisfied\n\n";
#}
}
}
# If there are disparate major nucleotides among groups, print out site info
if($maj_nt_diff_flag == 1) {
my $site_num = $i+1;
print "$site_num";
foreach my $group (@groups) {
## print "\t" . $group2maj_nt{$group}->{maj_nt};
## print "\t" . $group2maj_nt{$group}->{maj_count};
## print "\t" . $group2maj_nt{$group}->{defined_count};
## print "\t" . $group2maj_nt{$group}->{maj_nt_freq};
# if($site_num == 83) {
# print "\n### GROUP $group\n";
# print "maj_nt=" . $group2maj_nt{$group}->{maj_nt} . "\n";
# print "maj_count=" . $group2maj_nt{$group}->{maj_count} . "\n";
# print "defined_count=" . $group2maj_nt{$group}->{defined_count} . "\n";
# print "maj_nt_freq=" . $group2maj_nt{$group}->{maj_nt_freq} . "\n";
# }
# ONLY PRINT if THIS group's frequency matches the frequency criterion
if($group2maj_nt{$group}->{maj_nt_freq} >= $min_variant_maj_nt_freq && $group2maj_nt{$group}->{defined_count} >= $min_site_coverage) {
print "\t" . $group2maj_nt{$group}->{maj_nt};
print "\t" . $group2maj_nt{$group}->{maj_count};
print "\t" . $group2maj_nt{$group}->{defined_count};
print "\t" . $group2maj_nt{$group}->{maj_nt_freq};
} else {
print "\t";
print "\t";
print "\t";
print "\t";
}
}
print "\n";
} # there's a difference in the major nucleotides
} # end last site
## my @A_counts;
## my @C_counts;
## my @G_counts;
## my @T_counts;
##
## # INITIALIZE HASH VALUES
## for(my $site_id=1; $site_id<=length($seq); $site_id++) { # for each site
## my $curr_site_index = $site_id - 1;
## push(@A_counts,0);
## push(@C_counts,0);
## push(@G_counts,0);
## push(@T_counts,0);
## }
##
## for(my $seq_id=1; $seq_id <= scalar(@seqs_arr); $seq_id++) { # for each sequence
## my $curr_seq_index = $seq_id - 1;
## my $curr_seq = $seqs_arr[$curr_seq_index];
## #print "\ncurr_seq: $curr_seq\n";
##
## for(my $site_id=1; $site_id<=length($curr_seq); $site_id++) { # for each site
## my $curr_site_index = $site_id - 1;
## my $curr_nt = substr($curr_seq,$curr_site_index,1); # substr is 0-based indexing. VAR,OFFSET,LEN
## #print "\ncurr_nt: $curr_nt";
##
## if($curr_nt eq 'A') {
## $A_counts[$curr_site_index]++;
## #$C_counts[$curr_site_index]+=0;
## #$G_counts[$curr_site_index]+=0;
## #$T_counts[$curr_site_index]+=0;
## } elsif($curr_nt eq 'C') {
## #$A_counts[$curr_site_index]+=0;
## $C_counts[$curr_site_index]++;
## #$G_counts[$curr_site_index]+=0;
## #$T_counts[$curr_site_index]+=0;
## } elsif($curr_nt eq 'G') {
## #$A_counts[$curr_site_index]+=0;
## #$C_counts[$curr_site_index]+=0;
## $G_counts[$curr_site_index]++;
## #$T_counts[$curr_site_index]+=0;
## } elsif($curr_nt eq 'T') {
## #$A_counts[$curr_site_index]+=0;
## #$C_counts[$curr_site_index]+=0;
## #$G_counts[$curr_site_index]+=0;
## $T_counts[$curr_site_index]++;
## }
## }
## }
##
## # Do calculations and output to summary file
## my $summary_file_name;
## if($filename =~ '.fasta') {
## $summary_file_name = $` . "_site_summary.txt";
## } elsif($filename =~ '.fa') {
## $summary_file_name = $` . "_site_summary.txt";
## } else {
## $summary_file_name = "fasta_site_summary.txt";
## }
##
## my $total_transitions;
## my $total_transversions;
##
## my %num_vars2num_nts; # keep track of how many variant nucleotides
##
## #my %non_singleton_sites;
## my $non_singleton_transitions;
## my $non_singleton_transversions;
##
## # For non-singleton polymorphic sites with only 2 nucleotides present
## my $non_singleton_2_transitions;
## my $non_singleton_2_transversions;
## my %non_singleton_2_codon_pos_counts;
## my %non_singleton_multiV_codon_pos_counts;
##
## # For singleton polymorphic sites with only 2 nucleotides present
## my $singleton_2_transitions;
## my $singleton_2_transversions;
## my %singleton_2_codon_pos_counts;
## my %singleton_multiV_codon_pos_counts;
##
## open(OUT, ">>$summary_file_name");
## print OUT "site\tA\tA_prop\tC\tC_prop\tG\tG_prop\tT\tT_prop\n";
## for(my $site_id=1; $site_id<=scalar(@A_counts); $site_id++) { # for each site
## my $site_index = $site_id - 1;
##
## # The following method should automatically ignore gaps (-)
## my $A = $A_counts[$site_index];
## my $C = $C_counts[$site_index];
## my $G = $G_counts[$site_index];
## my $T = $T_counts[$site_index];
##
## my $total = ($A + $C + $G + $T);
##
## # print "My total is $total\n";
##
## if($total != $seq_num) {
## #die "\n\nNucleotide sum ($total) at site $site_id does not match number of sequences ($seq_num).\n".
## # "A=$A\nC=$C\nG=$G\nT=$T\nTERMINATED\n\n";
##
## # print "\n\nNucleotide sum ($total) at site $site_id does not match number of sequences ($seq_num).\n".
## # "A=$A\nC=$C\nG=$G\nT=$T\nALIGNMENT GAP?\n\n";
## }
##
## if($total > 0) {
##
## # die "\nMAKE SURE SITES WITH ONLY N's WON'T OFFPUT THE ALIGNMENT ANALYSIS\n".
## # "(I think we're okay, but check)\n\n";
##
## # Which is the dominant nucleotide?
## my $maj_nt; # a variant nucleotide may have fixed
## my $maj_nt_count = 0;
## if($A > $maj_nt_count) {
## $maj_nt_count = $A;
## $maj_nt = 'A';
## }
## if($C > $maj_nt_count) {
## $maj_nt_count = $C;
## $maj_nt = 'C';
## }
## if($G > $maj_nt_count) {
## $maj_nt_count = $G;
## $maj_nt = 'G';
## }
## if($T > $maj_nt_count) {
## $maj_nt_count = $T;
## $maj_nt = 'T';
## }
##
## my $min_sum = $total - $maj_nt_count;
##
## # if($min_sum > 1) {
## # $non_singleton_sites{$site_id} = 1;
## # }
##
## # How many different variable nucleotides? Want to find only 2 (1 shared variant)
## my $num_alt_nts = 0;
## if($A > 0) {
## $num_alt_nts++;
## }
## if($C > 0) {
## $num_alt_nts++;
## }
## if($G > 0) {
## $num_alt_nts++;
## }
## if($T > 0) {
## $num_alt_nts++;
## }
##
## $num_vars2num_nts{$min_sum}->{$num_alt_nts}++;
##
## my $A_prop = ($A / $total);
## my $C_prop = ($C / $total);
## my $G_prop = ($G / $total);
## my $T_prop = ($T / $total);
##
## # Compute transitions and transversions
## my $num_pw_comps = (($total ** 2) - $total) / 2;
## my $AC = $A * $C;
## my $AG = $A * $G;
## my $AT = $A * $T;
## my $CG = $C * $G;
## my $CT = $C * $T;
## my $GT = $G * $T;
##
## my $transitions = $AG + $CT;
## my $transversions = $AC + $AT + $CG + $GT;
##
## $total_transitions += $transitions;
## $total_transversions += $transversions;
##
##
##
##
## if($min_sum == 1) { # SINGLETONS
## if($num_alt_nts == 2) { # singleton AND one-variant
## $singleton_2_transitions += $transitions;
## $singleton_2_transversions += $transversions;
##
## if($coding_start_site && $coding_stop_site) { # second and third argts
## if($site_id < $coding_start_site) {
## $singleton_2_codon_pos_counts{UTR_5}++;
## } elsif($site_id <= $coding_stop_site) {
## my $codon_position = (($site_id - $coding_start_site) % 3) + 1;
## $singleton_2_codon_pos_counts{$codon_position}++;
## } else {
## $singleton_2_codon_pos_counts{UTR_3}++;
## }
## }
##
## } else { # singleton, multi-variant
## die "\n\nThis should never occur\n\n";
## }
## }
##
##
##
##
##
## if($min_sum > 1) { # non-singleton (more than one variable sequence)
## $non_singleton_transitions += $transitions;
## $non_singleton_transversions += $transversions;
##
## if($num_alt_nts == 2) { # non-singleton AND one-variant
## $non_singleton_2_transitions += $transitions;
## $non_singleton_2_transversions += $transversions;
##
## if($coding_start_site && $coding_stop_site) { # second and third argts
## if($site_id < $coding_start_site) {
## $non_singleton_2_codon_pos_counts{UTR_5}++;
## } elsif($site_id <= $coding_stop_site) { # CODING SITE
## my $codon_position = (($site_id - $coding_start_site) % 3) + 1;
## $non_singleton_2_codon_pos_counts{$codon_position}++;
##
## # DETERMINE CODON HERE FOR SYNONYMOUS COUNT?
##
## } else {
## $non_singleton_2_codon_pos_counts{UTR_3}++;
## }
## }
##
##
## } else { # non-singleton, multi-variant
##
##
## if($coding_start_site && $coding_stop_site) { # second and third argts
## if($site_id < $coding_start_site) {
## $non_singleton_multiV_codon_pos_counts{UTR_5}++;
## } elsif($site_id <= $coding_stop_site) {
## my $codon_position = (($site_id - $coding_start_site) % 3) + 1;
## $non_singleton_multiV_codon_pos_counts{$codon_position}++;
## } else {
## $non_singleton_multiV_codon_pos_counts{UTR_3}++;
## }
## }
##
##
##
##
##
## }
## }
##
## my $transi_transv_ratio;
## if($transversions > 0) {
## $transi_transv_ratio = $transitions / $transversions;
## } else {
## $transi_transv_ratio = '*';
## }
##
## # print "\nThere are $transitions transitions and $transversions transversions\n".
## # "The ratio is: $transi_transv_ratio\n\n";
##
## print OUT "$site_id\t$A\t$A_prop\t$C\t$C_prop\t$G\t$G_prop\t$T\t$T_prop\n";
##
## }
##
## }
## close OUT;
##
## my $total_transi_transv_ratio;
## if($total_transversions > 0) {
## $total_transi_transv_ratio = $total_transitions / $total_transversions;
## } else {
## $total_transi_transv_ratio = '*';
## }
##
## my $non_singleton_transi_transv_ratio;
## if($non_singleton_transversions > 0) {
## $non_singleton_transi_transv_ratio = $non_singleton_transitions / $non_singleton_transversions;
## } else {
## $non_singleton_transi_transv_ratio = '*';
## }
##
## my $non_singleton_2_transi_transv_ratio;
## if($non_singleton_2_transversions > 0) {
## $non_singleton_2_transi_transv_ratio = $non_singleton_2_transitions / $non_singleton_2_transversions;
## } else {
## $non_singleton_2_transi_transv_ratio = '*';
## }
##
## my $singleton_2_transi_transv_ratio;
## if($singleton_2_transversions > 0) {
## $singleton_2_transi_transv_ratio = $singleton_2_transitions / $singleton_2_transversions;
## } else {
## $singleton_2_transi_transv_ratio = '*';
## }
##
## print "\nThere are $total_transitions transitions and $total_transversions transversions\n".
## "The ratio is: $total_transi_transv_ratio\nThe proportion is: " .
## $total_transitions / ($total_transitions + $total_transversions) . "\n\n";
##
## print "\nFor non-singletons, there are $non_singleton_transitions transitions and $non_singleton_transversions transversions\n".
## "The ratio is: $non_singleton_transi_transv_ratio\nThe proportion is: " .
## $non_singleton_transitions / ($non_singleton_transitions + $non_singleton_transversions) . "\n\n";
##
## print "\nFor non-singletons one-variant sites, there are $non_singleton_2_transitions transitions and $non_singleton_2_transversions transversions\n".
## "The ratio is: $non_singleton_2_transi_transv_ratio\nThe proportion is: " .
## $non_singleton_2_transitions / ($non_singleton_2_transitions + $non_singleton_2_transversions) . "\n".
## "These occur at the following sites:\n5\'NCR: ".$non_singleton_2_codon_pos_counts{UTR_5}.
## "\nCodon pos 1: ".$non_singleton_2_codon_pos_counts{1}.
## "\nCodon pos 2: ".$non_singleton_2_codon_pos_counts{2}.
## "\nCodon pos 3: ".$non_singleton_2_codon_pos_counts{3}.
## "\n3\'NCR: ".$non_singleton_2_codon_pos_counts{UTR_3}.
## "\nNon-singleton, MULTI-variant occur at the following sites:\n5\'NCR: ".$non_singleton_multiV_codon_pos_counts{UTR_5}.
## "\nCodon pos 1: ".$non_singleton_multiV_codon_pos_counts{1}.
## "\nCodon pos 2: ".$non_singleton_multiV_codon_pos_counts{2}.
## "\nCodon pos 3: ".$non_singleton_multiV_codon_pos_counts{3}.
## "\n3\'NCR: ".$non_singleton_multiV_codon_pos_counts{UTR_3}.
## "\n\n";
##
## # We don't really need these data right now
## print "\nFor singletons one-variant sites, there are $singleton_2_transitions transitions and $singleton_2_transversions transversions\n".
## "The ratio is: $singleton_2_transi_transv_ratio\nThe proportion is: " .
## $singleton_2_transitions / ($singleton_2_transitions + $singleton_2_transversions) . "\n".
## "These occur at the following sites:\n5\'NCR: ".$singleton_2_codon_pos_counts{UTR_5}.
## "\nCodon pos 1: ".$singleton_2_codon_pos_counts{1}.
## "\nCodon pos 2: ".$singleton_2_codon_pos_counts{2}.
## "\nCodon pos 3: ".$singleton_2_codon_pos_counts{3}.
## "\n3\'NCR: ".$singleton_2_codon_pos_counts{UTR_3}.
## "\n\n";
##
## print "num_var_seqs\tnum_distinct_nts\tcount\n";
## foreach my $num_var_seqs (sort {$a <=> $b} keys %num_vars2num_nts) {
## foreach my $num_distinct_nts (sort {$a <=> $b} keys %{$num_vars2num_nts{$num_var_seqs}}) {
## print "$num_var_seqs\t$num_distinct_nts\t" . $num_vars2num_nts{$num_var_seqs}->{$num_distinct_nts} . "\n";
## }
## }
print "\n\nCOMPLETED.\n\n";
#########################################################################################
# Obtains all file names in current directory ending in .fa and/or .fasta
sub get_fasta_file_names {
my @fasta_file_names = glob "*.fa";
my @other_fasta_file_names;
#if (scalar(@fasta_file_names) == 0) {
# @fasta_file_names = glob "*.fasta";
#} else {
@other_fasta_file_names = glob "*.fasta";
push (@fasta_file_names,@other_fasta_file_names);
#}
#print "\n\n@fasta_file_names\n\n";
if (scalar(@fasta_file_names) == 0) {
#chdir('SNPGenie_Results');
#open(ERROR_FILE,">>SNPGenie\_LOG\.txt");
## FILE | PRODUCT | SITE | CODON | WARNING
#print ERROR_FILE "N/A\tN/A\tN/A\t".
# "No FASTA (.fa or .fasta) files in directory. SNPGenie terminated.\n";
#close ERROR_FILE;
#chdir('..');
die "\n\n## WARNING: There are no .fa or .fasta files. SNPGenie terminated.\n\n";
}
#print "\n\n@fasta_file_names\n\n";
return @fasta_file_names;
}