org.opentox.toxotis.core.component
Class Model

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

public class Model
extends OTOnlineResource<Model>
implements IOntologyServiceSupport<Model>, IHTMLSupport, IBibTexReferencable

QSAR, DoA or other OpenTox models. Models in OpenTox are services on which a dataset can be POSTed for processing. An OpenTox model may correspond to a predictive QSAR model, a domain of applicability estimator, a filtering model that outputs a (filtered) dataset or any other process on datasets and is not identical to the notion of a predictive model as it appears in QSAR.

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
Model()
          Creates an empty model.
Model(VRI uri)
          Create a new empty Model with a given URI.
 
Method Summary
 IBibTexReferencable addBibTeXReferences(VRI... references)
           
 Model addDependentFeatures(Feature... features)
          Adds dependent features to the current list of features.
 Model addIndependentFeatures(Feature... features)
          Adds independent features to the current list of features.
 Model addPredictedFeatures(Feature... features)
          Adds predicted features to the current list of features.
 com.hp.hpl.jena.ontology.Individual asIndividual(com.hp.hpl.jena.ontology.OntModel model)
          The OpenTox component as an individual.
 boolean equals(Object obj)
           
 Serializable getActualModel()
          The actual model, serializable object, that encapsulates all necessary information for the calculated model that was trained by some algorithm.
 Algorithm getAlgorithm()
          The algorithm with which the model was built/trained.
 Set<VRI> getBibTeXReferences()
           
 Blob getBlob()
           
 User getCreatedBy()
          The user that created the model.
 VRI getDataset()
          Get the URI of the dataset that was used to train the model.
 List<Feature> getDependentFeatures()
          A list of the dependent features of the model, i.e.
 List<Feature> getIndependentFeatures()
          A list of the independent features of the model, i.e.
 String getLocalCode()
          If the actual model is stored as a file on the file system, this method returns the pathname for it.
 List<MultiParameter> getMultiParameters()
           
 Set<Parameter> getParameters()
          The parameters of the model.
 List<Feature> getPredictedFeatures()
          A list of the predicted features of the model, i.e.
 int hashCode()
           
 HTMLContainer inHtml()
          Create an HTML container for the online resource.
protected  Model 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.
 Model publishToOntService(VRI ontologyService, AuthenticationToken token)
          Publishes the underlying component to the ontology service.
 Model setActualModel(Serializable actualModel)
          Set the actual model.
 void setAlgorithm(Algorithm algorithm)
          Specify the algorithm that was used to train the model.
 IBibTexReferencable setBibTeXReferences(Set<VRI> references)
           
 IBibTexReferencable setBibTeXReferences(VRI... references)
           
 void setBlob(Blob modelBlob)
           
 void setCreatedBy(User createdBy)
          Specify who created this model.
 Model setDataset(VRI dataset)
          Specify the URI of the training dataset.
 Model setDependentFeatures(List<Feature> dependentFeature)
          Set the list of dependent features of the current model
 Model setIndependentFeatures(List<Feature> independentFeatures)
          Set the list of independent features of the current model.
 void setLocalCode(String localCode)
          Sets the local code of the model.
 Model setMultiParameters(List<MultiParameter> multiParameters)
           
 void setParameters(Set<Parameter> parameters)
          Specify the set of parameters for the current model.
 Model setPredictedFeatures(List<Feature> predictedFeature)
          Set the list of predicted features of the current model.
 Object toObject(byte[] bytes)
           
 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, getMeta, getOntologicalClasses, getUri, 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

Model

public Model(VRI uri)
Create a new empty Model with a given URI.

Parameters:
uri - URI of the model.

Model

public Model()
Creates an empty model.

Method Detail

getActualModel

public Serializable getActualModel()
The actual model, serializable object, that encapsulates all necessary information for the calculated model that was trained by some algorithm. Can be any implementation of Serializable, meaning practically almost anything. Users can implement their own models that can encapsulate potentially a Weka model file and a PMML representation of the model.

Returns:
Model object with which predictions can be done.

setActualModel

public Model setActualModel(Serializable actualModel)
                     throws NotSerializableException
Set the actual model. This object is converted into an array of bytes using a ByteArrayOutputStream and an ObjectOutputStream.

Parameters:
actualModel - The object which can be used to perform predictions.
Returns:
The current updated instance of the model containing the actual model
Throws:
NotSerializableException - In case the provided actual model cannot be serialized. This is the case when the provided model is an instance of a class which implements java.io.Serializable but has some non-serializable fields. In that case it is good practise to either exclude these fields from the serialization tagging them as transient or replace them with other serializable fields if possible

getLocalCode

public String getLocalCode()
If the actual model is stored as a file on the file system, this method returns the pathname for it.

