コード例 #1
0
ファイル: CChemEq.cpp プロジェクト: mgaldzic/copasi_api
void CChemEq::addElement(CCopasiVector < CChemEqElement > & structure,
                         const CChemEqElement & element,
                         CChemEq::MetaboliteRole role)
{
  unsigned C_INT32 i;

  std::string key = element.getMetaboliteKey();

  if (key == "")
    return; // don�t add empty element

  for (i = 0; i < structure.size(); i++)
    if (key == structure[i]->getMetaboliteKey())
      break;

  if (i >= structure.size())
    {
      CChemEqElement * Element = new CChemEqElement(element);

      if (role == CChemEq::SUBSTRATE)
        Element->setMultiplicity(- Element->getMultiplicity());

      structure.add(Element, true);
    }
  else if (role == CChemEq::SUBSTRATE)
    structure[i]->addToMultiplicity(- element.getMultiplicity());
  else
    structure[i]->addToMultiplicity(element.getMultiplicity());
}
コード例 #2
0
ファイル: abiochem.cpp プロジェクト: Koliham/COPASI
// calculates the clustering coefficient of gene g
C_FLOAT64 cluster(CCopasiVector < CGene > &gene, C_INT32 g)
{
  C_INT32 i, j, k, m, n, edges;
  CCopasiVector <CGene> neighbors;
  CGene *ptG;
  // create the neighborhood
  n = gene[g]->getModifierNumber();
  if (n <= 1)
    return 0.0;
  for (i = 0; i < n; i++)
    neighbors.add(gene[g]->getModifier(i));
  // count the number of links within the neighborhood
  for (edges = i = 0; i < n; i++)
    {// one neighbor at a time
      m = neighbors[i]->getModifierNumber();
      for (j = 0; j < m; j++)
        {// one modifier at a time
          ptG = neighbors[i]->getModifier(j);
          // increment if this modifier is in the neighborhood
          // but it is not itself
          if (ptG != neighbors[i])
            for (k = 0; k < n; k++)
              if (ptG == neighbors[k])
                edges++;
        }
    }
  return (C_FLOAT64) edges / (C_FLOAT64) (n*(n - 1));
}