owltools.gaf.lego
Class MolecularModelManager

java.lang.Object
  extended by owltools.gaf.lego.MolecularModelManager

public class MolecularModelManager
extends Object

Manager object for operations on collections of MolecularModels (aka lego diagrams) any number of models can be loaded at any time (todo - impose some limit to avoid using too much memory) each model has a generator, an OWLOntology (containing the set of class assertions) and a reasoner associated with it (todo - test memory requirements) This manager is designed to be used within a web server. Multiple clients can contact the same manager instance through services


Nested Class Summary
static class MolecularModelManager.LegoAnnotationType
           
protected  class MolecularModelManager.LegoStringDotRenderer
          Deprecated. 
 class MolecularModelManager.OWLOperationResponse
          Represents the reponse to a requested translation on an ontology/model
static class MolecularModelManager.UnknownIdentifierException
           
 
Constructor Summary
MolecularModelManager(OWLGraphWrapper graph)
           
MolecularModelManager(org.semanticweb.owlapi.model.OWLOntology ont)
           
 
Method Summary
 void addAnnotations(String modelId, Collection<org.apache.commons.lang3.tuple.Pair<String,String>> pairs)
           
 void addAnnotations(String modelId, org.semanticweb.owlapi.model.OWLNamedIndividual i, Collection<org.semanticweb.owlapi.model.OWLAnnotation> annotations)
           
 MolecularModelManager.OWLOperationResponse addAnnotations(String modelId, org.semanticweb.owlapi.model.OWLObjectPropertyExpression p, org.semanticweb.owlapi.model.OWLNamedIndividual i, org.semanticweb.owlapi.model.OWLNamedIndividual j, Set<org.semanticweb.owlapi.model.OWLAnnotation> annotations)
           
 org.semanticweb.owlapi.model.OWLNamedIndividual addAnnotations(String modelId, String iid, Collection<org.apache.commons.lang3.tuple.Pair<String,String>> pairs)
           
 List<org.semanticweb.owlapi.model.OWLNamedIndividual> addAnnotations(String modelId, String pid, String iid, String jid, Collection<org.apache.commons.lang3.tuple.Pair<String,String>> pairs)
           
 MolecularModelManager.OWLOperationResponse addCompositeIndividual(String modelId, String classId, String enabledById, String occursInId)
          A simple wrapping function that captures the most basic type of editing.
 MolecularModelManager.OWLOperationResponse addEnabledBy(String modelId, org.semanticweb.owlapi.model.OWLNamedIndividual i, org.semanticweb.owlapi.model.OWLClassExpression enabler)
          Adds a ClassAssertion to the model, connecting an activity instance to the class of molecule that enables the activity.
 MolecularModelManager.OWLOperationResponse addEnabledBy(String modelId, String iid, String eid)
          Convenience wrapper for addEnabledBy(String, OWLNamedIndividual, OWLClassExpression)
 MolecularModelManager.OWLOperationResponse addFact(String modelId, OBOUpperVocabulary vocabElement, org.semanticweb.owlapi.model.OWLNamedIndividual i, org.semanticweb.owlapi.model.OWLNamedIndividual j, Set<org.semanticweb.owlapi.model.OWLAnnotation> annotations)
          Convenience wrapper for addFact(String, OWLObjectPropertyExpression, OWLNamedIndividual, OWLNamedIndividual, Set)
 MolecularModelManager.OWLOperationResponse addFact(String modelId, OBOUpperVocabulary vocabElement, String iid, String jid, Collection<org.apache.commons.lang3.tuple.Pair<String,String>> pairs)
          Convenience wrapper for addFact(String, OWLObjectPropertyExpression, OWLNamedIndividual, OWLNamedIndividual, Set)
 MolecularModelManager.OWLOperationResponse addFact(String modelId, org.semanticweb.owlapi.model.OWLObjectPropertyExpression p, org.semanticweb.owlapi.model.OWLNamedIndividual i, org.semanticweb.owlapi.model.OWLNamedIndividual j, Set<org.semanticweb.owlapi.model.OWLAnnotation> annotations)
          Adds triple (i,p,j) to specified model
 MolecularModelManager.OWLOperationResponse addFact(String modelId, String pid, String iid, String jid, Collection<org.apache.commons.lang3.tuple.Pair<String,String>> pairs)
          Convenience wrapper for addFact(String, OWLObjectPropertyExpression, OWLNamedIndividual, OWLNamedIndividual, Set)
 List<org.semanticweb.owlapi.model.OWLNamedIndividual> addFactNonReasoning(String modelId, String pid, String iid, String jid, Collection<org.apache.commons.lang3.tuple.Pair<String,String>> pairs)
          Convenience wrapper for addFact(String, OWLObjectPropertyExpression, OWLNamedIndividual, OWLNamedIndividual, Set)
 void addImports(Iterable<String> imports)
          Add additional import declarations for any newly generated model.
 MolecularModelManager.OWLOperationResponse addOccursIn(String modelId, org.semanticweb.owlapi.model.OWLNamedIndividual i, org.semanticweb.owlapi.model.OWLClassExpression enabler)
          Adds a ClassAssertion to the model, connecting an activity instance to the class of molecule that enables the activity.
 MolecularModelManager.OWLOperationResponse addOccursIn(String modelId, String iid, String eid)
          Convenience wrapper for addOccursIn(String, OWLNamedIndividual, OWLClassExpression)
 MolecularModelManager.OWLOperationResponse addPartOf(String modelId, org.semanticweb.owlapi.model.OWLNamedIndividual i, org.semanticweb.owlapi.model.OWLNamedIndividual j, Set<org.semanticweb.owlapi.model.OWLAnnotation> annotations)
          Adds an OWL ObjectPropertyAssertion connecting i to j via part_of Note that the inverse assertion is entailed, but not asserted
 MolecularModelManager.OWLOperationResponse addPartOf(String modelId, String iid, String jid, Collection<org.apache.commons.lang3.tuple.Pair<String,String>> pairs)
          Convenience wrapper for addPartOf(String, OWLNamedIndividual, OWLNamedIndividual, Set)
 String addProcess(String modelId, org.semanticweb.owlapi.model.OWLClass processCls)
          Adds a process individual (and inferred individuals) to a model
 MolecularModelManager.OWLOperationResponse addType(String modelId, org.semanticweb.owlapi.model.OWLNamedIndividual i, org.semanticweb.owlapi.model.OWLClass c)
          Adds ClassAssertion(c,i) to specified model
 MolecularModelManager.OWLOperationResponse addType(String modelId, org.semanticweb.owlapi.model.OWLNamedIndividual i, org.semanticweb.owlapi.model.OWLObjectPropertyExpression p, org.semanticweb.owlapi.model.OWLClassExpression filler)
          Adds a ClassAssertion, where the class expression instantiated is an ObjectSomeValuesFrom expression Example: Individual: i Type: enabledBy some PRO_123
 MolecularModelManager.OWLOperationResponse addType(String modelId, String iid, String cid)
          Convenience wrapper for addType(String, OWLNamedIndividual, OWLClass)
 MolecularModelManager.OWLOperationResponse addType(String modelId, String iid, String pid, String cid)
          Convenience wrapper for addType(String, OWLNamedIndividual, OWLObjectPropertyExpression, OWLClassExpression)
 org.semanticweb.owlapi.model.OWLNamedIndividual addTypeNonReasoning(String modelId, String iid, org.semanticweb.owlapi.model.OWLClassExpression clsExp)
           
 org.semanticweb.owlapi.model.OWLNamedIndividual addTypeNonReasoning(String modelId, String iid, String pid, org.semanticweb.owlapi.model.OWLClassExpression ce)
           
 MolecularModelManager.OWLOperationResponse createIndividual(String modelId, org.semanticweb.owlapi.model.OWLClass c)
           
 MolecularModelManager.OWLOperationResponse createIndividual(String modelId, String cid, Collection<org.apache.commons.lang3.tuple.Pair<String,String>> annotations)
          Shortcut for createIndividual(String, OWLClass)
 org.apache.commons.lang3.tuple.Pair<String,org.semanticweb.owlapi.model.OWLNamedIndividual> createIndividualNonReasoning(String modelId, String cid, Collection<org.apache.commons.lang3.tuple.Pair<String,String>> annotations)
          Shortcut for createIndividual(String, OWLClass)
 String createMostSpecificClass(String modelId, String individualId, String newClassId)
          Given an instance, generate the most specific class instance that classifies this instance, and add this as a class to the model ontology
 MolecularModelManager.OWLOperationResponse deleteIndividual(String modelId, org.semanticweb.owlapi.model.OWLNamedIndividual i)
          Deletes an individual
 MolecularModelManager.OWLOperationResponse deleteIndividual(String modelId, String iid)
          Deletes an individual
 void deleteModel(String id)
           
 void dispose()
          internal method to cleanup this instance
 String exportModel(String modelId)
          Export the ABox for the given modelId in the default OWLOntologyFormat.
 String exportModel(String modelId, org.semanticweb.owlapi.model.OWLOntologyFormat ontologyFormat)
          Export the ABox, will try to set the ontologyID to the given modelId (to ensure import assumptions are met)
 String exportModel(String modelId, String format)
          Export the ABox for the given modelId in the given ontology format.
