2
# AUTHOR: malcolm.cook@stowers-institute.org
9
use Bio::DB::SeqFeature::Store;
22
'adaptor=s' => \$ADAPTOR,
24
'password=s' => \$PASS,
25
'gff3opt=i{,}' => \@gff3opt,
27
Usage: $0 [options] -- [WHICH FEATURES]
28
output GFF3 for selected database features
30
-d --dsn The database name ($DSN)
31
-a --adaptor The storage adaptor to use ($ADAPTOR)
32
-u --user User to connect to database as
33
-p --password Password to use to connect to database
34
-g --gff3opt flag options to gff3_string (i.e.: pass -gffopt 1 to recurse)
36
WHICH FEATURES: any remaining options after '--' will select
37
a subset of features. The arguments are identical to those
38
accepted by Bio::DB::SeqFeature::Store->features().
42
$ADAPTOR ||= 'DBI::mysql';
43
$DSN ||= $ADAPTOR eq 'DBI::mysql' ? "mysql_read_default_file=$ENV{HOME}/.my.cnf" : '';
45
my $store = Bio::DB::SeqFeature::Store->new(
51
or die "Couldn't create connection to the database";
53
# on signals, give objects a chance to call their DESTROY methods
54
$SIG{TERM} = $SIG{INT} = sub { undef $store; die "Aborted..."; };
56
my $seq_stream = $store->get_seq_stream(@ARGV) or die "failed to get_seq_stream(@ARGV)";
57
while (my $seq = $seq_stream->next_seq) {
58
### 20100725 // genehack
59
# Try to call a gff3_string() method, but fall back to gff_string() if $seq
60
# doesn't support that. Note that gff_string() is required per
61
# Bio::SeqFeatureI, while gff3_string() is not. Currently, only
62
# Bio::SeqFeature::Lite implements gff3_string().
63
if ( $seq->can( 'gff3_string' )) {
64
print $seq->gff3_string(@gff3opt) . "\n";
66
elsif ( $seq->can( 'gff_string' )) {
67
# since we intend on getting a GFF3 string, make sure to pass the version
68
$seq->gff_format->gff_version(3);
69
print $seq->gff_string() . "\n";
72
confess "sequence object $seq does not support gff3_string() or gff_string() methods!"