Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -633,7 +633,7 @@ public XmlTreeDiff compareWithSaved(VCDocument document) {
public XmlTreeDiff compareApplications(BioModel bioModel, String appName1, String appName2) throws Exception {

// clone BioModel as bioModel1 and remove all but appName1
BioModel bioModel1 = (BioModel) BeanUtils.cloneSerializable(bioModel);
BioModel bioModel1 = XmlHelper.cloneBioModel(bioModel);
bioModel1.refreshDependencies();
SimulationContext[] allSimContexts1 = bioModel1.getSimulationContexts();
for (SimulationContext sc : allSimContexts1) {
Expand All @@ -643,7 +643,7 @@ public XmlTreeDiff compareApplications(BioModel bioModel, String appName1, Strin
}

// clone BioModel as bioModel2 and remove all but appName2
BioModel bioModel2 = (BioModel) BeanUtils.cloneSerializable(bioModel);
BioModel bioModel2 = XmlHelper.cloneBioModel(bioModel);
bioModel2.refreshDependencies();
SimulationContext[] allSimContexts2 = bioModel2.getSimulationContexts();
for (SimulationContext sc : allSimContexts2) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import java.util.Vector;

import cbit.vcell.solver.*;
import cbit.vcell.xml.XmlHelper;
import org.vcell.util.*;
import org.vcell.util.document.VCDocument;
import org.vcell.util.gui.DialogUtils;
Expand Down Expand Up @@ -197,7 +198,7 @@ public void run(Hashtable<String, Object> hashTable) throws java.lang.Exception
int defaultTotalVolumeElements = mathGeometry.getGeometrySurfaceDescription().getVolumeSampleSize().getXYZ();
int newTotalVolumeElements = meshSpecification.getSamplingSize().getXYZ();
if (defaultTotalVolumeElements > newTotalVolumeElements) { // coarser
Geometry resampledGeometry = (Geometry) BeanUtils.cloneSerializable(mathGeometry);
Geometry resampledGeometry = XmlHelper.cloneGeometry(mathGeometry);
GeometrySurfaceDescription geoSurfaceDesc = resampledGeometry.getGeometrySurfaceDescription();
geoSurfaceDesc.setVolumeSampleSize(newSize);
geoSurfaceDesc.updateAll();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -550,7 +550,7 @@ private cbit.vcell.geometry.surface.SurfaceCollection getCentroidSurface(cbit.vc
cbit.vcell.geometry.surface.OrigSurface quadSurface = (cbit.vcell.geometry.surface.OrigSurface)quadSurfaceCollection.getSurfaces(0);
cbit.vcell.geometry.surface.OrigSurface quadSurfaceCopy = null;
try {
quadSurfaceCopy = (cbit.vcell.geometry.surface.OrigSurface)org.vcell.util.BeanUtils.cloneSerializable(quadSurface);
quadSurfaceCopy = quadSurface.deepClone();
}catch (Throwable e){
e.printStackTrace(System.out);
throw new RuntimeException(e.getMessage());
Expand Down
78 changes: 19 additions & 59 deletions vcell-client/src/main/java/cbit/vcell/graph/gui/BioCartoonTool.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,78 +9,38 @@
*/

package cbit.vcell.graph.gui;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.Window;
import java.beans.PropertyVetoException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Hashtable;
import java.util.IdentityHashMap;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
import java.util.Vector;

import javax.swing.JComboBox;
import javax.swing.JOptionPane;
import javax.swing.JTextField;

import org.vcell.model.rbm.MolecularType;
import org.vcell.model.rbm.RbmNetworkGenerator.CompartmentMode;
import org.vcell.model.rbm.RbmUtils;
import org.vcell.model.rbm.SpeciesPattern;
import org.vcell.util.BeanUtils;
import org.vcell.util.CommentStringTokenizer;
import org.vcell.util.Compare;
import org.vcell.util.Issue;
import org.vcell.util.Issue.IssueCategory;
import org.vcell.util.IssueContext;
import org.vcell.util.IssueContext.ContextType;
import org.vcell.util.document.KeyValue;
import org.vcell.util.TokenMangler;
import org.vcell.util.UserCancelException;
import org.vcell.util.gui.DialogUtils;

import cbit.gui.graph.gui.GraphPane;
import cbit.vcell.client.task.AsynchClientTask;
import cbit.vcell.client.task.ClientTaskDispatcher;
import cbit.vcell.clientdb.DocumentManager;
import cbit.vcell.model.BioModelEntityObject;
import cbit.vcell.model.Catalyst;
import cbit.vcell.model.Feature;
import cbit.vcell.model.FluxReaction;
import cbit.vcell.model.Kinetics;
import cbit.vcell.model.*;
import cbit.vcell.model.Kinetics.KineticsParameter;
import cbit.vcell.model.Kinetics.KineticsProxyParameter;
import cbit.vcell.model.KineticsDescription;
import cbit.vcell.model.Membrane;
import cbit.vcell.model.Membrane.MembraneVoltage;
import cbit.vcell.model.Model;
import cbit.vcell.model.Model.ModelParameter;
import cbit.vcell.model.Model.RbmModelContainer;
import cbit.vcell.model.Model.StructureTopology;
import cbit.vcell.model.ModelException;
import cbit.vcell.model.Product;
import cbit.vcell.model.Reactant;
import cbit.vcell.model.ReactionDescription;
import cbit.vcell.model.ReactionParticipant;
import cbit.vcell.model.ReactionRule;
import cbit.vcell.model.ReactionSpeciesCopy;
import cbit.vcell.model.ReactionStep;
import cbit.vcell.model.SimpleReaction;
import cbit.vcell.model.Species;
import cbit.vcell.model.SpeciesContext;
import cbit.vcell.model.Structure;
import cbit.vcell.model.Structure.StructureSize;
import cbit.vcell.parser.Expression;
import cbit.vcell.parser.ExpressionBindingException;
import cbit.vcell.parser.SymbolTableEntry;
import cbit.vcell.xml.XmlHelper;
import org.vcell.model.rbm.MolecularType;
import org.vcell.model.rbm.RbmNetworkGenerator.CompartmentMode;
import org.vcell.model.rbm.RbmUtils;
import org.vcell.model.rbm.SpeciesPattern;
import org.vcell.util.*;
import org.vcell.util.Issue.IssueCategory;
import org.vcell.util.IssueContext.ContextType;
import org.vcell.util.gui.DialogUtils;

import javax.swing.*;
import java.awt.*;
import java.beans.PropertyVetoException;
import java.util.*;
import java.util.List;
import java.util.Map.Entry;

public abstract class BioCartoonTool extends cbit.gui.graph.gui.CartoonTool {
private DocumentManager documentManager = null;
Expand Down Expand Up @@ -338,7 +298,7 @@ public static final void pasteReactionsAndRules(Component requester, ReactionSpe
AsynchClientTask issueTask = new AsynchClientTask("Checking Issues...",AsynchClientTask.TASKTYPE_SWING_BLOCKING) {
@Override
public void run(Hashtable<String, Object> hashTable) throws Exception {
Model clonedModel = (Model)org.vcell.util.BeanUtils.cloneSerializable(pasteModel);
Model clonedModel = XmlHelper.cloneModel(pasteModel);
clonedModel.refreshDependencies();
// Model clonedModel = pasteModel;
IssueContext issueContext = new IssueContext(ContextType.Model, clonedModel, null);
Expand Down Expand Up @@ -549,7 +509,7 @@ public void run(Hashtable<String, Object> hashTable) throws Exception {
public void run(Hashtable<String, Object> hashTable) throws Exception {
ReactionStep[] reactionStepsArrOrig = new ReactionStep[] {(ReactionStep)hashTable.get("fromRXStep")};
UserResolvedRxElements userResolvedRxElements = (UserResolvedRxElements)hashTable.get("userResolvedRxElements");
Model clonedModel = (Model)org.vcell.util.BeanUtils.cloneSerializable(pasteToModel);
Model clonedModel = XmlHelper.cloneModel(pasteToModel);
clonedModel.refreshDependencies();
IssueContext issueContext = new IssueContext(ContextType.Model, clonedModel, null);
HashMap<String,HashMap<ReactionParticipant,Structure>> userResolved_rxPartMapStruct = null;
Expand Down
47 changes: 19 additions & 28 deletions vcell-core/src/main/java/cbit/vcell/biomodel/BioModel.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,24 @@

package cbit.vcell.biomodel;

import java.beans.PropertyChangeListener;
import java.beans.PropertyChangeSupport;
import java.beans.PropertyVetoException;
import java.beans.VetoableChangeListener;
import java.beans.VetoableChangeSupport;
import java.util.*;
import java.util.function.Consumer;
import java.util.stream.Collectors;

import cbit.image.ImageException;
import cbit.image.VCImage;
import cbit.vcell.biomodel.meta.IdentifiableProvider;
import cbit.vcell.biomodel.meta.VCID;
import cbit.vcell.biomodel.meta.VCMetaData;
import cbit.vcell.geometry.*;
import cbit.vcell.geometry.surface.GeometrySurfaceDescription;
import cbit.vcell.mapping.*;
import cbit.vcell.mapping.SimulationContext.Application;
import cbit.vcell.math.MathDescription;
import cbit.vcell.model.*;
import cbit.vcell.model.Model.RbmModelContainer;
import cbit.vcell.model.Structure.SpringStructureEnum;
import cbit.vcell.parser.ExpressionException;
import cbit.vcell.parser.NameScope;
import cbit.vcell.parser.SymbolTableEntry;
import cbit.vcell.solver.Simulation;
import cbit.vcell.xml.XmlHelper;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.vcell.model.rbm.MolecularType;
Expand All @@ -38,24 +43,10 @@
import org.vcell.util.document.*;
import org.vcell.util.document.BioModelChildSummary.MathType;

import cbit.image.ImageException;
import cbit.vcell.biomodel.meta.IdentifiableProvider;
import cbit.vcell.biomodel.meta.VCID;
import cbit.vcell.biomodel.meta.VCMetaData;
import cbit.vcell.geometry.AnalyticSubVolume;
import cbit.vcell.geometry.Geometry;
import cbit.vcell.geometry.GeometryException;
import cbit.vcell.geometry.GeometrySpec;
import cbit.vcell.geometry.SubVolume;
import cbit.vcell.geometry.SurfaceClass;
import cbit.vcell.geometry.surface.GeometrySurfaceDescription;
import cbit.vcell.math.MathDescription;
import cbit.vcell.model.Model.RbmModelContainer;
import cbit.vcell.model.Structure.SpringStructureEnum;
import cbit.vcell.parser.ExpressionException;
import cbit.vcell.parser.NameScope;
import cbit.vcell.parser.SymbolTableEntry;
import cbit.vcell.solver.Simulation;
import java.beans.*;
import java.util.*;
import java.util.function.Consumer;
import java.util.stream.Collectors;

/**
* Insert the type's description here.
Expand Down Expand Up @@ -114,7 +105,7 @@ public void transformLumpedToDistributed(){
Kinetics origKinetics = reactionStep.getKinetics();
// clone it for backup purposes
origKinetics.setReactionStep(null);
Kinetics clonedKinetics = (Kinetics) BeanUtils.cloneSerializable(origKinetics);
Kinetics clonedKinetics = XmlHelper.cloneReactionStep(reactionStep).getKinetics();
origKinetics.setReactionStep(reactionStep);
try {
DistributedKinetics.toDistributedKinetics((LumpedKinetics) origKinetics, false);
Expand Down
11 changes: 11 additions & 0 deletions vcell-core/src/main/java/cbit/vcell/bionetgen/BNGMolecule.java
Original file line number Diff line number Diff line change
Expand Up @@ -117,4 +117,15 @@ public void setComponentsStates(){
public String toString(){
return getName();
}

public BNGMolecule deepClone() {
BNGMolecule bngMoleculeClone = new BNGMolecule(getName());
if (molComponents != null) {
bngMoleculeClone.molComponents = new BNGSpeciesComponent[molComponents.length];
for (int i = 0; i < molComponents.length; i++) {
bngMoleculeClone.molComponents[i] = molComponents[i].deepClone();
}
}
return bngMoleculeClone;
}
}
45 changes: 45 additions & 0 deletions vcell-core/src/main/java/cbit/vcell/bionetgen/BNGOutputSpec.java
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,51 @@ public BNGOutputSpec(BNGParameter[] argParams, BNGMolecule[] argMols, BNGSpecies
}
}

public BNGOutputSpec deepClone() {
BNGParameter[] bngParamsClone = null;
if (bngParams != null) {
bngParamsClone = new BNGParameter[bngParams.length];
for (int i = 0; i < bngParams.length; i++) {
bngParamsClone[i] = bngParams[i].deepClone();
}
}
BNGMolecule[] bngMoleculeTypesClone = null;
if (bngMoleculeTypes != null){
bngMoleculeTypesClone = new BNGMolecule[bngMoleculeTypes.length];
for (int i = 0; i < bngMoleculeTypes.length; i++) {
bngMoleculeTypesClone[i] = bngMoleculeTypes[i].deepClone();
}
}
BNGSpecies[] bngSpeciesClone = null;
if (bngSpecies != null){
bngSpeciesClone = new BNGSpecies[bngSpecies.length];
for (int i = 0; i < bngSpecies.length; i++) {
bngSpeciesClone[i] = bngSpecies[i].deepClone();
}
}
BNGReactionRule[] bngReactionRulesClone = null;
if (bngReactionRules != null){
bngReactionRulesClone = new BNGReactionRule[bngReactionRules.length];
for (int i = 0; i < bngReactionRules.length; i++) {
bngReactionRulesClone[i] = bngReactionRules[i].deepClone();
}
}
BNGReaction[] bngReactionsClone = null;
if (bngReactions != null) {
bngReactionsClone = new BNGReaction[bngReactions.length];
for (int i = 0; i < bngReactions.length; i++) {
bngReactionsClone[i] = bngReactions[i].deepClone();
}
}
ObservableGroup[] bngObservableGroupsClone = null;
if (bngObservableGroups != null){
bngObservableGroupsClone = new ObservableGroup[bngObservableGroups.length];
for (int i = 0; i < bngObservableGroups.length; i++) {
bngObservableGroupsClone[i] = bngObservableGroups[i].deepClone();
}
}
return new BNGOutputSpec(bngParamsClone, bngMoleculeTypesClone, bngSpeciesClone, bngReactionRulesClone, bngReactionsClone, bngObservableGroupsClone);
}
public BNGMolecule[] getBNGMolecules() {
return bngMoleculeTypes;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,4 +69,8 @@ public void setValue(double argValue) {
public String toString() {
return new String(getName() + ";\t" + getValue());
}

public BNGParameter deepClone() {
return new BNGParameter(name, value);
}
}
18 changes: 18 additions & 0 deletions vcell-core/src/main/java/cbit/vcell/bionetgen/BNGReaction.java
Original file line number Diff line number Diff line change
Expand Up @@ -354,4 +354,22 @@ public String toStringShort() {
}
return reactionStr;
}


public BNGReaction deepClone() {
BNGSpecies[] bngReactantsClone = new BNGSpecies[reactants.length];
for (int i = 0; i < reactants.length; i++) {
bngReactantsClone[i] = reactants[i].deepClone();
}
BNGSpecies[] bngProductsClone = new BNGSpecies[products.length];
for (int i = 0; i < products.length; i++) {
bngProductsClone[i] = products[i].deepClone();
}
Expression newParamExpression = paramExpression;
if (newParamExpression != null) {
newParamExpression = Expression.clone(paramExpression);
}
BNGReaction bngReactionClone = new BNGReaction(matchingKey, matchingKey, bngReactantsClone, bngProductsClone, newParamExpression, ruleName, bRuleReversed);
return bngReactionClone;
}
}
16 changes: 16 additions & 0 deletions vcell-core/src/main/java/cbit/vcell/bionetgen/BNGReactionRule.java
Original file line number Diff line number Diff line change
Expand Up @@ -186,4 +186,20 @@ public String writeReaction() {

return reactionStr;
}

public BNGReactionRule deepClone() {
BNGParameter[] bngParamsClone = new BNGParameter[parameters.length];
for (int i = 0; i < parameters.length; i++) {
bngParamsClone[i] = parameters[i].deepClone();
}
BNGSpecies[] bngReactantsClone = new BNGSpecies[reactants.length];
for (int i = 0; i < reactants.length; i++) {
bngReactantsClone[i] = reactants[i].deepClone();
}
BNGSpecies[] bngProductsClone = new BNGSpecies[products.length];
for (int i = 0; i < products.length; i++) {
bngProductsClone[i] = products[i].deepClone();
}
return new BNGReactionRule(bngParamsClone, bngReactantsClone, bngProductsClone, isReversible());
}
}
10 changes: 9 additions & 1 deletion vcell-core/src/main/java/cbit/vcell/bionetgen/BNGSpecies.java
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,15 @@ public String toStringShort() {
return new String(getName());
}

public enum SignatureDetailLevel {
public BNGSpecies deepClone() {
Expression newConc = getConcentration();
if (newConc != null) {
newConc = Expression.clone(newConc);
}
return new BNGComplexSpecies(getName(), newConc, getNetworkFileIndex());
}

public enum SignatureDetailLevel {
MoleculesOnly,
ComponentsAndStates // molecules and components with states, no bond
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,4 +88,15 @@ public String extractComponentPatternSignature() {
}
return prefix;
}

public BNGSpeciesComponent deepClone() {
String[] newStateNames = null;
if (stateNames != null) {
newStateNames = new String[stateNames.length];
for (int i = 0; i < stateNames.length; i++) {
newStateNames[i] = stateNames[i];
}
}
return new BNGSpeciesComponent(componentName, currentState, newStateNames);
}
}
Loading