Menu

SrsUrlApi

Hamish McWilliam

Introduction

A Perl implementation of an API for accessing data in SRS via web page retrievals via LWP.

Features supported:

  • Multiple SRS versions: known to work with 5.x, 6.x, 7.x, 8.0 and 8.1
  • Partial support for SRS 8.2.
  • Handling of SRS error messages
  • Configurable pauses between requests, as required for use with public servers such as SRS@EBI
  • Support for retrieval of results in chunks

Examples

  • getCount.pl: get the number of entries matching a query.
  • getDatabanks.pl: list the databanks available from an SRS server.
  • getEntriesList.pl: get the complete entries for an SRS query.
  • getEntriesStr.pl: retrieving entries from SRS using a query.
  • urlgetz.pl: an implementation of a subset of the ''getz'' command-line interface to SRS.
  • srsservers: implementation of the public SRS servers list.

Requirements

Download

For releases see downloads, or for the current state of development see the Subversion repository.

Installation

The module can be installed in the standard Perl way:

perl Makefile.PL
make
make test
make install

Alternatively the module can be used directly by adding the lib/ directory to the Perl @INC path.

NB: the SRS version tests depend on the availability of public SRS servers and some properties of the data available through those servers. Thus these tests may fail due to inability to access a server, or due to data changes. Please take care when interpreting failures in these tests. Since public SRS servers have to be used for these tests the test suites for SRS 6.0 and 8.0 are currently set to be skipped, since we know of no public servers running these versions. If you have access to one of these versions you can enable the appropriate tests by editing the corresponding .t file in the t/ directory, setting the server URL, commenting out the server URL check and uncommenting the test count indicator.

API Documentation

The Srs::BasicApi::SrsUrlApi module contains POD mark-up usable with the perldoc documentation reader. To access this documentation either install the module into your Perl installation, or change the current directory to the lib/ directory containing the module, and run the following command:

perldoc Srs::BasicApi::SrsUrlApi

Example

getEntries.pl

A simple script to get a set of entries from the command-line:

# Load the module
use Srs::BasicApi::SrsUrlApi;
# Usage message
my $usageMsg = "Usage: getEntries.pl <queryStr> [srsUrl]\n";
# Set the defaults
my (%config) = (
                'srsUrl' => 'http://srs.ebi.ac.uk/srs/', # EBI
                'queryStr' => '',
                'htmlMode' => 0,    # ASCII, no HTML markup
                'viewName' => '',   # will default to complete entries
                'chunkSize' => 100, # maximum size of a chunk
);
# Process command-line
if(length(@ARGV) > 0) {
    # First argument is the query
    $config{'queryStr'} = $ARGV[0];
    if($ARGV[1] ne '') {
        # Second is the URL
        $config{'srsUrl'} = $ARGV[1];
    }
}
# Check for query
if($config{'queryStr'} eq '') {
    die "Error: no query specified\n",$usageMsg;
}
# Create a connection object
my $srsUrlApi = Srs::BasicApi::SrsUrlApi->new();
$srsUrlApi->setSrsUrl($config{'srsUrl'});
# How many entries
my $numEntries = $srsUrlApi->getCount($config{'queryStr'});
# Get in chunks
for(my $i=1; $i<=$numEntries; $i+=$config{'chunkSize'}) {
    # Get the chunk as a string
    print $srsUrlApi->getEntriesStr($config{'queryStr'},
                                    $config{'htmlMode'},
                                    $config{'viewName'},
                                    $i,
                                    $config{'chunkSize'}
                                    );
}

To Do

  • Databank information:
    • Field information
    • Subentry information
    • Link information
    • Views/loaders
    • Release
    • Virtual libraries (members)
  • Sessions
    • Access to named permanent and temporary sessions
    • Persistent access through a session (currently no session access used)
    • Project support for permanent sessions: listing and selection
    • Access to query history
  • Views
    • Custom view creation (needs session support)
    • Specification of column and record separators (default: cs = \t, rs = \n)
    • Listing of views applicable to a result/databank
    • SRS 7+ XML from loader functionality
    • Listing of loaders available for result set
    • Retrieval of XML using "Generic Format"
    • Retrieval of XML using "Specific Format"
  • Workarounds for problems with SRS 8.2 wgetz support
  • Tests:
    • Test SRS error messages
    • Tests for SRS 6.0, 7.0 and 8.0 servers
    • Query tests for all SRS versions
  • Sample getz-like client (urlgetz.pl)
    • Default configuration support (~/.urlgetz.rc)
    • -f support (requires custom view support)
    • -vf support (requires custom view support)
    • -sf and -af support to control sequence and alignment formats (requires custom view support)
    • -rs and -cs support for table view separators
    • -lv and -lmin support to view index tokens
    • -lb and -ll support for chunking results
    • -info support for databank details
    • -id support to specify a user ID
    • -sort and -sortDir support to specify sorting for a result set


Project Admins:


MongoDB Logo MongoDB