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

« back to all changes in this revision

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