示例#1
0
 public void Combine(ArrayList shareWindowList, ArrayList combinedShareWindowList)   //combine a sharewindow with next window(id+1)
 {
     foreach (ShareWindow shareWindowItem in shareWindowList)
     {
         if (shareWindowItem.windowStart.id == this.windowLast.id + 1)
         {
             //Console.Write("{0}\t{1}\t{2}\r\n", shareWindowItem.windowStart.id,this.group.Count,shareWindowItem.group.Count);
             //Console.ReadKey();
             ArrayList newGroup = new ArrayList();
             foreach (int individualA in this.group)  //find the share individuals between two groups
             {
                 foreach (int individualB in shareWindowItem.group)
                 {
                     if (individualA == individualB)
                     {
                         newGroup.Add(individualA);
                     }
                 }
             }
             if (newGroup.Count >= 5)   //gourp size should be >=3 for combined window
             {
                 ShareWindow newShareWindow = new ShareWindow();
                 newShareWindow.group       = newGroup;
                 newShareWindow.windowStart = this.windowStart;
                 newShareWindow.windowLast  = shareWindowItem.windowLast;
                 newShareWindow.Combine(shareWindowList, combinedShareWindowList);
                 if ((this.group.Count - newGroup.Count > 1) && (newShareWindow.windowLast.id - newShareWindow.windowStart.id) > 3)
                 {
                     combinedShareWindowList.Add(newShareWindow);
                     Console.Write("{0}\t{1}\t{2}\r\n", newShareWindow.group.Count, newShareWindow.windowStart.id, newShareWindow.windowLast.id);
                 }
             }
             else
             {
                 if (this.windowLast.id - this.windowStart.id > 0)
                 {
                     combinedShareWindowList.Add(this);
                 }
             }
         }
         else if (shareWindowItem.windowStart.id - this.windowLast.id > 3)
         {
             break;
         }
     }
 }
示例#2
0
        public void inWindowExtend(ArrayList group, int snpPosition, SnpDataSet dataSet, ArrayList shareWindowListRef)
        {
            if (snpPosition == this.end)                        //when it reached the end of the window
            {
                ShareWindow newShareWindow = new ShareWindow(); //construct a shareWindow object
                newShareWindow.windowStart = this;
                newShareWindow.windowLast  = this;
                newShareWindow.group       = group;
                group.Sort();
                shareWindowListRef.Add(newShareWindow);  // Add newShareWindow to shareWindow List;
                return;
            }

            ArrayList group0 = new ArrayList();         //store the individuals that the data of this snp is 0
            ArrayList group1 = new ArrayList();         //store the individuals that the data of this snp is 1
            ArrayList group2 = new ArrayList();         //store the individuals that the data of this snp is 2

            foreach (int individual in group)
            {
                if (dataSet.GetSnp(individual, snpPosition) == 0) // the data is 0
                {
                    group0.Add(individual);
                }
                else if (dataSet.GetSnp(individual, snpPosition) == 1) //the data is 1
                {
                    group1.Add(individual);
                }
                else                                      //the data is 2
                {
                    group2.Add(individual);
                }
            }

            if (group2.Count + group1.Count >= 3)           // construct a new group if group2+group1>=3
            {
                ArrayList group12 = new ArrayList();
                foreach (int ind in group2)                 //add group2 and group1 into group21
                {
                    group12.Add(ind);
                }
                foreach (int ind in group1)
                {
                    group12.Add(ind);
                }
                //group12.ToArray();
                inWindowExtend(group12, snpPosition + 1, dataSet, shareWindowListRef);     //use group21 to do the next Extend
            }

            if (group0.Count + group1.Count >= 3)            // construct a new group if group0+group1>=3, similar to last.
            {
                ArrayList group01 = new ArrayList();
                foreach (int ind in group0)
                {
                    group01.Add(ind);
                }
                foreach (int ind in group1)
                {
                    group01.Add(ind);
                }
                //group01.ToArray();
                inWindowExtend(group01, snpPosition + 1, dataSet, shareWindowListRef);  //do the next Extend
            }
        }