Bio::Das::ProServer::SourceAdaptor - base class for sources
$Revision: 688 $
A base class implementing stubs for all SourceAdaptors.
SourceAdaptor.pm generates XML and manages callouts for DAS request handling.
If you're extending ProServer, this class is probably what you need to inherit. The build_* methods are probably the ones you need to extend. build_features() in particular.
Roger Pettett <rmp@sanger.ac.uk>
Andy Jenkinson <andy.jenkinson@ebi.ac.uk>
my $oSourceAdaptor = Bio::Das::ProServer::SourceAdaptor::<implementation>->new({ 'dsn' => q(), 'port' => q(), 'hostname' => q(), 'protocol' => q(), 'baseuri' => q(), 'config' => q(), 'debug' => 1, }); Generally this would only be invoked on a subclass
$oSourceAdaptor->init();
my $sSegmentLength = $oSourceAdaptor->length('DYNA_CHICK'); By default returns 0
my $sMapMaster = $oSourceAdaptor->mapmaster(); By default returns configuration 'mapmaster' setting
my $sDescription = $oSourceAdaptor->description(); By default returns configuration 'description' setting or $self->title
my $sDocHref = $oSourceAdaptor->doc_href(); By default returns configuration 'doc_href' setting
my $title = $oSourceAdaptor->title(); By default returns configuration 'title' setting or $self->source_uri
my $uriS = $oSourceAdaptor->source_uri(); By default returns configuration 'source_uri' setting or $self->dsn
my $uriV = $oSourceAdaptor->version_uri(); By default returns configuration 'version_uri' setting or $self->source_uri
my $email = $oSourceAdaptor->maintainer(); By default returns configuration 'maintainer' setting, server setting or an empty string
my $strict = $oSourceAdaptor->strict_boundaries(); # boolean By default returns configuration 'strict_boundaries' setting, server setting or nothing (false)
This call is made by das_features(). It is passed one of:
{ 'segment' => $, 'start' => $, 'end' => $, 'types' => [$,$,...], 'categories' => [$,$,...], 'maxbins' => $ } # if support is indicated by the 'maxbins' capability
OR, if support is indicated by the 'feature-by-id' capability:
{ 'feature_id' => $, 'types' => [$,$,...], 'categories' => [$,$,...], 'maxbins' => $ } # if support is indicated by the 'maxbins' capability
When running in legacy mode, it may also be passed:
{ 'group_id' => $, 'types' => [$,$,...], 'categories' => [$,$,...], 'maxbins' => $ } # if support is indicated by the 'maxbins' capability
The 'types' and 'categories' parameters are filters. They do not need to be honoured as the das_features method will do this for you. They are included in case you wish to use them to improve performance.
The method must return an array of hash references, i.e. ( {},{}...{} )
Each hash returned represents a single feature and should contain a subset of the following keys and types. For scalar types (i.e. numbers and strings) refer to the specification on biodas.org.
segment => $ # segment ID (if not provided) id || feature_id => $ # feature ID label || feature_label => $ # feature text label start => $ # feature start position end => $ # feature end position ori => $ # feature strand phase => $ # feature phase type => $ # feature type ID type_cvid => $ # feature type controlled vocabulary ID typetxt => $ # feature type text label typecategory || type_category => $ # feature type category typesubparts => $ # feature has subparts typesuperparts => $ # feature has superparts typereference => $ # feature is reference method => $ # annotation method ID method_cvid => $ # annotation method controlled vocabulary ID method_label => $ # annotation method text label score => $ # annotation score note => $ or [$,$,$...] # feature text note ########################################################################## # For one or more links: link => $ or [$,$,$...] # feature link href linktxt => $ or [$,$,$...] # feature link label # For hash-based links: link => { $ => $, # href => label ... } ############################################################################### # For a single target: target_id => $ # target ID target_start => $ # target start position target_stop => $ # target end position targettxt => $ # target text label # For multiple targets: target => scalar or [{ id => $, start => $, stop => $, targettxt => $, },{}...] ############################################################################### # For hierarchical relationships: parent => $ or [$,$,$...] # parent feature IDs part => $ or [$,$,$...] # child feature IDs ###############################################################################
When running in legacy mode, the following may also be included:
# For a single group: group_id => $ # feature group ID grouplabel => $ # feature group text label grouptype => $ # feature group type ID groupnote => $ # feature group text note grouplink => $ # feature group ID grouplinktxt => $ # feature group ID # For multiple groups: group => [{ grouplabel => $ grouptype => $ groupnote => $ grouplink => $ grouplinktxt => $ note => $ or [$,$,$...] target => [{ id => $ start => $ stop => $ targettxt => $ }], }, {}...] ###############################################################################
This call is made by das_sequence(). It is passed:
{ 'segment' => $, 'start' => $, 'end' => $ }
It is expected to return a hash reference:
{ seq => $, version => $, # can also be specified with the segment_version method label => $, # optional human readable label }
For details of the data constraints refer to the specification on biodas.org.
This call is made by das_types(). If no specific segments are requested by the client, it is passed no arguments. Otherwise it is passed:
It is expected to return an array of hash references, i.e. ( {},{}...{} )
Each hash returned represents a single type and should contain a subset of the following keys and values. For scalar types (i.e. numbers and strings) refer to the specification on biodas.org.
type => $ # required type_cvid || c_ontology => $ typetxt || description => $ category || typecategory || type_category => $ count => $
This call is made by das_entry_points(). It is not passed any args
and is expected to return an array of hash references, i.e. ( {},{}...{} )
Each hash returned represents a single entry_point and should contain a subset of the following keys and values. For scalar types (i.e. numbers and strings) refer to the specification on biodas.org.
segment => $ length => $ subparts => $ start => $ stop => $ ori => $
This call is made by das_alignment(). It is passed these arguments:
( $, # query ID (either subject or alignment, depending on the source) $, # range of rows (X-Y) [ $, $ ], # subjects (ID[:X,Y]) $, # subject coordinate system $ # range of columns (X-Y) )
The that the query ID is required; all other arguments are optional. The optional arguments pertain to restricting parts of the alignment(s). This method must perform that restriction and should consider the most efficient mechanism to do so, but default implementations exist if needed (see the restrict_alignment_rows and restrict_alignment_columns methods).
The method is expected to return an array of alignment hash references:
( { name => $, description => $, type => $, max => $, position => $, alignObj => [ { id => $, # internal object ID version => $, dbSource => $, dbVersion => $, dbAccession => $, chain => $, # structure chain ID, if applicable dbCoordSys => $, sequence => $, aliObjectDetail => [ { property => $, value => $, dbSource => $, }, ], }, ], scores => [ { method => $, score => $, }, ], blocks => [ { blockOrder => $, blockScore => $, segments => [ { id => $, # internal object ID start => $, end => $, orientation => $, # + / - / undef cigar => $, }, ], ], geo3D => [ { id vector => { x => $, y => $, z => $, }, matrix => [ [$,$,$], # mat11, mat12, mat13 [$,$,$], # mat21, mat22, mat23 [$,$,$], # mat31, mat32, mat33 ], }, ], } )
This method may be called by subclasses in the build_alignment method. It exists as a helper to enable subclasses to easily implement the row filtering capability of the alignment command. It expects these arguments:
( $, # alignment hashref $, # rows, of format START-END [ $, $ ], # subjects, of format ID[:BEFORE,AFTER] $ # subject coordinate system )
Subclasses can pass these arguments as they are received from the das_alignment method verbatim, without modification. This method will modify the alignment hashref and return.
The algorithm will apply two filters: one for each of the 'subjects' and 'rows' arguments. In the former case, the row identified by a subject ID (looking first at the object's dbAccession and then its internal ID) plus a surrounding range (if specified) will be retained. In the latter case, the specific requested rows will be retained. All other rows are discarded. Note that the filter acts on both the alignObjects and segments within the alignment. If after filtering a block contains no segments, it is not retained.
This method may be called by subclasses in the build_alignment method. It exists as a helper to enable subclasses to easily implement the column filtering capability of the alignment command. It expects these arguments:
( $, # alignment hashref $, # cols, of format START-END )
The algorithm will modify the alignment such that only alignment blocks that at least partially lie within the requested range of columns will be retained. Within such blocks, only segments that lie at least partially within the requested range will be retained. Finally, the segment start, end and cigar properties will be adjusted to reflect the new composition of the alignment. Note that the sequence of an alignObject (if present) is never changed - this refers to the entire object rather than a segment of it and is therefore not affected.
This call is made by das_structure(). It is passed these arguments:
( $, # query ID [ $, $ ], # chain ID filters [ $, $ ], # model number filters )
Note that the query ID is required, the other arguments may be empty arrayrefs.
It is expected to return a hash reference representing a structure:
{ # Structure objects: objects => [ dbAccessionId => $, # the ID of the object in the source database objectVersion => $, # the version of the object in the source database dbSource => $, # the source database dbVersion => $, # the version of the source database dbCoordSys => $, # the name of the object's coordinate system objectDetails => [ source => $, # the source of the property property => $, # name detail => $, # value ] ], # Structural chains, containing groups and atoms: chains => [ id => $, modelNumber => $, groups => [ id => $, # unique identifier in the structure name => $, # e.g. ALA type => $, # amino|nucleotide|hetatom icode => $, # insertion code atoms => [ x => $, # X coordinate y => $, z => $, atomId => $, # unique ID within the structure atomName => $, # label, e.g. "CA" occupancy => $, # floating point tempFactor => $, # floating point altLoc => $, # conformation ID ] ], ], # Atom connections: connects => [ type => $, # e.g. bond atomSerial => $, # source atomId atom_ids => [ $, $, $, # target atomId(s) ], ], }
This call is made by das_interaction(). It is passed this structure:
# For request: # /interaction?interactor=$;interactor=$;detail=property:$;detail=property:$,value:$ { interactors => [$, $, ..], details => { $ => undef, # property exists $ => $, # property has a certain value }, }
It is expected to return a hash reference of interactions and interactors where all the requested interactors are part of the interaction:
{ interactors => [ { id => $, label || name => $, dbSource => $, dbSourceCvId => $, # controlled vocabulary ID dbVersion => $, dbAccession => $, dbCoordSys => $, # co-ordinate system sequence => $, details => [ { property => $, value => $, propertyCvId => $, valueCvId => $, start => $, end => $, startStatus => $, endStatus => $, startStatusCvId => $, endStatusCvId => $, }, .. ], }, .. ], interactions => [ { label || name => $, dbSource => $, dbSourceCvId => $, dbVersion => $, dbAccession => $, details => [ { property => $, value => $, propertyCvId => $, valueCvId => $, }, .. ], participants => [ { id => $, details => [ { property => $, value => $, propertyCvId => $, valueCvId => $, start => $, end => $, startStatus => $, endStatus => $, startStatusCvId => $, endStatusCvId => $, }, .. ], }, .. ], }, .. ], }
This call is made by das_volmap(). It is passed a single 'query' argument.
It is expected to return a hash reference for a single volume map:
{ id => $, class => $, type => $, version => $, link => $, # href for data linktxt => $, # text note => $ OR [ $, $, .. ] }
By default - do nothing Not necessary for most circumstances, but useful for deciding on what sort of coordinate system you return the results if more than one type is available. $self->init_segments() is called inside das_features() before build_features().
my @aSegmentNames = $oSourceAdaptor->known_segments();
my $sVersion = $oSourceAdaptor->segment_version($sSegment);
my $sDSN = $oSourceAdaptor->dsn();
my $sDSNVersion = $oSourceAdaptor->dsnversion(); By default returns $self->{'dsnversion'}, configuration 'dsnversion' setting or '1.0'
# e.g. '2007-09-20T15:26:23Z' -- ISO 8601, Coordinated Universal Time # e.g. '2007-09-20T16:26:23+01:00' -- ISO 8601, British Summer Time # e.g. '2007-09-20 07:26:23 -08' -- indicating Pacific Standard Time # e.g. 1190301983 -- UNIX # e.g. '2007-09-20' my $sDSNCreated = $oSourceAdaptor->dsncreated(); By default tries and returns the following: 1. $self->{'dsncreated'} 2. configuration 'dsncreated' setting 3. adaptor's 'last_modified' method (if it exists) 4. zero (epoch)
# e.g. 1190301983 my $sDSNCreated = $oSourceAdaptor->dsncreated_unix();
# e.g. '2007-09-20T15:26:23Z' my $sDSNCreated = $oSourceAdaptor->dsncreated_iso();
my $hCoords = $oSourceAdaptor->coordinates(); Hash contains a key-value pair for each coordinate system, the key being either the URI or description, and the value being a suitable test range. By default returns an empty hash reference
my $aCoords = $oSourceAdaptor->_coordinates(); Returns the fully-annotated co-ordinate systems this adaptor supports, as an array or array reference (depending on context): [ { 'description' => 'NCBI_36,Chromosome,Homo sapiens', 'uri' => 'http://www.dasregistry.org/dasregistry/coordsys/CS_DS40', 'taxid' => '9606', 'authority' => 'NCBI', 'source' => 'Chromosome', 'version' => '36', 'test_range' => '1:11000000,12000000', }, { ... }, ] The co-ordinate system details are read in from disk by Bio::Das::ProServer. By default returns an empty array. DO NOT OVERRIDE THIS METHOD IN SUBCLASSES.
my $hCapabilities = $oSourceAdaptor->capabilities(); Hash contains a key-value pair for each command, the key being the command name, and the value being the implementation version. By default returns an empty hash.
my $hCapabilities = $oSourceAdaptor->_capabilities(); Hash contains a key-value pair for each command, the key being the command name, and the value being the implementation version. By default returns an empty hash. DO NOT OVERRIDE THIS METHOD IN SUBCLASSES.
my $hProps = $oSourceAdaptor->properties(); Hash contains key-scalar or key-array pairs for custom properties. By default returns an empty hash reference
my $sStart = $oSourceAdaptor->start('DYNA_CHICK'); By default returns 1
my $sEnd = $oSourceAdaptor->end('DYNA_CHICK'); By default returns $self->length
my $sUrl = $oSourceAdaptor->server_url();
my $sUrl = $oSourceAdaptor->source_url();
my $oHydra = $oSourceAdaptor->hydra();
my $oTransport = $oSourceAdaptor->transport(); OR my $oTransport1 = $oSourceAdaptor->transport('foo'); my $oTransport2 = $oSourceAdaptor->transport('bar');
my $oAuthenticator = $oSourceAdaptor->authenticator(); Authenticators are built only if explicitly configured in the INI file, e.g.: [mysource] state = on adaptor = simple authenticator = ip See L<Bio::Das::ProServer::Authenticator|Bio::Das::ProServer::Authenticator> for more details.
$oSourceAdaptor->config($oConfig); my $oConfig = $oSourceAdaptor->config();
my $bIsImplemented = $oSourceAdaptor->implements($sDASCall); # e.g. $sDASCall = 'sequence'
my $sHTTPHeader = $oSourceAdaptor->das_capabilities();
my $sXMLResponse = $sa->unknown_segment(); Reference sources (i.e. those implementing the 'sequence' command) will return an <ERRORSEGMENT> element. Annotation sources will return an <UNKNOWNSEGMENT> element.
my $sXMLResponse = $sa->error_segment(); Returns an <ERRORSEGMENT> element.
my $sXMLResponse = $sa->error_feature();
my $sXMLResponse = $sa->das_features(); See the build_features method for details of custom implementations.
my $sXMLResponse = $sa->das_sequence(); See the sequence method for details of custom implementations.
my $sXMLResponse = $sa->das_types(); See the build_types method for details of custom implementations.
my $sXMLResponse = $sa->das_entry_points(); See the build_entry_points method for details of custom implementations.
my $sXMLResponse = $sa->das_interaction(); See the build_interaction method for details of custom implementations.
my $sXMLResponse = $sa->das_volmap(); See the build_volmap method for details of custom implementations.
my $sXMLResponse = $sa->das_stylesheet(); By default will use (in order of preference): the "stylesheet" INI property (inline XML) the "stylesheetfile" INI property (XML file location) the "stylesheetfile" INI property, prepended with the "styleshome" property a default stylesheet
my $sXMLResponse = $sa->das_sourcedata(); Provides information about the DAS source for use in the sources command, such as title, description, coordinates and capabilities.
my $sXMLResponse = $sa->das_dsn();
my $sXSLResponse = $sa->das_xsl();
my $sXMLResponse = $sa->das_alignment(); See the build_alignment method for details of custom implementations. Example Response:
<alignment> <alignObject> <alignObjectDetail /> <sequence /> </alignObject> <score/> <block> <segment> <cigar /> </segment> </block> <geo3D> <vector /> <matrix mat11="float" mat12="float" mat13="float" mat21="float" mat22="float" mat23="float" mat31="float" mat32="float" mat33="float" /> </geo3D> </alignment>
Title : _gen_align_object_response Function : Formats alignment object into dasalignment xml Args : align data structure Returns : Das Response string encapuslating aliObject
Title : _gen_align_score_response Function: Formats input score data structure into dasalignment xml Args : score data structure Returns : Das Response string from alignment score
Title : _gen_align_block_response Function: Formats an input block data structure into : dasalignment xml Args : block data structure Returns : Das Response string from alignmentblock
Title : genAlignGeo3d Function : Formats geo3d data structure into alignment matrix xml Args : data structure containing the vector and matrix Returns : String containing the DAS response xml
Title : das_structure Function : This produces the das repsonse for a pdb structure Args : query options. Currently, this will that query, chain and modelnumber. : The only part of the specification that this does not adhere to is the range argument. : However, I think this argument is a potential can of worms! returns : string containing Das repsonse for the pdb structure comment : See http://www.efamily.org.uk/xml/das/documentation/structure.shtml for more information : on the das structure specification. Example Response: <object dbAccessionId="1A4A" intObjectId="1A4A" objectVersion="29-APR-98" dbSource="PDB" dbVersion="20040621" dbCoordSys="PDBresnum,Protein Structure" /> <chain id="A" SwissprotId="null"> <group name="ALA" type="amino" groupID="1"> <atom atomID="1" atomName=" N " x="-19.031" y="16.695" z="3.708" /> <atom atomID="2" atomName=" CA " x="-20.282" y="16.902" z="4.404" /> <atom atomID="3" atomName=" C " x="-20.575" y="18.394" z="4.215" /> <atom atomID="4" atomName=" O " x="-20.436" y="19.194" z="5.133" /> <atom atomID="5" atomName=" CB " x="-20.077" y="16.548" z="5.883" /> <atom atomID="6" atomName="1H " x="-18.381" y="17.406" z="4.081" /> <atom atomID="7" atomName="2H " x="-18.579" y="15.781" z="3.874" /> <atom atomID="8" atomName="3H " x="-19.018" y="16.844" z="2.68" /> </group> <group name="HOH" type="hetatm" groupID="219"> <atom atomID="3057" atomName=" O " x="-17.904" y="13.635" z="-7.538" /> <atom atomID="3058" atomName="1H " x="-18.717" y="14.098" z="-7.782" /> <atom atomID="3059" atomName="2H " x="-17.429" y="13.729" z="-8.371" /> </group> </chain> <connect atomSerial="26" type="bond"> <atomID atomID="25" /> <atomID atomID="242" /> </connect>
Title : _gen_object_response Function : Formats the supplied structure object data structure into dasstructure xml Args : object data structure Returns : Das Response string encapuslating 'object' Comment : The object response allows the details of the coordinates to be descriped. For example : the fact that the coos are part of a pdb file.
Title : _gen_chain_response Function : Formats the supplied chain object data structure into dasstructure xml Args : chain data structure Returns : Das Response string encapuslating 'chain' Comment : Chain objects contain all of the atom positions (including hetatoms). : The groups are typically residues or ligands.
Title : _gen_connect_response Function : Formats the supplied connect data structure into dasstructure xml Args : connect data structure Returns : Das Response string encapuslating "connect" Comment : Such objects are specified to enable groups of atoms to be connected together.
Used within Bio::Das::ProServer::Config, eg/proserver and of course all subclasses.
set $self->{'debug'} = 1
None reported
Copyright (c) 2008 The Sanger Institute
This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.
To install Bio::Das::ProServer, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Bio::Das::ProServer
CPAN shell
perl -MCPAN -e shell install Bio::Das::ProServer
For more information on module installation, please visit the detailed CPAN module installation guide.