Warning: The mapping from String to OWLOntologyFormat does not map every format!
 String generateBlankModel(String db)
          Generates a new model taking as input a database D.
 String generateDot(String modelId)
          Deprecated. 
 File generateImage(String modelId)
          Deprecated. 
 String generateModel(org.semanticweb.owlapi.model.OWLClass processCls, String db)
          Generates a new model taking as input a biological process P and a database D.
 String generateModel(String pid, String db)
          wrapper for generateModel(OWLClass, String)
 Set<String> getAvailableModelIds()
          Retrieve a collection of all available model ids.
Note: Models may not be loaded at this point.
 Set<String> getCurrentModelIds()
          Retrieve a collection of all model ids currently in memory.
 Map<String,String> getDbToTaxon()
           
 GafDocument getGaf(String db)
           
 OWLGraphWrapper getGraph()
           
 Collection<org.semanticweb.owlapi.model.IRI> getImports()
           
 MolecularModelManager.OWLOperationResponse getIndividualById(String modelId, String iid)
          Get the individual information for return.
 Set<org.semanticweb.owlapi.model.OWLNamedIndividual> getIndividuals(String modelId)
           
 Set<org.semanticweb.owlapi.model.OWLNamedIndividual> getIndividualsByQuery(String modelId, org.semanticweb.owlapi.model.OWLClassExpression q)
           
 Set<org.semanticweb.owlapi.model.OWLNamedIndividual> getIndividualsByQuery(String modelId, String qs)
           
 LegoModelGenerator getModel(String id)
          Fetches a model by its Id
 Set<String> getModelIds()
           
 Map<Object,Object> getModelObject(String modelId)
           
 org.semanticweb.owlapi.model.OWLNamedIndividual getNamedIndividual(String modelId, String iid)
           
 org.semanticweb.owlapi.model.OWLOntology getOntology()
           
 org.semanticweb.owlapi.model.OWLDataFactory getOWLDataFactory(String modelId)
           
