Search in sources :

Example 66 with MolecularTypePattern

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

the class ReactionRule method getReactantComponentBondType.

public BondType getReactantComponentBondType(MolecularComponentPattern mcpProduct) {
    MolecularTypePattern mtpProduct = getProductMoleculeOfComponent(mcpProduct);
    MolecularTypePattern mtpReactant = getMatchingReactantMolecule(mtpProduct);
    if (mtpReactant == null) {
        // possible if this product has no matching explicit or implicit reactant
        return null;
    }
    for (MolecularComponentPattern mcpReactant : mtpReactant.getComponentPatternList()) {
        if (mcpReactant.getMolecularComponent() != mcpProduct.getMolecularComponent()) {
            continue;
        }
        return mcpReactant.getBondType();
    }
    return null;
}
Also used : MolecularComponentPattern(org.vcell.model.rbm.MolecularComponentPattern) MolecularTypePattern(org.vcell.model.rbm.MolecularTypePattern)

Example 67 with MolecularTypePattern

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

the class RuleParticipantSignature method getListOfMolecularTypePatternSignatures.

private static ArrayList<String> getListOfMolecularTypePatternSignatures(SpeciesPattern sp, GroupingCriteria crit) {
    ArrayList<String> mtpSignatures = new ArrayList<String>();
    for (MolecularTypePattern mtp : sp.getMolecularTypePatterns()) {
        if (crit == GroupingCriteria.molecule) {
            mtpSignatures.add(mtp.getMolecularType().getName());
        } else if (crit == GroupingCriteria.rule) {
            mtpSignatures.add(mtp.getMolecularType().getName());
        } else if (crit == GroupingCriteria.full) {
            String signature = RbmUtils.toBnglString(mtp, null, CompartmentMode.hide, -1, true);
            mtpSignatures.add(signature);
        }
    }
    return mtpSignatures;
}
Also used : ArrayList(java.util.ArrayList) MolecularTypePattern(org.vcell.model.rbm.MolecularTypePattern)

Example 68 with MolecularTypePattern

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

the class SpeciesContext method findComponentUsage.

public void findComponentUsage(MolecularType mt, MolecularComponent mc, Map<String, Pair<Displayable, SpeciesPattern>> usedHere) {
    if (!hasSpeciesPattern()) {
        return;
    }
    SpeciesPattern sp = getSpeciesPattern();
    for (MolecularTypePattern mtp : sp.getMolecularTypePatterns()) {
        if (mtp.getMolecularType() == mt) {
            List<MolecularComponentPattern> componentPatterns = mtp.getComponentPatternList();
            for (MolecularComponentPattern mcp : componentPatterns) {
                if (mcp.getMolecularComponent() == mc) {
                    // here all components are always in use
                    if (mcp.getBond() != null) {
                        // we only care about the components with a bond
                        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 69 with MolecularTypePattern

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

the class SpeciesContext method checkBondsSufficiency.

private void checkBondsSufficiency(IssueContext issueContext, List<Issue> issueList, SpeciesPattern sp) {
    if (sp.getMolecularTypePatterns().size() < 2) {
        return;
    }
    int numberOfMolecularTypeCandidates = 0;
    for (MolecularTypePattern mtp : sp.getMolecularTypePatterns()) {
        if (mtp.getComponentPatternList().size() > 0) {
            numberOfMolecularTypeCandidates++;
        }
    }
    if (numberOfMolecularTypeCandidates < 2) {
        // we need at least 2 molecular types with at least 1 component each
        return;
    }
    boolean atLeastOneBad = false;
    for (MolecularTypePattern mtp : sp.getMolecularTypePatterns()) {
        boolean bondSpecifiedExists = false;
        for (MolecularComponentPattern mcp : mtp.getComponentPatternList()) {
            if (mcp.getBondType() == BondType.Specified) {
                Bond b = mcp.getBond();
                if (b != null) {
                    bondSpecifiedExists = true;
                    break;
                }
            }
        }
        if (!bondSpecifiedExists) {
            atLeastOneBad = true;
        }
    }
    if (atLeastOneBad) {
        String msg = "Each Molecular Pattern of the Species Pattern " + sp.toString() + " needs at least one explicit Bond.\n";
        IssueSource parent = issueContext.getContextObject();
        issueList.add(new Issue(parent, issueContext, IssueCategory.Identifiers, msg, Issue.Severity.ERROR));
    }
}
Also used : IssueSource(org.vcell.util.Issue.IssueSource) Issue(org.vcell.util.Issue) MolecularComponentPattern(org.vcell.model.rbm.MolecularComponentPattern) MolecularTypePattern(org.vcell.model.rbm.MolecularTypePattern) Bond(org.vcell.model.rbm.SpeciesPattern.Bond)

Example 70 with MolecularTypePattern

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

the class SpeciesContext method findStateUsage.

public void findStateUsage(MolecularType mt, MolecularComponent mc, ComponentStateDefinition csd, Map<String, Pair<Displayable, SpeciesPattern>> usedHere) {
    if (!hasSpeciesPattern()) {
        return;
    }
    SpeciesPattern sp = getSpeciesPattern();
    for (MolecularTypePattern mtp : sp.getMolecularTypePatterns()) {
        if (mtp.getMolecularType() == mt) {
            List<MolecularComponentPattern> componentPatterns = mtp.getComponentPatternList();
            for (MolecularComponentPattern mcp : componentPatterns) {
                if (mcp.getMolecularComponent() == mc) {
                    // here some state is always in use if available
                    ComponentStatePattern csp = mcp.getComponentStatePattern();
                    if (csp == null) {
                        System.out.println("This component " + mc.getName() + " should have had some State specified.");
                        continue;
                    }
                    if ((csp.getComponentStateDefinition() == csd) && (mcp.getBond() != null)) {
                        // we only care if there's a bond
                        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)

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