Returns:

setLocalCode

public void setLocalCode(String localCode)
Sets the local code of the model. With this code the model is locally identified (e.g. on the file system).

Parameters:
localCode - A custom (unique) identifier.

getAlgorithm

public Algorithm getAlgorithm()
The algorithm with which the model was built/trained.

Returns:
An instance of Algorithm

setAlgorithm

public void setAlgorithm(Algorithm algorithm)
Specify the algorithm that was used to train the model.

Parameters:
algorithm - An instance of Algorithm.

getCreatedBy

public User getCreatedBy()
The user that created the model.

Returns:
An instance of User

setCreatedBy

public void setCreatedBy(User createdBy)
Specify who created this model.

Parameters:
createdBy - An instance of User

getDataset

public VRI getDataset()
Get the URI of the dataset that was used to train the model. The actual data should be fetched from the remote location if necessary.

Returns:
URI of training dataset.

setDataset

public Model setDataset(VRI dataset)
Specify the URI of the training dataset.

Parameters:
dataset - URI of the training set.
Returns:
The current modifiable instance of Model with updated training dataset.

getDependentFeatures

public List<Feature> getDependentFeatures()
A list of the dependent features of the model, i.e. the target property (the response, e.g. experimentally measured property).

Returns:
List of features

setDependentFeatures

public Model setDependentFeatures(List<Feature> dependentFeature)
Set the list of dependent features of the current model

Parameters:
dependentFeature - List of dependent features.
Returns:
The current Model instance with an updated list of features.

addDependentFeatures

public Model addDependentFeatures(Feature... features)
Adds dependent features to the current list of features.

Parameters:
features - Array of features.
Returns:
The current model with updated list of dependent features.

getIndependentFeatures

public List<Feature> getIndependentFeatures()
A list of the independent features of the model, i.e. the descriptors.

Returns:
List of features

setIndependentFeatures

public Model setIndependentFeatures(List<Feature> independentFeatures)
Set the list of independent features of the current model.

Parameters:
independentFeatures - List of independent features.
Returns:
The current Model instance with an updated list of independent features.

addIndependentFeatures

public Model addIndependentFeatures(Feature... features)
Adds independent features to the current list of features.

Parameters:
features - Array of features.
Returns:
The current model with updated list of independent features.

getParameters

public Set<Parameter> getParameters()
The parameters of the model.

Returns:
A set of parameters for the current model.
See Also:
Parameter

setParameters

public void setParameters(Set<Parameter> parameters)
Specify the set of parameters for the current model.

Parameters:
parameters -

getMultiParameters

public List<MultiParameter> getMultiParameters()

setMultiParameters

public Model setMultiParameters(List<MultiParameter> multiParameters)

getPredictedFeatures

public List<Feature> getPredictedFeatures()
A list of the predicted features of the model, i.e. the properties that the model predicts.

Returns:
List of predicted features.

setPredictedFeatures

public Model setPredictedFeatures(List<Feature> predictedFeature)
Set the list of predicted features of the current model.

Parameters:
predictedFeature - List of predicted features.
Returns:
The current Model instance with an updated list of predicted features.

addPredictedFeatures

public Model addPredictedFeatures(Feature... features)
Adds predicted features to the current list of features.

Parameters:
features - Array of predicted features.
Returns:
The current model with updated list of predicted features.

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

protected Model 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<Model>
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

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.

publishToOntService

public Model 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<Model>
token - An authentication token is needed in case the ontology service
Returns:
The published instance.
Throws:
ServiceInvocationException

equals

public boolean equals(Object obj)
Overrides:
equals in class OTComponent<Model>

hashCode

public int hashCode()
Overrides:
hashCode in class OTComponent<Model>

setBlob

public void setBlob(Blob modelBlob)

toObject

public Object toObject(byte[] bytes)

getBlob

public Blob getBlob()
             throws SerialException,
                    SQLException
Throws:
SerialException
SQLException

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.

getBibTeXReferences

public Set<VRI> getBibTeXReferences()
Specified by:
getBibTeXReferences in interface IBibTexReferencable

addBibTeXReferences

public IBibTexReferencable addBibTeXReferences(VRI... references)
Specified by:
addBibTeXReferences in interface IBibTexReferencable

setBibTeXReferences

public IBibTexReferencable setBibTeXReferences(VRI... references)
Specified by:
setBibTeXReferences in interface IBibTexReferencable

setBibTeXReferences

public IBibTexReferencable setBibTeXReferences(Set<VRI> references)
Specified by:
setBibTeXReferences in interface IBibTexReferencable


Copyright © 2011-2012 OpenTox. All Rights Reserved.