protected  org.semanticweb.owlapi.model.OWLOntologyManager getOWLOntologyManager(String modelId)
           
 String getPathToGafs()
           
 String getPathToOWLFiles()
          Note this may move to an implementation-specific subclass in future
 String getPathToProteinFiles()
           
 Set<String> getStoredModelIds()
          Retrieve a collection of all file/stored model ids found in the repo.
Note: Models may not be loaded at this point.
 String importModel(String modelData)
          Try to load (or replace) a model with the given ontology.
protected  void init()
           
 boolean isConsistent(String modelId)
           
 GafDocument loadGaf(String db)
          loads/register a Gaf document
 GafDocument loadGaf(String db, File gafFile)
          Loads and caches a GAF document from a specified location
protected  void loadModel(String modelId, boolean isOverride)
           
static org.semanticweb.owlapi.model.OWLClassExpression parseClassExpression(String expression, OWLGraphWrapper g)
           
 void removeAnnotations(String modelId, Collection<org.apache.commons.lang3.tuple.Pair<String,String>> pairs)
           
 void removeAnnotations(String modelId, org.semanticweb.owlapi.model.OWLNamedIndividual i, Collection<org.semanticweb.owlapi.model.OWLAnnotation> annotations)
           
 org.semanticweb.owlapi.model.OWLNamedIndividual removeAnnotations(String modelId, String iid, Collection<org.apache.commons.lang3.tuple.Pair<String,String>> pairs)
           
 List<org.semanticweb.owlapi.model.OWLNamedIndividual> removeAnnotations(String modelId, String pid, String iid, String jid, Collection<org.apache.commons.lang3.tuple.Pair<String,String>> pairs)
           
 MolecularModelManager.OWLOperationResponse removeFact(String modelId, org.semanticweb.owlapi.model.OWLObjectPropertyExpression p, org.semanticweb.owlapi.model.OWLNamedIndividual i, org.semanticweb.owlapi.model.OWLNamedIndividual j)
           
 MolecularModelManager.OWLOperationResponse removeFact(String modelId, String pid, String iid, String jid)
           
 List<org.semanticweb.owlapi.model.OWLNamedIndividual> removeFactNonReasoning(String modelId, String pid, String iid, String jid)
           
 MolecularModelManager.OWLOperationResponse removeType(String modelId, org.semanticweb.owlapi.model.OWLNamedIndividual i, org.semanticweb.owlapi.model.OWLClass c)
          remove ClassAssertion(c,i) to specified model
 MolecularModelManager.OWLOperationResponse removeType(String modelId, org.semanticweb.owlapi.model.OWLNamedIndividual i, org.semanticweb.owlapi.model.OWLObjectPropertyExpression p, org.semanticweb.owlapi.model.OWLClassExpression filler)
          Removes a ClassAssertion, where the class expression instantiated is an ObjectSomeValuesFrom expression TODO - in future it should be possible to remove multiple assertions by leaving some fields null
 MolecularModelManager.OWLOperationResponse removeType(String modelId, String iid, String cid)
          Convenience wrapper for removeType(String, OWLNamedIndividual, OWLClass)
 org.semanticweb.owlapi.model.OWLNamedIndividual removeTypeNonReasoning(String modelId, String iid, org.semanticweb.owlapi.model.OWLClassExpression clsExp)
           
 void saveAllModels()
           
 void saveModel(String modelId)
          TODO - locking
 void setDbToTaxon(Map<String,String> dbToTaxon)
           
 void setPathToGafs(String pathToGafs)
          Can either be an HTTP prefix, or an absolute file path
 void setPathToOWLFiles(String pathToOWLFiles)
           
 void setPathToProteinFiles(String pathToProteinFiles)
           
 void setPathToProteinFiles(String pathToProteinFiles, String catalogXML)
           
 MolecularModelManager.OWLOperationResponse undo(String modelId, String changeId)
           
 void unlinkModel(String id)
           
 void writeLego(org.semanticweb.owlapi.model.OWLOntology ontology, String output, String name)
          Deprecated. 
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MolecularModelManager

public MolecularModelManager(OWLGraphWrapper graph)
                      throws org.semanticweb.owlapi.model.OWLOntologyCreationException
Parameters:
graph -
Throws:
org.semanticweb.owlapi.model.OWLOntologyCreationException

MolecularModelManager

public MolecularModelManager(org.semanticweb.owlapi.model.OWLOntology ont)
                      throws org.semanticweb.owlapi.model.OWLOntologyCreationException
Parameters:
ont -
Throws:
org.semanticweb.owlapi.model.OWLOntologyCreationException
Method Detail

init

protected void init()
             throws org.semanticweb.owlapi.model.OWLOntologyCreationException
Throws:
org.semanticweb.owlapi.model.OWLOntologyCreationException

getGraph

public OWLGraphWrapper getGraph()
Returns:
graph wrapper for core/source ontology

getOntology

public org.semanticweb.owlapi.model.OWLOntology getOntology()
Returns:
core/source ontology

getPathToGafs

public String getPathToGafs()
Returns:
path to gafs direcory

setPathToGafs

public void setPathToGafs(String pathToGafs)
Can either be an HTTP prefix, or an absolute file path

Parameters:
pathToGafs -

getPathToOWLFiles

public String getPathToOWLFiles()
Note this may move to an implementation-specific subclass in future

Returns:
path to owl on server

setPathToOWLFiles

public void setPathToOWLFiles(String pathToOWLFiles)
Parameters:
pathToOWLFiles -

setPathToProteinFiles

public void setPathToProteinFiles(String pathToProteinFiles)
                           throws IOException
Parameters:
pathToProteinFiles -
Throws:
IOException

setPathToProteinFiles

public void setPathToProteinFiles(String pathToProteinFiles,
                                  String catalogXML)
                           throws IOException
Parameters:
pathToProteinFiles -
catalogXML -
Throws:
IOException

