Search in sources :

Example 51 with MolecularComponentPattern

use of org.vcell.model.rbm.MolecularComponentPattern in project vcell by virtualcell.

the class RbmObservable method findComponentUsage.

public void findComponentUsage(MolecularType mt, MolecularComponent mc, Map<String, Pair<Displayable, SpeciesPattern>> usedHere) {
    for (SpeciesPattern sp : getSpeciesPatternList()) {
        for (MolecularTypePattern mtp : sp.getMolecularTypePatterns()) {
            if (mtp.getMolecularType() == mt) {
                List<MolecularComponentPattern> componentPatterns = mtp.getComponentPatternList();
                for (MolecularComponentPattern mcp : componentPatterns) {
                    if (mcp.isImplied()) {
                        // we don't care about these
                        continue;
                    }
                    if (mcp.getMolecularComponent() == mc) {
                        // found mc in use
                        String key = sp.getDisplayName();
                        key = getDisplayType() + getDisplayName() + key;
                        usedHere.put(key, new Pair<Displayable, SpeciesPattern>(this, sp));
                    }
                }
            }
        }
    }
}
Also used : Displayable(org.vcell.util.Displayable) MolecularComponentPattern(org.vcell.model.rbm.MolecularComponentPattern) MolecularTypePattern(org.vcell.model.rbm.MolecularTypePattern) SpeciesPattern(org.vcell.model.rbm.SpeciesPattern)

Example 52 with MolecularComponentPattern

use of org.vcell.model.rbm.MolecularComponentPattern in project vcell by virtualcell.

the class ReactionRule method findComponentUsage.

// TODO: almost identical to findStateUsage() below - pay attention to keep both in sync
public void findComponentUsage(MolecularType mt, MolecularComponent mc, Map<String, Pair<Displayable, SpeciesPattern>> usedHere) {
    for (ProductPattern pp : getProductPatterns()) {
        SpeciesPattern sp = pp.getSpeciesPattern();
        for (MolecularTypePattern mtp : sp.getMolecularTypePatterns()) {
            if (mtp.getMolecularType() == mt) {
                List<MolecularComponentPattern> componentPatterns = mtp.getComponentPatternList();
                for (MolecularComponentPattern mcp : componentPatterns) {
                    if (mcp.isImplied()) {
                        // we don't care about these
                        continue;
                    }
                    if (mcp.getMolecularComponent() == mc) {
                        // found mc in use
                        String key = getDisplayType() + getDisplayName() + sp.getDisplayName();
                        usedHere.put(key, new Pair<Displayable, SpeciesPattern>(this, sp));
                    }
                }
            }
        }
    }
    for (ReactantPattern rp : getReactantPatterns()) {
        SpeciesPattern sp = rp.getSpeciesPattern();
        for (MolecularTypePattern mtp : sp.getMolecularTypePatterns()) {
            if (mtp.getMolecularType() == mt) {
                List<MolecularComponentPattern> componentPatterns = mtp.getComponentPatternList();
                for (MolecularComponentPattern mcp : componentPatterns) {
                    if (mcp.isImplied()) {
                        continue;
                    }
                    if (mcp.getMolecularComponent() == mc) {
                        String key = getDisplayType() + getDisplayName() + sp.getDisplayName();
                        usedHere.put(key, new Pair<Displayable, SpeciesPattern>(this, sp));
                    }
                }
            }
        }
    }
}
Also used : Displayable(org.vcell.util.Displayable) MolecularComponentPattern(org.vcell.model.rbm.MolecularComponentPattern) MolecularTypePattern(org.vcell.model.rbm.MolecularTypePattern) SpeciesPattern(org.vcell.model.rbm.SpeciesPattern)

Example 53 with MolecularComponentPattern

use of org.vcell.model.rbm.MolecularComponentPattern in project vcell by virtualcell.

the class ReactionRule method deleteComponentFromPatterns.

