getProduct() public method

public getProduct ( long n ) : SpeciesReference
n long
return SpeciesReference
示例#1
0
        /// <summary>
        ///     Saves products of a SBML reaction into a dictionary, containing their compartment and SpeciesReference.
        /// </summary>
        private Dictionary <string, List <SpeciesReference> > ComputeProducts(Reaction sbmlReaction, Model model)
        {
            var productCompartmentMoleculeDictionary = new Dictionary <string, List <SpeciesReference> >();

            for (long i = 0; i < sbmlReaction.getNumProducts(); i++)
            {
                var product        = sbmlReaction.getProduct(i);
                var productSpecies = GetSpeciesById(product.getSpecies(), model);
                var compartment    = productSpecies.getCompartment();
                if (_sbmlInformation.MoleculeInformation.All(info => info.SpeciesIds.TrueForAll(s => s != productSpecies.getId())))
                {
                    continue;
                }

                if (!productCompartmentMoleculeDictionary.ContainsKey(compartment))
                {
                    productCompartmentMoleculeDictionary[compartment] = new List <SpeciesReference> {
                        product
                    }
                }
                ;
                else
                {
                    productCompartmentMoleculeDictionary[compartment].Add(product);
                }
            }
            return(productCompartmentMoleculeDictionary);
        }
示例#2
0
        /// <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);
        }
示例#3
0
 /// <summary>
 ///     Creates the Products of the MoBi reaction.
 /// </summary>
 private void CreateProducts(Reaction sbmlReaction, IReactionBuilder reactionBuilder, Model model)
 {
     for (long i = 0; i < sbmlReaction.getNumProducts(); i++)
     {
         var product = CreateReactionPartner(sbmlReaction.getProduct(i), model);
         if (product != null)
         {
             reactionBuilder.AddProduct(product);
         }
     }
 }
示例#4
0
        /// <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_Product_parent_create()
 {
     Reaction r = new Reaction(2,4);
       SpeciesReference sr = r.createProduct();
       ListOf lo = r.getListOfProducts();
       assertTrue( lo == r.getProduct(0).getParentSBMLObject() );
       assertTrue( lo == sr.getParentSBMLObject() );
       assertTrue( r == lo.getParentSBMLObject() );
 }
 public void test_SpeciesReference_Product_parent_add()
 {
     SpeciesReference sr = new SpeciesReference(2,4);
       Reaction r = new Reaction(2,4);
       sr.setSpecies("p");
       r.addProduct(sr);
       sr = null;
       ListOf lo = r.getListOfProducts();
       assertTrue( lo == r.getProduct(0).getParentSBMLObject() );
       assertTrue( r == lo.getParentSBMLObject() );
 }
示例#7
0
        /// <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_Product_ancestor_create()
 {
     Reaction r = new Reaction(2,4);
       SpeciesReference sr = r.createProduct();
       ListOf lo = r.getListOfProducts();
       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.getProduct(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_Product_ancestor_add()
 {
     SpeciesReference sr = new SpeciesReference(2,4);
       Reaction r = new Reaction(2,4);
       sr.setSpecies("p");
       r.addProduct(sr);
       sr = null;
       ListOf lo = r.getListOfProducts();
       SpeciesReference obj = r.getProduct(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 );
 }