getPathToProteinFiles

public String getPathToProteinFiles()

getDbToTaxon

public Map<String,String> getDbToTaxon()
Returns:
the dbToTaxon

setDbToTaxon

public void setDbToTaxon(Map<String,String> dbToTaxon)
Parameters:
dbToTaxon - the dbToTaxon to set

loadGaf

public GafDocument loadGaf(String db)
                    throws IOException,
                           URISyntaxException
loads/register a Gaf document

Parameters:
db -
Returns:
Gaf document
Throws:
IOException
URISyntaxException

loadGaf

public GafDocument loadGaf(String db,
                           File gafFile)
                    throws IOException,
                           URISyntaxException
Loads and caches a GAF document from a specified location

Parameters:
db -
gafFile -
Returns:
Gaf document
Throws:
IOException
URISyntaxException

getGaf

public GafDocument getGaf(String db)
                   throws IOException,
                          URISyntaxException
Parameters:
db -
Returns:
Gaf document for db
Throws:
IOException
URISyntaxException

addImports

public void addImports(Iterable<String> imports)
Add additional import declarations for any newly generated model.

Parameters:
imports -

getImports

public Collection<org.semanticweb.owlapi.model.IRI> getImports()

generateModel

public String generateModel(org.semanticweb.owlapi.model.OWLClass processCls,
                            String db)
                     throws org.semanticweb.owlapi.model.OWLOntologyCreationException,
                            IOException,
                            URISyntaxException
Generates a new model taking as input a biological process P and a database D. The axioms from P and annotations to P from D are used to seed a new model See LegoModelGenerator.buildNetwork(OWLClass, java.util.Collection) And also https://docs.google.com/document/d/1TV8Eb9sSvFY-weVZaIfzCxF1qbnmkUaiUhTm9Bs3gRE/edit Note the resulting model is uniquely identified by the modeId, which is currently constructed as a concatenation of the db and the P id. This means that if there is an existing model by this ID it will be overwritten

Parameters:
processCls -
db -
Returns:
modelId
Throws:
org.semanticweb.owlapi.model.OWLOntologyCreationException
URISyntaxException
IOException

generateModel

public String generateModel(String pid,
                            String db)
                     throws org.semanticweb.owlapi.model.OWLOntologyCreationException,
                            IOException,
                            URISyntaxException,
                            MolecularModelManager.UnknownIdentifierException
wrapper for generateModel(OWLClass, String)

Parameters:
pid -
db -
Returns:
modelId
Throws:
org.semanticweb.owlapi.model.OWLOntologyCreationException
IOException
URISyntaxException
MolecularModelManager.UnknownIdentifierException

generateBlankModel

public String generateBlankModel(String db)
                          throws org.semanticweb.owlapi.model.OWLOntologyCreationException,
                                 IOException,
                                 URISyntaxException
Generates a new model taking as input a database D. Note that the resulting model is uniquely identified by the modeId, which is currently constructed as a concatenation of the db and a hidden UUID state. This means that in the unlikely case that there is an existing model by this ID, it will be overwritten,

Parameters:
db -
Returns:
modelId
Throws:
org.semanticweb.owlapi.model.OWLOntologyCreationException
URISyntaxException
IOException

addProcess

public String addProcess(String modelId,
                         org.semanticweb.owlapi.model.OWLClass processCls)
                  throws org.semanticweb.owlapi.model.OWLOntologyCreationException
Adds a process individual (and inferred individuals) to a model

Parameters:
modelId -
processCls -
Returns:
null TODO
Throws:
org.semanticweb.owlapi.model.OWLOntologyCreationException

getIndividuals

public Set<org.semanticweb.owlapi.model.OWLNamedIndividual> getIndividuals(String modelId)
Parameters:
modelId -
Returns:
all individuals in the model

getIndividualsByQuery

public Set<org.semanticweb.owlapi.model.OWLNamedIndividual> getIndividualsByQuery(String modelId,
                                                                                  org.semanticweb.owlapi.model.OWLClassExpression q)
Parameters:
modelId -
q -
Returns:
all individuals in the model that satisfy q

getIndividualsByQuery

public Set<org.semanticweb.owlapi.model.OWLNamedIndividual> getIndividualsByQuery(String modelId,
                                                                                  String qs)
Parameters:
modelId -
qs -
Returns:
all individuals in the model that satisfy q

getModelObject

public Map<Object,Object> getModelObject(String modelId)
Parameters:
modelId -
Returns:
Map object ready for Gson

createMostSpecificClass

public String createMostSpecificClass(String modelId,
                                      String individualId,
                                      String newClassId)
Given an instance, generate the most specific class instance that classifies this instance, and add this as a class to the model ontology

Parameters:
modelId -
individualId -
newClassId -
Returns:
newClassId

createIndividual

public MolecularModelManager.OWLOperationResponse createIndividual(String modelId,
                                                                   org.semanticweb.owlapi.model.OWLClass c)
Parameters:
modelId -
c -
Returns:
id of created individual

createIndividual

public MolecularModelManager.OWLOperationResponse createIndividual(String modelId,
                                                                   String cid,
                                                                   Collection<org.apache.commons.lang3.tuple.Pair<String,String>> annotations)
                                                            throws MolecularModelManager.UnknownIdentifierException
Shortcut for createIndividual(String, OWLClass)

Parameters:
modelId -
cid -
annotations -
Returns:
id of created individual
Throws:
MolecularModelManager.UnknownIdentifierException

createIndividualNonReasoning

public org.apache.commons.lang3.tuple.Pair<String,org.semanticweb.owlapi.model.OWLNamedIndividual> createIndividualNonReasoning(String modelId,
                                                                                                                                String cid,
                                                                                                                                Collection<org.apache.commons.lang3.tuple.Pair<String,String>> annotations)
                                                                                                                         throws MolecularModelManager.UnknownIdentifierException
