-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathrename_feature.pl
More file actions
87 lines (63 loc) · 1.67 KB
/
rename_feature.pl
File metadata and controls
87 lines (63 loc) · 1.67 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
80
81
82
83
84
85
86
#!/usr/bin/env perl
use strict;
use warnings;
use Data::Dumper;
use feature 'say';
use feature 'switch';
use autodie;
use Pod::Usage;
use Getopt::Long;
my $help;
my $input;
my $output;
my $rep;
my $result = GetOptions (
"input|i=s" => \$input,
"output|o=s" => \$output,
"replacement|r=s" => \$rep,
"help" => \$help,
);
pod2usage(-verbose => 99, -sections => [qw/NAME SYNOPSIS OPTIONS/]) if (!$result || !$input || !$rep);
my $ofh;
given ($output){
when (q{-}){
$ofh = \*STDOUT;
}
when (undef){
my $orig = $input;
$input .= '.bak';
rename $orig, $input;
open $ofh, '>', $orig;
}
default {
open $ofh, '>', $output;
}
}
open my $ifh, q{<}, $input;
while (defined(my $line = <$ifh>)){
my @split = split /\t/, $line;
die "line $. does not look like a GFF line."
unless @split == 9;
$split[2] = $rep;
print $ofh join qq{\t}, @split;
}
close $ifh;
close $ofh;
=head1 NAME
rename_feature.pl - replace the feature column (column 3)
=head1 SYNOPSIS
rename the windows in genes.gff to "new_window_name", creating a backup in genes.gff.bak
rename_feature.pl -i genes.gff -r new_window_name
create new file genes-new.gff with new_window_name as feature.
rename_feature.pl -i genes.gff -r new_window_name -o genes-new.gff
=head1 OPTIONS
=over
=item --input <file> | -i <file>
Input file.
=item --output <file> | -o <file>
Output file. If this is omitted, input file will be overwritten AND a backup will be saved with a '.bak' file
extension. If '-', output to screen.
=item --replacement "new name" | -r "new name"
New name for feature column.
=back
=cut