Bio-ViennaNGS
view release on metacpan or search on metacpan
scripts/gff2bed.pl view on Meta::CPAN
use Path::Class;
use Bio::ViennaNGS::AnnoC;
#^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^#
#^^^^^^^^^^ Variables ^^^^^^^^^^^#
#^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^#
my $feature = undef; # look for all features per default
my $gff_in = '-';
my $outdir = './';
my ($basename,$gffdir,$gffext,$obj);
#^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^#
#^^^^^^^^^^^^^^ Main ^^^^^^^^^^^^^#
#^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^#
Getopt::Long::config('no_ignore_case');
pod2usage(-verbose => 1) unless GetOptions("gff=s" => \$gff_in,
"o|out=s" => \$outdir,
"f|feature=s" => \$feature,
"man" => sub{pod2usage(-verbose => 2)},
"help|h" => sub{pod2usage(1)}
);
unless ($gff_in =~ /^\// || $gff_in =~ /\.\//){$gff_in = "./".$gff_in;}
unless (-f $gff_in){
warn "Could not find input file $gff_in given via --gff option";
pod2usage(-verbose => 0);
}
#TODO check if we are allowed to write to $outdir
unless ($outdir =~ /\/$/){$outdir .= "/";}
unless (-d $outdir){mkdir $outdir or die $!;}
($basename,$gffdir,$gffext) = fileparse($gff_in,qr/\..*/);
$obj = Bio::ViennaNGS::AnnoC->new();
$obj->parse_gff($gff_in);
$obj->featstat;
$obj->feature_summary($outdir);
$obj->features2bed($feature,$outdir,$basename,undef);
__END__
=head1 NAME
gff2bed.pl - Convert (non-spliced) GFF3 to BED12
=head1 SYNOPSIS
gff2bed.pl [--gff I<FILE>] [options]
=head1 DESCRIPTION
Convert feature annotation of non-spliced organisms in GFF3 format to
BED12. A separate BED12 file will be created for each genomic feature
type (eg CDS, tRNA, rRNA, ncRNA, etc.).
This script serves as a reference implementation of code fragments
from bio::ViennaNGS::AnnoC and has been successfully tested with
NCBI's bacterial annotation in GFF3 format.
Please note that this script is NOT meant to be run on GFF genome
annotation other than bacteria since it DOES NOT consider splice
events present in most higher organisms.
=head1 OPTIONS
=over
=item B<--gff>
Input GFF file.
=item B<--feature -f>
Specify feature type (eg. CDS,tRNA,rRNA,SBS, etc) to be extracted from GFF3.
=item B<--out -o>
Output path.
=item B<--help -h>
Print short help
=item B<--man>
Prints the manual page and exits
=back
=head1 AUTHOR
Michael T. Wolfinger E<lt>michael@wolfinger.euE<gt>
=cut
( run in 1.312 second using v1.01-cache-2.11-cpan-364913b4093 )