use of org.vcell.model.rbm.MolecularComponent in project vcell by virtualcell.
the class SpeciesContext method checkMolecularTypeConsistency.
// I think this should never fire issues, that's why I keep issue severity to error to force further investigation
// TODO: oct 30, 2015: hasn't fired in 9 months, we replace the issues with exception just to protect ourselves against regressions
private void checkMolecularTypeConsistency(IssueContext issueContext, List<Issue> issueList, MolecularType mtThat, MolecularTypePattern mtpThis) {
issueContext = issueContext.newChildContext(ContextType.SpeciesContext, this);
Map<String, MolecularComponent> hashThat = new HashMap<String, MolecularComponent>();
Map<String, MolecularComponent> hashThis = new HashMap<String, MolecularComponent>();
for (MolecularComponent mcThat : mtThat.getComponentList()) {
hashThat.put(mcThat.getName(), mcThat);
}
for (MolecularComponentPattern mcpThis : mtpThis.getComponentPatternList()) {
hashThis.put(mcpThis.getMolecularComponent().getName(), mcpThis.getMolecularComponent());
}
Iterator<Entry<String, MolecularComponent>> it = hashThat.entrySet().iterator();
while (it.hasNext()) {
String key = ((Map.Entry<String, MolecularComponent>) it.next()).getKey();
if (hashThis.containsKey(key)) {
it.remove();
hashThis.remove(key);
}
}
// any component still present in hashThis it means that it has been deleted in the molecular types definition and is now invalid
for (String key : hashThat.keySet()) {
String msg = "All components in the " + mtThat.getDisplayType() + " definition must be present. Missing: " + key + ".";
throw new RuntimeException(msg);
// issueList.add(new Issue(this, issueContext, IssueCategory.Identifiers, msg, Issue.SEVERITY_ERROR));
}
for (String key : hashThis.keySet()) {
String msg = "Component " + key + " is no longer defined for the " + mtThat.getDisplayType() + " and must be removed.";
throw new RuntimeException(msg);
// issueList.add(new Issue(this, issueContext, IssueCategory.Identifiers, msg, Issue.SEVERITY_ERROR));
}
}
use of org.vcell.model.rbm.MolecularComponent 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