Esempio n. 1
0
 public float GetScore(Nucleotide[] nucs)
 {
     if (nucs.Length != Length)
         throw new ArgumentException("nucs.Len != " + Length);
     if (_cache == null)
         _cache = new ProbMotifCache(_data);
     var norm = _cache.NormFactor;
     var max = 0.0;
     foreach (var ds in _cache.DataInversions)
     {
         var cur = 1.0;
         for (int i = 0; i < Length; i++)
         {
             var nicId = (int)nucs[i];
             var d = ds[i];
             if (nicId < 4)
                 cur *= d[nicId];
             else
                 if (nicId == (int) Nucleotide.Any)
                 cur *= 0.1;
             else
                 throw new NotSupportedException();
         }
         if (cur > max)
             max = cur;
     }
     return (float)(max*norm);
 }
Esempio n. 2
0
 /// <summary>
 /// Добавление прецедента в мотив.
 /// </summary>
 public void AddItem(Nucleotide[] nucs, int factor = 1)
 {
     if(nucs == null || nucs.Length != Length)
         throw new ArgumentException("nucs");
     for (int i = 0; i < nucs.Length; i++)
     {
         var nucId = (int) nucs[i];
         if (nucId < 4)
         {
             var d = _data[i];
             d[nucId] += factor;
             d[4] += factor;
         }
         else
             if (nucId == (int) Nucleotide.Any)
             _data[i][4] += factor;
         else
             throw new NotSupportedException();
     }
     _cache = null;
 }