org.opentox.toxotis.core.component
Class Algorithm

java.lang.Object
  extended by org.opentox.toxotis.core.OTComponent<T>
      extended by org.opentox.toxotis.core.OTOnlineResource<Algorithm>
          extended by org.opentox.toxotis.core.component.Algorithm
All Implemented Interfaces:
Serializable, IHTMLSupport, IOnlineResource, IOntologyServiceSupport<Algorithm>, IOTComponent, IStAXWritable

public class Algorithm
extends OTOnlineResource<Algorithm>
implements IOntologyServiceSupport<Algorithm>, IHTMLSupport

Provides access to different types of algorithms. An algorithm object contains very general meta-data about an algorithm and in fact describes its input and output requirements and gives information about its parametrization. The different types of algorithms used in OpenTox and the connection to each other is formally established through the OpenTox Algorithm Ontology.

Author:
Pantelis Sopasakis, Charalampos Chomenides
See Also:
Serialized Form

Field Summary
 
Fields inherited from class org.opentox.toxotis.core.OTOnlineResource
XSD_DATATYPE_LINKS
 
Fields inherited from class org.opentox.toxotis.core.OTComponent
meta, RDF_ABOUT, RDF_RDF, RDF_RESOURCE, RDF_TYPE
 
Constructor Summary
Algorithm()
          Dummy constructor for an Algorithm object.
Algorithm(String uri)
          Constructs a new instance of Algorithm with given URI.
Algorithm(VRI uri)
          Create a new instance of Algorithm providing its identifier as a VRI.
 
Method Summary
 com.hp.hpl.jena.ontology.Individual asIndividual(com.hp.hpl.jena.ontology.OntModel model)
          The OpenTox component as an individual.
 Set<MultiParameter> getMultiParameters()
           
 Set<OntologicalClass> getOntologies()
          Get the ontological classes of the algorithm
 Set<Parameter> getParameters()
          Retrieve the set of parameters for this algorithm.
 HTMLContainer inHtml()
          Create an HTML container for the online resource.
 Algorithm loadFromRemote(InputStream stream, VRI uri)
          Allows algorithms to be created from arbitrary input sources (in general files, URLs or other).Note that this is still an experimental method.
protected  Algorithm loadFromRemote(VRI uri, AuthenticationToken token)
          Loads an OpenTox component from a remote location identified by its uri and parses it into an instance of T.
 Algorithm publishToOntService(VRI ontologyService, AuthenticationToken token)
          Publishes the underlying component to the ontology service.
 void setMultiParameters(Set<MultiParameter> multiParameters)
           
 void setOntologies(Set<OntologicalClass> ontologies)
          Specify the ontologies for this algorithm.
 Algorithm setParameters(Set<Parameter> parameters)
          ParameterValue the parameters of the algorithm.
 void writeRdf(XMLStreamWriter writer)
          Due to the large size of some objects like datasets, it is advisable to use this method for serializing large objects to RDF/XML rather than the method OntModel#write(OutputStream).
 
Methods inherited from class org.opentox.toxotis.core.OTOnlineResource
download, download, download, download, downloadImage, loadFromRemote, loadFromRemote
 
Methods inherited from class org.opentox.toxotis.core.OTComponent
addOntologicalClasses, asOntModel, endRdfWriter, equals, getMeta, getOntologicalClasses, getUri, hashCode, initRdfWriter, isEnabled, setEnabled, setMeta, setOntologicalClasses, setUri, writeAnnotationProperty, writeClass, writeDatatypeProperty, writeMetaDataProperties, writeObjectProperty, writeRdf, writeRdf, writeSuperClassRelationships
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.opentox.toxotis.core.IOTComponent
addOntologicalClasses, asOntModel, getMeta, getOntologicalClasses, getUri, isEnabled, setEnabled, setMeta, setOntologicalClasses
 

Constructor Detail

Algorithm

public Algorithm()
Dummy constructor for an Algorithm object. Creates an algorithm with null URI and no other characteristics.


Algorithm

public Algorithm(VRI uri)
          throws ToxOtisException
Create a new instance of Algorithm providing its identifier as a VRI.

Parameters:
uri - The URI of the algorithm as a VRI.
Throws:
ToxOtisException - In case the provided URI is not a valid algorithm URI according to the OpenTox specifications.

Algorithm

public Algorithm(String uri)
          throws URISyntaxException
Constructs a new instance of Algorithm with given URI.

