예제 #1
0
 public MotifOp(MotifCode code, TElement codon, int lower, int upper)
 {
     Code  = code;
     Value = codon;
     Lower = lower;
     Upper = upper;
 }
예제 #2
0
        private void ParseFragment(string str, List <MotifOp <TElement> > code)
        {
            int length = str.Length;

            for (int i = 0; i < length; ++i)
            {
                int      val     = 0;
                TElement element = default(TElement);
                char     chr     = str[i];
                if (OPEN_GROUP.Contains(chr))
                {
                    char        open  = chr;
                    List <char> chars = new List <char>();
                    ++i;
                    chr = str[i];
                    do
                    {
                        chars.Add(chr);
                        val += CHARSET(chr);
                        ++i;
                        chr = str[i];
                    } while (!CLOSE_GROUP.Contains(chr));

                    MotifCode temp = MotifCode.NIL;
                    element = (TElement)Enum.ToObject(typeof(TElement), val);

                    temp |= chars.Count == 1 ? MotifCode.One : MotifCode.Set;
                    if (chr == ']')
                    {
                        temp |= MotifCode.Not;
                    }

                    if (TryGetRange(str.Substring(i + 1), out int lower, out int upper))
                    {
                        MinimumSequenceLength += lower;
                        temp |= MotifCode.Loop;
                        var op = new MotifOp <TElement>(temp, element, lower, upper);
                        code.Add(op);
                        AddDelegate(code.Count - 1, op);
                        i = str.IndexOf(')', i + 3);
                    }
                    else
                    {
                        ++MinimumSequenceLength;
                        code.Add(new MotifOp <TElement>(temp, element, -1, -1));
                    }
                }