use of org.vcell.model.rbm.SpeciesPattern in project vcell by virtualcell.
the class XmlReader method getRbmObservables.
private RbmObservable getRbmObservables(Element e, Model newModel) {
String n = e.getAttributeValue(XMLTags.NameAttrTag);
if (n == null || n.isEmpty()) {
System.out.println("XMLReader: getRbmObservables: name is missing.");
return null;
}
String t = e.getAttributeValue(XMLTags.RbmObservableTypeTag);
if (t == null || t.isEmpty()) {
System.out.println("XMLReader: getRbmObservables: type is missing.");
return null;
}
RbmObservable.ObservableType ot = RbmObservable.ObservableType.Molecules;
if (!t.equals(ot.name())) {
ot = RbmObservable.ObservableType.Species;
}
Structure structure = null;
String structureName = e.getAttributeValue(XMLTags.StructureAttrTag);
if (structureName == null || structureName.isEmpty()) {
// the tag is missing
if (newModel.getStructures().length == 1) {
// possible old single compartment model where we were not saving the structure for observable
structure = newModel.getStructure(0);
} else {
throw new RuntimeException("XMLReader: structure missing for observable " + n);
}
} else {
structure = newModel.getStructure(structureName);
}
RbmObservable o = new RbmObservable(newModel, n, structure, ot);
// Sequence
RbmObservable.Sequence se = RbmObservable.Sequence.Multimolecular;
String ses = e.getAttributeValue(XMLTags.RbmObservableSequenceAttrTag);
if (ses != null && ses.equals(RbmObservable.Sequence.PolymerLengthEqual.name())) {
se = RbmObservable.Sequence.PolymerLengthEqual;
} else if (ses != null && ses.equals(RbmObservable.Sequence.PolymerLengthGreater.name())) {
se = RbmObservable.Sequence.PolymerLengthGreater;
}
o.setSequence(se);
String lens = e.getAttributeValue(XMLTags.RbmObservableLenEqualAttrTag);
if (lens != null) {
// may be null for older models in which case the observable has default initial values
int len = Integer.parseInt(lens);
o.setSequenceLength(RbmObservable.Sequence.PolymerLengthEqual, len);
}
lens = e.getAttributeValue(XMLTags.RbmObservableLenGreaterAttrTag);
if (lens != null) {
int len = Integer.parseInt(lens);
o.setSequenceLength(RbmObservable.Sequence.PolymerLengthGreater, len);
}
// Element element = e.getChild(XMLTags.RbmSpeciesPatternTag, vcNamespace);
// SpeciesPattern sp = getSpeciesPattern(element, newModel);
List<Element> children = e.getChildren(XMLTags.RbmSpeciesPatternTag, vcNamespace);
for (Element e2 : children) {
SpeciesPattern sp = getSpeciesPattern(e2, newModel);
// setSpeciesPattern() will call resolveBonds()
if (sp != null) {
o.addSpeciesPattern(sp);
}
}
return o;
}
use of org.vcell.model.rbm.SpeciesPattern in project vcell by virtualcell.
the class Xmlproducer method getXML.
/**
* This method returns a XML representation of a SpeciesContext object.
* Creation date: (2/26/2001 11:26:37 AM)
* @return Element
* @param param cbit.vcell.model.SpeciesContext
*/
private Element getXML(SpeciesContext param) {
Element speciecontext = new Element(XMLTags.SpeciesContextTag);
// Add atributes
speciecontext.setAttribute(XMLTags.NameAttrTag, mangle(param.getName()));
speciecontext.setAttribute(XMLTags.SpeciesRefAttrTag, mangle(param.getSpecies().getCommonName()));
speciecontext.setAttribute(XMLTags.StructureAttrTag, mangle(param.getStructure().getName()));
speciecontext.setAttribute(XMLTags.HasOverrideAttrTag, true + "");
// If keyFlag is on print the Keyvalue
if (param.getKey() != null && this.printKeysFlag) {
speciecontext.setAttribute(XMLTags.KeyValueAttrTag, param.getKey().toString());
}
SpeciesPattern sp = param.getSpeciesPattern();
if (sp != null) {
speciecontext.addContent(getXML(sp));
}
return speciecontext;
}
use of org.vcell.model.rbm.SpeciesPattern in project vcell by virtualcell.
the class Xmlproducer method getXML.
// private Element getXMLShort(SpeciesPattern param) {
// Element e = new Element(XMLTags.RbmSpeciesPatternTag);
// e.setAttribute(XMLTags.NameAttrTag, mangle(param.getId()));
// return e;
// }
private Element getXML(RbmObservable param) {
// if RbmObservableEmbedded we don't save the model or the structure
// we know which they are once we use the XmlReader to recreate the object
Element e = new Element(XMLTags.RbmObservableTag);
e.setAttribute(XMLTags.NameAttrTag, mangle(param.getName()));
RbmObservable.ObservableType ot = param.getType();
e.setAttribute(XMLTags.RbmObservableTypeTag, mangle(ot.name()));
String sequenceName = param.getSequence().name();
e.setAttribute(XMLTags.RbmObservableSequenceAttrTag, sequenceName);
e.setAttribute(XMLTags.RbmObservableLenEqualAttrTag, "" + param.getSequenceLength(RbmObservable.Sequence.PolymerLengthEqual));
e.setAttribute(XMLTags.RbmObservableLenGreaterAttrTag, "" + param.getSequenceLength(RbmObservable.Sequence.PolymerLengthGreater));
e.setAttribute(XMLTags.StructureAttrTag, mangle(param.getStructure().getName()));
// SpeciesPattern sp = param.getSpeciesPattern(0);
// Element e1 = new Element(XMLTags.RbmSpeciesPatternTag);
// e1.setAttribute(XMLTags.NameAttrTag, mangle(sp.getId()));
// e.addContent(getXML(sp));
List<SpeciesPattern> spl = param.getSpeciesPatternList();
for (SpeciesPattern sp : spl) {
e.addContent(getXML(sp));
}
return e;
}
use of org.vcell.model.rbm.SpeciesPattern in project vcell by virtualcell.
the class SpeciesPropertiesTreeModel method propertyChange.
public void propertyChange(PropertyChangeEvent evt) {
if (evt.getPropertyName().equals(PropertyConstants.PROPERTY_NAME_NAME)) {
nodeChanged(rootNode);
// } else if (evt.getSource() == seedSpecies && evt.getPropertyName().equals(SeedSpecies.PROPERTY_NAME_TYPE)){
// nodeChanged(rootNode);
} else if (evt.getPropertyName().equals("entityChange")) {
nodeChanged(rootNode);
} else {
populateTree();
Object source = evt.getSource();
if (source == speciesContext) {
if (evt.getPropertyName().equals(SeedSpecies.PROPERTY_NAME_SPECIES_PATTERN)) {
SpeciesPattern oldValue = (SpeciesPattern) evt.getOldValue();
if (oldValue != null) {
RbmUtils.removePropertyChangeListener(oldValue, this);
}
SpeciesPattern newValue = (SpeciesPattern) evt.getNewValue();
if (newValue != null) {
// TODO
RbmUtils.addPropertyChangeListener(newValue, this);
}
}
} else if (source instanceof SpeciesPattern) {
if (evt.getPropertyName().equals(SpeciesPattern.PROPERTY_NAME_MOLECULAR_TYPE_PATTERNS)) {
List<MolecularTypePattern> oldValue = (List<MolecularTypePattern>) evt.getOldValue();
if (oldValue != null) {
for (MolecularTypePattern mtp : oldValue) {
RbmUtils.removePropertyChangeListener(mtp, this);
}
}
List<MolecularTypePattern> newValue = (List<MolecularTypePattern>) evt.getNewValue();
if (newValue != null) {
for (MolecularTypePattern mtp : newValue) {
RbmUtils.addPropertyChangeListener(mtp, this);
}
}
}
} else if (source instanceof MolecularTypePattern) {
if (evt.getPropertyName().equals(MolecularTypePattern.PROPERTY_NAME_COMPONENT_PATTERN_LIST)) {
List<MolecularComponentPattern> oldValue = (List<MolecularComponentPattern>) evt.getOldValue();
if (oldValue != null) {
for (MolecularComponentPattern mcp : oldValue) {
RbmUtils.removePropertyChangeListener(mcp, this);
}
}
List<MolecularComponentPattern> newValue = (List<MolecularComponentPattern>) evt.getNewValue();
if (newValue != null) {
for (MolecularComponentPattern mcp : newValue) {
RbmUtils.addPropertyChangeListener(mcp, this);
}
}
}
} else if (source instanceof MolecularComponentPattern) {
if (evt.getSource().equals(MolecularComponentPattern.PROPERTY_NAME_COMPONENT_STATE)) {
// it's componentStatePattern
ComponentStateDefinition oldValue = (ComponentStateDefinition) evt.getOldValue();
if (oldValue != null) {
oldValue.removePropertyChangeListener(this);
}
ComponentStateDefinition newValue = (ComponentStateDefinition) evt.getNewValue();
if (newValue != null) {
newValue.addPropertyChangeListener(this);
}
}
}
}
}
use of org.vcell.model.rbm.SpeciesPattern in project vcell by virtualcell.
the class ReactionRuleEditorPropertiesPanel method addReactant.
public void addReactant() {
ReactantPattern reactant = new ReactantPattern(new SpeciesPattern(), reactionRule.getStructure());
reactionRule.addReactant(reactant);
final TreePath path = reactantTreeModel.findObjectPath(null, reactant);
reactantTree.setSelectionPath(path);
SwingUtilities.invokeLater(new Runnable() {
public void run() {
reactantTree.scrollPathToVisible(path);
// productTreeModel.populateTree();
}
});
}
Aggregations