-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathexon_count.pl
executable file
·78 lines (61 loc) · 1.59 KB
/
exon_count.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
#!/usr/bin/env perl
use strict;
use warnings;
use List::MoreUtils qw/all/;
use List::Util qw/max min/;
use Data::Dumper;
use feature 'say';
use Carp;
use autodie;
use Pod::Usage;
use Getopt::Long;
use FindBin;
use lib "$FindBin::Bin/lib";
use GFF::Parser;
my $locus_tag = q/ID/;
my $input;
my $output = q{-};
my $help;
my $result = GetOptions (
"locus-tag|l=s" => \$locus_tag,
"input|i=s" => \$input,
"output|o=s" => \$output,
"help" => \$help,
);
pod2usage(-verbose => 1) if (!$result || $help || !$input || !$output);
unless ($output eq '-'){
close STDOUT;
open STDOUT, '>', $output or die "can't open $output for writing";
}
my $p = GFF::Parser->new(file => $input,locus => $locus_tag);
my $index = $p->slurp_index($locus_tag);
while (my ($locus,$seqs) = each %$index) {
my @exons = grep {$_->{feature} eq 'exon'} @$seqs;
my $min = (min sort { $a->{start} <=> $b->{start} } @exons)->{start};
my $max = (max sort { $a->{end} <=> $b->{end} } @exons)->{end};
say join "\t",
$exons[0]->{seqname} || '.',
'dzlab',
'exon',
$min,
$max,
scalar @$seqs,
$exons[0]->{strand} || '.',
'.',
join("=",$locus_tag,$locus);
}
=head1 NAME
exon_count.pl - count number of exons for each gene model
=head1 SYNOPSIS
exon_count.pl -l Parent -i TAIR8_gmod-exons.gff -o
=head1 DESCRIPTION
Long description
=head1 OPTIONS
--locus-tag Locus tag (default: 'ID').
-l
--input name of input exon gff file (required)
-i
--output output file. defaults to stdout (screen)
-o
--help print this information
=cut