-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathcount_SNPs.pl
More file actions
executable file
·79 lines (62 loc) · 1.82 KB
/
count_SNPs.pl
File metadata and controls
executable file
·79 lines (62 loc) · 1.82 KB
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
#!/usr/bin/env perl
## Pombert JF, Illinois tech - 2019
my $version = '1.2a';
my $name = 'count_SNPs.pl';
my $updated = '2021-03-13';
use strict;
use warnings;
use Getopt::Long qw(GetOptions);
#########################################################################
### Command line options
#########################################################################
my $options = <<"OPTIONS";
NAME ${name}
VERSION ${version}
UPDATED ${updated}
SYNOPSIS Summarizes the number variants found in the VCF files
USAGE ${name} -o OUTPUT_PREFIX -v *.vcf
OPTIONS:
-o (--output) Desired output file prefix ## File extension (.tsv) will be appended automatically
-v (--vcf) VCF files to summarize
--version Show script version
OPTIONS
unless (@ARGV){
print "\n$usage\n";
exit(0);
};
my $output;
my @vcf;
my $sc_version;
GetOptions(
'o|output=s' => \$output,
'v|vcf=s@{1,}' => \@vcf,
'version' => \$sc_version
);
#########################################################################
### Version
#########################################################################
if ($sc_version){
print "\n";
print "Script: $name\n";
print "Version: $version\n";
print "Updated: $updated\n\n";
exit(0);
}
#########################################################################
### Creating tab-delmited table
#########################################################################
open OUT, ">", "$output.tsv" or die "Can't create output file $output.tsv: $!\n";
while (my $file = shift@vcf){
open IN, "<", "$file" or die "Can't read file $file: $!\n";
my $snps = 0;
while (my $line = <IN>){
chomp $line;
if ($line =~ /^#/){
next;
}
else {
$snps++;
}
}
print OUT "$file\t$snps\n";
}