3a33c42de3131c7f376c77a06849bc8b3dc53919 hiram Mon Apr 29 08:51:22 2019 -0700 eliminate the db argument replaced by genome arg refs #18869 diff --git src/hg/hubApi/tests/jsonConsumer.pl src/hg/hubApi/tests/jsonConsumer.pl index f8138fe..1911fa7 100755 --- src/hg/hubApi/tests/jsonConsumer.pl +++ src/hg/hubApi/tests/jsonConsumer.pl @@ -1,59 +1,58 @@ #!/usr/bin/env perl use strict; use warnings; use HTTP::Tiny; use Time::HiRes; use JSON; use Getopt::Long; my $http = HTTP::Tiny->new(); # my $server = 'https://apibeta.soe.ucsc.edu'; -# my $server = 'https://api-test.gi.ucsc.edu'; +my $server = 'https://api-test.gi.ucsc.edu'; # my $server="https://genome-euro.ucsc.edu/cgi-bin/loader/hubApi"; -my $server = 'https://hgwdev-api.gi.ucsc.edu'; +# my $server = 'https://hgwdev-api.gi.ucsc.edu'; # my $server = 'https://hgwbeta.soe.ucsc.edu/cgi-bin/hubApi'; my $globalHeaders = { 'Content-Type' => 'application/json' }; my $lastRequestTime = Time::HiRes::time(); my $processStartTime = Time::HiRes::time(); my $requestCount = 0; ############################################################################## # command line options my $endpoint = ""; my $hubUrl = ""; my $genome = ""; -my $db = ""; my $track = ""; my $chrom = ""; my $start = ""; my $end = ""; my $test0 = 0; my $debug = 0; my $trackLeavesOnly = 0; my $measureTiming = 0; my $jsonOutputArrays = 0; my $maxItemsOutput = ""; ############################################################################## sub usage() { printf STDERR "usage: ./jsonConsumer.pl [arguments]\n"; printf STDERR "arguments: -test0 - perform test of /list/publicHubs and /list/ucscGenomes endpoints -hubUrl=<URL> - use the URL to access the track or assembly hub --db=<dbName> - use one of the UCSC databases for data access +-genome=<name> - name for UCSC database genome or assembly/track hub genome -track=<trackName> - specify a single track in a hub or database -chrom=<chromName> - restrict the operation to a single chromosome -start=<coordinate> - restrict the operation to a range, use both start and end -end=<coordinate> - restrict the operation to a range, use both start and end -maxItemsOutput=<N> - limit output to this number of items. Default 1,000 maximum allowed 1,000,000 -trackLeavesOnly - for list tracks function, no containers listed -measureTimeing - turn on timing measurement -debug - turn on debugging business -endpoint=<function> - where <function> is one of the following: /list/publicHubs - provide a listing of all available public hubs /list/ucscGenomes - provide a listing of all available UCSC genomes /list/hubGenomes - list genomes from a specified hub (with hubUrl=...) /list/tracks - list data tracks available in specified hub or database genome /list/chromosomes - list chromosomes from specified data track @@ -231,102 +230,87 @@ ############################################################################# sub processEndPoint() { my $errReturn = 0; if (length($endpoint)) { my $json = JSON->new; my $jsonReturn = {}; if ($endpoint eq "/list/hubGenomes") { my %parameters; # allow no hubUrl argument to test error reports if (length($hubUrl)) { $parameters{"hubUrl"} = "$hubUrl"; } if (length($genome)) { $parameters{"genome"} = "$genome"; } - if (length($db)) { - $parameters{"db"} = "$db"; - } $jsonReturn = performJsonAction($endpoint, \%parameters); $errReturn = 1 if (defined ($jsonReturn->{'error'})); printf "%s", $json->pretty->encode( $jsonReturn ); } elsif ($endpoint eq "/list/tracks") { # no need to verify arguments here, pass them along, or not, # so that error returns can be verified my %parameters; if ($trackLeavesOnly) { $parameters{"trackLeavesOnly"} = "1"; } - if (length($db)) { - $parameters{"db"} = "$db"; - } # allow no hubUrl argument to test error reports if (length($hubUrl)) { $parameters{"hubUrl"} = "$hubUrl"; } # allow call to go through without a genome specified to test error if (length($genome)) { $parameters{"genome"} = "$genome"; } $jsonReturn = performJsonAction($endpoint, \%parameters); $errReturn = 1 if (defined ($jsonReturn->{'error'})); printf "%s", $json->pretty->encode( $jsonReturn ); } elsif ($endpoint eq "/list/chromosomes") { my %parameters; - if (length($db)) { - $parameters{"db"} = "$db"; - } if (length($hubUrl)) { $parameters{"hubUrl"} = "$hubUrl"; } # allow call to go through without a genome specified to test error if (length($genome)) { $parameters{"genome"} = "$genome"; } if (length($track)) { $parameters{"track"} = "$track"; } $jsonReturn = performJsonAction($endpoint, \%parameters); $errReturn = 1 if (defined ($jsonReturn->{'error'})); printf "%s", $json->pretty->encode( $jsonReturn ); } elsif ($endpoint eq "/getData/sequence") { my %parameters; - if (length($db)) { - $parameters{"db"} = "$db"; - } if (length($hubUrl)) { $parameters{"hubUrl"} = "$hubUrl"; } # allow call to go through without a genome specified to test error if (length($genome)) { $parameters{"genome"} = "$genome"; } if (length($chrom)) { $parameters{"chrom"} = "$chrom"; } if (length($start)) { $parameters{"start"} = "$start"; $parameters{"end"} = "$end"; } $jsonReturn = performJsonAction($endpoint, \%parameters); $errReturn = 1 if (defined ($jsonReturn->{'error'})); printf "%s", $json->pretty->encode( $jsonReturn ); } elsif ($endpoint eq "/getData/track") { my %parameters; - if (length($db)) { - $parameters{"db"} = "$db"; - } if (length($hubUrl)) { $parameters{"hubUrl"} = "$hubUrl"; } # allow call to go through without a genome specified to test error if (length($genome)) { $parameters{"genome"} = "$genome"; } if (length($track)) { $parameters{"track"} = "$track"; } if (length($chrom)) { $parameters{"chrom"} = "$chrom"; } if (length($start)) { $parameters{"start"} = "$start"; @@ -424,31 +408,30 @@ my $endTime = Time::HiRes::time(); my $et = $endTime - $processStartTime; printf STDERR "# procesing time: %.3fs\n", $et; } } ############################################################################# ### main() ############################################################################# my $argc = scalar(@ARGV); GetOptions ("hubUrl=s" => \$hubUrl, "endpoint=s" => \$endpoint, "genome=s" => \$genome, - "db=s" => \$db, "track=s" => \$track, "chrom=s" => \$chrom, "start=s" => \$start, "end=s" => \$end, "test0" => \$test0, "debug" => \$debug, "trackLeavesOnly" => \$trackLeavesOnly, "measureTiming" => \$measureTiming, "jsonOutputArrays" => \$jsonOutputArrays, "maxItemsOutput=s" => \$maxItemsOutput) or die "Error in command line arguments\n"; if ($test0) { test0; elapsedTime();