org.opentox.toxotis.core.component
Class Compound

java.lang.Object
  extended by org.opentox.toxotis.core.OTComponent<T>
      extended by org.opentox.toxotis.core.OTOnlineResource<T>
          extended by org.opentox.toxotis.core.OTPublishable<T>
              extended by org.opentox.toxotis.core.DescriptorCaclulation<Compound>
                  extended by org.opentox.toxotis.core.component.Compound
All Implemented Interfaces:
Serializable, IDescriptorCalculation, IOnlineResource, IOTComponent, IStAXWritable
Direct Known Subclasses:
Conformer

public class Compound
extends DescriptorCaclulation<Compound>

Provides different representations for chemical compounds with a unique and defined chemical structure up to its 2D characteristics. Also provides access to different representations of the compound such as its SMILES or SDF formats. Allows users to easily download these representations from remote locations and store them locally in files. Also allows such representations to be POSTed to remote services and new compounds to be created (published) online.

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
Compound()
          Create a new (empty) instance of Compound
Compound(VRI uri)
          Construct a new compound identified by its URI.
 
Method Summary
 com.hp.hpl.jena.ontology.Individual asIndividual(com.hp.hpl.jena.ontology.OntModel model)
          The OpenTox component as an individual.
 LiteralValue<?> getAssayProperty(OntologicalClass featurePrototype, AuthenticationToken token)
           
 String getCasrn()
           
 String getCompoundId()
          Return the (local) identifier of the compound as it is extracted from its URI.
 Set<Conformer> getConformers()
           
 ImageIcon getDepiction(String depictionService)
           
 ImageIcon getDepictionFromRemote(AuthenticationToken token)
          Deprecated. 
 String getEinecs()
           
 String getInchi()
           
 String getInchiKey()
           
 String getIupacName()
           
 String getMolecularStructure()
          The molecular structure or a compound (MOL file, SDF etc).
 Dataset getProperties(AuthenticationToken token, VRI... featureUris)
          Creates a dataset with the current compound and the features prescribed in the list of input arguments.
 Dataset getPropertiesByOnt(OntologicalClass featurePrototype, AuthenticationToken token)
          Returns the sub-dataset that has properties of a given ontological type.
 LiteralValue<?> getProperty(Feature feature, AuthenticationToken token)
          Retrieves a property as a typed value, for a given feature, from the remote server that hosts the underlying compound.
 LiteralValue getProperty(VRI uri, AuthenticationToken token)
           
 String getRegistrationDate()
           
 Set<VRI> getSimilar(double similarity, AuthenticationToken token)
          Get a set of URIs for similar compounds using the default similarity search service at http://apps.ideaconsut.net:8080/ambit2/query/similarity which is based on the Tanimoto Distance between compounds.
 Set<VRI> getSimilar(double similarity, VRI service, AuthenticationToken token)
          Method for performing similarity search for this compound given a similarity measure which is usually a number between 0 and 1.
 String getSmiles()
           
 List<String> getSynonyms()
           
 Set<VRI> listAvailableFeatures()
          Performs a GET operation on /compound/{id}/feature and obtains the set of available features for this compound.
 Set<Conformer> listConformers(AuthenticationToken token)
          Performs a HTTP GET request on /compound/{id} to acquire a URI list of all conformers providing also an authentication token (set it to null if you think there's no need for Authentication.
protected  Compound loadFromRemote(VRI uri, AuthenticationToken token)
          This method is not implemented yet!
 Task publishOnline(AuthenticationToken token)
          Publish the component to a standard (default) server.
 Task publishOnline(VRI vri, AuthenticationToken token)
          Publish the component to a proper server identified by the uri of the publishing service provided in this method.
 void setCasrn(String casrn)
           
 void setConformers(Set<Conformer> conformers)
           
 void setDepiction(ImageIcon depiction)
           
 void setEinecs(String einecs)
           
 void setInchi(String inchi)
           
 void setInchiKey(String inchiKey)
           
 void setIupacName(String iupacName)
           
 void setMolecularStructure(String molecularStructure)
          Define the molecular structure or a compound (MOL file, SDF etc).
 void setRegistrationDate(String registrationDate)
           
 void setSmiles(String smiles)
           
 void setSynonyms(List<String> synonyms)
           
 Dataset wrapInDataset(VRI datasetUri)
          Wraps the compound in a dataset object.
 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.DescriptorCaclulation
calculateDescriptors, calculateDescriptors, futureCDKPhysChemDescriptors, futureDescriptors, futureDescriptors, futureDescriptors, futureJoeLibDescriptors
 
Methods inherited from class org.opentox.toxotis.core.OTPublishable
publish, publish
 
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

Compound

public Compound(VRI uri)
         throws ToxOtisException
Construct a new compound identified by its URI. You should provide a valid compound URI. Conformer URIs are not acceptable in this constructor. The pattern matching your URI should be:

.+[^query]+/(?i)compound(s||)/([^/]+/$|[^/]+)$

Parameters:
uri - The URI of the compound which should be a valid compound URI
Throws:
ToxOtisException - In case the provided URI is not a valid compound or conformer URI.
See Also:
Identify the type of a URI

Compound

public Compound()
Create a new (empty) instance of Compound

Method Detail

getCompoundId

public String getCompoundId()
Return the (local) identifier of the compound as it is extracted from its URI. For example http://someserver.com/compound/phenol will return phenol. When applied on a conformer, it will also return the (local) id of the compound. For example, if applied on http://someserver.com/compound/1/conformer/2, the method returns 1.

Returns:
Compound ID.

listConformers

public Set<Conformer> listConformers(AuthenticationToken token)
                              throws ServiceInvocationException
Performs a HTTP GET request on /compound/{id} to acquire a URI list of all conformers providing also an authentication token (set it to null if you think there's no need for Authentication.

Returns:
List of conformers
Throws:
ToxOtisException - In case an authentication error occurs or the remote service responds with an error code like 500 or 503.
ServiceInvocationException

getPropertiesByOnt

public Dataset getPropertiesByOnt(OntologicalClass featurePrototype,
                                  AuthenticationToken token)
                           throws ServiceInvocationException
Returns the sub-dataset that has properties of a given ontological type.

Parameters:
featurePrototype - A feature ontological class.
token - An authentication token
Returns:
Throws:
ServiceInvocationException

getAssayProperty

public LiteralValue<?> getAssayProperty(OntologicalClass featurePrototype,
                                        AuthenticationToken token)
                                 throws ToxOtisException
Throws:
ToxOtisException

getProperty

public LiteralValue<?> getProperty(Feature feature,
                                   AuthenticationToken token)
                            throws ServiceInvocationException
Retrieves a property as a typed value, for a given feature, from the remote server that hosts the underlying compound.

Parameters:
feature - Feature for which the value is retrieved
token - Token used to authenticate the client and authorize it to perform the GET request to the remote servrer. If you think that no authentication is needed to access the resource, you may set it to null.
Returns:
Feature value for this compound as a Typed Value
Throws:
ToxOtisException - In case an authentication error occurs or the remote service responds with an error code like 500 or 503 or the submitted representation is syntactically or semantically wrong (status 400).
ServiceInvocationException

getProperty

public LiteralValue getProperty(VRI uri,
                                AuthenticationToken token)
                         throws ServiceInvocationException
Throws:
ServiceInvocationException

getProperties

public Dataset getProperties(AuthenticationToken token,
                             VRI... featureUris)
                      throws ServiceInvocationException
Creates a dataset with the current compound and the features prescribed in the list of input arguments. The dataset is fetched from a remote location.

Parameters:
token - Authentication token that will allow us to access the resource.
featureUris - List of Feature URIs to be included in the dataset.
Returns:
The requested dataset.
Throws:
ServiceInvocationException - In case some of the involved services experiences some error or if the request is mal-formed.

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.

Parameters:
model - The ontological model to which the individual belongs.
Returns:
The OpenTox component as an individual of a data model.

loadFromRemote

protected Compound loadFromRemote(VRI uri,
                                  AuthenticationToken token)
                           throws ServiceInvocationException
This method is not implemented yet!

Specified by:
loadFromRemote in class OTOnlineResource<Compound>
Parameters:
uri - Identifier of the location from where the RDF document should be downloaded from and parsed into a Compound object.
token - Token provided
Returns:
Parsed instance of the component into an instance of Compound.
Throws:
ToxOtisException - A ToxOtisException is thrown in case the remote resource is unreachable, the service responds with an unexpected or error status code (500, 503, 400 etc) or other potent communication error occur during the connection or the transaction of data.
ServiceInvocationException

publishOnline

public Task publishOnline(VRI vri,
                          AuthenticationToken token)
                   throws ServiceInvocationException
Description copied from class: OTPublishable
Publish the component to a proper server identified by the uri of the publishing service provided in this method. The resource will be posted to the server in RDF format (application/rdf+xml).

Specified by:
publishOnline in class OTPublishable<Compound>
Parameters:
vri - URI of the service that is responsible for the publication of this kind of resources.
token - Provide an authentication token. If you think that the service does not require auhtentication/authorization, you can leave this field null or you can provide an empty authentication token. If the provided URI already contains an authentication token (as the URL parameter tokenid) it will be replaced by the new token provided to this method.
Returns:
A Task for monitoring the progress of your request. If the service returns the URI of the resource right away and does not return a task, then the object you will receive from this method will now have an identifier, its status will be set to Completed, its progress will be set to 100% and the URI of the created resource will be available applying the method Task.getResultUri() on the returned task. In any case, the service's response will be wrapped in a Task object.
Throws:
ServiceInvocationException

publishOnline

public Task publishOnline(AuthenticationToken token)
                   throws ServiceInvocationException
Description copied from class: OTPublishable
Publish the component to a standard (default) server. The resource will be posted to the server in RDF format (application/rdf+xml). If you want to specify at which server the resource should be posted, use the other method.

Specified by:
publishOnline in class OTPublishable<Compound>
Parameters:
token - Provide an authentication token. If you think that the service does not require auhtentication/authorization, you can leave this field null or you can provide an empty authentication token.If the provided URI already contains an authentication token (as the URL parameter tokenid) it will be replaced by the new token provided to this method.
Returns:
A Task for monitoring the progress of your request. If the service returns the URI of the resource right away and does not return a task, then the object you will receive from this method will now have an identifier, its status will be set to Completed, its progress will be set to 100% and the URI of the created resource will be available applying the method Task.getResultUri() on the returned task. In any case, the service's response will be wrapped in a Task object.
Throws:
ServiceInvocationException - In case of invalid credentials, if the POSTed resource is not acceptable by the remote service (returns a status code 400), communication error occur with the remote server or other connection problems or the access to the service was denied (401 or 403).
See Also:
alternative method

listAvailableFeatures

public Set<VRI> listAvailableFeatures()
                               throws ServiceInvocationException
Performs a GET operation on /compound/{id}/feature and obtains the set of available features for this compound. Afterwards, users can invoke the method getProperty to get the value of a feature on this compound.

Returns:
A set of the URIs of all available features.
Throws:
ToxOtisException - In case the remote service responds with an error status code.
ServiceInvocationException

getDepictionFromRemote

@Deprecated
public ImageIcon getDepictionFromRemote(AuthenticationToken token)
                                 throws ServiceInvocationException
Deprecated. 

Get the depiction of the compound using some depiction service. The service generates the depiction of the chemical compound based on its SMILES string. By default this method performs a GET HTTP request on the remote location identified by the URI of the compound and acquires with Header Accept: chemical/x-daylight-smiles and acquires the SMILES representation of the chemical structure. Afterwards, this is POSTed to the default depiction service at http://apps.ideaconsult.net:8080/ambit2/ depict/cdk?query={smiles} and the result is cast as an instance of javax.swing.ImageIcon.

Parameters:
token - Authentication token used to be granted access to the compound and depiction services
Returns:
Returns the depiction of the chemical compound as an ImageIcon.
Throws:
ToxOtisException - In case the authentication fails or the user is not authorized to perform some request (e.g. access the compound or depiction service) or the coumpound or depiction services respond in an unexpected manner (e.g. return an error status code like 500 or 503).
ServiceInvocationException

wrapInDataset

public Dataset wrapInDataset(VRI datasetUri)
                      throws ToxOtisException,
                             ServiceInvocationException
Wraps the compound in a dataset object. The URI of the dataset can be specified by the input argument of this method.

Parameters:
datasetUri - The identifier (URI) of the dataset which acts as a wrapper to the compound. If set to null, an anonymous node will be created for the dataset resource.
Returns:
A dataset object that wraps the compound.
Throws:
ToxOtisException - In case the provided URI is not a valid dataset URI (does not comply with the OpenTox standards).
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).

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.

getSimilar

public Set<VRI> getSimilar(double similarity,
                           VRI service,
                           AuthenticationToken token)
                    throws ServiceInvocationException
Method for performing similarity search for this compound given a similarity measure which is usually a number between 0 and 1.

Parameters:
similarity - Similarity Index. The smaller this index is, the larger the length of the resulting set will be. Setting it equal to 1 will return just the submitted compound.
service - Remote similarity search service to be used for obtaining the list of similar compounds as a URI list. The remote invokation is a GET method applied on service?search={smiles_string}&threshold={threshold}
token - Authentication token used to obtain the SMILES string of the token and acquire access to the similarity service.
Returns:
ParameterValue of URIs that are similar to the compound on which the method is applied up to a certain threshold.
Throws:
ToxOtisException - In case the remote service responds with a non-success status code like 400 (bad request/bad smiles string) or 500 (internal error of the server) or if authentication or authorization fails.
ServiceInvocationException

getSimilar

public Set<VRI> getSimilar(double similarity,
                           AuthenticationToken token)
                    throws ServiceInvocationException
Get a set of URIs for similar compounds using the default similarity search service at http://apps.ideaconsut.net:8080/ambit2/query/similarity which is based on the Tanimoto Distance between compounds.

Parameters:
similarity - Similarity threshold; a number between 0 and 1.
token - Authentication token used to obtain the SMILES string of the token and acquire access to the similarity service.
Returns:
ParameterValue of URIs that are similar to the compound on which the method is applied up to a certain threshold.
Throws:
ToxOtisException - In case the remote service responds with a non-success status code like 400 (bad request/bad smiles string) or 500 (internal error of the server) or if authentication or authorization fails.
ServiceInvocationException

getSynonyms

public List<String> getSynonyms()

setSynonyms

public void setSynonyms(List<String> synonyms)

getDepiction

public ImageIcon getDepiction(String depictionService)

setDepiction

public void setDepiction(ImageIcon depiction)

getCasrn

public String getCasrn()

setCasrn

public void setCasrn(String casrn)

getEinecs

public String getEinecs()

setEinecs

public void setEinecs(String einecs)

getInchi

public String getInchi()

setInchi

public void setInchi(String inchi)

getInchiKey

public String getInchiKey()

setInchiKey

public void setInchiKey(String inchiKey)

getIupacName

public String getIupacName()

setIupacName

public void setIupacName(String iupacName)

getRegistrationDate

public String getRegistrationDate()

setRegistrationDate

public void setRegistrationDate(String registrationDate)

getSmiles

public String getSmiles()

setSmiles

public void setSmiles(String smiles)

getConformers

public Set<Conformer> getConformers()

setConformers

public void setConformers(Set<Conformer> conformers)

getMolecularStructure

public String getMolecularStructure()
The molecular structure or a compound (MOL file, SDF etc).

Returns:
The molecular structure as a string

setMolecularStructure

public void setMolecularStructure(String molecularStructure)
Define the molecular structure or a compound (MOL file, SDF etc).



Copyright © 2011-2012 OpenTox. All Rights Reserved.