blib/script/gff2bed.pl untested

filter: Statementstmt 0.0% 0 / 47 Branchbran 0.0% 0 / 10 Conditioncond 0.0% 0 / 5 MC/DCmcdc n/a Subroutinesub 0.0% 0 / 8 Podpod n/a totaltotal 0.0% 0 / 70 CC 1 SCAR 6.9
CC
1
Cov
0%
BEGIN
2.0
BEGIN
2.0
BEGIN
2.0
CRAP 2.0
1 #!/usr/bin/env perl
2 # -*-CPerl-*-
3 # Last changed Time-stamp: <2014-12-10 00:34:41 mtw>
4 #
5 # Convert GFF3 to BED12; produce separate BED files for each gbkey
6 # (CDS/tRNA/rRNA/ncRNA etc.)
7 #
8 # usage: gff2bed.pl --gff input.gff
9 #
10 # ***********************************************************************
11 # * Copyright notice
12 # *
13 # * Copyright 2014 Michael T. Wolfinger <michael@wolfinger.eu>
14 # * All rights reserved
15 # *
16 # * This program is free software: you can redistribute it and/or modify
17 # * it under the terms of the GNU General Public License as published by
18 # * the Free Software Foundation, either version 3 of the License, or
19 # * (at your option) any later version.
20 # *
21 # * This program is distributed in the hope that it will be useful,
22 # * but WITHOUT ANY WARRANTY; without even the implied warranty of
23 # * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24 # * GNU General Public License for more details.
25 # *
26 # * You should have received a copy of the GNU General Public License
27 # * along with this program. If not, see <http://www.gnu.org/licenses/>.
28 # *
29 # * This copyright notice MUST APPEAR in all copies of the script!
30 # ***********************************************************************
31 #
32  
33 use strict;
34 use warnings;
35 use Getopt::Long qw( :config posix_default bundling no_ignore_case );
36 use Pod::Usage;
37 use Data::Dumper;
38 use File::Basename;
39 use Path::Class;
40 use Bio::ViennaNGS::AnnoC;
41  
42 #^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^#
43 #^^^^^^^^^^ Variables ^^^^^^^^^^^#
44 #^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^#
45  
46 my $feature = undef; # look for all features per default
47 my $gff_in = '-';
48 my $outdir = './';
49 my ($basename,$gffdir,$gffext,$obj);
50  
51 #^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^#
52 #^^^^^^^^^^^^^^ Main ^^^^^^^^^^^^^#
53 #^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^#
54  
55 Getopt::Long::config('no_ignore_case');
56 pod2usage(-verbose => 1) unless GetOptions("gff=s" => \$gff_in,
57 "o|out=s" => \$outdir,
58 "f|feature=s" => \$feature,
59 "man" => sub{pod2usage(-verbose => 2)},
60 "help|h" => sub{pod2usage(1)}
61 );
62  
63 unless ($gff_in =~ /^\// || $gff_in =~ /\.\//){$gff_in = "./".$gff_in;}
64 unless (-f $gff_in){
65 warn "Could not find input file $gff_in given via --gff option";
66 pod2usage(-verbose => 0);
67 }
68  
69 #TODO check if we are allowed to write to $outdir
70 unless ($outdir =~ /\/$/){$outdir .= "/";}
71 unless (-d $outdir){mkdir $outdir or die $!;}
72  
73 ($basename,$gffdir,$gffext) = fileparse($gff_in,qr/\..*/);
74  
75 $obj = Bio::ViennaNGS::AnnoC->new();
76 $obj->parse_gff($gff_in);
77 $obj->featstat;
78 $obj->feature_summary($outdir);
79 $obj->features2bed($feature,$outdir,$basename,undef);
80  
81  
82 __END__
83  
84  
85 =head1 NAME
86  
87 gff2bed.pl - Convert (non-spliced) GFF3 to BED12
88  
89 =head1 SYNOPSIS
90  
91 gff2bed.pl [--gff I<FILE>] [options]
92  
93 =head1 DESCRIPTION
94  
95 Convert feature annotation of non-spliced organisms in GFF3 format to
96 BED12. A separate BED12 file will be created for each genomic feature
97 type (eg CDS, tRNA, rRNA, ncRNA, etc.).
98  
99 This script serves as a reference implementation of code fragments
100 from bio::ViennaNGS::AnnoC and has been successfully tested with
101 NCBI's bacterial annotation in GFF3 format.
102  
103 Please note that this script is NOT meant to be run on GFF genome
104 annotation other than bacteria since it DOES NOT consider splice
105 events present in most higher organisms.
106  
107 =head1 OPTIONS
108  
109 =over
110  
111 =item B<--gff>
112  
113 Input GFF file.
114  
115 =item B<--feature -f>
116  
117 Specify feature type (eg. CDS,tRNA,rRNA,SBS, etc) to be extracted from GFF3.
118  
119 =item B<--out -o>
120  
121 Output path.
122  
123 =item B<--help -h>
124  
125 Print short help
126  
127 =item B<--man>
128  
129 Prints the manual page and exits
130  
131 =back
132  
133 =head1 AUTHOR
134  
135 Michael T. Wolfinger E<lt>michael@wolfinger.euE<gt>
136  
137 =cut
138  
139