예제 #1
0
        public TrinucCalculation Calc()
        {
            TrinucCalculation tri         = new TrinucCalculation();
            TrinucArray       trinucArray = new TrinucArray();
            string            seqTrinuc   = string.Empty;
            int trinucIndex = 0;
            int firstFrame  = 0;
            int secondFrame = 0;
            int thirdFrame  = 0;

            string seqCalc = seq + seq.Substring(0, 6);

            for (int i = 0; i < seq.Length; i += 3)
            {
                seqTrinuc   = seqCalc.Substring(i, 3);
                trinucIndex = Array.FindIndex(trinucArray.trinuc, item => item == seqTrinuc);
                tri.trinucleotides[trinucIndex].Trinuc1st += 1;
                firstFrame += 1;
            }

            for (int i = 1; i < seq.Length + 1; i += 3)
            {
                seqTrinuc   = seqCalc.Substring(i, 3);
                trinucIndex = Array.FindIndex(trinucArray.trinuc, item => item == seqTrinuc);
                tri.trinucleotides[trinucIndex].Trinuc2nd += 1;
                secondFrame += 1;
            }

            for (int i = 2; i < seq.Length + 2; i += 3)
            {
                seqTrinuc   = seqCalc.Substring(i, 3);
                trinucIndex = Array.FindIndex(trinucArray.trinuc, item => item == seqTrinuc);
                tri.trinucleotides[trinucIndex].Trinuc3rd += 1;
                thirdFrame += 1;
            }

            foreach (var item in tri.trinucleotides)
            {
                item.TrinucFrq1st = (double)item.Trinuc1st / (double)firstFrame;
                item.TrinucFrq2nd = (double)item.Trinuc2nd / (double)secondFrame;
                item.TrinucFrq3rd = (double)item.Trinuc3rd / (double)thirdFrame;
            }

            foreach (var item in tri.trinucleotides)
            {
                item.TrinucDiff1st2nd = Math.Abs(item.TrinucFrq1st - item.TrinucFrq2nd);
                item.TrinucDiff2nd3rd = Math.Abs(item.TrinucFrq2nd - item.TrinucFrq3rd);
                item.TrinucDiff1st3rd = Math.Abs(item.TrinucFrq1st - item.TrinucFrq3rd);
            }

            foreach (var item in tri.trinucleotides)
            {
                item.TrinucDiffSum = item.TrinucDiff1st2nd + item.TrinucDiff2nd3rd + item.TrinucDiff1st3rd;
            }

            //TrinucOutput trinucOutput = new TrinucOutput(seq, trinucleotide);
            //trinucOutput.TrinucOut();
            return(tri);
        }
예제 #2
0
 public TrinucCalc()
 {
     trinucArray        = new TrinucArray();
     trinucleotideMatch = new List <TrinucleotideMatch>();
 }