Search in sources :

Example 11 with BNGSpecies

use of cbit.vcell.bionetgen.BNGSpecies in project vcell by virtualcell.

the class BNGExecutorServiceMultipass method isIdentityReaction.

private static boolean isIdentityReaction(BNGReaction r) {
    // System.out.println("check if we ended up with an identity reaction because of repairing");
    if (r.getReactants().length != r.getProducts().length) {
        return false;
    }
    Set<String> reactants = new HashSet<>();
    Set<String> products = new HashSet<>();
    for (BNGSpecies reactant : r.getReactants()) {
        String rStr = reactant.getName();
        reactants.add(rStr);
    }
    for (BNGSpecies product : r.getProducts()) {
        String pStr = product.getName();
        products.add(pStr);
    }
    // extract products from reactants
    reactants.removeAll(products);
    if (reactants.size() == 0) {
        // it's identity reaction
        return true;
    }
    return false;
}
Also used : HashSet(java.util.HashSet) BNGSpecies(cbit.vcell.bionetgen.BNGSpecies)

Aggregations

BNGSpecies (cbit.vcell.bionetgen.BNGSpecies)11 ArrayList (java.util.ArrayList)6 LinkedHashMap (java.util.LinkedHashMap)5 Structure (cbit.vcell.model.Structure)4 HashMap (java.util.HashMap)4 BNGComplexSpecies (cbit.vcell.bionetgen.BNGComplexSpecies)3 ObservableGroup (cbit.vcell.bionetgen.ObservableGroup)3 RbmObservable (cbit.vcell.model.RbmObservable)3 HashSet (java.util.HashSet)3 Map (java.util.Map)3 FakeSeedSpeciesInitialConditionsParameter (org.vcell.model.rbm.FakeSeedSpeciesInitialConditionsParameter)3 BNGMultiStateSpecies (cbit.vcell.bionetgen.BNGMultiStateSpecies)2 BNGOutputSpec (cbit.vcell.bionetgen.BNGOutputSpec)2 BNGReaction (cbit.vcell.bionetgen.BNGReaction)2 ReactionRule (cbit.vcell.model.ReactionRule)2 SpeciesContext (cbit.vcell.model.SpeciesContext)2 TreeSet (java.util.TreeSet)2 BNGParameter (cbit.vcell.bionetgen.BNGParameter)1 BNGSpeciesComponent (cbit.vcell.bionetgen.BNGSpeciesComponent)1 LocalParameter (cbit.vcell.mapping.ParameterContext.LocalParameter)1