Ejemplo n.º 1
0
        internal TmpPartitionNew Add(int a, IList <double> masses, string aas)
        {
            TmpPartitionNew result = new TmpPartitionNew {
                remainder = remainder - a, partition = new List <int>()
            };

            result.partition.AddRange(partition);
            result.mass = mass;
            if (result.partition.Count < 20)
            {
                result.mass += a * masses[aas[result.partition.Count]];
            }
            result.partition.Add(a);
            return(result);
        }
Ejemplo n.º 2
0
 private static void Partition(TmpPartitionNew x, int len, double maxMass, IList <double> masses, string aas,
                               ISet <string> result)
 {
     if (x.remainder == 0 && x.partition.Count == len)
     {
         IList <int> part = x.partition;
         double      m1   = Molecule.massWater;
         for (int i = 0; i < part.Count; i++)
         {
             if (i < 20)
             {
                 m1 += part[i] * masses[aas[i]];
             }
         }
         if (m1 <= maxMass)
         {
             string   seq     = GetSequence(part, aas);
             Molecule m       = GetPeptideMolecule(seq);
             string   formula = m.GetEmpiricalFormula();
             if (!result.Contains(formula))
             {
                 result.Add(formula);
             }
         }
         return;
     }
     if (x.partition.Count == len)
     {
         return;
     }
     for (int i = 0; i <= x.remainder; i++)
     {
         TmpPartitionNew w = x.Add(i, masses, aas);
         if (w.mass > maxMass)
         {
             break;
         }
         Partition(w, len, maxMass, masses, aas, result);
     }
 }