RT 103272 - fix for deleting features that have decimals
[bioperl-live.git] / scripts / Bio-DB-GFF / bp_meta_gff.pl
blob974d2d039a1dc2ba0952d132d163a542e99051fd
1 #!/usr/bin/perl
3 use strict;
4 use warnings;
5 use DBI;
6 use Getopt::Long;
7 use Bio::DB::GFF;
9 =head1 NAME
11 bp_meta_gff.pl - Get/set Bio::DB::GFF meta-data
13 =head1 SYNOPSIS
15 # set the following meta data values
16 % bp_meta_gff.pl -d testdb tag1=value1 tag2=value2
18 # get the indicated meta data value
19 % bp_meta_gff.pl -d testdb tag1 tag2
21 =head1 DESCRIPTION
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.
28 The output from the get operation will be an easily parseable set of
29 tag=value pairs, one per line.
31 =head1 COMMAND-LINE OPTIONS
33 Command-line options can be abbreviated to single-letter options.
34 e.g. -d instead of --database.
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
41 =head1 SEE ALSO
43 L<Bio::DB::GFF>
45 =head1 AUTHOR
47 Lincoln Stein, lstein@cshl.org
49 Copyright (c) 2002 Cold Spring Harbor Laboratory
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.
55 =cut
57 my ($DSN,$ADAPTOR,$USER,$PASSWORD);
59 GetOptions ('database:s' => \$DSN,
60 'adaptor:s' => \$ADAPTOR,
61 'user:s' => \$USER,
62 'password:s' => \$PASSWORD,
63 ) or (system('pod2text', $0), exit -1);
65 $DSN ||= 'dbi:mysql:test';
66 $ADAPTOR ||= 'dbi::mysqlopt';
68 my @args;
69 push @args,(-user=>$USER) if defined $USER;
70 push @args,(-pass=>$PASSWORD) if defined $PASSWORD;
72 my $db = Bio::DB::GFF->new(-adaptor=>$ADAPTOR,-dsn => $DSN,@args)
73 or die "Can't open database: ",Bio::DB::GFF->error,"\n";
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";
82 } else {
83 print "$tag=",$db->meta($tag),"\n";
87 __END__