From: <and...@us...> - 2015-06-14 23:35:51
|
Revision: 2332 http://sourceforge.net/p/jsbml/code/2332 Author: andreas-draeger Date: 2015-06-14 23:35:49 +0000 (Sun, 14 Jun 2015) Log Message: ----------- * Updated SBO * Enums inside of CVTerm are now easier to extend because each entry contains now information about itself that had been stored in complex switch statements before. * TidySBMLWriter is now able to interpret the user's choice of the indentation count and character (tabs vs. spaces) and its settings were alphabetically ordered. Modified Paths: -------------- trunk/core/resources/org/sbml/jsbml/resources/cfg/SBO_OBO.obo trunk/core/src/org/sbml/jsbml/AbstractSBase.java trunk/core/src/org/sbml/jsbml/CVTerm.java trunk/core/src/org/sbml/jsbml/SBase.java trunk/core/src/org/sbml/jsbml/util/compilers/FormulaCompiler.java trunk/modules/tidy/src/org/sbml/jsbml/TidySBMLWriter.java Modified: trunk/core/resources/org/sbml/jsbml/resources/cfg/SBO_OBO.obo =================================================================== --- trunk/core/resources/org/sbml/jsbml/resources/cfg/SBO_OBO.obo 2015-06-14 16:46:08 UTC (rev 2331) +++ trunk/core/resources/org/sbml/jsbml/resources/cfg/SBO_OBO.obo 2015-06-14 23:35:49 UTC (rev 2332) @@ -1,5 +1,5 @@ format-version: 1.2 -date: 14:05:2015 07:00 +date: 14:06:2015 07:00 data-version: 13:05:2015 13:49 saved-by: SBO community auto-generated-by: SBO Browser (http://www.ebi.ac.uk/sbo/) @@ -1066,19 +1066,6 @@ is_a: SBO:0000041 ! mass action rate law for irreversible reactions [Term] -id: SBO:0000231 -name: occurring entity representation -def: "Representation of an entity that manifests, unfolds or develops through time, such as a discrete event, or a mutual or reciprocal action or influence that happens between participating physical entities, and/or other occurring entities. " [src_code:NR] -comment: modified as part of ontology 'refactoring' process \[SF bug #3172586\]\nName changed to \"interaction\" on November 18 2008 by Nicolas Le Novere.\nDefinition changed to mention interaction with other interactions, in order to cover \"process\" and \"relationship\". -is_a: SBO:0000000 ! systems biology representation - -[Term] -id: SBO:0000232 -name: obsolete event -def: "A phenomenon that takes place and which may be observable, or may be determined to have occurred as the result of an action or process." [src_code:NR] -is_obsolete: true - -[Term] id: SBO:0000167 name: biochemical or transport reaction def: "An event involving one or more physical entities that modifies the structure, location or free energy of at least one of the participants." [src_code:NR] @@ -1517,6 +1504,19 @@ is_a: SBO:0000227 ! mass density of an entity [Term] +id: SBO:0000231 +name: occurring entity representation +def: "Representation of an entity that manifests, unfolds or develops through time, such as a discrete event, or a mutual or reciprocal action or influence that happens between participating physical entities, and/or other occurring entities. " [src_code:NR] +comment: modified as part of ontology 'refactoring' process \[SF bug #3172586\]\nName changed to \"interaction\" on November 18 2008 by Nicolas Le Novere.\nDefinition changed to mention interaction with other interactions, in order to cover \"process\" and \"relationship\". +is_a: SBO:0000000 ! systems biology representation + +[Term] +id: SBO:0000232 +name: obsolete event +def: "A phenomenon that takes place and which may be observable, or may be determined to have occurred as the result of an action or process." [src_code:NR] +is_obsolete: true + +[Term] id: SBO:0000233 name: hydroxylation def: "Addition of an hydroxyl group (-OH) to a chemical entity. " [src_code:NR] Modified: trunk/core/src/org/sbml/jsbml/AbstractSBase.java =================================================================== --- trunk/core/src/org/sbml/jsbml/AbstractSBase.java 2015-06-14 16:46:08 UTC (rev 2331) +++ trunk/core/src/org/sbml/jsbml/AbstractSBase.java 2015-06-14 23:35:49 UTC (rev 2332) @@ -1905,7 +1905,7 @@ * @see org.sbml.jsbml.SBase#setMetaId(java.lang.String) */ @Override - public void setMetaId(String metaId) { + public void setMetaId(String metaId) throws IllegalArgumentException { if (metaId != null) { if (isSetMetaId() && getMetaId().equals(metaId)) { /* Do nothing if the identical metaId has already been assigned to this Modified: trunk/core/src/org/sbml/jsbml/CVTerm.java =================================================================== --- trunk/core/src/org/sbml/jsbml/CVTerm.java 2015-06-14 16:46:08 UTC (rev 2331) +++ trunk/core/src/org/sbml/jsbml/CVTerm.java 2015-06-14 23:35:49 UTC (rev 2332) @@ -209,36 +209,7 @@ * @return */ public static Qualifier getBiologicalQualifierFor(String elementNameEquivalent) { - - if (elementNameEquivalent.equals(BQB_ENCODES.nameEquivalent)) { - return BQB_ENCODES; - } else if (elementNameEquivalent.equals(BQB_HAS_PART.nameEquivalent)) { - return BQB_HAS_PART; - } else if (elementNameEquivalent.equals(BQB_HAS_VERSION.nameEquivalent)) { - return BQB_HAS_VERSION; - } else if (elementNameEquivalent.equals(BQB_HAS_PROPERTY.nameEquivalent)) { - return BQB_HAS_PROPERTY; - } else if (elementNameEquivalent.equals(BQB_HAS_TAXON.nameEquivalent)) { - return BQB_HAS_TAXON; - } else if (elementNameEquivalent.equals(BQB_IS_PROPERTY_OF.nameEquivalent)) { - return BQB_IS_PROPERTY_OF; - } else if (elementNameEquivalent.equals(BQB_IS.nameEquivalent)) { - return BQB_IS; - } else if (elementNameEquivalent.equals(BQB_IS_DESCRIBED_BY.nameEquivalent)) { - return BQB_IS_DESCRIBED_BY; - } else if (elementNameEquivalent.equals(BQB_IS_ENCODED_BY.nameEquivalent)) { - return BQB_IS_ENCODED_BY; - } else if (elementNameEquivalent.equals(BQB_IS_HOMOLOG_TO.nameEquivalent)) { - return BQB_IS_HOMOLOG_TO; - } else if (elementNameEquivalent.equals(BQB_IS_PART_OF.nameEquivalent)) { - return BQB_IS_PART_OF; - } else if (elementNameEquivalent.equals(BQB_IS_VERSION_OF.nameEquivalent)) { - return BQB_IS_VERSION_OF; - } else if (elementNameEquivalent.equals(BQB_OCCURS_IN.nameEquivalent)) { - return BQB_OCCURS_IN; - } - - return BQB_UNKNOWN; + return getQualifierFor(elementNameEquivalent, "BQB_", BQB_UNKNOWN); } /** @@ -247,20 +218,23 @@ * @return */ public static Qualifier getModelQualifierFor(String elementNameEquivalent) { + return getQualifierFor(elementNameEquivalent, "BQM_", BQM_UNKNOWN); + } - if (elementNameEquivalent.equals(BQM_IS.nameEquivalent)) { - return BQM_IS; - } else if (elementNameEquivalent.equals(BQM_IS_DESCRIBED_BY.nameEquivalent)) { - return BQM_IS_DESCRIBED_BY; - } else if (elementNameEquivalent.equals(BQM_IS_DERIVED_FROM.nameEquivalent)) { - return BQM_IS_DERIVED_FROM; - } else if (elementNameEquivalent.equals(BQM_IS_INSTANCE_OF.nameEquivalent)) { - return BQM_IS_INSTANCE_OF; - } else if (elementNameEquivalent.equals(BQM_HAS_INSTANCE.nameEquivalent)) { - return BQM_HAS_INSTANCE; + /** + * @param elementNameEquivalent + * @param prefix + * @param unknownQualifier + * @return + */ + private static Qualifier getQualifierFor(String elementNameEquivalent, + String prefix, Qualifier unknownQualifier) { + for (Qualifier q : values()) { + if (q.name().startsWith(prefix) && q.getElementNameEquivalent().equals(elementNameEquivalent)) { + return q; + } } - - return BQM_UNKNOWN; + return unknownQualifier; } @@ -305,7 +279,9 @@ public boolean isModelQualifier() { return toString().startsWith("BQM_"); } + } + /** * This enum list all the possible MIRIAM qualifiers type. * Modified: trunk/core/src/org/sbml/jsbml/SBase.java =================================================================== --- trunk/core/src/org/sbml/jsbml/SBase.java 2015-06-14 16:46:08 UTC (rev 2331) +++ trunk/core/src/org/sbml/jsbml/SBase.java 2015-06-14 23:35:49 UTC (rev 2332) @@ -940,11 +940,14 @@ * * @param metaid * the meatId to be set. + * @throws IllegalArgumentException + * if the given metaid does not follow the pattern for valid metaids + * ore if it is already used in the {@link SBMLDocument} * @throws PropertyNotAvailableException * in SBML level 1, as this attribute was introduced only from SBML * level 2. */ - public void setMetaId(String metaid); + public void setMetaId(String metaid) throws IllegalArgumentException; /** * Sets the notes with 'notes'. Modified: trunk/core/src/org/sbml/jsbml/util/compilers/FormulaCompiler.java =================================================================== --- trunk/core/src/org/sbml/jsbml/util/compilers/FormulaCompiler.java 2015-06-14 16:46:08 UTC (rev 2331) +++ trunk/core/src/org/sbml/jsbml/util/compilers/FormulaCompiler.java 2015-06-14 23:35:49 UTC (rev 2332) @@ -67,8 +67,11 @@ public class FormulaCompiler extends StringTools implements ASTNodeCompiler { + /** + * + */ public static final String FORMULA_ARGUMENT_SEPARATOR = ""; - + /** * Basic method which links several elements with a mathematical operator. * All empty StringBuffer object are excluded. @@ -480,7 +483,7 @@ /** * Creates brackets if needed. * - * @param nodes + * @param node * @return * @throws SBMLException */ @@ -492,7 +495,7 @@ || node.isFunction()) { return term; } - + return term = brackets(term).toString(); } Modified: trunk/modules/tidy/src/org/sbml/jsbml/TidySBMLWriter.java =================================================================== --- trunk/modules/tidy/src/org/sbml/jsbml/TidySBMLWriter.java 2015-06-14 16:46:08 UTC (rev 2331) +++ trunk/modules/tidy/src/org/sbml/jsbml/TidySBMLWriter.java 2015-06-14 23:35:49 UTC (rev 2332) @@ -59,25 +59,24 @@ /** * */ - private static Tidy tidy = new Tidy(); // obtain a new Tidy instance + private static final transient Tidy tidy = new Tidy(); // obtain a new Tidy instance static { - // set desired configuration options using tidy setters - tidy.setXmlTags(true); + tidy.setDropEmptyParas(false); + tidy.setHideComments(false); tidy.setIndentContent(true); - tidy.setXmlOut(true); tidy.setInputEncoding("UTF-8"); tidy.setOutputEncoding("UTF-8"); - - tidy.setDropEmptyParas(false); - + tidy.setQuiet(true); tidy.setSmartIndent(true); + tidy.setTrimEmptyElements(true); + tidy.setWraplen(200); + tidy.setWrapAttVals(false); tidy.setWrapScriptlets(true); - tidy.setWraplen(200); - tidy.setSpaces(2); + tidy.setXmlOut(true); tidy.setXmlSpace(true); - tidy.setQuiet(true); + tidy.setXmlTags(true); } /** @@ -111,10 +110,23 @@ String sbmlDocString = sbmlWriter.writeSBMLToString(sbmlDocument); + setIndentation(indentChar, indentCount); tidy.parse(new StringReader(sbmlDocString), new FileWriter(file)); // run tidy, providing an input and output stream } /** + * @param indentChar + * @param indentCount + */ + public static void setIndentation(char indentChar, short indentCount) { + if (indentChar == ' ') { + tidy.setSpaces(indentCount); + } else { + tidy.setTabsize(indentCount); + } + } + + /** * Writes the given SBML document to a {@link File}. * <p> * @@ -146,6 +158,7 @@ SBMLWriter sbmlWriter = new SBMLWriter(); String sbmlDocString = sbmlWriter.writeSBMLToString(sbmlDocument, programName, programVersion); + setIndentation(' ', (short) 2); tidy.parse(new StringReader(sbmlDocString), new FileWriter(file)); // run tidy, providing an input and output stream } @@ -189,6 +202,7 @@ sbmlWriter.setIndentationCount(indentCount); String sbmlDocString = sbmlWriter.writeSBMLToString(sbmlDocument, programName, programVersion); + setIndentation(indentChar, indentCount); tidy.parse(new StringReader(sbmlDocString), new FileWriter(file)); // run tidy, providing an input and output stream } @@ -213,6 +227,7 @@ sbmlWriter.setIndentationCount(indentCount); String sbmlDocString = sbmlWriter.writeSBMLToString(sbmlDocument); + setIndentation(indentChar, indentCount); tidy.parse(new StringReader(sbmlDocString), stream); // run tidy, providing an input and output stream } @@ -244,6 +259,7 @@ SBMLWriter sbmlWriter = new SBMLWriter(); String sbmlDocString = sbmlWriter.writeSBMLToString(sbmlDocument, programName, programVersion); + setIndentation(' ', (short) 2); tidy.parse(new StringReader(sbmlDocString), stream); // run tidy, providing an input and output stream } @@ -283,6 +299,7 @@ sbmlWriter.setIndentationCount(indentCount); String sbmlDocString = sbmlWriter.writeSBMLToString(sbmlDocument, programName, programVersion); + setIndentation(indentChar, indentCount); tidy.parse(new StringReader(sbmlDocString), stream); // run tidy, providing an input and output stream } @@ -318,6 +335,7 @@ String sbmlDocString = sbmlWriter.writeSBMLToString(sbmlDocument); try { + setIndentation(indentChar, indentCount); tidy.parse(new StringReader(sbmlDocString), new FileWriter(fileName)); // run tidy, providing an input and output stream } catch (IOException e) { throw new SBMLException(e); @@ -357,6 +375,7 @@ String sbmlDocString = sbmlWriter.writeSBMLToString(sbmlDocument, programName, programVersion); try { + setIndentation(' ', (short) 2); tidy.parse(new StringReader(sbmlDocString), new FileWriter(fileName)); // run tidy, providing an input and output stream } catch (IOException e) { throw new SBMLException(e); @@ -405,6 +424,7 @@ String sbmlDocString = sbmlWriter.writeSBMLToString(sbmlDocument, programName, programVersion); try { + setIndentation(indentChar, indentCount); tidy.parse(new StringReader(sbmlDocString), new FileWriter(fileName)); // run tidy, providing an input and output stream } catch (IOException e) { throw new SBMLException(e); @@ -518,6 +538,7 @@ { String sbmlDocString = sbmlWriter.writeSBMLToString(sbmlDocument); + setIndentation(' ', (short) 2); tidy.parse(new StringReader(sbmlDocString), new FileWriter(file)); // run tidy, providing an input and output stream } @@ -546,6 +567,7 @@ { String sbmlDocString = sbmlWriter.writeSBMLToString(sbmlDocument, getProgramName(), getProgramVersion()); + setIndentation(' ', (short) 2); tidy.parse(new StringReader(sbmlDocString), stream); // run tidy, providing an input and output stream } @@ -579,6 +601,7 @@ String sbmlDocString = sbmlWriter.writeSBMLToString(sbmlDocument, getProgramName(), getProgramVersion()); try { + setIndentation(' ', (short) 2); tidy.parse(new StringReader(sbmlDocString), new FileWriter(fileName)); // run tidy, providing an input and output stream } catch (IOException e) { throw new SBMLException(e); @@ -613,6 +636,7 @@ String sbmlDocString = sbmlWriter.writeSBMLToString(sbmlDocument, getProgramName(), getProgramVersion()); try { + setIndentation(' ', (short) 2); tidy.parse(new StringReader(sbmlDocString), new FileWriter(file)); // run tidy, providing an input and output stream } catch (IOException e) { throw new SBMLException(e); @@ -672,6 +696,7 @@ String sbmlDocString = sbmlWriter.writeSBMLToString(sbmlDocument, getProgramName(), getProgramVersion()); StringWriter stringWriter = new StringWriter(); + setIndentation(' ', (short) 2); tidy.parse(new StringReader(sbmlDocString), stringWriter); // run tidy, providing an input and output stream return stringWriter.toString(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |