-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathadd_prefix_chr_to_chromosome_names
executable file
·93 lines (74 loc) · 1.29 KB
/
add_prefix_chr_to_chromosome_names
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
#!/usr/bin/perl -w
use warnings;
use strict;
use POSIX;
use Getopt::Long;
use File::Path;
use File::Basename;
use Pod::Usage;
=head1 NAME
add_prefix_chr_to_chromosome_names
=head1 SYNOPSIS
add_prefix_chr_to_chromosome_names [options]
=head1 DESCRIPTION
Adds chr prefix to chromosome names.
=cut
#option variables
my $help;
my $verbose;
my $debug;
#initialize options
Getopt::Long::Configure ('bundling');
if(!GetOptions ('h'=>\$help, 'v'=>\$verbose, 'd'=>\$debug)
|| scalar(@ARGV)!=1)
{
if ($help)
{
pod2usage(-verbose => 2);
}
else
{
pod2usage(1);
}
}
my $inputVCFFile = $ARGV[0];
if ($inputVCFFile ne "-")
{
open(VCF, $inputVCFFile);
while(<VCF>)
{
chomp;
if (/^#/)
{
if (/^##contig=<ID=/)
{
s/ID=/ID=chr/;
}
print "$_\n";
}
else
{
print "chr$_\n";
}
}
close(VCF);
}
else
{
while(<STDIN>)
{
chomp;
if (/^#/)
{
if (/^##contig=<ID=/)
{
s/ID=/ID=chr/;
}
print "$_\n";
}
else
{
print "chr$_\n";
}
}
}