Shortcut for createIndividual(String, OWLClass)

Parameters:
modelId -
cid -
annotations -
Returns:
id of created individual
Throws:
MolecularModelManager.UnknownIdentifierException

getIndividualById

public MolecularModelManager.OWLOperationResponse getIndividualById(String modelId,
                                                                    String iid)
                                                             throws MolecularModelManager.UnknownIdentifierException
Get the individual information for return.

Parameters:
modelId -
iid -
Returns:
response concerning individual data
Throws:
MolecularModelManager.UnknownIdentifierException

getNamedIndividual

public org.semanticweb.owlapi.model.OWLNamedIndividual getNamedIndividual(String modelId,
                                                                          String iid)
                                                                   throws MolecularModelManager.UnknownIdentifierException
Throws:
MolecularModelManager.UnknownIdentifierException

deleteIndividual

public MolecularModelManager.OWLOperationResponse deleteIndividual(String modelId,
                                                                   String iid)
                                                            throws MolecularModelManager.UnknownIdentifierException
Deletes an individual

Parameters:
modelId -
iid -
Returns:
response into
Throws:
MolecularModelManager.UnknownIdentifierException

deleteIndividual

public MolecularModelManager.OWLOperationResponse deleteIndividual(String modelId,
                                                                   org.semanticweb.owlapi.model.OWLNamedIndividual i)
Deletes an individual

Parameters:
modelId -
i -
Returns:
response into

addAnnotations

public void addAnnotations(String modelId,
                           Collection<org.apache.commons.lang3.tuple.Pair<String,String>> pairs)
                    throws MolecularModelManager.UnknownIdentifierException
Throws:
MolecularModelManager.UnknownIdentifierException

addAnnotations

public org.semanticweb.owlapi.model.OWLNamedIndividual addAnnotations(String modelId,
                                                                      String iid,
                                                                      Collection<org.apache.commons.lang3.tuple.Pair<String,String>> pairs)
                                                               throws MolecularModelManager.UnknownIdentifierException
Throws:
MolecularModelManager.UnknownIdentifierException

addAnnotations

public void addAnnotations(String modelId,
                           org.semanticweb.owlapi.model.OWLNamedIndividual i,
                           Collection<org.semanticweb.owlapi.model.OWLAnnotation> annotations)

removeAnnotations

public org.semanticweb.owlapi.model.OWLNamedIndividual removeAnnotations(String modelId,
                                                                         String iid,
                                                                         Collection<org.apache.commons.lang3.tuple.Pair<String,String>> pairs)
                                                                  throws MolecularModelManager.UnknownIdentifierException
Throws:
MolecularModelManager.UnknownIdentifierException

removeAnnotations

public void removeAnnotations(String modelId,
                              org.semanticweb.owlapi.model.OWLNamedIndividual i,
                              Collection<org.semanticweb.owlapi.model.OWLAnnotation> annotations)

removeAnnotations

public void removeAnnotations(String modelId,
                              Collection<org.apache.commons.lang3.tuple.Pair<String,String>> pairs)
                       throws MolecularModelManager.UnknownIdentifierException
Throws:
MolecularModelManager.UnknownIdentifierException

getModel

public LegoModelGenerator getModel(String id)
Fetches a model by its Id

Parameters:
id -
Returns:
wrapped model

unlinkModel

public void unlinkModel(String id)
Parameters:
id -

deleteModel

public void deleteModel(String id)
Parameters:
id -

getModelIds

public Set<String> getModelIds()
Returns:
ids for all loaded models

dispose

public void dispose()
internal method to cleanup this instance


saveModel

public void saveModel(String modelId)
               throws org.semanticweb.owlapi.model.OWLOntologyStorageException,
                      org.semanticweb.owlapi.model.OWLOntologyCreationException,
                      IOException
TODO - locking

Parameters:
modelId -
Throws:
org.semanticweb.owlapi.model.OWLOntologyStorageException
org.semanticweb.owlapi.model.OWLOntologyCreationException
IOException

saveAllModels

public void saveAllModels()
                   throws org.semanticweb.owlapi.model.OWLOntologyStorageException,
                          org.semanticweb.owlapi.model.OWLOntologyCreationException,
                          IOException
Throws:
org.semanticweb.owlapi.model.OWLOntologyStorageException
org.semanticweb.owlapi.model.OWLOntologyCreationException
IOException

exportModel

public String exportModel(String modelId)
                   throws org.semanticweb.owlapi.model.OWLOntologyStorageException
Export the ABox for the given modelId in the default OWLOntologyFormat.

Parameters:
modelId -
Returns:
modelContent
Throws:
org.semanticweb.owlapi.model.OWLOntologyStorageException

exportModel

public String exportModel(String modelId,
                          String format)
                   throws org.semanticweb.owlapi.model.OWLOntologyStorageException
Export the ABox for the given modelId in the given ontology format.
Warning: The mapping from String to OWLOntologyFormat does not map every format!

Parameters:
modelId -
format -
Returns:
modelContent
Throws:
org.semanticweb.owlapi.model.OWLOntologyStorageException

exportModel

public String exportModel(String modelId,
                          org.semanticweb.owlapi.model.OWLOntologyFormat ontologyFormat)
                   throws org.semanticweb.owlapi.model.OWLOntologyStorageException
Export the ABox, will try to set the ontologyID to the given modelId (to ensure import assumptions are met)

Parameters:
modelId -
ontologyFormat -
Returns:
modelContent
Throws:
org.semanticweb.owlapi.model.OWLOntologyStorageException

importModel

public String importModel(String modelData)
                   throws org.semanticweb.owlapi.model.OWLOntologyCreationException
