Search in sources :

Example 16 with MolecularTypePattern

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

the class RbmObservable method resolveStates.

// TODO: this will have to go once we get rid of ComponentStatePattern
// use as a stopgap measure to eliminate a bug where the ComponentStatePattern is null
// instead of being Any (which happens when the MolecularComponent has states defined)
private void resolveStates() {
    for (SpeciesPattern sp : speciesPatternList) {
        for (MolecularTypePattern mtp : sp.getMolecularTypePatterns()) {
            for (MolecularComponentPattern mcp : mtp.getComponentPatternList()) {
                if (mcp.getComponentStatePattern() == null && mcp.getMolecularComponent().getComponentStateDefinitions().size() > 0) {
                    ComponentStatePattern csp = new ComponentStatePattern();
                    mcp.setComponentStatePattern(csp);
                }
            }
        }
    }
}
Also used : 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 17 with MolecularTypePattern

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

the class RbmObservable method findStateUsage.

public void findStateUsage(MolecularType mt, MolecularComponent mc, ComponentStateDefinition csd, 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
                        // now let's look at component state definition
                        ComponentStatePattern csp = mcp.getComponentStatePattern();
                        if (csp == null) {
                            continue;
                        }
                        if (csp.getComponentStateDefinition() == csd) {
                            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) ComponentStatePattern(org.vcell.model.rbm.ComponentStatePattern) MolecularTypePattern(org.vcell.model.rbm.MolecularTypePattern) SpeciesPattern(org.vcell.model.rbm.SpeciesPattern)

Example 18 with MolecularTypePattern

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

the class RbmObservable method resolveBonds.

private void resolveBonds() {
    for (SpeciesPattern sp : speciesPatternList) {
        List<MolecularTypePattern> molecularTypePatterns = sp.getMolecularTypePatterns();
        for (int i = 0; i < molecularTypePatterns.size(); ++i) {
            molecularTypePatterns.get(i).setIndex(i + 1);
        }
        sp.resolveBonds();
    }
}
Also used : MolecularTypePattern(org.vcell.model.rbm.MolecularTypePattern) SpeciesPattern(org.vcell.model.rbm.SpeciesPattern)

Example 19 with MolecularTypePattern

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

the class ReactionRule method removeMatch.

public void removeMatch(String keyToRemove) {
    // no need to specify where the key is, we remove it from everywhere
    if (keyToRemove == null || keyToRemove.equals("*")) {
        // nothing to remove if key is bad or no key
        return;
    }
    int matches = 0;
    for (ReactionRuleParticipant participant : reactantPatterns) {
        List<MolecularTypePattern> molecularTypePatterns = participant.getSpeciesPattern().getMolecularTypePatterns();
        for (MolecularTypePattern mtp : molecularTypePatterns) {
            if (mtp.hasExplicitParticipantMatch() && mtp.getParticipantMatchLabel().equals(keyToRemove)) {
                mtp.setParticipantMatchLabel("*");
                matches++;
            }
        }
    }
    for (ReactionRuleParticipant participant : productPatterns) {
        List<MolecularTypePattern> molecularTypePatterns = participant.getSpeciesPattern().getMolecularTypePatterns();
        for (MolecularTypePattern mtp : molecularTypePatterns) {
            if (mtp.hasExplicitParticipantMatch() && mtp.getParticipantMatchLabel().equals(keyToRemove)) {
                mtp.setParticipantMatchLabel("*");
                matches++;
            }
        }
    }
    if (matches > 1) {
        throw new RuntimeException("Found more than one MolecularTypePatterns to remove matching the key " + keyToRemove);
    }
}
Also used : MolecularTypePattern(org.vcell.model.rbm.MolecularTypePattern)

Example 20 with MolecularTypePattern

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

the class ReactionRule method populateMaps.

public List<MolecularTypePattern> populateMaps(MolecularType mt, ReactionRuleParticipantType type) {
    List<MolecularTypePattern> mtpList = new ArrayList<MolecularTypePattern>();
    List<? extends ReactionRuleParticipant> patterns = (type == ReactionRuleParticipantType.Reactant) ? reactantPatterns : productPatterns;
    for (ReactionRuleParticipant participant : patterns) {
        List<MolecularTypePattern> molecularTypePatterns = participant.getSpeciesPattern().getMolecularTypePatterns();
        for (MolecularTypePattern mtp : molecularTypePatterns) {
            if (mtp.getMolecularType() == mt) {
                mtpList.add(mtp);
            }
        }
    }
    return mtpList;
}
Also used : ArrayList(java.util.ArrayList) MolecularTypePattern(org.vcell.model.rbm.MolecularTypePattern)

Aggregations

MolecularTypePattern (org.vcell.model.rbm.MolecularTypePattern)72 MolecularComponentPattern (org.vcell.model.rbm.MolecularComponentPattern)49 SpeciesPattern (org.vcell.model.rbm.SpeciesPattern)39 ComponentStatePattern (org.vcell.model.rbm.ComponentStatePattern)19 Graphics (java.awt.Graphics)16 MolecularType (org.vcell.model.rbm.MolecularType)16 Point (java.awt.Point)14 BioModelNode (cbit.vcell.desktop.BioModelNode)11 RbmObservable (cbit.vcell.model.RbmObservable)10 SpeciesContext (cbit.vcell.model.SpeciesContext)10 Icon (javax.swing.Icon)10 ComponentStateDefinition (org.vcell.model.rbm.ComponentStateDefinition)10 MolecularComponent (org.vcell.model.rbm.MolecularComponent)10 ArrayList (java.util.ArrayList)9 SpeciesPatternLargeShape (cbit.vcell.graph.SpeciesPatternLargeShape)7 ReactionRule (cbit.vcell.model.ReactionRule)7 LinkedHashMap (java.util.LinkedHashMap)7 MolecularTypeLargeShape (cbit.vcell.graph.MolecularTypeLargeShape)6 MolecularTypeSmallShape (cbit.vcell.graph.MolecularTypeSmallShape)6 RuleAnalysisChanged (cbit.vcell.graph.ReactionCartoon.RuleAnalysisChanged)6