bin/bioconda-packages

filter: Statementstmt 98.7% 77 / 78 Branchbran 61.1% 22 / 36 Conditioncond 47.2% 17 / 36 MC/DCmcdc 5.5% 1 / 18 Subroutinesub 100% 17 / 17 Podpod n/a totaltotal 72.4% 134 / 185 CC 36 SCAR 21.2
CC
36
Cov
77%
cmd_info
20.0
cmd_version
11.7
cmd_rdeps
4.6
CRAP 8.4
« blib/lib/Bioconda/Packages/DB.pm ↑ Summary blib/lib/Bioconda/Packages.pm »
1 #!/usr/bin/env perl
2 14 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 14 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 14 ▶use FindBin qw($RealBin);
Subroutine BEGIN: called CC=1 SCAR=0.0
5 14 ▶use lib "$RealBin/../lib";
Subroutine BEGIN: called CC=1 SCAR=0.0
6 14 ▶use Getopt::Long qw(GetOptions);
Subroutine BEGIN: called CC=1 SCAR=0.0
7 14 ▶use Bioconda::Packages;
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 =head1 NAME
10  
11 bioconda-packages - Offline query tool for the bundled Bioconda package database
12  
13 =head1 SYNOPSIS
14  
15 bioconda-packages <command> [args] [options]
16  
17 # Package information
18 bioconda-packages info samtools
19 bioconda-packages versions samtools
20  
21 # Dependencies
22 bioconda-packages deps multiqc # run-time deps (default)
23 bioconda-packages deps multiqc --kind host # host deps
24 bioconda-packages deps multiqc --kind all # all dep kinds
25  
26 # Reverse dependencies
27 bioconda-packages rdeps zlib # who uses zlib at run time
28 bioconda-packages rdeps zlib --kind build # who uses it at build time
29 bioconda-packages rdeps zlib --all # include removed packages
30  
31 # Search & listing
32 bioconda-packages search aligner
33 bioconda-packages search aligner --all # include removed packages
34 bioconda-packages list
35 bioconda-packages list --all
36  
37 # Database housekeeping
38 bioconda-packages removed
39 bioconda-packages stats
40 bioconda-packages version
41  
42 =head1 COMMANDS
43  
44 =over 4
45  
46 =item B<info> I<PACKAGE>
47  
48 Print a summary for I<PACKAGE>: current version, one-line description, license,
49 homepage, documentation URL, noarch flag, download count, known identifiers, and
50 the number of run-time dependencies.
51  
52 =item B<deps> I<PACKAGE>
53  
54 List dependencies of I<PACKAGE>. Defaults to run-time deps; use C<--kind> to
55 select C<run>, C<host>, C<build>, or C<all>. Each line is C<name> or
56 C<name constraint>.
57  
58 =item B<versions> I<PACKAGE>
59  
60 List every version of I<PACKAGE> that is recorded in the database, one per line.
61  
62 =item B<search> I<TERM>
63  
64 Search package names and summaries for I<TERM> (case-insensitive substring
65 match) and print matching package names. Pass C<--all> to include packages that
66 have been removed from the bioconda recipe tree.
67  
68 =item B<rdeps> I<PACKAGE>
69  
70 Print packages that depend on I<PACKAGE>. Defaults to run-time reverse deps;
71 use C<--kind> (C<run>|C<host>|C<build>|C<all>). Pass C<--all> to include
72 removed packages.
73  
74 =item B<list>
75  
76 Print the name of every package in the database, one per line. Pass C<--all>
77 to include removed packages.
78  
79 =item B<removed>
80  
81 Print the names of all packages that have been removed from the bioconda recipe
82 tree but are still tracked in the database.
83  
84 =item B<stats>
85  
86 Print database statistics: version, total / current / removed package counts,
87 noarch count, build timestamp, and the upstream recipes commit.
88  
89 =item B<version>
90  
91 Print the tool version (C<Bioconda::Packages> module version) and, if the
92 database can be located, its version, file path, build timestamp, generator
93 identifier, package count, and the bioconda-recipes commit it was built from.
94  
95 =back
96  
97 =head1 OPTIONS
98  
99 =over 4
100  
101 =item B<--db> I<PATH>
102  
103 Load the database from I<PATH> instead of the default location. The default
104 search order is: (1) C<BIOCONDA_PACKAGES_DB> environment variable, (2)
105 C<File::ShareDir> installed location, (3) C<share/bioconda-packages.json.gz>
106 relative to the module file.
107  
108 =item B<--kind> I<KIND>
109  
110 Dependency kind for C<deps> and C<rdeps>. One of C<run> (default), C<host>,
111 C<build>, or C<all>.
112  
113 =item B<--all>
114  
115 Include packages that have been removed from the bioconda recipe tree in
116 C<search>, C<list>, and C<rdeps> output.
117  
118 =item B<--version>, B<-V>
119  
120 Print the tool and database version, then exit.
121  
122 =item B<--help>
123  
124 Show this manual page and exit.
125  
126 =back
127  
128 =head1 ENVIRONMENT
129  
130 =over 4
131  
132 =item C<BIOCONDA_PACKAGES_DB>
133  
134 Override the database path without using C<--db>.
135  
136 =back
137  
138 =head1 SEE ALSO
139  
140 L<Bioconda::Packages>, L<Bioconda::Packages::Package>
141  
142 =head1 AUTHOR
143  
144 Andrea Telatin, Quadram Institute Bioscience (2026)
145  
146 =cut
147  
148 14 my %opt = (kind => undef, all => 0);
149 GetOptions(
150 'db=s' => \$opt{db},
151 'kind=s' => \$opt{kind},
152 'all' => \$opt{all},
153 'version|V' => \$opt{version},
154 'help' => \$opt{help},
155 14 ▶) or die "Bad arguments. Try --help.\n";
Branch: 1 branch
BranchTrueFalseTotal
&GetOptions("db=s", \$opt{"db"}, "kind=s", \$opt{"kind"}, "all", \$opt{"all"}, "version|V", \$opt{"version"}, "help", \$opt{"help"}) or die "Bad arguments. Try --help.\n" 14 0 14
156  
157 14 ▶exec('perldoc', $0) if $opt{help};
Branch: 1 branch
BranchTrueFalseTotal
if $opt{"help"} 0 14 14
158  
159 14 ▶my $cmd = $opt{version} ? 'version' : (shift @ARGV or die usage());
Branch: 1 branch
BranchTrueFalseTotal
$opt{'version'} ? : 0 14 14
Condition50%1/2
shift @ARGV or die usage()
l!l
140
MC/DC0%0/1
shift @ARGV or die usage()
shift @ARGV
Truth table50%1/2
A
A= shift @ARGV
Aresult
11
00
160  
161 # 'version' must work even if the database cannot be located.
162 14 ▶if ($cmd eq 'version') { cmd_version(); exit 0 }
Branch: 1 branch
BranchTrueFalseTotal
if ($cmd eq "version") 1 13 14
163  
164 13 ▶my $bp = Bioconda::Packages->new($opt{db} ? (db => $opt{db}) : ());
Branch: 1 branch
BranchTrueFalseTotal
$opt{'db'} ? : 13 0 13
165  
166 13 my %dispatch = (
167 info => \&cmd_info,
168 deps => \&cmd_deps,
169 versions => \&cmd_versions,
170 search => \&cmd_search,
171 rdeps => \&cmd_rdeps,
172 removed => \&cmd_removed,
173 stats => \&cmd_stats,
174 list => \&cmd_list,
175 );
176  
177 13 ▶my $handler = $dispatch{$cmd} or die "Unknown command '$cmd'.\n", usage();
Branch: 1 branch
BranchTrueFalseTotal
my $handler = $dispatch{$cmd} or die "Unknown command '${cmd}'.\n", usage() 12 1 13
178 12 $handler->();
179  
180 1 ▶sub usage {
Subroutine usage: called CC=1 SCAR=0.0
181 1 return "Usage: bioconda-packages <info|deps|versions|search|rdeps|removed|list|stats|version> [args]\n";
182 }
183  
184 1 ▶sub cmd_version {
Subroutine cmd_version: called CC=9 SCAR=24.6
185 1 ▶ printf "bioconda-packages (Bioconda::Packages) %s\n",
Condition50%1/2
"Bioconda::Packages"->VERSION // "dev"
l!l
10
MC/DC0%0/1
"Bioconda::Packages"->VERSION // "dev"
"Bioconda::Packages"->VERSION
Truth table50%1/2
A
A= "Bioconda::Packages"->VERSION
Aresult
11
00
186 Bioconda::Packages->VERSION // 'dev';
187 1 ▶ my $bp = eval { Bioconda::Packages->new($opt{db} ? (db => $opt{db}) : ()) };
Branch: 1 branch
BranchTrueFalseTotal
$opt{'db'} ? : 1 0 1
188 1 ▶ if ($bp) {
Branch: 1 branch
BranchTrueFalseTotal
if ($bp) { } 1 0 1
189 1 my $m = $bp->meta;
190 1 ▶ printf "database version: %s\n", $m->{db_version} // '(unversioned)';
Condition50%1/2
$m->{"db_version"} // "(unversioned)"
l!l
10
MC/DC0%0/1
$m->{"db_version"} // "(unversioned)"
$m->{"db_version"}
Truth table50%1/2
A
A= $m->{"db_version"}
Aresult
11
00
191 1 printf "database: %s\n", $bp->db_path;
192 printf " built from: bioconda-recipes %s\n",
193 1 ▶ $m->{recipes_commit} // 'unknown';
Condition50%1/2
$m->{"recipes_commit"} // "unknown"
l!l
10
MC/DC0%0/1
$m->{"recipes_commit"} // "unknown"
$m->{"recipes_commit"}
Truth table50%1/2
A
A= $m->{"recipes_commit"}
Aresult
11
00
194 1 ▶ printf " generated at: %s\n", $m->{generated_at} // '-';
Condition50%1/2
$m->{"generated_at"} // "-"
l!l
10
MC/DC0%0/1
$m->{"generated_at"} // "-"
$m->{"generated_at"}
Truth table50%1/2
A
A= $m->{"generated_at"}
Aresult
11
00
195 1 ▶ printf " packages: %s\n", $m->{package_count} // '-';
Condition50%1/2
$m->{"package_count"} // "-"
l!l
10
MC/DC0%0/1
$m->{"package_count"} // "-"
$m->{"package_count"}
Truth table50%1/2
A
A= $m->{"package_count"}
Aresult
11
00
196 1 ▶ printf " generator: %s\n", $m->{generator} // '-';
Condition50%1/2
$m->{"generator"} // "-"
l!l
10
MC/DC0%0/1
$m->{"generator"} // "-"
$m->{"generator"}
Truth table50%1/2
A
A= $m->{"generator"}
Aresult
11
00
197 }
198 else {
199 0 print "database: (not found)\n";
200 }
201 }
202  
203 5 ▶sub need_pkg {
Subroutine need_pkg: called CC=3 SCAR=11.0
204 5 ▶ my $name = shift @ARGV or die "This command needs a package name.\n";
Branch: 1 branch
BranchTrueFalseTotal
my $name = shift @ARGV or die "This command needs a package name.\n" 5 0 5
205 5 my $pkg = $bp->get($name);
206 5 ▶ die "Package '$name' not found.\n" unless $pkg;
Branch: 1 branch
BranchTrueFalseTotal
unless $pkg 1 4 5
207 4 return $pkg;
208 }
209  
210 2 ▶sub cmd_info {
Subroutine cmd_info: called CC=12 SCAR=30.0
211 2 my $p = need_pkg();
212 1 ▶ printf "%-16s %s%s\n", 'Package:', $p->name,
Branch: 1 branch
BranchTrueFalseTotal
$p->is_removed ? : 0 1 1
Condition0%0/2
$p->removed_at // ""
l!l
00
MC/DC0%0/1
$p->removed_at // ""
$p->removed_at
Truth table0%0/2
A
A= $p->removed_at
Aresult
11
00
213 ($p->is_removed ? " [REMOVED ".($p->removed_at//'')."]" : '');
214 1 ▶ printf "%-16s %s\n", 'Version:', $p->current_version // '-';
Condition50%1/2
$p->current_version // "-"
l!l
10
MC/DC0%0/1
$p->current_version // "-"
$p->current_version
Truth table50%1/2
A
A= $p->current_version
Aresult
11
00
215 1 ▶ printf "%-16s %s\n", 'Summary:', $p->summary // '-';
Condition50%1/2
$p->summary // "-"
l!l
10
MC/DC0%0/1
$p->summary // "-"
$p->summary
Truth table50%1/2
A
A= $p->summary
Aresult
11
00
216 1 ▶ printf "%-16s %s\n", 'License:', $p->license // '-';
Condition50%1/2
$p->license // "-"
l!l
10
MC/DC0%0/1
$p->license // "-"
$p->license
Truth table50%1/2
A
A= $p->license
Aresult
11
00
217 1 ▶ printf "%-16s %s\n", 'Home:', $p->home // '-';
Condition50%1/2
$p->home // "-"
l!l
01
MC/DC0%0/1
$p->home // "-"
$p->home
Truth table50%1/2
A
A= $p->home
Aresult
11
00
218 1 ▶ printf "%-16s %s\n", 'Doc URL:', $p->doc_url // '-' if $p->doc_url;
Branch: 1 branch
BranchTrueFalseTotal
if $p->doc_url 0 1 1
Condition0%0/2
$p->doc_url // "-"
l!l
00
MC/DC0%0/1
$p->doc_url // "-"
$p->doc_url
Truth table0%0/2
A
A= $p->doc_url
Aresult
11
00
219 1 ▶ printf "%-16s %s\n", 'noarch:', $p->noarch if $p->noarch;
Branch: 1 branch
BranchTrueFalseTotal
if $p->noarch 0 1 1
220 1 ▶ printf "%-16s %s\n", 'Downloads:', $p->downloads if defined $p->downloads;
Branch: 1 branch
BranchTrueFalseTotal
if defined $p->downloads 0 1 1
221 1 my @ids = $p->identifiers;
222 1 ▶ printf "%-16s %s\n", 'Identifiers:', join(', ', @ids) if @ids;
Branch: 1 branch
BranchTrueFalseTotal
if @ids 0 1 1
223 1 printf "%-16s %s\n", 'Run deps:', scalar($p->dependencies('run'));
224 }
225  
226 2 ▶sub cmd_deps {
Subroutine cmd_deps: called CC=4 SCAR=13.9
227 2 my $p = need_pkg();
228 2 ▶ my $kind = $opt{kind} || 'run';
Condition100%2/2
$opt{'kind'} || 'run'
l!l
11
MC/DC100%1/1
$opt{'kind'} || 'run'
$opt{'kind'}
Truth table100%2/2
A
A= $opt{'kind'}
Aresult
11
00
229 2 for my $d ($p->dependencies($kind)) {
230 printf "%s%s\n", $d->{name},
231 2 ▶ (defined $d->{constraint} ? " $d->{constraint}" : '');
Branch: 1 branch
BranchTrueFalseTotal
defined $d->{'constraint'} ? : 1 1 2
232 }
233 }
234  
235 1 ▶sub cmd_versions {
Subroutine cmd_versions: called CC=2 SCAR=6.9
236 1 my $p = need_pkg();
237 1 print "$_\n" for $p->versions;
238 }
239  
240 3 ▶sub cmd_search {
Subroutine cmd_search: called CC=3 SCAR=11.4
241 3 ▶ my $term = shift @ARGV or die "search needs a term.\n";
Branch: 1 branch
BranchTrueFalseTotal
my $term = shift @ARGV or die "search needs a term.\n" 3 0 3
242 3 print "$_\n" for $bp->search($term, include_removed => $opt{all});
243 }
244  
245 1 ▶sub cmd_rdeps {
Subroutine cmd_rdeps: called CC=4 SCAR=15.2
246 1 ▶ my $name = shift @ARGV or die "rdeps needs a package name.\n";
Branch: 1 branch
BranchTrueFalseTotal
my $name = shift @ARGV or die "rdeps needs a package name.\n" 1 0 1
247 1 ▶ print "$_\n" for $bp->reverse_dependencies(
Condition50%1/2
$opt{'kind'} || 'run'
l!l
10
MC/DC0%0/1
$opt{'kind'} || 'run'
$opt{'kind'}
Truth table50%1/2
A
A= $opt{'kind'}
Aresult
11
00
248 $name, kind => ($opt{kind} || 'run'), include_removed => $opt{all});
249 }
250  
251 1 ▶sub cmd_removed {
Subroutine cmd_removed: called CC=2 SCAR=6.9
252 1 print "$_\n" for $bp->removed;
253 }
254  
255 1 ▶sub cmd_list {
Subroutine cmd_list: called CC=2 SCAR=6.9
256 1 print "$_\n" for $bp->list(include_removed => $opt{all});
257 }
258  
259 1 ▶sub cmd_stats {
Subroutine cmd_stats: called CC=4 SCAR=14.2
260 1 my %s = $bp->stats;
261 1 ▶ printf "Database version: %s\n", $s{db_version} // '(unversioned)';
Condition50%1/2
$s{"db_version"} // "(unversioned)"
l!l
10
MC/DC0%0/1
$s{"db_version"} // "(unversioned)"
$s{"db_version"}
Truth table50%1/2
A
A= $s{"db_version"}
Aresult
11
00
262 1 printf "Total packages: %d\n", $s{total};
263 1 printf "Current: %d\n", $s{current};
264 1 printf "Removed: %d\n", $s{removed};
265 1 printf "noarch: %d\n", $s{noarch};
266 1 ▶ printf "Generated at: %s\n", $s{generated_at} // '-';
Condition50%1/2
$s{"generated_at"} // "-"
l!l
10
MC/DC0%0/1
$s{"generated_at"} // "-"
$s{"generated_at"}
Truth table50%1/2
A
A= $s{"generated_at"}
Aresult
11
00
267 1 ▶ printf "Recipes commit: %s\n", $s{recipes_commit} // '-';
Condition50%1/2
$s{"recipes_commit"} // "-"
l!l
10
MC/DC0%0/1
$s{"recipes_commit"} // "-"
$s{"recipes_commit"}
Truth table50%1/2
A
A= $s{"recipes_commit"}
Aresult
11
00
268 }
« blib/lib/Bioconda/Packages/DB.pm ↑ Summary blib/lib/Bioconda/Packages.pm »