Try to load (or replace) a model with the given ontology. It is expected that the content is an A-Box ontology, which imports the T-BOX. Also the ontology ID is used to extract the modelId.

This method will currently NOT work due to a bug in the OWL-API. The functional syntax parser does not properly report the exceptions and will return an ontology with an wrong ontology ID!

Parameters:
modelData -
Returns:
modelId
Throws:
org.semanticweb.owlapi.model.OWLOntologyCreationException

getStoredModelIds

public Set<String> getStoredModelIds()
                              throws IOException
Retrieve a collection of all file/stored model ids found in the repo.
Note: Models may not be loaded at this point.

Returns:
set of modelids.
Throws:
IOException

getCurrentModelIds

public Set<String> getCurrentModelIds()
                               throws IOException
Retrieve a collection of all model ids currently in memory.

Returns:
set of modelids.
Throws:
IOException

getAvailableModelIds

public Set<String> getAvailableModelIds()
                                 throws IOException
Retrieve a collection of all available model ids.
Note: Models may not be loaded at this point.

Returns:
set of modelids.
Throws:
IOException

loadModel

protected void loadModel(String modelId,
                         boolean isOverride)
                  throws org.semanticweb.owlapi.model.OWLOntologyCreationException
Throws:
org.semanticweb.owlapi.model.OWLOntologyCreationException

isConsistent

public boolean isConsistent(String modelId)
Parameters:
modelId -
Returns:
true if the ontology formed by the specified model is inconsistent

getOWLDataFactory

public org.semanticweb.owlapi.model.OWLDataFactory getOWLDataFactory(String modelId)
Parameters:
modelId -
Returns:
data factory for the specified model

getOWLOntologyManager

protected org.semanticweb.owlapi.model.OWLOntologyManager getOWLOntologyManager(String modelId)

addType

public MolecularModelManager.OWLOperationResponse addType(String modelId,
                                                          org.semanticweb.owlapi.model.OWLNamedIndividual i,
                                                          org.semanticweb.owlapi.model.OWLClass c)
Adds ClassAssertion(c,i) to specified model

Parameters:
modelId -
i -
c -
Returns:
response info

addType

public MolecularModelManager.OWLOperationResponse addType(String modelId,
                                                          String iid,
                                                          String cid)
                                                   throws MolecularModelManager.UnknownIdentifierException
Convenience wrapper for addType(String, OWLNamedIndividual, OWLClass)

Parameters:
modelId -
iid -
cid -
Returns:
response info
Throws:
MolecularModelManager.UnknownIdentifierException

addTypeNonReasoning

public org.semanticweb.owlapi.model.OWLNamedIndividual addTypeNonReasoning(String modelId,
                                                                           String iid,
                                                                           org.semanticweb.owlapi.model.OWLClassExpression clsExp)
                                                                    throws MolecularModelManager.UnknownIdentifierException
Parameters:
modelId -
iid -
clsExp -
Returns:
individual
Throws:
MolecularModelManager.UnknownIdentifierException

addType

public MolecularModelManager.OWLOperationResponse addType(String modelId,
                                                          org.semanticweb.owlapi.model.OWLNamedIndividual i,
                                                          org.semanticweb.owlapi.model.OWLObjectPropertyExpression p,
                                                          org.semanticweb.owlapi.model.OWLClassExpression filler)
Adds a ClassAssertion, where the class expression instantiated is an ObjectSomeValuesFrom expression Example: Individual: i Type: enabledBy some PRO_123

Parameters:
modelId -
i -
p -
filler -
Returns:
response info

addType

public MolecularModelManager.OWLOperationResponse addType(String modelId,
                                                          String iid,
                                                          String pid,
                                                          String cid)
                                                   throws MolecularModelManager.UnknownIdentifierException
Convenience wrapper for addType(String, OWLNamedIndividual, OWLObjectPropertyExpression, OWLClassExpression)

Parameters:
modelId -
iid -
pid -
cid -
Returns:
response info
Throws:
MolecularModelManager.UnknownIdentifierException

addTypeNonReasoning

public org.semanticweb.owlapi.model.OWLNamedIndividual addTypeNonReasoning(String modelId,
                                                                           String iid,
                                                                           String pid,
                                                                           org.semanticweb.owlapi.model.OWLClassExpression ce)
                                                                    throws MolecularModelManager.UnknownIdentifierException
Throws:
MolecularModelManager.UnknownIdentifierException

removeType

public MolecularModelManager.OWLOperationResponse removeType(String modelId,
                                                             org.semanticweb.owlapi.model.OWLNamedIndividual i,
                                                             org.semanticweb.owlapi.model.OWLClass c)
remove ClassAssertion(c,i) to specified model

Parameters:
modelId -
i -
c -
Returns:
response info

removeType

public MolecularModelManager.OWLOperationResponse removeType(String modelId,
                                                             String iid,
                                                             String cid)
                                                      throws MolecularModelManager.UnknownIdentifierException
Convenience wrapper for removeType(String, OWLNamedIndividual, OWLClass)

Parameters:
modelId -
iid -
cid -
Returns:
response info
Throws:
MolecularModelManager.UnknownIdentifierException

removeTypeNonReasoning

public org.semanticweb.owlapi.model.OWLNamedIndividual removeTypeNonReasoning(String modelId,
                                                                              String iid,
                                                                              org.semanticweb.owlapi.model.OWLClassExpression clsExp)
                                                                       throws MolecularModelManager.UnknownIdentifierException
Throws:
MolecularModelManager.UnknownIdentifierException

removeType

