use of org.vcell.model.rbm.MolecularType in project vcell by virtualcell.
the class Model method removeStructure.
public void removeStructure(Structure removedStructure) throws PropertyVetoException {
if (removedStructure == null) {
throw new RuntimeException("structure is null");
}
if (!contains(removedStructure)) {
throw new RuntimeException("structure " + removedStructure.getName() + " not found");
}
// Check that the feature is empty
String prefix = "Remove model compartment Error\n\nStructure to be removed : '" + removedStructure.getName() + "' : ";
String errorMessage = null;
for (int i = 0; i < fieldReactionSteps.length; i++) {
if (fieldReactionSteps[i].getStructure() == removedStructure) {
errorMessage = "cannot contain Reactions";
throw new RuntimeException(prefix + errorMessage + ".");
}
}
for (int i = 0; i < fieldSpeciesContexts.length; i++) {
if (fieldSpeciesContexts[i].getStructure() == removedStructure) {
errorMessage = "cannot contain Species";
throw new RuntimeException(prefix + errorMessage + ".");
}
}
for (ReactionRule rr : getRbmModelContainer().getReactionRuleList()) {
if (rr.getStructure() == removedStructure) {
errorMessage = "cannot contain Reaction Rules";
throw new RuntimeException(prefix + errorMessage + ".");
}
boolean found = false;
for (ReactantPattern rp : rr.getReactantPatterns()) {
if (rp.getStructure() == removedStructure) {
errorMessage = "cannot contain Reactant Patterns";
throw new RuntimeException(prefix + errorMessage + ".");
}
}
for (ProductPattern pp : rr.getProductPatterns()) {
if (pp.getStructure() == removedStructure) {
errorMessage = "cannot contain Product Patterns";
throw new RuntimeException(prefix + errorMessage + ".");
}
}
}
for (RbmObservable o : getRbmModelContainer().getObservableList()) {
if (o.getStructure() == removedStructure) {
errorMessage = "cannot contain Observables";
throw new RuntimeException(prefix + errorMessage + ".");
}
}
for (MolecularType mt : getRbmModelContainer().getMolecularTypeList()) {
if (mt.getAnchors().contains(removedStructure)) {
errorMessage = "cannot be Molecule anchor";
throw new RuntimeException(prefix + errorMessage + ".");
}
}
//
// remove this structure
//
Structure[] newStructures = (Structure[]) fieldStructures.clone();
newStructures = (Structure[]) BeanUtils.removeElement(newStructures, removedStructure);
setStructures(newStructures);
}
use of org.vcell.model.rbm.MolecularType in project vcell by virtualcell.
the class PathwayMapping method generateSpeciesPattern.
private SpeciesPattern generateSpeciesPattern(BioModel bioModel, PhysicalEntity bioPaxObject, boolean addSubunits) {
SpeciesPattern sp = new SpeciesPattern();
if (bioPaxObject instanceof Complex) {
Complex c = (Complex) bioPaxObject;
for (PhysicalEntity pc : c.getComponents()) {
MolecularType mt = createMolecularTypeFromBioPaxObject(bioModel, pc, addSubunits);
MolecularTypePattern mtp = new MolecularTypePattern(mt);
sp.addMolecularTypePattern(mtp);
}
return sp;
} else {
// else if(!(bioPaxObject instanceof Complex))
MolecularType mt = createMolecularTypeFromBioPaxObject(bioModel, bioPaxObject, addSubunits);
MolecularTypePattern mtp = new MolecularTypePattern(mt);
sp.addMolecularTypePattern(mtp);
return sp;
}
// return null;
}
use of org.vcell.model.rbm.MolecularType in project vcell by virtualcell.
the class PathwayMapping method createMolecularTypeFromBioPaxObject.
// TODO: not in use
// public void createBioModelEntitiesFromBioPaxObjects(BioModel bioModel, Object[] selectedObjects) throws Exception
// {
// for(int i = 0; i < selectedObjects.length; i++) {
// if(selectedObjects[i] instanceof BioPaxObject) {
// BioPaxObject bioPaxObject = (BioPaxObject)selectedObjects[i];
// if(bioPaxObject instanceof PhysicalEntity && !(bioPaxObject instanceof Complex)) {
// createMolecularTypeFromBioPaxObject(bioModel, (PhysicalEntity)bioPaxObject);
// }
// } else if(selectedObjects[i] instanceof ConversionTableRow) {
// ConversionTableRow ctr = (ConversionTableRow)selectedObjects[i];
// if(ctr.getBioPaxObject() instanceof PhysicalEntity && !(ctr.getBioPaxObject() instanceof Complex)) {
// createMolecularTypeFromBioPaxObject(bioModel, (PhysicalEntity)ctr.getBioPaxObject());
// }
// }
// }
//
// for(int i = 0; i < selectedObjects.length; i++) {
// if(selectedObjects[i] instanceof BioPaxObject) {
// BioPaxObject bioPaxObject = (BioPaxObject)selectedObjects[i];
// if(bioPaxObject instanceof PhysicalEntity) {
// createSpeciesContextFromBioPaxObject(bioModel, (PhysicalEntity)bioPaxObject);
// } else if(bioPaxObject instanceof Conversion) {
// createReactionStepsFromBioPaxObject(bioModel, (Conversion)bioPaxObject);
// }
// } else if(selectedObjects[i] instanceof ConversionTableRow) {
// ConversionTableRow ctr = (ConversionTableRow)selectedObjects[i];
// if(ctr.getBioPaxObject() instanceof PhysicalEntity) {
// createSpeciesContextFromTableRow(bioModel, (PhysicalEntity)ctr.getBioPaxObject(), ctr.stoich(), ctr.id(), ctr.location());
// } else if(ctr.getBioPaxObject() instanceof Conversion) {
// createReactionStepsFromTableRow(bioModel, (Conversion)ctr.getBioPaxObject(), ctr.stoich(), ctr.id(), ctr.location());
// }
// }
// }
// }
private MolecularType createMolecularTypeFromBioPaxObject(BioModel bioModel, PhysicalEntity bioPaxObject, boolean addSubunits) {
String name;
if (bioPaxObject.getName().size() == 0) {
name = getSafetyName(bioPaxObject.getID());
} else {
name = getSafetyName(bioPaxObject.getName().get(0));
}
RbmModelContainer rbmmc = bioModel.getModel().getRbmModelContainer();
if (rbmmc.getMolecularType(name) != null) {
// already exists
MolecularType mt = rbmmc.getMolecularType(name);
// check whether it links to pathway object, create relationship object if not
if (!bioModel.getRelationshipModel().isRelationship(mt, bioPaxObject)) {
RelationshipObject ro = new RelationshipObject(mt, bioPaxObject);
bioModel.getRelationshipModel().addRelationshipObject(ro);
}
return mt;
}
int numSubunits = 0;
if (addSubunits) {
for (String comment : bioPaxObject.getComments()) {
numSubunits = StringUtils.countMatches(comment, "SUBUNIT:");
}
}
MolecularType mt = new MolecularType(name, bioModel.getModel());
try {
for (int i = 0; i < numSubunits; i++) {
MolecularComponent mc = new MolecularComponent("Subunit" + i);
mt.addMolecularComponent(mc);
}
rbmmc.addMolecularType(mt, true);
// we know for sure that a relationship can't exist, so we make one
RelationshipObject ro = new RelationshipObject(mt, bioPaxObject);
bioModel.getRelationshipModel().addRelationshipObject(ro);
} catch (ModelException | PropertyVetoException e) {
e.printStackTrace();
}
ArrayList<String> commentList = bioPaxObject.getComments();
final String htmlStart = "<html><font face = \"Arial\"><font size =\"-2\">";
final String htmlEnd = "</font></font></html>";
if (commentList != null && !commentList.isEmpty()) {
String comment = commentList.get(0);
if (!comment.isEmpty()) {
String text = FormatDetails(comment);
mt.setComment(htmlStart + text + htmlEnd);
}
} else {
mt.setComment("");
}
return mt;
}
Aggregations