Package org.helm.notation2
Class MonomerFactory
java.lang.Object
org.helm.notation2.MonomerFactory
public class MonomerFactory extends Object
This is a factory class to build monomer database from
MonomerDBGZEnconded.xml document
- Author:
- zhangtianhong
-
Field Summary
Fields Modifier and Type Field Description static StringATTACHMENT_LIST_ELEMENTstatic StringATTACHMENTS_RESOURCEstatic StringDEFAULT_NAME_SPACEstatic StringEXTERNAL_SCHEMA_LOCATION_KEYstatic StringMONOMER_CACHE_FILE_NAMEstatic StringMONOMER_CACHE_FILE_PATHstatic StringMONOMER_DB_FILE_NAMEstatic StringMONOMER_DB_FILE_PATHstatic StringMONOMER_DB_SCHEMA_RESOURCEstatic StringMONOMER_DB_XML_RESOURCEprotected MonomerStoremonomerStorestatic StringNOTATION_DIRECTORYstatic StringPOLYMER_ELEMENTstatic StringPOLYMER_LIST_ELEMENTstatic StringPOLYMER_TYPE_ATTRIBUTEstatic StringXML_SCHEMA_VALIDATION_FEATURE -
Method Summary
Modifier and Type Method Description voidaddNewMonomer(Monomer monomer)To add new monomer into monomerCacheMonomerCachebuildMonomerCacheFromXML(String monomerDBXML)Build an MonomerCache object with monomerDBXML Stringstatic voidfinalizeMonomerCache()Map<String,Attachment>getAttachmentDB()Map<String,List<String>>getAttachmentLabelIDs()Map<Monomer,Monomer>getConflictedMonomerMap(MonomerCache remoteMonomerCache)static MonomerFactorygetInstance()Initialize MonomerCache and returns the singleton Factory classMap<String,Map<String,Monomer>>getMonomerDB()retruns the monomer databaseMap<String,Map<String,Monomer>>getMonomerDB(boolean includeNewMonomers)returns the monomer database including monomers that where temporary marked as new, else without those monomersMonomerStoregetMonomerStore()create a MonomerStore instance based on MonomerFactory's monomerDB and smilesMonomerDBList<String>getMonomerTypes()List<String>getPolymerTypes()Map<String,Monomer>getSmilesMonomerDB()Map<String,Monomer>getSmilesMonomerDB(boolean includeNewMonomers)static booleanhasDBChanged()Returns whether one of the stored databases has changed, for example by adding or removing monomers.voidmerge(MonomerCache remoteMonomerCache)merge remote monomerCache with local monomerCache, will throw exception if conflicts found.static voidrefreshMonomerCache()static voidresetDBChanged()voidsaveMonomerCache()save monomerCache to disk filestatic voidsetDBChanged(boolean isChanged)voidsetMonomerCache(MonomerCache remoteMonomerCache)replace local cache with remote one completely, may cause loss of datastatic voidsetupBuilder()
-
Field Details
-
NOTATION_DIRECTORY
-
MONOMER_CACHE_FILE_NAME
- See Also:
- Constant Field Values
-
MONOMER_CACHE_FILE_PATH
-
MONOMER_DB_FILE_NAME
- See Also:
- Constant Field Values
-
MONOMER_DB_FILE_PATH
-
MONOMER_DB_XML_RESOURCE
- See Also:
- Constant Field Values
-
MONOMER_DB_SCHEMA_RESOURCE
- See Also:
- Constant Field Values
-
ATTACHMENTS_RESOURCE
- See Also:
- Constant Field Values
-
XML_SCHEMA_VALIDATION_FEATURE
- See Also:
- Constant Field Values
-
EXTERNAL_SCHEMA_LOCATION_KEY
- See Also:
- Constant Field Values
-
DEFAULT_NAME_SPACE
- See Also:
- Constant Field Values
-
POLYMER_LIST_ELEMENT
- See Also:
- Constant Field Values
-
POLYMER_ELEMENT
- See Also:
- Constant Field Values
-
POLYMER_TYPE_ATTRIBUTE
- See Also:
- Constant Field Values
-
ATTACHMENT_LIST_ELEMENT
- See Also:
- Constant Field Values
-
monomerStore
-
-
Method Details
-
getMonomerDB
retruns the monomer database- Returns:
- Map as
Map<String, Map<String, Monomer>>
-
getMonomerDB
returns the monomer database including monomers that where temporary marked as new, else without those monomers- Parameters:
includeNewMonomers- if true, then the new monomers will be added to the monomer db- Returns:
- Map as
Map<String, Map<String, Monomer>>
-
getMonomerStore
create a MonomerStore instance based on MonomerFactory's monomerDB and smilesMonomerDB- Returns:
- MonomerStore
-
getAttachmentDB
-
getSmilesMonomerDB
-
getSmilesMonomerDB
-
getPolymerTypes
-
getMonomerTypes
-
getAttachmentLabelIDs
-
setupBuilder
public static void setupBuilder() -
getInstance
Initialize MonomerCache and returns the singleton Factory class- Returns:
- MonomerFactory current monomerfactory
- Throws:
MonomerLoadingException- if the monomer could not be loaded from the sourceChemistryException- if the chemistry could not be initialized
-
refreshMonomerCache
-
setDBChanged
public static void setDBChanged(boolean isChanged) -
hasDBChanged
public static boolean hasDBChanged()Returns whether one of the stored databases has changed, for example by adding or removing monomers.- Returns:
- true when database has changed else false
-
resetDBChanged
public static void resetDBChanged() -
addNewMonomer
To add new monomer into monomerCache- Parameters:
monomer- given Monomer- Throws:
IOException- if monomer store can not be readMonomerException- if monomer is not valid
-
buildMonomerCacheFromXML
public MonomerCache buildMonomerCacheFromXML(String monomerDBXML) throws MonomerException, IOException, org.jdom2.JDOMException, ChemistryException, org.helm.chemtoolkit.CTKExceptionBuild an MonomerCache object with monomerDBXML String- Parameters:
monomerDBXML- monomer db in xml format as string- Returns:
- MonomerCache
- Throws:
MonomerException- if monomer is not validIOException- if string can not be readorg.jdom2.JDOMException- if xml file is not validChemistryException- if chemistry could not be initializedorg.helm.chemtoolkit.CTKException- general ChemToolKit exception passed to HELMToolKit
-
merge
merge remote monomerCache with local monomerCache, will throw exception if conflicts found. Client needs to resolve conflicts prior to calling merge- Parameters:
remoteMonomerCache- remote monomer cache- Throws:
IOException- if monomer store can not be readMonomerException- if monomer is not valid
-
setMonomerCache
replace local cache with remote one completely, may cause loss of data- Parameters:
remoteMonomerCache- remote monomer cache- Throws:
IOException- if monomer store can not be readMonomerException- if monomer is not valid
-
getConflictedMonomerMap
public Map<Monomer,Monomer> getConflictedMonomerMap(MonomerCache remoteMonomerCache) throws IOException, MonomerException- Parameters:
remoteMonomerCache- remoteMonomerCache- Returns:
- localMonomer and remoteMonomer mismatch, key is local, value is remote
- Throws:
IOException- if monomer store can not be readMonomerException- if monomer is not valid
-
saveMonomerCache
save monomerCache to disk file- Throws:
IOException- if the monomer can not be saved to disk fileMonomerException- if monomer is not valid
-
finalizeMonomerCache
public static void finalizeMonomerCache()
-