use of org.vcell.pathway.Conversion in project vcell by virtualcell.
the class PathwayMapping method createReactionStep.
/*
* for reaction:
* 1. annotate the selected vcell object using linked pathway conversion
* 2. add non-existing speciesContexts from linked pathway conversion
* 3. add links between relative vcell objects and pathway objects
* Questions:
* - how to deal with the case that the reaction is existing in the model?
* + add it in no matter what?
* (this is the version we have now:
* add the duplicated reactions in without name changing,
* all duplicated reactions share the same participant objects)
* + just modify the existing one?
*/
private void createReactionStep(BioModel bioModel, Process process, ReactionStep reactionStep, RelationshipObject relationshipObject, ArrayList<ConversionTableRow> participants, boolean addSubunits) throws Exception {
if (reactionStep == null || bioModel == null || bioModel.getRelationshipModel() == null || participants.size() < 1) {
return;
}
ArrayList<ReactionParticipant> rplist = new ArrayList<ReactionParticipant>();
// create and add reaction participants to list
for (ConversionTableRow ctr : participants) {
if (ctr.getBioPaxObject() instanceof Conversion)
continue;
int stoich = ctr.stoich().intValue();
String safeId = getSafetyName(ctr.id());
// get speciesContext object based on its name
// if the speciesContext is not existed, create a new one
createSpeciesContextFromTableRow(bioModel, (PhysicalEntity) ctr.getBioPaxObject(), ctr.stoich(), ctr.id(), ctr.location(), addSubunits);
// add the existed speciesContext objects or new speciesContext objects to reaction participant list
if (ctr.participantType().equals("Reactant")) {
if (reactionStep instanceof SimpleReaction || reactionStep instanceof FluxReaction) {
rplist.add(new Reactant(null, reactionStep, bioModel.getModel().getSpeciesContext(safeId), stoich));
}
} else if (ctr.participantType().equals("Product")) {
if (reactionStep instanceof SimpleReaction || reactionStep instanceof FluxReaction) {
rplist.add(new Product(null, reactionStep, bioModel.getModel().getSpeciesContext(safeId), stoich));
}
}
// we do not add catalysts
}
ReactionParticipant[] rpArray = rplist.toArray(new ReactionParticipant[0]);
reactionStep.setReactionParticipants(rpArray);
// add Controls to the reaction
Set<PhysicalEntity> controllers = process.getControllers();
for (ConversionTableRow ctr : participants) {
if (controllers.contains(ctr.getBioPaxObject())) {
if (ctr.participantType().equals("Catalyst")) {
String safeId = getSafetyName(ctr.id());
/*
* using addCatalyst() to create catalyst in reaction:
* this function cannot allow an object to be catalyst and (reactant/product) in the same reaction
*/
// reactionStep.addCatalyst(bioModel.getModel().getSpeciesContext(safeId));
/* However, in pathway interaction object, an physicalEntity can be catalyst and (reactant/product) in the same reaction
* So we just call create catalyst for the reaction no matter what rolls the object is playing in the reaction
* Switch back to the addCatalyst() function when it is necessary, but exceptions make be reported for some reactions
*/
reactionStep.addReactionParticipant(new Catalyst(null, reactionStep, bioModel.getModel().getSpeciesContext(safeId)));
} else if (ctr.participantType().equals("Control")) {
String safeId = getSafetyName(ctr.id());
// reactionStep.addCatalyst(bioModel.getModel().getSpeciesContext(safeId));
reactionStep.addReactionParticipant(new Catalyst(null, reactionStep, bioModel.getModel().getSpeciesContext(safeId)));
}
}
}
}
use of org.vcell.pathway.Conversion in project vcell by virtualcell.
the class PathwayReaderBiopax3 method addObjectConversion.
private Conversion addObjectConversion(Element conversionElement) {
if (conversionElement.getChildren().size() == 0) {
ConversionProxy proxy = new ConversionProxy();
addAttributes(proxy, conversionElement);
pathwayModel.add(proxy);
return proxy;
}
Conversion conversion = new ConversionImpl();
addAttributes(conversion, conversionElement);
for (Object child : conversionElement.getChildren()) {
if (child instanceof Element) {
if (!addContentConversion(conversion, conversionElement, (Element) child)) {
showUnexpected((Element) child);
}
}
}
pathwayModel.add(conversion);
return conversion;
}
use of org.vcell.pathway.Conversion in project vcell by virtualcell.
the class PathwayProducerBiopax3 method addContentConversion.
// right PhysicalEntity multiple
// participantStoichiometry Stoichiometry multiple
// left PhysicalEntity multiple
// spontaneous Boolean single
// conversionDirection String single
private Element addContentConversion(BioPaxObject bpObject, Element element) {
element = addContentInteraction(bpObject, element);
Conversion ob = (Conversion) bpObject;
Element tmpElement = null;
if (ob.getLeft() != null && ob.getLeft().size() > 0) {
List<PhysicalEntity> list = ob.getLeft();
for (PhysicalEntity item : list) {
tmpElement = new Element("left", bp);
addIDToProperty(tmpElement, item);
mustPrintObject(item);
element.addContent(tmpElement);
}
}
if (ob.getRight() != null && ob.getRight().size() > 0) {
List<PhysicalEntity> list = ob.getRight();
for (PhysicalEntity item : list) {
tmpElement = new Element("right", bp);
addIDToProperty(tmpElement, item);
mustPrintObject(item);
element.addContent(tmpElement);
}
}
if (ob.getParticipantStoichiometry() != null && ob.getParticipantStoichiometry().size() > 0) {
List<Stoichiometry> list = ob.getParticipantStoichiometry();
for (Stoichiometry item : list) {
tmpElement = new Element("participantStoichiometry", bp);
addIDToProperty(tmpElement, item);
mustPrintObject(item);
element.addContent(tmpElement);
}
}
if (ob.getSpontaneous() != null) {
tmpElement = new Element("spontaneous", bp);
tmpElement.setAttribute("datatype", schemaBoolean, rdf);
tmpElement.setText(ob.getSpontaneous().toString());
element.addContent(tmpElement);
}
if (ob.getConversionDirection() != null && ob.getConversionDirection().length() > 0) {
tmpElement = new Element("conversionDirection", bp);
tmpElement.setAttribute("datatype", schemaString, rdf);
tmpElement.setText(ob.getConversionDirection());
element.addContent(tmpElement);
}
return element;
}
Aggregations