Debian Codegraph @

bin/bp_einfo

raw
1 #!/usr/bin/perl
2
3 use strict;
4 use warnings;
5
6 # PODNAME: bp_einfo
7 # ABSTRACT: Query einfo to find all available databases or information about a specific database (field information or links to other NCBI databases).
8 # AUTHOR: Chris Fields <[email protected]>
9 # OWNER: 2009-2012 Chris Fields
10 # LICENSE: Perl_5
11
12
13 use Getopt::Long;
14 use Bio::DB::EUtilities;
15
16 my ($db, @fields, @links, $outfile, $email, $api_key);
17 GetOptions(
18 'e|email:s' => \$email,
19 'a|api_key:s' => \$api_key,
20 'd|db|database:s' => \$db,
21 'f|field:s' => \@fields,
22 'l|link:s' => \@links,
23 'o|out|outfile:s' => \$outfile,
24 'h|help' => sub { exec('perldoc',$0); exit; }
25 );
26
27 my $outfh;
28 if( $outfile ) {
29 open($outfh, ">$outfile") || die("$outfile: $!");
30 } else {
31 $outfh = \*STDOUT;
32 }
33
34 if (!defined $db) {
35 my $eutil = Bio::DB::EUtilities->new(-eutil => 'einfo',
36 -api_key => $api_key,
37 -email => $email);
38 print $outfh join("\n",$eutil->get_available_databases);
39 exit;
40 } else {
41 my $eutil = Bio::DB::EUtilities->new(-eutil => 'einfo',
42 -db => $db,
43 -api_key => $api_key,
44 -email => $email);
45 if (@links || @fields) {
46 for my $fi ($eutil->get_FieldInfo) {
47 my $code = $fi->get_field_code;
48 if (grep {$_ eq $code} @fields) {
49 print $outfh $fi->to_string."\n";
50 }
51 }
52 for my $li ($eutil->get_LinkInfo) {
53 my $nm = $li->get_link_name;
54 if (grep {$_ eq $nm} @links) {
55 print $outfh $li->to_string."\n";
56 }
57 }
58 } else {
59 $eutil->print_FieldInfo;
60 $eutil->print_LinkInfo;
61 }
62 }
63
64 __END__
65
66 =pod
67
68 =encoding UTF-8
69
70 =head1 NAME
71
72 bp_einfo - Query einfo to find all available databases or information about a specific database (field information or links to other NCBI databases).
73
74 =head1 VERSION
75
76 version 1.77
77
78 =head1 SYNOPSIS
79
80 bp_einfo [-d database] [-f Field Code] [-l Link Name] [-o outfile]
81
82 =head1 DESCRIPTION
83
84 Command line options:
85
86 -e/--email
87 Valid email (required by NCBI policy)
88
89 -d/--db/--database
90 NCBI database to query
91 (default = none, which shows available databases)
92
93 -f/--field
94 print out information about a specific field code
95 (default = none)
96
97 -l/--link
98 print out information about a specific link name
99 (default = none)
100
101 -o/--out
102 outfile
103 (default = STDOUT)
104
105 -h/--help
106 show this documentation
107 -a/api_key
108 NCBI API key (recommended)
109
110 As per NCBI's policy regarding eutils access, a valid email is required. This
111 is not enforced here (if one is provided you will get a standard warning), but
112 don't be surprised if this doesn't work after June 1, 2010 unless one is
113 supplied.
114
115 If -d is not specified, field and link arguments are ignored and all available
116 databases are printed instead.
117
118 If either link names or field codes (or both) are specified, nothing else is
119 printed out (only the info requested). You can specify as many fields and/or
120 links as you want by using multiple -f/-l E<lt>ARGE<gt> on the command line.
121
122 =head1 FEEDBACK
123
124 =head2 Mailing lists
125
126 User feedback is an integral part of the evolution of this and other
127 Bioperl modules. Send your comments and suggestions preferably to
128 the Bioperl mailing list. Your participation is much appreciated.
129
130 [email protected] - General discussion
131 https://bioperl.org/Support.html - About the mailing lists
132
133 =head2 Support
134
135 Please direct usage questions or support issues to the mailing list:
136 I<[email protected]>
137 rather than to the module maintainer directly. Many experienced and
138 reponsive experts will be able look at the problem and quickly
139 address it. Please include a thorough description of the problem
140 with code and data examples if at all possible.
141
142 =head2 Reporting bugs
143
144 Report bugs to the Bioperl bug tracking system to help us keep track
145 of the bugs and their resolution. Bug reports can be submitted via the
146 web:
147
148 https://github.com/bioperl/bio-eutilities/issues
149
150 =head1 AUTHOR
151
152 Chris Fields <[email protected]>
153
154 =head1 COPYRIGHT
155
156 This software is copyright (c) 2009-2012 by Chris Fields.
157
158 This software is available under the same terms as the perl 5 programming language system itself.
159
160 =cut