org.opentox.toxotis.factory
Class DatasetFactory

java.lang.Object
  extended by org.opentox.toxotis.factory.DatasetFactory

public final class DatasetFactory
extends Object

DatasetFactory provides methods for creating Datasets from various sources. Main functionality features parsing an .arff file or a weka Instances object to create a Dataset.

Author:
Charalampos Chomenides, Pantelis Sopasakis

Method Summary
 DataEntry createDataEntry(weka.core.Instance instance)
          Create a data entry from a single instance.
 Dataset createFromArff(File file)
          Create a dataset using an ARFF file at a given location.
 Dataset createFromArff(InputStream stream)
           
 Dataset createFromArff(weka.core.Instances instances)
          Create a dataset using a weka.core.Instances object (based on Weka, version 3.6.2).
 Dataset createFromArff(Reader reader)
           
static DatasetFactory getInstance()
          Returns the DatasetFactory object associated with the current Java application.
 Task publishFromFile(File sourceFile, Media fileType, AuthenticationToken token)
           
 Task publishFromFile(File sourceFile, Media fileType, AuthenticationToken token, VRI service)
           
 Task publishFromFile(File sourceFile, String fileType, AuthenticationToken token, VRI service)
          Publishes a dataset reading from a file.
 Task publishFromStream(InputStream source, Media fileType, AuthenticationToken token)
           
 Task publishFromStream(InputStream source, String fileType, AuthenticationToken token, VRI service)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getInstance

public static DatasetFactory getInstance()
Returns the DatasetFactory object associated with the current Java application. All factories in ToxOtis are singletons and have a single access point.

Returns:
The DatasetFactory object associated with the current Java application.

createFromArff

public Dataset createFromArff(weka.core.Instances instances)
                       throws ToxOtisException
Create a dataset using a weka.core.Instances object (based on Weka, version 3.6.2). Since datasets structurally differ from Instances object for they store the information in a more expanded way including meta data and nodes that do not appear in Instances object (or ARFF files), the provided object has to possess a certain structure: The first attribute of it has to be always named compound_uri and be of type string. This attribute stores the URIs of the compounds of the dataset. Second, the rest attributes have to be of type string or numeric or nominal and their name should be an acceptable feature URI (for example http://someserver.com:1234/opentox/feature/54234).

Parameters:
instances - Instances object to be converted into a Dataset.
Returns:
The dataset that is created from the provided Instances object.
Throws:
ToxOtisException - In case the conversion is not possible due to structural inconsistencies of the provided Instances object.

createFromArff

public Dataset createFromArff(File file)
                       throws ToxOtisException
Create a dataset using an ARFF file at a given location. Since datasets structurally differ from Instances object for they store the information in a more expanded way including meta data and nodes that do not appear in Instances object (or ARFF files), the provided ARFF file has to possess a certain structure: The first attribute of it has to be always named compound_uri and be of type string. This attribute stores the URIs of the compounds of the dataset. Second, the rest attributes have to be of type string or numeric or nominal and their name should be an acceptable feature URI (for example http://someserver.com:1234/opentox/feature/54234).

Parameters:
file - Pointer to an ARFF file
Returns:
The dataset that is created from the provided ARFF file.
Throws:
ToxOtisException - In case the conversion is not possible due to structural inconsistencies of the provided Instances object or the file is not found.

createFromArff

public Dataset createFromArff(InputStream stream)
                       throws ToxOtisException
Throws:
ToxOtisException

createFromArff

public Dataset createFromArff(Reader reader)
                       throws ToxOtisException
Parameters:
reader -
Returns:
Throws:
ToxOtisException

createDataEntry

public DataEntry createDataEntry(weka.core.Instance instance)
                          throws ToxOtisException
Create a data entry from a single instance.

Parameters:
instance -
Returns:
A Data Entry that corresponds to the provided instance.
Throws:
ToxOtisException

publishFromFile

public Task publishFromFile(File sourceFile,
                            String fileType,
                            AuthenticationToken token,
                            VRI service)
                     throws ServiceInvocationException,
                            FileNotFoundException
Publishes a dataset reading from a file. The mediatype of the file should be provided.

Parameters:
sourceFile - The source file which can be any sort of 'chemical' file format, such as SFD, MOL etc. Check out in Media for more.
fileType - MIME type of the file provided as a string.
token - An authentication token is usually necessary to upload data.
service - The remote dataset service to undertake the uploading and storage.
Returns:
A Task with which to monitor the progress of the upload process.
Throws:
ServiceInvocationException - In case the remote service does not respond as expected.
FileNotFoundException - In case the specified file cannot be located on the file-system.
See Also:
publishFromFile(java.io.File, org.opentox.toxotis.client.collection.Media, org.opentox.toxotis.util.aa.AuthenticationToken)

publishFromFile

public Task publishFromFile(File sourceFile,
                            Media fileType,
                            AuthenticationToken token,
                            VRI service)
                     throws ServiceInvocationException,
                            FileNotFoundException
Throws:
ServiceInvocationException
FileNotFoundException

publishFromFile

public Task publishFromFile(File sourceFile,
                            Media fileType,
                            AuthenticationToken token)
                     throws ServiceInvocationException,
                            FileNotFoundException
Parameters:
sourceFile -
fileType -
token -
Returns:
Throws:
ServiceInvocationException
FileNotFoundException

publishFromStream

public Task publishFromStream(InputStream source,
                              String fileType,
                              AuthenticationToken token,
                              VRI service)
                       throws ServiceInvocationException
Throws:
ServiceInvocationException

publishFromStream

public Task publishFromStream(InputStream source,
                              Media fileType,
                              AuthenticationToken token)
                       throws ServiceInvocationException
Throws:
ServiceInvocationException


Copyright © 2011-2012 OpenTox. All Rights Reserved.