Ejemplo n.º 1
0
                public bool Compare(Phrase compare, out int exactMatch, out int partialMatch)
                {
                    bool result = false;

                    CCount matchCount = new CCount();

                    char[] outer = this.CharValue();
                    char[] inner = compare.CharValue();

                    // this outer
                    for (int i = 0; i < PhraseSize; i++)
                    {
                        // compare inner
                        for (int j = 0; j < PhraseSize; j++)
                        {
                            //exact match
                            if (outer[i] == inner[j] && i == j)
                            {
                                switch (outer[i])
                                {
                                case 'G':
                                    matchCount.G++;
                                    break;

                                case 'A':
                                    matchCount.A++;
                                    break;

                                case 'T':
                                    matchCount.T++;
                                    break;

                                case 'C':
                                    matchCount.C++;
                                    break;
                                }
                            }
                        }
                    }

                    exactMatch = matchCount.G + matchCount.A + matchCount.T + matchCount.C;

                    // (if actual > 0 ? ((if guess >= actual ? actual : guess) - matchcount) : 0) + ...
                    partialMatch = (this.Count.G > 0 ? (compare.Count.G >= this.Count.G ? this.Count.G : compare.Count.G) - matchCount.G : 0) +
                                   (this.Count.A > 0 ? (compare.Count.A >= this.Count.A ? this.Count.A : compare.Count.A) - matchCount.A : 0) +
                                   (this.Count.T > 0 ? (compare.Count.T >= this.Count.G ? this.Count.T : compare.Count.T) - matchCount.T : 0) +
                                   (this.Count.C > 0 ? (compare.Count.C >= this.Count.C ? this.Count.C : compare.Count.C) - matchCount.C : 0);

                    if (exactMatch == PhraseSize)
                    {
                        result = true;
                    }

                    return(result);
                }
Ejemplo n.º 2
0
                public bool Compare(Phrase compare, out int exactMatch, out int partialMatch)
                {
                    bool result = false;

                    CCount matchCount = new CCount();

                    char[] outer = this.CharValue();
                    char[] inner = compare.CharValue();

                    // this outer
                    for (int i = 0; i < PhraseSize; i++)
                    {
                        // compare inner
                        for (int j = 0; j < PhraseSize; j++)
                        {
                            //exact match
                            if (outer[i] == inner[j] && i == j)
                            {
                                switch (outer[i])
                                {
                                    case 'G':
                                        matchCount.G++;
                                        break;
                                    case 'A':
                                        matchCount.A++;
                                        break;
                                    case 'T':
                                        matchCount.T++;
                                        break;
                                    case 'C':
                                        matchCount.C++;
                                        break;
                                }
                            }
                        }
                    }

                    exactMatch = matchCount.G + matchCount.A + matchCount.T + matchCount.C;

                    // (if actual > 0 ? ((if guess >= actual ? actual : guess) - matchcount) : 0) + ...
                    partialMatch = (this.Count.G > 0 ? (compare.Count.G >= this.Count.G ? this.Count.G : compare.Count.G) - matchCount.G : 0) +
                        (this.Count.A > 0 ? (compare.Count.A >= this.Count.A ? this.Count.A : compare.Count.A) - matchCount.A : 0) +
                        (this.Count.T > 0 ? (compare.Count.T >= this.Count.G ? this.Count.T : compare.Count.T) - matchCount.T : 0) +
                        (this.Count.C > 0 ? (compare.Count.C >= this.Count.C ? this.Count.C : compare.Count.C) - matchCount.C : 0);

                    if (exactMatch == PhraseSize)
                    {
                        result = true;
                    }

                    return result;
                }