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

« back to all changes in this revision

Viewing changes to scripts/Bio-DB-GFF/bp_meta_gff.pl

  • 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/perl
 
2
 
 
3
use strict;
 
4
use warnings;
 
5
use DBI;
 
6
use Getopt::Long;
 
7
use Bio::DB::GFF;
 
8
 
 
9
=head1 NAME
 
10
 
 
11
bp_meta_gff.pl - Get/set Bio::DB::GFF meta-data
 
12
 
 
13
=head1 SYNOPSIS
 
14
 
 
15
  # set the following meta data values
 
16
  % bp_meta_gff.pl -d testdb tag1=value1 tag2=value2
 
17
 
 
18
  # get the indicated meta data value
 
19
  % bp_meta_gff.pl -d testdb tag1 tag2
 
20
 
 
21
=head1 DESCRIPTION
 
22
 
 
23
This script gets or sets metadata in a Bio::DB::GFF database.  Not all
 
24
adaptors support this operation!  To set a series of tags, pass a set
 
25
of tag=value pairs to the script.  To get the contents of a series of
 
26
tags, pass the bare tag names.
 
27
 
 
28
The output from the get operation will be an easily parseable set of
 
29
tag=value pairs, one per line.
 
30
 
 
31
=head1 COMMAND-LINE OPTIONS
 
32
 
 
33
Command-line options can be abbreviated to single-letter options.
 
34
e.g. -d instead of --database.
 
35
 
 
36
   --database <dsn>      Mysql database name (default dbi:mysql:test)
 
37
   --adaptor <adaptor>   Mysql adaptor (default dbi::mysqlopt)
 
38
   --user    <user>      Username for mysql authentication
 
39
   --pass    <password>  Password for mysql authentication
 
40
 
 
41
=head1 SEE ALSO
 
42
 
 
43
L<Bio::DB::GFF>
 
44
 
 
45
=head1 AUTHOR
 
46
 
 
47
Lincoln Stein, lstein@cshl.org
 
48
 
 
49
Copyright (c) 2002 Cold Spring Harbor Laboratory
 
50
 
 
51
This library is free software; you can redistribute it and/or modify
 
52
it under the same terms as Perl itself.  See DISCLAIMER.txt for
 
53
disclaimers of warranty.
 
54
 
 
55
=cut
 
56
 
 
57
my ($DSN,$ADAPTOR,$USER,$PASSWORD);
 
58
 
 
59
GetOptions ('database:s'    => \$DSN,
 
60
            'adaptor:s'     => \$ADAPTOR,
 
61
            'user:s'      => \$USER,
 
62
            'password:s'  => \$PASSWORD,
 
63
           ) or (system('pod2text', $0), exit -1);
 
64
 
 
65
$DSN     ||= 'dbi:mysql:test';
 
66
$ADAPTOR ||= 'dbi::mysqlopt';
 
67
 
 
68
my @args;
 
69
push @args,(-user=>$USER)     if defined $USER;
 
70
push @args,(-pass=>$PASSWORD) if defined $PASSWORD;
 
71
 
 
72
my $db = Bio::DB::GFF->new(-adaptor=>$ADAPTOR,-dsn => $DSN,@args)
 
73
  or die "Can't open database: ",Bio::DB::GFF->error,"\n";
 
74
 
 
75
for my $pair (@ARGV) {
 
76
  my ($tag,$value) = split /=/,$pair;
 
77
  if ($value) {  # set operation
 
78
    $db->meta($tag,$value);
 
79
    unless ($db->meta($tag) eq $value) {
 
80
      print STDERR "value for '$tag' not set; perhaps this adaptor does not support meta data?\n";
 
81
    }
 
82
  } else {
 
83
    print "$tag=",$db->meta($tag),"\n";
 
84
  }
 
85
}
 
86
 
 
87
__END__