getNumProducts() public method

public getNumProducts ( ) : long
return long
示例#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>
 ///     Creates a multicompartment reaction.
 /// </summary>
 private void CreateMulticompartmentReaction(Reaction sbmlReaction, Model model)
 {
     if ((sbmlReaction.getNumReactants() + sbmlReaction.getNumProducts() == 2) && (IsPassiveTransport(sbmlReaction, model)))
     {
         CreatePassiveTransport(sbmlReaction, model);
     }
     else
     {
         CreateGhostReaction(sbmlReaction, model);
     }
 }
示例#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);
         }
     }
 }
 public void test_Reaction_addProduct1()
 {
     Reaction m = new  Reaction(2,2);
       SpeciesReference p = new  SpeciesReference(2,2);
       SpeciesReference p1 = new  SpeciesReference(2,2);
       p1.setSpecies( "k");
       p1.setId( "k1");
       int i = m.addProduct(p);
       assertTrue( i == libsbml.LIBSBML_INVALID_OBJECT );
       p.setSpecies( "k");
       p.setId( "k1");
       i = m.addProduct(p);
       assertTrue( i == libsbml.LIBSBML_OPERATION_SUCCESS );
       assertTrue( m.getNumProducts() == 1 );
       i = m.addProduct(p1);
       assertTrue( i == libsbml.LIBSBML_DUPLICATE_OBJECT_ID );
       assertTrue( m.getNumProducts() == 1 );
       p = null;
       p1 = null;
       m = null;
 }
示例#5
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_Reaction_addProduct3()
 {
     Reaction m = new  Reaction(2,2);
       SpeciesReference p = new  SpeciesReference(1,2);
       p.setSpecies( "k");
       int i = m.addProduct(p);
       assertTrue( i == libsbml.LIBSBML_LEVEL_MISMATCH );
       assertTrue( m.getNumProducts() == 0 );
       p = null;
       m = null;
 }
 public void test_Reaction_createProduct()
 {
     Reaction m = new  Reaction(2,2);
       SpeciesReference p = m.createProduct();
       assertTrue( m.getNumProducts() == 1 );
       assertTrue( (p).getLevel() == 2 );
       assertTrue( (p).getVersion() == 2 );
       m = null;
 }
 public void test_Reaction_addProduct4()
 {
     Reaction m = new  Reaction(2,2);
       SpeciesReference p = null;
       int i = m.addProduct(p);
       assertTrue( i == libsbml.LIBSBML_OPERATION_FAILED );
       assertTrue( m.getNumProducts() == 0 );
       m = null;
 }