Parameters:
uri - URI of the algorithm
Throws:
URISyntaxException - In case the provided string cannot be cast as a VRI.
Method Detail

getOntologies

public Set<OntologicalClass> getOntologies()
Get the ontological classes of the algorithm

Returns:
The collection of ontological classes for this algorithm.

setOntologies

public void setOntologies(Set<OntologicalClass> ontologies)
Specify the ontologies for this algorithm.

Parameters:
ontologies - A collection of ontological classes that characterize this algorithm.

getParameters

public Set<Parameter> getParameters()
Retrieve the set of parameters for this algorithm.

Returns:
ParameterValue of parameters.

setParameters

public Algorithm setParameters(Set<Parameter> parameters)
ParameterValue the parameters of the algorithm.

Parameters:
parameters - ParameterValue of parameters.

getMultiParameters

public Set<MultiParameter> getMultiParameters()

setMultiParameters

public void setMultiParameters(Set<MultiParameter> multiParameters)

asIndividual

public com.hp.hpl.jena.ontology.Individual asIndividual(com.hp.hpl.jena.ontology.OntModel model)
Description copied from interface: IOTComponent
The OpenTox component as an individual.

Specified by:
asIndividual in interface IOTComponent
Parameters:
model - The ontological model to which the individual belongs.
Returns:
The OpenTox component as an individual of a data model.

loadFromRemote

public Algorithm loadFromRemote(InputStream stream,
                                VRI uri)
                         throws ServiceInvocationException
Allows algorithms to be created from arbitrary input sources (in general files, URLs or other).Note that this is still an experimental method.

Parameters:
stream - Input stream used to create the algorithm
uri - The URI of the algorithm resource. To obfuscate any misunderstanding we underline that this URI needs not be a URL, i.e. it will not be used to retrieve any information from the corresponding (remote) location but serves exclusively as a reference. It indicates which individual or the data model should be parsed. If set to null, then an arbitrary individual is chosen. This is not a good practice in cases where more than one instances of ot:Algorithm might be present in the same data model.
Returns:
Updates this algorithm object and returns the updated instance.
Throws:
ToxOtisException - In case the input stream does not provide a valid data model for an algorithm
ServiceInvocationException

loadFromRemote

protected Algorithm loadFromRemote(VRI uri,
                                   AuthenticationToken token)
                            throws ServiceInvocationException
Description copied from class: OTOnlineResource
Loads an OpenTox component from a remote location identified by its uri and parses it into an instance of T. This method is protected and should be implemented by all subclasses of OTOnlineResource. The method is invoked by its public counterpart OTOnlineResource.loadFromRemote(org.opentox.toxotis.util.aa.AuthenticationToken) which accesses the remote location providing an authentication token.

Specified by:
loadFromRemote in class OTOnlineResource<Algorithm>
Parameters:
uri - Identifier of the location from where the component should be downloaded and parsed
token - Token provided
Returns:
Parsed instance of the component.
Throws:
ServiceInvocationException

publishToOntService

public Algorithm publishToOntService(VRI ontologyService,
                                     AuthenticationToken token)
                              throws ServiceInvocationException
Description copied from interface: IOntologyServiceSupport
Publishes the underlying component to the ontology service. When an OpenTox online resource is published to the ontology service then it will be easily found through the lookup services of OpenTox and will be available in the demo applications of OpenTox (ToxPredict and ToxCreate).

Specified by:
publishToOntService in interface IOntologyServiceSupport<Algorithm>
token - An authentication token is needed in case the ontology service
Returns:
The published instance.
Throws:
ServiceInvocationException

writeRdf

public void writeRdf(XMLStreamWriter writer)
              throws XMLStreamException
Description copied from interface: IStAXWritable
Due to the large size of some objects like datasets, it is advisable to use this method for serializing large objects to RDF/XML rather than the method OntModel#write(OutputStream). In the case of Datasets, it has been shown that this method performs much faster (about 7,5 times faster on a dataset of 21 features and 1000 compounds).

Specified by:
writeRdf in interface IStAXWritable
Parameters:
writer - XML Stream Writer used for the serialization of the dataset object.
Throws:
XMLStreamException - In case the serialization is not possible due to syntax errors.

inHtml

public HTMLContainer inHtml()
Description copied from interface: IHTMLSupport
Create an HTML container for the online resource.

Specified by:
inHtml in interface IHTMLSupport
Returns:
HTMLContainer which can be used to create an HTML representation for the component.


Copyright © 2011-2012 OpenTox. All Rights Reserved.