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;
}
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;
}
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));
}
}
}
}
}
}
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));
}
}
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));
}
}
}
}
}
}
Aggregations