Remove objects with same displayId before creating new

Fix run deadlock on errors
This commit is contained in:
Chris Myers 2020-05-10 13:37:36 -06:00
parent ca58aa4f9d
commit 515c7634a2
22 changed files with 368 additions and 16027 deletions

65
dataModels/log4j2.xml Normal file
View file

@ -0,0 +1,65 @@
<?xml version="1.0" encoding="UTF-8"?>
<Configuration status="WARN" name="XMLConfigTest" packages="org.sbml.*">
<Properties>
<Property name="filename">jsbml.log</Property>
</Properties>
<ThresholdFilter level="trace"/>
<Appenders>
<Console name="console">
<PatternLayout pattern="%5p (%F:%L) - %m%n"/>
</Console>
<File name="file" fileName="${filename}">
<PatternLayout>
<pattern>%d %p %C{1.} [%t] %m%n</pattern>
</PatternLayout>
</File>
</Appenders>
<Loggers>
<Logger name="org.sbml" level="info" additivity="false">
<AppenderRef ref="console"/>
<AppenderRef ref="file"/>
</Logger>
<!--
<Logger name="org.sbml.jsbml.xml.stax.SBMLWriter" level="debug" additivity="false">
<AppenderRef ref="console"/>
<AppenderRef ref="file"/>
</Logger>
<Logger name="org.sbml.jsbml.xml.stax.SBMLReader" level="debug" additivity="false">
<AppenderRef ref="console"/>
<AppenderRef ref="file"/>
</Logger>
-->
<!--
# org.sbml.jsbml.test.SimpleSBaseChangeListener - DEBUG : it will display all add, remove or change event (lot of output when reading an SBML file)
# org.sbml.jsbml.xml.parsers.SBMLCoreParser - ERROR to DEBUG : anything related to problems when parsing the SBML core elements.
# org.sbml.jsbml.xml.parsers.StringParser - ERROR to DEBUG : (lot of output) display all the event when reading XHTML
# org.sbml.jsbml.xml.parsers.AnnotationParser - DEBUG : output when reading non RDF annotations.
# org.sbml.jsbml.xml.parsers.XMLNodeWriter - DEBUG : output events when writing XMLNode, so HTML block
# org.sbml.jsbml.xml.stax.SBMLReader - ERROR to DEBUG : (lot of output) display all the event when reading an SBML file
# org.sbml.jsbml.xml.stax.SBMLWriter - ERROR to DEBUG : (lot of output) display all the event when writing an SBML file
# org.sbml.jsbml.util.StringTools - WARN : warning when there is a problem with the conversion of a String into a number or boolean.
# org.sbml.jsbml.util.compilers.MathMLXMLStreamCompiler - WARN to DEBUG : (lot of output) display all the event when writing mathML
# org.sbml.jsbml.xml.parsers.MathMLStaxParser - ERROR to DEBUG : (lot of output) display all the event when reading a MathML block
# org.sbml.jsbml.SBMLDocument - ERROR to DEBUG : will display problems related to the checkConsistency call
# org.sbml.jsbml.validator.SBMLValidator - DEBUG : will print the xml result file from http://sbml.org/validator/ with few others checks when the parsing is done
# org.sbml.jsbml.util.SubModel - DEBUG : will print the details of the submodel building
# org.sbml.jsbml.ASTNode - ERROR to DEBUG
# org.sbml.jsbml.xml.parsers.AbstractReaderWriter - DEBUG : events when reading or writing L3 packages block (if the parser extends this abstract class)
# org.sbml.jsbml.xml.parsers.QualParser - DEBUG : events when reading/writing the qual package/extension.
# org.sbml.jsbml.ext.comp.CompModelPlugin - DEBUG: register and unregister debug output for the comp package id namespace
# org.sbml.jsbml.ext.comp.ArraysSBasePlugin - DEBUG: register and unregister debug output for the arrays package id namespace
# org.sbml.jsbml.Model - DEBUG: register and unregister debug output for the core package id namespace
# org.sbml.jsbml.xml.parsers.SBMLRDFAnnotationParser - DEBUG: debug output when reading and writing RDF annotations
-->
<Root level="info">
<AppenderRef ref="file"/>
</Root>
</Loggers>
</Configuration>