public boolean deleteComponentFromPatterns(MolecularType mt, MolecularComponent mc) {
    for (ProductPattern pp : getProductPatterns()) {
        SpeciesPattern sp = pp.getSpeciesPattern();
        for (MolecularTypePattern mtp : sp.getMolecularTypePatterns()) {
            if (mtp.getMolecularType() == mt) {
                List<MolecularComponentPattern> componentPatterns = mtp.getComponentPatternList();
                for (Iterator<MolecularComponentPattern> iterator = componentPatterns.iterator(); iterator.hasNext(); ) {
                    MolecularComponentPattern mcp = iterator.next();
                    if (mcp.getMolecularComponent() == mc) {
                        iterator.remove();
                    }
                }
            }
        }
        sp.resolveBonds();
    }
    for (ReactantPattern rp : getReactantPatterns()) {
        SpeciesPattern sp = rp.getSpeciesPattern();
        for (MolecularTypePattern mtp : sp.getMolecularTypePatterns()) {
            if (mtp.getMolecularType() == mt) {
                List<MolecularComponentPattern> componentPatterns = mtp.getComponentPatternList();
                for (Iterator<MolecularComponentPattern> iterator = componentPatterns.iterator(); iterator.hasNext(); ) {
                    MolecularComponentPattern mcp = iterator.next();
                    if (mcp.getMolecularComponent() == mc) {
                        iterator.remove();
                    }
                }
            }
        }
        sp.resolveBonds();
    }
    return true;
}
Also used : MolecularComponentPattern(org.vcell.model.rbm.MolecularComponentPattern) MolecularTypePattern(org.vcell.model.rbm.MolecularTypePattern) SpeciesPattern(org.vcell.model.rbm.SpeciesPattern)

Example 54 with MolecularComponentPattern

use of org.vcell.model.rbm.MolecularComponentPattern in project vcell by virtualcell.

the class ReactionRule method findStateUsage.

public void findStateUsage(MolecularType mt, MolecularComponent mc, ComponentStateDefinition csd, Map<String, Pair<Displayable, SpeciesPattern>> usedHere) {
    for (ProductPattern pp : getProductPatterns()) {
        SpeciesPattern sp = pp.getSpeciesPattern();
        for (MolecularTypePattern mtp : sp.getMolecularTypePatterns()) {
            if (mtp.getMolecularType() == mt) {
                List<MolecularComponentPattern> componentPatterns = mtp.getComponentPatternList();
                for (MolecularComponentPattern mcp : componentPatterns) {
                    if (mcp.isImplied()) {
                        // we don't care about these
                        continue;
                    }
                    if (mcp.getMolecularComponent() == mc) {
                        // found mc in use
                        // now let's look at component state definition
                        ComponentStatePattern csp = mcp.getComponentStatePattern();
                        if (csp == null) {
                            continue;
                        }
                        if (csp.getComponentStateDefinition() == csd) {
                            String key = getDisplayType() + getDisplayName() + sp.getDisplayName();
                            usedHere.put(key, new Pair<Displayable, SpeciesPattern>(this, sp));
                        }
                    }
                }
            }
        }
    }
    for (ReactantPattern rp : getReactantPatterns()) {
        SpeciesPattern sp = rp.getSpeciesPattern();
        for (MolecularTypePattern mtp : sp.getMolecularTypePatterns()) {
            if (mtp.getMolecularType() == mt) {
                List<MolecularComponentPattern> componentPatterns = mtp.getComponentPatternList();
                for (MolecularComponentPattern mcp : componentPatterns) {
                    if (mcp.isImplied()) {
                        continue;
                    }
                    if (mcp.getMolecularComponent() == mc) {
                        ComponentStatePattern csp = mcp.getComponentStatePattern();
                        if (csp == null) {
                            continue;
                        }
                        if (csp.getComponentStateDefinition() == csd) {
                            String key = getDisplayType() + getDisplayName() + sp.getDisplayName();
                            usedHere.put(key, new Pair<Displayable, SpeciesPattern>(this, sp));
                        }
                    }
                }
            }
        }
    }
}
Also used : Displayable(org.vcell.util.Displayable) MolecularComponentPattern(org.vcell.model.rbm.MolecularComponentPattern) ComponentStatePattern(org.vcell.model.rbm.ComponentStatePattern) MolecularTypePattern(org.vcell.model.rbm.MolecularTypePattern) SpeciesPattern(org.vcell.model.rbm.SpeciesPattern)

Example 55 with MolecularComponentPattern

use of org.vcell.model.rbm.MolecularComponentPattern in project vcell by virtualcell.

the class ReactionRule method checkComponentStateConsistency.

