#!/usr/bin/env perl
use strict;
use warnings FATAL => 'all';
use File::Copy;
use Getopt::Std;
use Pod::Usage;
use Bio::GFF3::Transform::SyncDirectives 'gff3_add_sync_directives';
my %opt;
getopts('i',\%opt) or pod2usage('invalid options');
@ARGV or pod2usage('must provide one or more filenames');
if( $opt{i} ) {
for my $file ( @ARGV ) {
-r $file or die "cannot open file '$file' for reading\n";
my $temp_out = File::Temp->new;
gff3_add_sync_directives( $temp_out, $file );
$temp_out->close;
move( "$temp_out", $file ) or die "cannot overwrite '$file': $!\n";
}
} else {
gff3_add_sync_directives( \*STDOUT, @ARGV );
}
# PODNAME: gff3_insert_sync_directives
# ABSTRACT: efficiently insert sync (###) directives into GFF3, printing to stdout
__END__
=pod
=encoding utf-8
=head1 NAME
gff3_insert_sync_directives - efficiently insert sync (###) directives into GFF3, printing to stdout
=head1 USAGE
gff3_insert_sync_directives file file ... > with_syncs.gff3
Note: because GFF3 is read in reverse order, cannot operate on
streamed input. So no stdin, sorry.
=head2 Options
=over 4
=item -i
Instead of printing to standard output, modify each file in-place.
Similar to perl's -i switch.
=back
=head1 AUTHOR
Robert Buels <rmb32@cornell.edu>
=head1 COPYRIGHT AND LICENSE
This software is copyright (c) 2012 by Robert Buels.
This is free software; you can redistribute it and/or modify it under
the same terms as the Perl 5 programming language system itself.
=cut