View file

@ -6,7 +6,7 @@
<parent>
<groupId>edu.utah.ece.async</groupId>
<artifactId>iBioSim</artifactId>
<version>3.0.0-SNAPSHOT</version>
<version>3.1.0-SNAPSHOT</version>
<relativePath>../</relativePath>
</parent>
<packaging>jar</packaging>
@ -71,7 +71,7 @@
<dependency>
<groupId>org.sbml.jsbml</groupId>
<artifactId>jsbml</artifactId>
<version>1.4</version>
<version>1.6-SNAPSHOT</version>
</dependency>
<dependency>
@ -132,7 +132,7 @@
<dependency>
<groupId>edu.utah.ece.async</groupId>
<artifactId>iBioSim-libsbml</artifactId>
<version>5.16.0-SNAPSHOT</version>
<version>5.18.0-SNAPSHOT</version>
</dependency>
</dependencies>
</project>

View file

@ -76,10 +76,6 @@ import org.sbml.jsbml.ext.comp.ReplacedBy;
import org.sbml.jsbml.ext.comp.ReplacedElement;
import org.sbml.jsbml.ext.comp.SBaseRef;
import org.sbml.jsbml.ext.comp.Submodel;
import org.sbml.jsbml.ext.distrib.DistribConstants;
import org.sbml.jsbml.ext.distrib.DistribFunctionDefinitionPlugin;
import org.sbml.jsbml.ext.distrib.DistribInput;
import org.sbml.jsbml.ext.distrib.DrawFromDistribution;
import org.sbml.jsbml.ext.fbc.FBCConstants;
import org.sbml.jsbml.ext.fbc.FBCModelPlugin;
import org.sbml.jsbml.ext.fbc.FBCReactionPlugin;
@ -90,10 +86,7 @@ import org.sbml.jsbml.ext.layout.LayoutModelPlugin;
import org.sbml.jsbml.text.parser.FormulaParserLL3;
import org.sbml.jsbml.text.parser.IFormulaParser;
import org.sbml.jsbml.text.parser.ParseException;
import org.sbml.jsbml.xml.XMLAttributes;
import org.sbml.jsbml.xml.XMLNamespaces;
import org.sbml.jsbml.xml.XMLNode;
import org.sbml.jsbml.xml.XMLTriple;
import org.sbml.libsbml.ConversionProperties;
import org.sbml.libsbml.SBMLNamespaces;
import org.sbml.libsbml.SBasePlugin;
@ -3138,35 +3131,35 @@ public class SBMLutilities extends CoreObservable
createFunction(model, "bernoulli", "Bernoulli distribution", "lambda(p,p)");
}
public static void createDistribution(FunctionDefinition f, String[] inputTypes, String[] inputs, String distribution)
{
DistribFunctionDefinitionPlugin distrib = SBMLutilities.getDistribFunctionDefinitionPlugin(f);
DrawFromDistribution draw = distrib.createDrawFromDistribution();
for (int i = 0; i < inputs.length; i++)
{
DistribInput input = draw.createDistribInput();
input.setId(inputs[i]);
input.setIndex(i);
}
// UncertML element
XMLNode xmlNode = new XMLNode(new XMLTriple("UncertML"), new XMLAttributes(), new XMLNamespaces());
xmlNode.addNamespace("http://www.uncertml.org/3.0");
// NormalDistribution element
XMLNode distNode = new XMLNode(new XMLTriple(distribution), new XMLAttributes(), new XMLNamespaces());
distNode.addAttr("definition", "http://www.uncertml.org/distributions");
xmlNode.addChild(distNode);
for (int i = 0; i < inputs.length; i++)
{
XMLNode inputNode = new XMLNode(new XMLTriple(inputTypes[i]), new XMLAttributes(), new XMLNamespaces());
distNode.addChild(inputNode);
XMLNode varNode = new XMLNode(new XMLTriple("var"), new XMLAttributes(), new XMLNamespaces());
varNode.addAttr("varId", inputs[i]);
inputNode.addChild(varNode);
}
// draw.setUncertML(xmlNode);
}
// public static void createDistribution(FunctionDefinition f, String[] inputTypes, String[] inputs, String distribution)
// {
// DistribFunctionDefinitionPlugin distrib = SBMLutilities.getDistribFunctionDefinitionPlugin(f);
// DrawFromDistribution draw = distrib.createDrawFromDistribution();
// for (int i = 0; i < inputs.length; i++)
// {
// DistribInput input = draw.createDistribInput();
// input.setId(inputs[i]);
// input.setIndex(i);
// }
// // UncertML element
// XMLNode xmlNode = new XMLNode(new XMLTriple("UncertML"), new XMLAttributes(), new XMLNamespaces());
// xmlNode.addNamespace("http://www.uncertml.org/3.0");
//
// // NormalDistribution element
// XMLNode distNode = new XMLNode(new XMLTriple(distribution), new XMLAttributes(), new XMLNamespaces());
// distNode.addAttr("definition", "http://www.uncertml.org/distributions");
// xmlNode.addChild(distNode);
//
// for (int i = 0; i < inputs.length; i++)
// {
// XMLNode inputNode = new XMLNode(new XMLTriple(inputTypes[i]), new XMLAttributes(), new XMLNamespaces());
// distNode.addChild(inputNode);
// XMLNode varNode = new XMLNode(new XMLTriple("var"), new XMLAttributes(), new XMLNamespaces());
// varNode.addAttr("varId", inputs[i]);
// inputNode.addChild(varNode);
// }
//// draw.setUncertML(xmlNode);
// }
/**
* Add a new function
@ -3194,50 +3187,50 @@ public class SBMLutilities extends CoreObservable
if (id.equals("uniform"))
{
AnnotationUtility.setDistributionAnnotation(f, "http://en.wikipedia.org/wiki/Uniform_distribution_(continuous)");
SBMLutilities.createDistribution(f, new String[] { "minimum", "maximum" }, new String[] { "a", "b" }, "UniformDistribution");
//SBMLutilities.createDistribution(f, new String[] { "minimum", "maximum" }, new String[] { "a", "b" }, "UniformDistribution");
}
else if (id.equals("normal"))
{
AnnotationUtility.setDistributionAnnotation(f, "http://en.wikipedia.org/wiki/Normal_distribution");
SBMLutilities.createDistribution(f, new String[] { "mean", "stddev" }, new String[] { "m", "s" }, "NormalDistribution");
//SBMLutilities.createDistribution(f, new String[] { "mean", "stddev" }, new String[] { "m", "s" }, "NormalDistribution");
}
else if (id.equals("exponential"))
{
AnnotationUtility.setDistributionAnnotation(f, "http://en.wikipedia.org/wiki/Exponential_distribution");
SBMLutilities.createDistribution(f, new String[] { "rate" }, new String[] { "l" }, "ExponentialDistribution");
//SBMLutilities.createDistribution(f, new String[] { "rate" }, new String[] { "l" }, "ExponentialDistribution");
}
else if (id.equals("gamma"))
{
AnnotationUtility.setDistributionAnnotation(f, "http://en.wikipedia.org/wiki/Gamma_distribution");
SBMLutilities.createDistribution(f, new String[] { "shape", "scale" }, new String[] { "a", "b" }, "GammaDistribution");
//SBMLutilities.createDistribution(f, new String[] { "shape", "scale" }, new String[] { "a", "b" }, "GammaDistribution");
}
else if (id.equals("poisson"))
{
AnnotationUtility.setDistributionAnnotation(f, "http://en.wikipedia.org/wiki/Poisson_distribution");
SBMLutilities.createDistribution(f, new String[] { "rate" }, new String[] { "mu" }, "PoissonDistribution");
//SBMLutilities.createDistribution(f, new String[] { "rate" }, new String[] { "mu" }, "PoissonDistribution");
}
else if (id.equals("lognormal"))
{
AnnotationUtility.setDistributionAnnotation(f, "http://en.wikipedia.org/wiki/Log-normal_distribution");
// TODO: check order
SBMLutilities.createDistribution(f, new String[] { "shape", "logScale" }, new String[] { "sh", "lsc" }, "GammaDistribution");
//SBMLutilities.createDistribution(f, new String[] { "shape", "logScale" }, new String[] { "sh", "lsc" }, "GammaDistribution");
}
else if (id.equals("chisq"))
{
AnnotationUtility.setDistributionAnnotation(f, "http://en.wikipedia.org/wiki/Chi-squared_distribution");
SBMLutilities.createDistribution(f, new String[] { "degreeOfFreedom" }, new String[] { "nu" }, "ChiSquareDistribution");
//SBMLutilities.createDistribution(f, new String[] { "degreeOfFreedom" }, new String[] { "nu" }, "ChiSquareDistribution");
}
else if (id.equals("laplace"))
{
AnnotationUtility.setDistributionAnnotation(f, "http://en.wikipedia.org/wiki/Laplace_distribution");
// TODO: mine only has one param?
SBMLutilities.createDistribution(f, new String[] { "location", "scale" }, new String[] { "l", "s" }, "LaplaceDistribution");
//SBMLutilities.createDistribution(f, new String[] { "location", "scale" }, new String[] { "l", "s" }, "LaplaceDistribution");
}
else if (id.equals("cauchy"))
{
AnnotationUtility.setDistributionAnnotation(f, "http://en.wikipedia.org/wiki/Cauchy_distribution");
// TODO: mine only has one param?
SBMLutilities.createDistribution(f, new String[] { "location", "scale" }, new String[] { "l", "s" }, "CauchyDistribution");
//SBMLutilities.createDistribution(f, new String[] { "location", "scale" }, new String[] { "l", "s" }, "CauchyDistribution");
}
else if (id.equals("rayleigh"))
{
@ -3247,13 +3240,13 @@ public class SBMLutilities extends CoreObservable
else if (id.equals("binomial"))
{
AnnotationUtility.setDistributionAnnotation(f, "http://en.wikipedia.org/wiki/Binomial_distribution");
SBMLutilities.createDistribution(f, new String[] { "probabilityOfSuccess", "numberOfTrials" }, new String[] { "p", "n" },
"BinomialDistribution");
//SBMLutilities.createDistribution(f, new String[] { "probabilityOfSuccess", "numberOfTrials" }, new String[] { "p", "n" },
// "BinomialDistribution");
}
else if (id.equals("bernoulli"))
{
AnnotationUtility.setDistributionAnnotation(f, "http://en.wikipedia.org/wiki/Bernoulli_distribution");
SBMLutilities.createDistribution(f, new String[] { "categoryProb" }, new String[] { "p" }, "BernoulliDistribution");
//SBMLutilities.createDistribution(f, new String[] { "categoryProb" }, new String[] { "p" }, "BernoulliDistribution");
}
}
}
@ -4937,16 +4930,16 @@ public class SBMLutilities extends CoreObservable
return null;
}
public static DistribFunctionDefinitionPlugin getDistribFunctionDefinitionPlugin(FunctionDefinition function)
{
if (function.getExtension(DistribConstants.namespaceURI) != null)
{
return (DistribFunctionDefinitionPlugin) function.getExtension(DistribConstants.namespaceURI);
}
DistribFunctionDefinitionPlugin distrib = new DistribFunctionDefinitionPlugin(function);
function.addExtension(DistribConstants.namespaceURI, distrib);
return distrib;
}
// public static DistribFunctionDefinitionPlugin getDistribFunctionDefinitionPlugin(FunctionDefinition function)
// {
// if (function.getExtension(DistribConstants.namespaceURI) != null)
// {
// return (DistribFunctionDefinitionPlugin) function.getExtension(DistribConstants.namespaceURI);
// }
// DistribFunctionDefinitionPlugin distrib = new DistribFunctionDefinitionPlugin(function);
// function.addExtension(DistribConstants.namespaceURI, distrib);
// return distrib;
// }
public static LayoutModelPlugin getLayoutModelPlugin(Model model)
{