public void checkComponentStateConsistency(IssueContext issueContext, List<Issue> issueList, MolecularTypePattern mtpThis) {
    if (issueList == null) {
        // this may be called during parsing before the model is consistent
        return;
    }
    issueContext = issueContext.newChildContext(ContextType.ReactionRule, this);
    MolecularType mtThat = mtpThis.getMolecularType();
    for (MolecularComponentPattern mcpThis : mtpThis.getComponentPatternList()) {
        if (mcpThis.isImplied()) {
            continue;
        }
        ComponentStatePattern cspThis = mcpThis.getComponentStatePattern();
        String mcNameThis = mcpThis.getMolecularComponent().getName();
        MolecularComponent[] mcThatList = mtThat.getMolecularComponents(mcNameThis);
        if (mcThatList.length == 0) {
            System.out.println("we already fired an issue about component missing");
            // nothing to do here, we already fired an issue about component missing
            continue;
        } else if (mcThatList.length > 1) {
            String msg = "Multiple " + MolecularComponent.typeName + "s with the same name are not yet supported.";
            issueList.add(new Issue(this, mcpThis, issueContext, IssueCategory.Identifiers, msg, msg, Issue.SEVERITY_ERROR));
        } else {
            // found exactly 1 component
            MolecularComponent mcThat = mcThatList[0];
            List<ComponentStateDefinition> csdListThat = mcThat.getComponentStateDefinitions();
            if (csdListThat.size() == 0) {
                // component has no states, we check if mcpThis has any states... it shouldn't
                if (cspThis == null) {
                    // all is well
                    continue;
                }
                if (!cspThis.isAny() || (cspThis.getComponentStateDefinition() != null)) {
                    String msg = MolecularComponentPattern.typeName + " " + mcNameThis + " is in an invalid State.";
                    issueList.add(new Issue(this, mcpThis, issueContext, IssueCategory.Identifiers, msg, msg, Issue.SEVERITY_WARNING));
                }
            } else {
                // we check if mcpThis has any of these states... it should!
                if ((cspThis == null) || cspThis.isAny() || (cspThis.getComponentStateDefinition() == null)) {
                // String msg = "Component pattern " + mcNameThis + " must be in an explicit State.";
                // issueList.add(new Issue(this, IssueCategory.Identifiers, msg, Issue.SEVERITY_WARNING));
                } else {
                    String csdNameThis = cspThis.getComponentStateDefinition().getName();
                    if (csdNameThis.isEmpty() || (mcThat.getComponentStateDefinition(csdNameThis) == null)) {
                        String msg = "Invalid State " + csdNameThis + " for component pattern " + mcNameThis;
                        issueList.add(new Issue(this, mcpThis, issueContext, IssueCategory.Identifiers, msg, msg, Issue.SEVERITY_WARNING));
                    }
                }
            }
        }
    }
}
Also used : MolecularType(org.vcell.model.rbm.MolecularType) Issue(org.vcell.util.Issue) MolecularComponentPattern(org.vcell.model.rbm.MolecularComponentPattern) MolecularComponent(org.vcell.model.rbm.MolecularComponent) ComponentStatePattern(org.vcell.model.rbm.ComponentStatePattern) ArrayList(java.util.ArrayList) List(java.util.List)

Aggregations

MolecularComponentPattern (org.vcell.model.rbm.MolecularComponentPattern)62 MolecularTypePattern (org.vcell.model.rbm.MolecularTypePattern)49 SpeciesPattern (org.vcell.model.rbm.SpeciesPattern)30 ComponentStatePattern (org.vcell.model.rbm.ComponentStatePattern)25 Graphics (java.awt.Graphics)16 MolecularComponent (org.vcell.model.rbm.MolecularComponent)14 Point (java.awt.Point)13 MolecularType (org.vcell.model.rbm.MolecularType)12 ComponentStateDefinition (org.vcell.model.rbm.ComponentStateDefinition)10 Icon (javax.swing.Icon)9 BondType (org.vcell.model.rbm.MolecularComponentPattern.BondType)9 Bond (org.vcell.model.rbm.SpeciesPattern.Bond)8 List (java.util.List)7 BioModelNode (cbit.vcell.desktop.BioModelNode)6 MolecularTypeLargeShape (cbit.vcell.graph.MolecularTypeLargeShape)6 MolecularTypeSmallShape (cbit.vcell.graph.MolecularTypeSmallShape)6 RuleAnalysisChanged (cbit.vcell.graph.ReactionCartoon.RuleAnalysisChanged)6 SpeciesPatternLargeShape (cbit.vcell.graph.SpeciesPatternLargeShape)6 SpeciesPatternSmallShape (cbit.vcell.graph.SpeciesPatternSmallShape)6 ZoomShapeIcon (cbit.vcell.graph.gui.ZoomShapeIcon)6