Search in sources :

Example 1 with InteractionParticipant

use of org.vcell.pathway.InteractionParticipant in project vcell by virtualcell.

the class PathwayMapping method createReactionStepFromPathway.

/*
	 * 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 createReactionStepFromPathway(BioModel bioModel, Process process, ReactionStep reactionStep, RelationshipObject relationshipObject, boolean addSubunits) throws Exception {
    // annotate the selected vcell object using linked pathway object
    // add non-existing speciesContexts from linked pathway conversion
    ReactionParticipant[] rpArray = parseReaction(reactionStep, bioModel, relationshipObject);
    // create a hashtable for interaction Participants
    Hashtable<String, BioPaxObject> participantTable = new Hashtable<String, BioPaxObject>();
    for (BioPaxObject bpObject : ((Conversion) relationshipObject.getBioPaxObject()).getLeft()) {
        if (((PhysicalEntity) bpObject).getName().size() == 0) {
            participantTable.put(getSafetyName(((PhysicalEntity) bpObject).getID()), bpObject);
        } else {
            participantTable.put(getSafetyName(((PhysicalEntity) bpObject).getName().get(0)), bpObject);
        }
    }
    for (BioPaxObject bpObject : ((Conversion) relationshipObject.getBioPaxObject()).getRight()) {
        if (((PhysicalEntity) bpObject).getName().size() == 0) {
            participantTable.put(getSafetyName(((PhysicalEntity) bpObject).getID()), bpObject);
        } else {
            participantTable.put(getSafetyName(((PhysicalEntity) bpObject).getName().get(0)), bpObject);
        }
    }
    for (ReactionParticipant rp : rpArray) {
        SpeciesContext speciesContext = rp.getSpeciesContext();
        if (bioModel.getModel().getSpeciesContext(speciesContext.getName()) == null) {
            // if the speciesContext is not existed, then add it to the bioModel and link it to the corresponding pathway object
            if (bioModel.getModel().getSpecies(speciesContext.getName()) == null) {
                bioModel.getModel().addSpecies(speciesContext.getSpecies());
            }
            bioModel.getModel().addSpeciesContext(speciesContext);
            RelationshipObject newSpeciesContext = new RelationshipObject(speciesContext, participantTable.get(speciesContext.getName()));
            bioModel.getRelationshipModel().addRelationshipObject(newSpeciesContext);
        } else {
            // if it is in the bioModel, then check whether it links to pathway object or not
            HashSet<RelationshipObject> linkedReObjects = bioModel.getRelationshipModel().getRelationshipObjects(bioModel.getModel().getSpeciesContext(speciesContext.getName()));
            if (linkedReObjects != null) {
                boolean isLinked = false;
                for (RelationshipObject reObject : linkedReObjects) {
                    if (reObject.getBioPaxObject() == participantTable.get(speciesContext.getName())) {
                        isLinked = true;
                        break;
                    }
                }
                if (!isLinked) {
                    RelationshipObject newSpeciesContext = new RelationshipObject(speciesContext, participantTable.get(speciesContext.getName()));
                    bioModel.getRelationshipModel().addRelationshipObject(newSpeciesContext);
                }
            } else {
                RelationshipObject newSpeciesContext = new RelationshipObject(speciesContext, participantTable.get(speciesContext.getName()));
                bioModel.getRelationshipModel().addRelationshipObject(newSpeciesContext);
            }
        }
    }
    (reactionStep).setReactionParticipants(rpArray);
    // add Control to the reaction
    if (process.getControl() != null) {
        for (InteractionParticipant pe : process.getControl().getParticipants()) {
            SpeciesContext newSpeciescontext = createSpeciesContextFromBioPaxObject(bioModel, pe.getPhysicalEntity(), addSubunits);
            (reactionStep).addReactionParticipant(new Catalyst(null, reactionStep, newSpeciescontext));
        }
    }
    addKinetics(reactionStep, process);
}
Also used : BioPaxObject(org.vcell.pathway.BioPaxObject) Hashtable(java.util.Hashtable) SpeciesContext(cbit.vcell.model.SpeciesContext) Conversion(org.vcell.pathway.Conversion) PhysicalEntity(org.vcell.pathway.PhysicalEntity) InteractionParticipant(org.vcell.pathway.InteractionParticipant) ReactionParticipant(cbit.vcell.model.ReactionParticipant) Catalyst(cbit.vcell.model.Catalyst)

Example 2 with InteractionParticipant

use of org.vcell.pathway.InteractionParticipant in project vcell by virtualcell.

the class PathwayProducerBiopax3 method addContentInteraction.

// interactionType InteractionVocabulary 	multiple
// participant 	Entity 					multiple
private Element addContentInteraction(BioPaxObject bpObject, Element element) {
    element = addContentEntity(bpObject, element);
    Interaction ob = (Interaction) bpObject;
    Element tmpElement = null;
    if (ob.getInteractionTypes() != null && ob.getInteractionTypes().size() > 0) {
        List<InteractionVocabulary> list = ob.getInteractionTypes();
        for (InteractionVocabulary item : list) {
            tmpElement = new Element("interactionType", bp);
            addIDToProperty(tmpElement, item);
            mustPrintObject(item);
            element.addContent(tmpElement);
        }
    }
    if (ob.getParticipants(InteractionParticipant.Type.PARTICIPANT) != null && ob.getParticipants(InteractionParticipant.Type.PARTICIPANT).size() > 0) {
        List<InteractionParticipant> list = ob.getParticipants(InteractionParticipant.Type.PARTICIPANT);
        for (InteractionParticipant item : list) {
            tmpElement = new Element("participant", bp);
            // tmpElement.setAttribute("resource", getResource(item), rdf);
            // mustPrintObject(item);
            addIDToProperty(tmpElement, item.getPhysicalEntity());
            mustPrintObject(item.getPhysicalEntity());
            element.addContent(tmpElement);
        }
    }
    return element;
}
Also used : Interaction(org.vcell.pathway.Interaction) MolecularInteraction(org.vcell.pathway.MolecularInteraction) GeneticInteraction(org.vcell.pathway.GeneticInteraction) InteractionVocabulary(org.vcell.pathway.InteractionVocabulary) Element(org.jdom.Element) InteractionParticipant(org.vcell.pathway.InteractionParticipant)

Example 3 with InteractionParticipant

use of org.vcell.pathway.InteractionParticipant in project vcell by virtualcell.

the class BioPaxObjectPropertiesPanel method refreshInterface.

protected void refreshInterface() {
    if (bioPaxObject == null) {
        // sanity check
        return;
    }
    ArrayList<BioPaxObjectProperty> propertyList = new ArrayList<BioPaxObjectProperty>();
    if (!(bioPaxObject instanceof SBEntity)) {
        tableModel.setData(propertyList);
        return;
    }
    SBEntity sbEntity = (SBEntity) bioPaxObject;
    if (!(sbEntity instanceof Entity)) {
        tableModel.setData(propertyList);
        return;
    }
    Entity entity = (Entity) sbEntity;
    // entity::type
    propertyList.add(new BioPaxObjectProperty("Type", bioPaxObject.getTypeLabel()));
    if (lookupContains(entity)) {
        propertyList.add(new BioPaxObjectProperty("Name", entity.getName().get(0) + " (looking...)"));
    } else if (entity.getFormalNames() != null && entity.getFormalNames().size() != 0) {
        propertyList.add(new BioPaxObjectProperty("Name", entity.getName().get(0) + " (" + entity.getFormalNames().get(0) + ")"));
    } else if (entity.getName() != null && entity.getName().size() > 0) {
        String displayName = entity.getName().get(0);
        if (entity.getxRef() != null && entity.getxRef().size() > 0) {
            displayName = displayName + " (double-click lookup)";
        }
        // entity::name
        propertyList.add(new BioPaxObjectProperty("Name", displayName));
    }
    // entity::Link
    for (RelationshipObject rObject : bioModel.getRelationshipModel().getRelationshipObjects(bioPaxObject)) {
        BioModelEntityObject beObject = rObject.getBioModelEntityObject();
        propertyList.add(new BioPaxObjectProperty("Linked physiology object", beObject.getName(), beObject));
    }
    if (entity instanceof PhysicalEntity) {
        // ------------------------ PHYSICAL ENTITY -----------------------
        PhysicalEntity physicalEntity = (PhysicalEntity) entity;
        // physicalEntity::feature (***ignored***)
        // physicalEntity::memberPhysicalEntity (***ignored***)
        // physicalEntity::notFeature (***ignored***)
        // TODO:  extract the kinetic law, then the SBEntities, then the measurables, units, aso
        boolean isReactionParticipant = BioPAXUtil.isReactionParticipant(physicalEntity, bioModel.getPathwayModel());
        String role = "";
        if (BioPAXUtil.isController(physicalEntity, bioModel.getPathwayModel())) {
            role += "Controller";
            if (isReactionParticipant) {
                role += ", Participant";
            }
        } else if (isReactionParticipant) {
            role += "Participant";
        }
        if (!role.isEmpty()) {
            propertyList.add(new BioPaxObjectProperty("Role(s)", role));
        }
        if (!(physicalEntity instanceof SmallMolecule)) {
            // physicalEntity::cellular location
            CellularLocationVocabulary cellularLocation = physicalEntity.getCellularLocation();
            if (cellularLocation != null && cellularLocation.getTerm() != null && cellularLocation.getTerm().size() > 0) {
                propertyList.add(new BioPaxObjectProperty("Cellular Location", cellularLocation.getTerm().get(0), cellularLocation));
            } else if (entity.getName() != null && entity.getName().size() > 1) {
                String location = entity.getName().get(1);
                if (location.contains("[") && location.contains("]")) {
                    location = location.substring(location.indexOf("[") + 1, location.indexOf("]"));
                    propertyList.add(new BioPaxObjectProperty("Cellular Location", location));
                }
            }
        }
        if (physicalEntity instanceof Complex) {
            Complex complex = (Complex) physicalEntity;
            // complex::components
            for (PhysicalEntity pe : complex.getComponents()) {
                propertyList.add(new BioPaxObjectProperty("Component", getEntityName(pe), pe));
            }
        } else if (physicalEntity instanceof Protein) {
        // Protein protein = (Protein)entity;
        // protein::entity reference (***ignored***)
        } else if (physicalEntity instanceof SmallMolecule) {
            SmallMolecule sm = (SmallMolecule) physicalEntity;
            EntityReference er = sm.getEntityReference();
            if (er != null && !er.getName().isEmpty() && er.getName().get(0) != null && !er.getName().get(0).isEmpty()) {
                propertyList.add(new BioPaxObjectProperty("Entity Reference", er.getName().get(0)));
                ArrayList<Xref> xrefList = er.getxRef();
                for (Xref xref : xrefList) {
                    propertyList.add(new BioPaxObjectProperty("   Xref", xref.getDb() + ":" + xref.getId(), xref));
                }
            }
        } else if (physicalEntity instanceof Dna) {
        // dna::entityReference (***ignored***)
        } else if (physicalEntity instanceof DnaRegion) {
        // dnaRegion::entityReference (***ignored***)
        } else if (physicalEntity instanceof Rna) {
        // rna::entityReference (***ignored***)
        } else if (physicalEntity instanceof RnaRegion) {
        // rnaRegion::entityReference (***ignored***)
        }
    } else if (entity instanceof Interaction) {
        // --------------------------- INTERACTION -------------------
        Interaction interaction = (Interaction) entity;
        // interaction::interactionType
        for (InteractionVocabulary interactionVocabulary : interaction.getInteractionTypes()) {
            if (interactionVocabulary.getTerm().size() > 0) {
                propertyList.add(new BioPaxObjectProperty("Interaction Type", interactionVocabulary.getTerm().get(0), interactionVocabulary));
            }
        }
        // interaction::participants
        for (InteractionParticipant interactionParticipant : interaction.getParticipants()) {
            PhysicalEntity physicalEntity = interactionParticipant.getPhysicalEntity();
            String physicalEntityName = physicalEntity.getName().size() > 0 ? physicalEntity.getName().get(0) : physicalEntity.getIDShort();
            String cellularLocation = "";
            if (physicalEntity.getCellularLocation() != null) {
                cellularLocation = physicalEntity.getCellularLocation().getTerm().size() > 0 ? " [" + physicalEntity.getCellularLocation().getTerm().get(0) + "]" : "";
            }
            propertyList.add(new BioPaxObjectProperty(interactionParticipant.getLevel3PropertyName(), physicalEntityName + cellularLocation, physicalEntity));
        }
        // get the controllers for interactions
        // we always need this because there's no guarantee we'll have kinetic laws
        // for instance pathway commons doesn't have quantitative information
        Set<String> controllersNames = getControllersNames(interaction);
        if (controllersNames.size() > 0) {
            for (String str : controllersNames) {
                // String tooltip = "<html>how many of these 12 M <br>average size  1.12345*E12 nm <br>temperature 37 degrees Celsius</html>";
                String tooltip = "";
                propertyList.add(new BioPaxObjectProperty("Controlled by", str, interaction, tooltip));
            }
        }
        // get the kinetic laws (if any)
        Set<Control> controls = BioPAXUtil.getControlsOfInteraction(interaction, bioModel.getPathwayModel());
        for (Control control : controls) {
            ArrayList<SBEntity> sbEntities = control.getSBSubEntity();
            for (SBEntity sbE : sbEntities) {
                // the only SBSubEntities allowed in a control are kinetic laws
                if (sbE.getID().contains("kineticLaw")) {
                    String str = new String();
                    if (control.getPhysicalControllers() != null) {
                        str += " for Controller(s): ";
                        for (PhysicalEntity ep : control.getPhysicalControllers()) {
                            if (ep.getName().size() > 0) {
                                str += ep.getName().get(0);
                            } else {
                                str += ep.getIDShort();
                            }
                            str += " ";
                        }
                    }
                    String sDetails = "";
                    ArrayList<SBVocabulary> sbTerms = sbE.getSBTerm();
                    for (SBVocabulary sbv : sbTerms) {
                        // type of kinetic law
                        String str1 = sbv.getID();
                        str1 = str1.substring(str1.lastIndexOf('#') + 1);
                        System.out.println(str1);
                        SBOTerm sboT = SBOListEx.sboMap.get(str1);
                        sDetails += "<font color=\"#660000\"><b>" + sboT.getName() + "</b></font>" + "  " + "<font color=\"#006600\">" + sboT.getDescription() + "</font>";
                        sDetails += "<br>";
                    }
                    ArrayList<SBEntity> klProperties = sbE.getSBSubEntity();
                    for (SBEntity klProperty : klProperties) {
                        if (klProperty instanceof SBMeasurable) {
                            SBMeasurable m = (SBMeasurable) klProperty;
                            String str1 = "";
                            String str2 = "";
                            String str3 = "";
                            if (m.hasTerm()) {
                                str1 += m.extractSBOTermAsString();
                            }
                            if (m.hasNumber()) {
                                str2 += m.getNumber().get(0);
                            }
                            if (m.hasUnit()) {
                                str3 += m.extractSBOUnitAsString();
                            }
                            // str1 is an SBO id, for example "SBO:0000064"
                            SBOTerm sboT = SBOListEx.sboMap.get(str1);
                            sDetails += sboT.getSymbol() + "   (" + sboT.getName() + ")" + "<font color=\"#660000\"><b>" + str2 + str3 + "</b></font>" + "  " + "<font color=\"#006600\">" + sboT.getDescription() + "</font>";
                        } else {
                            sDetails = klProperty.getIDShort() + "  " + klProperty.getTypeLabel();
                        }
                        sDetails += "<br>";
                    }
                    // String tooltip = "<html>how many of these 12 M <br>average size  1.12345*E12 nm <br>temperature 37 degrees Celsius</html>";
                    String tooltip = "";
                    BioPaxObjectProperty bpop = new BioPaxObjectProperty("Kinetic Law" + str, sbE.getID(), sbE, tooltip);
                    bpop.setDetails(sDetails);
                    propertyList.add(bpop);
                }
            }
        }
        if (interaction instanceof Control) {
            // TODO: is this ever being called?
            Control c = (Control) interaction;
            // catalysis::controlled
            Interaction controlledInteraction = c.getControlledInteraction();
            if (controlledInteraction != null) {
                String controlledName = controlledInteraction.getIDShort();
                if (controlledInteraction.getName().size() > 0) {
                    controlledName = controlledInteraction.getName().get(0);
                }
                propertyList.add(new BioPaxObjectProperty("Controlled Interaction", controlledName, controlledInteraction));
            }
        }
    } else if (entity instanceof GroupObject) {
        // ---------------------- GROUP OBJECT ------------------
        GroupObject groupObject = (GroupObject) entity;
        for (BioPaxObject bpo : groupObject.getGroupedObjects()) {
            propertyList.add(new BioPaxObjectProperty("Element::" + bpo.getTypeLabel(), getEntityName((Entity) bpo), bpo));
        }
    }
    // entity::comments
    for (String comment : entity.getComments()) {
        propertyList.add(new BioPaxObjectProperty("Comment", comment));
    }
    // entity::xRef
    ArrayList<Xref> xrefList = ((Entity) bioPaxObject).getxRef();
    for (Xref xref : xrefList) {
        if (xref instanceof UnificationXref) {
            propertyList.add(new BioPaxObjectProperty("Xref", xref.getDb() + ":" + xref.getId(), xref));
        }
    }
    for (Xref xref : xrefList) {
        if (xref instanceof RelationshipXref) {
            propertyList.add(new BioPaxObjectProperty("Xref (related)", xref.getDb() + ":" + xref.getId(), xref));
        }
    }
    for (Xref xref : xrefList) {
        if (xref instanceof PublicationXref) {
            propertyList.add(new BioPaxObjectProperty("Publication", xref.getDb() + ":" + xref.getId(), xref));
        }
    }
    // for(SBVocabulary sbVocab : sbEntity.getSBTerm()) {
    // propertyList.add(new BioPaxObjectProperty("SBO Term", SBPAXLabelUtil.makeLabel(sbVocab)));
    // }
    // if(sbEntity instanceof Interaction) {
    // // TODO: this goes away
    // Interaction interaction = (Interaction) sbEntity;
    // Set<SBEntity> subEntities = new HashSet<SBEntity>();
    // subEntities.add(interaction);
    // Set<Control> controls = BioPAXUtil.findAllControls(interaction, bioModel.getPathwayModel());
    // subEntities.addAll(controls);
    // subEntities = SBPAX3Util.extractAllEntities(subEntities);
    // for(SBEntity subEntity : subEntities) {
    // if(subEntity instanceof SBMeasurable) {
    // propertyList.add(new BioPaxObjectProperty("Measured quantity", SBPAXLabelUtil.makeLabel(subEntity)));
    // }
    // }
    // }
    tableModel.setData(propertyList);
}
Also used : SBVocabulary(org.vcell.pathway.sbpax.SBVocabulary) SBEntity(org.vcell.pathway.sbpax.SBEntity) PhysicalEntity(org.vcell.pathway.PhysicalEntity) Entity(org.vcell.pathway.Entity) Set(java.util.Set) TreeSet(java.util.TreeSet) HashSet(java.util.HashSet) Rna(org.vcell.pathway.Rna) PublicationXref(org.vcell.pathway.PublicationXref) InteractionVocabulary(org.vcell.pathway.InteractionVocabulary) BioPaxObject(org.vcell.pathway.BioPaxObject) ArrayList(java.util.ArrayList) CellularLocationVocabulary(org.vcell.pathway.CellularLocationVocabulary) SBEntity(org.vcell.pathway.sbpax.SBEntity) RelationshipObject(org.vcell.relationship.RelationshipObject) Complex(org.vcell.pathway.Complex) RnaRegion(org.vcell.pathway.RnaRegion) SBMeasurable(org.vcell.pathway.sbpax.SBMeasurable) Xref(org.vcell.pathway.Xref) UnificationXref(org.vcell.pathway.UnificationXref) RelationshipXref(org.vcell.pathway.RelationshipXref) PublicationXref(org.vcell.pathway.PublicationXref) Control(org.vcell.pathway.Control) DnaRegion(org.vcell.pathway.DnaRegion) EntityReference(org.vcell.pathway.EntityReference) Interaction(org.vcell.pathway.Interaction) UnificationXref(org.vcell.pathway.UnificationXref) GroupObject(org.vcell.pathway.GroupObject) SBOTerm(org.vcell.pathway.sbo.SBOTerm) BioModelEntityObject(cbit.vcell.model.BioModelEntityObject) Protein(org.vcell.pathway.Protein) RelationshipXref(org.vcell.pathway.RelationshipXref) PhysicalEntity(org.vcell.pathway.PhysicalEntity) SmallMolecule(org.vcell.pathway.SmallMolecule) Dna(org.vcell.pathway.Dna) InteractionParticipant(org.vcell.pathway.InteractionParticipant)

Example 4 with InteractionParticipant

use of org.vcell.pathway.InteractionParticipant in project vcell by virtualcell.

the class PathwayGraphModel method refreshInteraction.

private void refreshInteraction(Interaction interaction) {
    BioPaxInteractionShape interactionShape = (BioPaxInteractionShape) getShapeFromModelObject(interaction);
    BioPaxObject ancestorObject = pathwayModel.findTopLevelGroupAncestor(interaction);
    if (ancestorObject == interaction) {
        // conversion was not grouped
        for (InteractionParticipant participant : interaction.getParticipants()) {
            refreshParticipant(interactionShape, participant);
        }
    } else {
        if (ancestorObject instanceof GroupObject) {
            // conversion has been grouped
            GroupObject groupObject = (GroupObject) ancestorObject;
            for (InteractionParticipant participant : interaction.getParticipants()) {
                refreshGroupInteraction(groupObject, participant);
            }
        }
    }
}
Also used : BioPaxObject(org.vcell.pathway.BioPaxObject) InteractionParticipant(org.vcell.pathway.InteractionParticipant) GroupObject(org.vcell.pathway.GroupObject)

Example 5 with InteractionParticipant

use of org.vcell.pathway.InteractionParticipant in project vcell by virtualcell.

the class BioPaxInteractionParticipantShape method getCurve.

// very similar with the code in ReactionParticipantShape
@Override
protected final CubicCurve2D.Double getCurve() {
    refreshLayoutSelf();
    // default behavior of control points is for direction at ends to follow secant between end-points.
    if (lastCurve_Start == null || !lastCurve_Start.equals(start) || lastCurve_End == null || !lastCurve_End.equals(end)) {
        lastp1ctrl = new Point2D.Double((1.0 - FRACT_WEIGHT) * start.getX() + FRACT_WEIGHT * end.getX(), (1.0 - FRACT_WEIGHT) * start.getY() + FRACT_WEIGHT * end.getY());
    }
    Point2D.Double p2ctrl = new Point2D.Double(FRACT_WEIGHT * start.getX() + (1.0 - FRACT_WEIGHT) * end.getX(), FRACT_WEIGHT * start.getY() + (1.0 - FRACT_WEIGHT) * end.getY());
    // check for siblings in the reaction (like a+a-> or a->a) and calculate a correction factor
    // so that the edges won't overlap
    correctionFactor = 0;
    if (endShape instanceof BioPaxInteractionShape) {
        // index in the array of siblings
        int myPosition = 0;
        // in total
        int numSiblings = 0;
        BioPaxInteractionShape reactionStepShape = (BioPaxInteractionShape) endShape;
        Interaction rs = reactionStepShape.getInteraction();
        for (InteractionParticipant rp : rs.getParticipants()) {
            if (rp == participant) {
                // myself
                if (rp.getType() == InteractionParticipant.Type.LEFT || rp.getType() == InteractionParticipant.Type.RIGHT) {
                    myPosition = numSiblings;
                    numSiblings++;
                }
            } else if (rp.getPhysicalEntity().getName().equals(participant.getPhysicalEntity().getName())) {
                if (rp.getType() == InteractionParticipant.Type.LEFT || rp.getType() == InteractionParticipant.Type.RIGHT) {
                    numSiblings++;
                }
            }
        }
        if (numSiblings > 1) {
            double offset = numSiblings / 2 - 0.5;
            correctionFactor = (myPosition - offset) * 0.08;
        }
    }
    // calculate tangent direction at interaction
    double tangentX = 0.0;
    double tangentY = 0.0;
    if (endShape instanceof BioPaxInteractionShape) {
        BioPaxInteractionShape reactionStepShape = (BioPaxInteractionShape) endShape;
        for (Shape shape : graphModel.getShapes()) {
            if (shape instanceof BioPaxInteractionParticipantShape && ((BioPaxInteractionParticipantShape) shape).endShape == reactionStepShape) {
                BioPaxInteractionParticipantShape rpShape = (BioPaxInteractionParticipantShape) shape;
                double dx = rpShape.start.getX() - rpShape.end.getX();
                double dy = rpShape.start.getY() - rpShape.end.getY();
                double len = dx * dx + dy * dy;
                if (rpShape.participant.getType() == InteractionParticipant.Type.LEFT) {
                    tangentX += (rpShape.start.getX() - rpShape.end.getX()) / len;
                    tangentY += (rpShape.start.getY() - rpShape.end.getY()) / len;
                } else if (rpShape.participant.getType() == InteractionParticipant.Type.RIGHT) {
                    tangentX -= (rpShape.start.getX() - rpShape.end.getX()) / len;
                    tangentY -= (rpShape.start.getY() - rpShape.end.getY()) / len;
                }
            }
        }
    }
    double tangentLength = Math.sqrt(tangentX * tangentX + tangentY * tangentY);
    if (tangentLength != 0) {
        tangentX = tangentX * CONTROL_WEIGHT / tangentLength;
        tangentY = tangentY * CONTROL_WEIGHT / tangentLength;
    }
    if (participant.getType() == InteractionParticipant.Type.CONTROLLER) {
        // choose side based on inner product with displacement vector between catalyst and reactionStep
        if (((start.getX() - end.getX()) * tangentY - (start.getY() - end.getY()) * tangentX) > 0) {
            p2ctrl.setLocation(end.getX() + tangentY, end.getY() - tangentX);
        } else {
            p2ctrl.setLocation(end.getX() - tangentY, end.getY() + tangentX);
        }
    } else if (participant.getType() == InteractionParticipant.Type.RIGHT) {
        p2ctrl.setLocation(end.getX() + tangentX, end.getY() + tangentY);
    } else if (participant.getType() == InteractionParticipant.Type.LEFT) {
        p2ctrl.setLocation(end.getX() - tangentX, end.getY() - tangentY);
    }
    if (lastCurve != null && lastCurve_Start != null && lastCurve_Start.equals(start) && lastCurve_End != null && lastCurve_End.equals(end) && lastp2ctrl != null && lastp2ctrl.equals(p2ctrl)) {
    // Do Nothing
    } else {
        lastCurve = new CubicCurve2D.Double(start.getX(), start.getY(), lastp1ctrl.getX() * (1 + correctionFactor), lastp1ctrl.getY() * (1 + correctionFactor), p2ctrl.getX(), p2ctrl.getY(), end.getX(), end.getY());
        lastCurve_Start = new Point(start);
        lastCurve_End = new Point(end);
        lastp2ctrl = p2ctrl;
    }
    return lastCurve;
}
Also used : EdgeShape(cbit.gui.graph.EdgeShape) Shape(cbit.gui.graph.Shape) Interaction(org.vcell.pathway.Interaction) Point(java.awt.Point) Point(java.awt.Point) Point2D(java.awt.geom.Point2D) InteractionParticipant(org.vcell.pathway.InteractionParticipant) CubicCurve2D(java.awt.geom.CubicCurve2D)

Aggregations

InteractionParticipant (org.vcell.pathway.InteractionParticipant)8 BioPaxObject (org.vcell.pathway.BioPaxObject)6 GroupObject (org.vcell.pathway.GroupObject)5 Interaction (org.vcell.pathway.Interaction)5 HashSet (java.util.HashSet)3 Complex (org.vcell.pathway.Complex)3 Conversion (org.vcell.pathway.Conversion)3 PhysicalEntity (org.vcell.pathway.PhysicalEntity)3 ArrayList (java.util.ArrayList)2 Control (org.vcell.pathway.Control)2 InteractionVocabulary (org.vcell.pathway.InteractionVocabulary)2 MolecularInteraction (org.vcell.pathway.MolecularInteraction)2 Protein (org.vcell.pathway.Protein)2 SmallMolecule (org.vcell.pathway.SmallMolecule)2 EdgeShape (cbit.gui.graph.EdgeShape)1 Shape (cbit.gui.graph.Shape)1 BioModelEntityObject (cbit.vcell.model.BioModelEntityObject)1 Catalyst (cbit.vcell.model.Catalyst)1 ReactionParticipant (cbit.vcell.model.ReactionParticipant)1 SpeciesContext (cbit.vcell.model.SpeciesContext)1