public MolecularModelManager.OWLOperationResponse removeType(String modelId,
                                                             org.semanticweb.owlapi.model.OWLNamedIndividual i,
                                                             org.semanticweb.owlapi.model.OWLObjectPropertyExpression p,
                                                             org.semanticweb.owlapi.model.OWLClassExpression filler)
Removes a ClassAssertion, where the class expression instantiated is an ObjectSomeValuesFrom expression TODO - in future it should be possible to remove multiple assertions by leaving some fields null

Parameters:
modelId -
i -
p -
filler -
Returns:
response info

addOccursIn

public MolecularModelManager.OWLOperationResponse addOccursIn(String modelId,
                                                              String iid,
                                                              String eid)
                                                       throws MolecularModelManager.UnknownIdentifierException
Convenience wrapper for addOccursIn(String, OWLNamedIndividual, OWLClassExpression)

Parameters:
modelId -
iid -
eid - - e.g. PR:P12345
Returns:
response info
Throws:
MolecularModelManager.UnknownIdentifierException

addOccursIn

public MolecularModelManager.OWLOperationResponse addOccursIn(String modelId,
                                                              org.semanticweb.owlapi.model.OWLNamedIndividual i,
                                                              org.semanticweb.owlapi.model.OWLClassExpression enabler)
Adds a ClassAssertion to the model, connecting an activity instance to the class of molecule that enables the activity. Example: FGFR receptor activity occursIn some UniProtKB:FGF The reasoner may detect an inconsistency under different scenarios: - i may be an instance of a class that is disjoint with a bfo process - the enabled may be an instance of a class that is disjoint with molecular entity Under these circumstances, no error is thrown, but the response code indicates that no operation was performed on the kb, and the response object indicates the operation caused an inconsistency

Parameters:
modelId -
i -
enabler -
Returns:
response info

addEnabledBy

public MolecularModelManager.OWLOperationResponse addEnabledBy(String modelId,
                                                               String iid,
                                                               String eid)
                                                        throws MolecularModelManager.UnknownIdentifierException,
                                                               org.semanticweb.owlapi.model.OWLException
Convenience wrapper for addEnabledBy(String, OWLNamedIndividual, OWLClassExpression)

Parameters:
modelId -
iid -
eid - - e.g. PR:P12345
Returns:
response info
Throws:
MolecularModelManager.UnknownIdentifierException
org.semanticweb.owlapi.model.OWLException

parseClassExpression

public static org.semanticweb.owlapi.model.OWLClassExpression parseClassExpression(String expression,
                                                                                   OWLGraphWrapper g)
                                                                            throws org.semanticweb.owlapi.model.OWLException
Throws:
org.semanticweb.owlapi.model.OWLException

addEnabledBy

public MolecularModelManager.OWLOperationResponse addEnabledBy(String modelId,
                                                               org.semanticweb.owlapi.model.OWLNamedIndividual i,
                                                               org.semanticweb.owlapi.model.OWLClassExpression enabler)
Adds a ClassAssertion to the model, connecting an activity instance to the class of molecule that enables the activity. Example: FGFR receptor activity enabledBy some UniProtKB:FGF The reasoner may detect an inconsistency under different scenarios: - i may be an instance of a class that is disjoint with a bfo process - the enabled may be an instance of a class that is disjoint with molecular entity Under these circumstances, no error is thrown, but the response code indicates that no operation was performed on the kb, and the response object indicates the operation caused an inconsistency

Parameters:
modelId -
i -
enabler -
Returns:
response info

addFact

public MolecularModelManager.OWLOperationResponse addFact(String modelId,
                                                          org.semanticweb.owlapi.model.OWLObjectPropertyExpression p,
                                                          org.semanticweb.owlapi.model.OWLNamedIndividual i,
                                                          org.semanticweb.owlapi.model.OWLNamedIndividual j,
                                                          Set<org.semanticweb.owlapi.model.OWLAnnotation> annotations)
Adds triple (i,p,j) to specified model

Parameters:
modelId -
p -
i -
j -
annotations -
Returns:
response info

addFact

public MolecularModelManager.OWLOperationResponse addFact(String modelId,
                                                          OBOUpperVocabulary vocabElement,
                                                          org.semanticweb.owlapi.model.OWLNamedIndividual i,
                                                          org.semanticweb.owlapi.model.OWLNamedIndividual j,
                                                          Set<org.semanticweb.owlapi.model.OWLAnnotation> annotations)
Convenience wrapper for addFact(String, OWLObjectPropertyExpression, OWLNamedIndividual, OWLNamedIndividual, Set)

Parameters:
modelId -
vocabElement -
i -
j -
annotations -
Returns:
response info

addFact

public MolecularModelManager.OWLOperationResponse addFact(String modelId,
                                                          String pid,
                                                          String iid,
                                                          String jid,
                                                          Collection<org.apache.commons.lang3.tuple.Pair<String,String>> pairs)
                                                   throws MolecularModelManager.UnknownIdentifierException
Convenience wrapper for addFact(String, OWLObjectPropertyExpression, OWLNamedIndividual, OWLNamedIndividual, Set)

Parameters:
modelId -
pid -
iid -
jid -
pairs -
Returns:
response info
Throws:
MolecularModelManager.UnknownIdentifierException

addFactNonReasoning

public List<org.semanticweb.owlapi.model.OWLNamedIndividual> addFactNonReasoning(String modelId,
                                                                                 String pid,
                                                                                 String iid,
                                                                                 String jid,
                                                                                 Collection<org.apache.commons.lang3.tuple.Pair<String,String>> pairs)
                                                                          throws MolecularModelManager.UnknownIdentifierException
Convenience wrapper for addFact(String, OWLObjectPropertyExpression, OWLNamedIndividual, OWLNamedIndividual, Set)

Parameters:
modelId -
pid -
iid -
jid -
pairs -
Returns:
relevant individuals
Throws:
MolecularModelManager.UnknownIdentifierException

