~ubuntu-branches/ubuntu/trusty/bioperl/trusty

« back to all changes in this revision

Viewing changes to scripts/Bio-DB-SeqFeature-Store/bp_seqfeature_gff3.PLS

  • Committer: Package Import Robot
  • Author(s): Charles Plessy
  • Date: 2013-09-22 13:39:48 UTC
  • mfrom: (3.1.11 sid)
  • Revision ID: package-import@ubuntu.com-20130922133948-c6z62zegjyp7ztou
Tags: 1.6.922-1
* New upstream release.
* Replaces and Breaks grinder (<< 0.5.3-3~) because of overlaping contents.
  Closes: #722910
* Stop Replacing and Breaking bioperl ( << 1.6.9 ): not needed anymore. 

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#!/usr/bin/env perl
2
 
# AUTHOR: malcolm.cook@stowers-institute.org
3
 
 
4
 
use strict;
5
 
 
6
 
use Carp;
7
 
use Getopt::Long;
8
 
use File::Spec;
9
 
use Bio::DB::SeqFeature::Store;
10
 
 
11
 
#use Carp::Always;
12
 
 
13
 
my $DSN;
14
 
my $ADAPTOR;
15
 
my $VERBOSE  = 1;
16
 
my $USER     = '';
17
 
my $PASS     = '';
18
 
my @gff3opt;
19
 
 
20
 
GetOptions(
21
 
           'dsn=s'       => \$DSN,
22
 
           'adaptor=s'   => \$ADAPTOR,
23
 
           'user=s'      => \$USER,
24
 
           'password=s'  => \$PASS,
25
 
           'gff3opt=i{,}'    => \@gff3opt,
26
 
          ) || die <<END;
27
 
Usage: $0 [options] -- [WHICH FEATURES]
28
 
  output GFF3 for selected database features
29
 
  Options:
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)
35
 
 
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().
39
 
 
40
 
END
41
 
 
42
 
$ADAPTOR     ||= 'DBI::mysql';
43
 
$DSN         ||= $ADAPTOR eq 'DBI::mysql' ? "mysql_read_default_file=$ENV{HOME}/.my.cnf" : '';
44
 
 
45
 
my $store = Bio::DB::SeqFeature::Store->new(
46
 
                                            -dsn     => $DSN,
47
 
                                            -adaptor => $ADAPTOR,
48
 
                                            -user    => $USER,
49
 
                                            -pass    => $PASS,
50
 
                                           )
51
 
  or die "Couldn't create connection to the database";
52
 
 
53
 
# on signals, give objects a chance to call their DESTROY methods
54
 
$SIG{TERM} = $SIG{INT} = sub {   undef $store; die "Aborted..."; };
55
 
 
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";
65
 
  }
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";
70
 
  }
71
 
  else {
72
 
    confess "sequence object $seq does not support gff3_string() or gff_string() methods!"
73
 
  }
74
 
}
75
 
 
76
 
exit 0;