/// <summary> /// Saves educts of a SBML reaction into a dictionary, containing their compartment and SpeciesReference. /// </summary> private Dictionary <string, List <SpeciesReference> > ComputeEducts(Reaction sbmlReaction, Model model) { var eductCompartmentMoleculeDictionary = new Dictionary <string, List <SpeciesReference> >(); for (long i = 0; i < sbmlReaction.getNumReactants(); i++) { var reactant = sbmlReaction.getReactant(i); var reactantSpecies = GetSpeciesById(reactant.getSpecies(), model); var compartment = reactantSpecies.getCompartment(); if (_sbmlInformation.MoleculeInformation.All(info => info.SpeciesIds.TrueForAll(s => s != reactantSpecies.getId()))) { continue; } if (!eductCompartmentMoleculeDictionary.ContainsKey(compartment)) { eductCompartmentMoleculeDictionary[compartment] = new List <SpeciesReference> { reactant } } ; else { eductCompartmentMoleculeDictionary[compartment].Add(reactant); } } return(eductCompartmentMoleculeDictionary); }
/// <summary> /// A passive Transport is created when two Species with the same name are reacting with /// each other. /// </summary> private bool IsPassiveTransport(Reaction sbmlReaction, Model model) { var educt = sbmlReaction.getReactant(0).getSpecies(); var product = sbmlReaction.getProduct(0).getSpecies(); var eductSpecies = GetSpeciesById(educt, model); var productSpecies = GetSpeciesById(product, model); if (eductSpecies.getName() != productSpecies.getName()) { return(false); } var molinfoEduct = _sbmlInformation.MoleculeInformation.FirstOrDefault(info => info.SpeciesIds.Any(s => s == educt)); var molinfoProduct = _sbmlInformation.MoleculeInformation.FirstOrDefault(info => info.SpeciesIds.Any(s => s == product)); if (molinfoEduct == null) { return(false); } if (molinfoProduct == null) { return(false); } var reactantMolecule = molinfoEduct.GetMoleculeBuilder(); var productMolecule = molinfoProduct.GetMoleculeBuilder(); return(reactantMolecule == productMolecule); }
/// <summary> /// Creates the Educts of the MoBi reaction. /// </summary> private void CreateEducts(Reaction sbmlReaction, IReactionBuilder reactionBuilder, Model model) { for (long i = 0; i < sbmlReaction.getNumReactants(); i++) { var educt = CreateReactionPartner(sbmlReaction.getReactant(i), model); if (educt != null) { reactionBuilder.AddEduct(educt); } } }
/// <summary> /// Checks if all reaction partners are in the same compartment. /// </summary> private bool IsMultiCompartmentReaction(Reaction sbmlReaction, Model model) { var compartment = String.Empty; for (long i = 0; i < sbmlReaction.getNumReactants(); i++) { var x = sbmlReaction.getReactant(i).getSpecies(); var species = GetSpeciesById(x, model); if (compartment == String.Empty) { compartment = species.getCompartment(); } else { if (compartment != species.getCompartment()) { return(true); } } } for (long i = 0; i < sbmlReaction.getNumProducts(); i++) { var x = sbmlReaction.getProduct(i).getSpecies(); var species = GetSpeciesById(x, model); if (compartment == String.Empty) { compartment = species.getCompartment(); } else { if (compartment != species.getCompartment()) { return(true); } } } return(false); }
public void test_SpeciesReference_Reactant_parent_create() { Reaction r = new Reaction(2,4); SpeciesReference sr = r.createReactant(); ListOf lo = r.getListOfReactants(); assertTrue( lo == r.getReactant(0).getParentSBMLObject() ); assertTrue( lo == sr.getParentSBMLObject() ); assertTrue( r == lo.getParentSBMLObject() ); }
public void test_SpeciesReference_Reactant_parent_add() { SpeciesReference sr = new SpeciesReference(2,4); Reaction r = new Reaction(2,4); sr.setSpecies("s"); r.addReactant(sr); sr = null; ListOf lo = r.getListOfReactants(); assertTrue( lo == r.getReactant(0).getParentSBMLObject() ); assertTrue( r == lo.getParentSBMLObject() ); }
/// <summary> /// Imports a SBML Reaction by creating a passive Transport. /// </summary> private void CreatePassiveTransport(Reaction sbmlReaction, Model model) { var reactant = sbmlReaction.getReactant(0).getSpecies(); var product = sbmlReaction.getProduct(0).getSpecies(); var reactantSpecies = GetSpeciesById(reactant, model); var productSpecies = GetSpeciesById(product, model); if (_sbmlInformation.MoleculeInformation.All(info => info.SpeciesIds.TrueForAll(s => s != reactant))) { return; } if (_sbmlInformation.MoleculeInformation.All(info => info.SpeciesIds.TrueForAll(s => s != product))) { return; } var molInfoReactant = _sbmlInformation.MoleculeInformation.FirstOrDefault(info => info.SpeciesIds.Contains(reactant)); var molInfoProduct = _sbmlInformation.MoleculeInformation.FirstOrDefault(info => info.SpeciesIds.Contains(product)); if (molInfoProduct == null) { return; } if (molInfoReactant == null) { return; } //must be the same Molecule if (molInfoReactant.GetMoleculeBuilder() != molInfoProduct.GetMoleculeBuilder()) { CreateErrorMessage(); } var passiveTransport = ObjectBaseFactory.Create <ITransportBuilder>().WithName(sbmlReaction.getId()); passiveTransport.ForAll = false; if (molInfoReactant.GetMoleculeBuilderName() == null) { return; } passiveTransport.MoleculeList.AddMoleculeName(molInfoReactant.GetMoleculeBuilderName()); var reactantCompartment = GetContainerFromCompartment_(molInfoReactant.GetCompartment(reactantSpecies)); var productCompartment = GetContainerFromCompartment_(molInfoProduct.GetCompartment(productSpecies)); if (reactantCompartment != null && productCompartment != null) { var reactantMatchTag = new MatchTagCondition(reactantCompartment.Name); var productMatchTag = new MatchTagCondition(productCompartment.Name); passiveTransport.SourceCriteria.Add(reactantMatchTag); passiveTransport.TargetCriteria.Add(productMatchTag); } var parameters = CreateLocalParameters(sbmlReaction); if (parameters != null) { parameters.ForEach(passiveTransport.AddParameter); } CreateKinetic(sbmlReaction, passiveTransport); AddNeighbourhood(reactantCompartment, productCompartment, model); _passiveTransportBuildingBlock.Add(passiveTransport); }
public void test_SpeciesReference_Reactant_ancestor_create() { Reaction r = new Reaction(2,4); SpeciesReference sr = r.createReactant(); ListOf lo = r.getListOfReactants(); assertTrue( sr.getAncestorOfType(libsbml.SBML_REACTION) == r ); assertTrue( sr.getAncestorOfType(libsbml.SBML_LIST_OF) == lo ); assertTrue( sr.getAncestorOfType(libsbml.SBML_DOCUMENT) == null ); assertTrue( sr.getAncestorOfType(libsbml.SBML_COMPARTMENT) == null ); SpeciesReference obj = r.getReactant(0); assertTrue( obj.getAncestorOfType(libsbml.SBML_REACTION) == r ); assertTrue( obj.getAncestorOfType(libsbml.SBML_LIST_OF) == lo ); assertTrue( obj.getAncestorOfType(libsbml.SBML_DOCUMENT) == null ); assertTrue( obj.getAncestorOfType(libsbml.SBML_COMPARTMENT) == null ); }
public void test_SpeciesReference_Reactant_ancestor_add() { SpeciesReference sr = new SpeciesReference(2,4); Reaction r = new Reaction(2,4); sr.setSpecies("s"); r.addReactant(sr); sr = null; ListOf lo = r.getListOfReactants(); SpeciesReference obj = r.getReactant(0); assertTrue( obj.getAncestorOfType(libsbml.SBML_REACTION) == r ); assertTrue( obj.getAncestorOfType(libsbml.SBML_LIST_OF) == lo ); assertTrue( obj.getAncestorOfType(libsbml.SBML_DOCUMENT) == null ); assertTrue( obj.getAncestorOfType(libsbml.SBML_COMPARTMENT) == null ); }