addFact

public MolecularModelManager.OWLOperationResponse addFact(String modelId,
                                                          OBOUpperVocabulary vocabElement,
                                                          String iid,
                                                          String jid,
                                                          Collection<org.apache.commons.lang3.tuple.Pair<String,String>> pairs)
                                                   throws MolecularModelManager.UnknownIdentifierException
Convenience wrapper for addFact(String, OWLObjectPropertyExpression, OWLNamedIndividual, OWLNamedIndividual, Set)

Parameters:
modelId -
vocabElement -
iid -
jid -
pairs -
Returns:
response info
Throws:
MolecularModelManager.UnknownIdentifierException

removeFact

public MolecularModelManager.OWLOperationResponse removeFact(String modelId,
                                                             org.semanticweb.owlapi.model.OWLObjectPropertyExpression p,
                                                             org.semanticweb.owlapi.model.OWLNamedIndividual i,
                                                             org.semanticweb.owlapi.model.OWLNamedIndividual j)
Parameters:
modelId -
p -
i -
j -
Returns:
response info

removeFact

public MolecularModelManager.OWLOperationResponse removeFact(String modelId,
                                                             String pid,
                                                             String iid,
                                                             String jid)
                                                      throws MolecularModelManager.UnknownIdentifierException
Parameters:
modelId -
pid -
iid -
jid -
Returns:
response info
Throws:
MolecularModelManager.UnknownIdentifierException

removeFactNonReasoning

public List<org.semanticweb.owlapi.model.OWLNamedIndividual> removeFactNonReasoning(String modelId,
                                                                                    String pid,
                                                                                    String iid,
                                                                                    String jid)
                                                                             throws MolecularModelManager.UnknownIdentifierException
Throws:
MolecularModelManager.UnknownIdentifierException

addAnnotations

public List<org.semanticweb.owlapi.model.OWLNamedIndividual> addAnnotations(String modelId,
                                                                            String pid,
                                                                            String iid,
                                                                            String jid,
                                                                            Collection<org.apache.commons.lang3.tuple.Pair<String,String>> pairs)
                                                                     throws MolecularModelManager.UnknownIdentifierException
Throws:
MolecularModelManager.UnknownIdentifierException

addAnnotations

public MolecularModelManager.OWLOperationResponse addAnnotations(String modelId,
                                                                 org.semanticweb.owlapi.model.OWLObjectPropertyExpression p,
                                                                 org.semanticweb.owlapi.model.OWLNamedIndividual i,
                                                                 org.semanticweb.owlapi.model.OWLNamedIndividual j,
                                                                 Set<org.semanticweb.owlapi.model.OWLAnnotation> annotations)

removeAnnotations

public List<org.semanticweb.owlapi.model.OWLNamedIndividual> removeAnnotations(String modelId,
                                                                               String pid,
                                                                               String iid,
                                                                               String jid,
                                                                               Collection<org.apache.commons.lang3.tuple.Pair<String,String>> pairs)
                                                                        throws MolecularModelManager.UnknownIdentifierException
Throws:
MolecularModelManager.UnknownIdentifierException

addPartOf

public MolecularModelManager.OWLOperationResponse addPartOf(String modelId,
                                                            String iid,
                                                            String jid,
                                                            Collection<org.apache.commons.lang3.tuple.Pair<String,String>> pairs)
                                                     throws MolecularModelManager.UnknownIdentifierException
Convenience wrapper for addPartOf(String, OWLNamedIndividual, OWLNamedIndividual, Set)

Parameters:
modelId -
iid -
jid -
pairs -
Returns:
response info
Throws:
MolecularModelManager.UnknownIdentifierException

addPartOf

public MolecularModelManager.OWLOperationResponse addPartOf(String modelId,
                                                            org.semanticweb.owlapi.model.OWLNamedIndividual i,
                                                            org.semanticweb.owlapi.model.OWLNamedIndividual j,
                                                            Set<org.semanticweb.owlapi.model.OWLAnnotation> annotations)
Adds an OWL ObjectPropertyAssertion connecting i to j via part_of Note that the inverse assertion is entailed, but not asserted

Parameters:
modelId -
i -
j -
annotations -
Returns:
response info

undo

public MolecularModelManager.OWLOperationResponse undo(String modelId,
                                                       String changeId)

generateDot

@Deprecated
public String generateDot(String modelId)
                   throws IOException,
                          LegoTools.UnExpectedStructureException
Deprecated. 

For testing purposes - may be obsoleted with rendering moved to client

Parameters:
modelId -
Returns:
dot string
Throws:
IOException
LegoTools.UnExpectedStructureException

generateImage

@Deprecated
public File generateImage(String modelId)
                   throws IOException,
                          LegoTools.UnExpectedStructureException,
                          InterruptedException
Deprecated. 

Parameters:
modelId -
Returns:
png File
Throws:
IOException
LegoTools.UnExpectedStructureException
InterruptedException

writeLego

@Deprecated
public void writeLego(org.semanticweb.owlapi.model.OWLOntology ontology,
                                 String output,
                                 String name)
               throws Exception
Deprecated. 

Parameters:
ontology -
output -
name -
Throws:
Exception

addCompositeIndividual

public MolecularModelManager.OWLOperationResponse addCompositeIndividual(String modelId,
                                                                         String classId,
                                                                         String enabledById,
                                                                         String occursInId)
                                                                  throws MolecularModelManager.UnknownIdentifierException
A simple wrapping function that captures the most basic type of editing.

Parameters:
modelId -
classId -
enabledById -
occursInId -
Returns:
response
Throws:
MolecularModelManager.UnknownIdentifierException


Copyright © 2010-2014. All Rights Reserved.