예제 #1
0
        public void generateDepthOneTreeRandomlyOld(List <Taxa> TaxaList, string DummyTaxaCharacter, int Level, List <string> _VALID_TAXA_LIST, List <Quartet> inputQuatrets)
        {
            string DummyTaxa = DummyTaxaCharacter + Level.ToString();
            Taxa   TaxaDummy = new Taxa();

            TaxaDummy._Taxa_Value = DummyTaxa;

            FinalPartionPair PartionPair = new FinalPartionPair();
            List <Taxa>      _LeftPartTaxaList;
            List <Taxa>      _RightPartTaxaList;

            if (CountValidTaxa(TaxaList, _VALID_TAXA_LIST) > 2)
            {
                _LeftPartTaxaList  = new List <Taxa>();
                _RightPartTaxaList = new List <Taxa>();


                int medianposition = TaxaList.Count / 2 - 1;

                for (int i = 0; i <= medianposition; i++)
                {
                    _LeftPartTaxaList.Add(TaxaList[i]);
                }

                for (int i = medianposition + 1; i < TaxaList.Count; i++)
                {
                    _RightPartTaxaList.Add(TaxaList[i]);
                }

                _LeftPartTaxaList.Add(TaxaDummy);
                _RightPartTaxaList.Add(TaxaDummy);

                generateDepthOneTreeRandomly(_LeftPartTaxaList, DummyTaxaCharacter, Level + 1, _VALID_TAXA_LIST, inputQuatrets);
                generateDepthOneTreeRandomly(_RightPartTaxaList, DummyTaxaCharacter, Level + 1, _VALID_TAXA_LIST, inputQuatrets);
            }

            else
            {
                PartionPair               = new FinalPartionPair();
                PartionPair._Root         = TaxaList;
                PartionPair._Q            = GetQuatretWithRandomDividedTaxa(TaxaList, inputQuatrets);
                PartionPair._InputQuatret = inputQuatrets;
                _ListFinalPartionPairRandom.Add(PartionPair);
            }
        }
예제 #2
0
        public void Divide(PartitionSet pPartitionSet, string DummyTaxaCharacter, int Level, List <string> _VALID_TAXA_LIST)
        {
            string DummyTaxa = DummyTaxaCharacter + Level.ToString();
            Taxa   TaxaDummy = new Taxa();

            TaxaDummy._Taxa_Value = DummyTaxa;


            //Adding Dummy Taxa to the Set PA and PB
            FinalPartionPair        PartionPair;
            List <FinalPartionPair> ListPartionPair = new List <FinalPartionPair>();

            foreach (Partition p in pPartitionSet.PartitionList)
            {
                PartionPair = new FinalPartionPair();
                p.TaxaList.Add(TaxaDummy);
                PartionPair       = SubDivideQuatret(pPartitionSet._ListQuatrets, p, DummyTaxa);
                PartionPair._Root = p.TaxaList;

                ListPartionPair.Add(PartionPair);
            }



            foreach (FinalPartionPair pair in ListPartionPair)
            {
                if (CountValidTaxa(pair._P.TaxaList, _VALID_TAXA_LIST) >= 1 && (pair._Q == null))
                {
                    _ListFinalPartionPair.Add(pair);
                }
                else if (CountValidTaxa(pair._P.TaxaList, _VALID_TAXA_LIST) >= 3 && (pair._Q != null))
                {
                    InputProcessing input  = new InputProcessing(pair._Q, pair._P.TaxaList);
                    Bipartition     bpA    = new Bipartition(input);
                    GainTable       GTable = bpA.getFinalGainTable();
                    Divide(GTable.PartitionSet, DummyTaxaCharacter, Level + 1, _VALID_TAXA_LIST);
                }
                else if (CountValidTaxa(pair._P.TaxaList, _VALID_TAXA_LIST) < 3 && (pair._Q != null))
                {
                    _ListFinalPartionPair.Add(pair);
                }
            }
        }
예제 #3
0
        public FinalPartionPair SubDivideQuatret(List <Quartet> inputQuatretList, Partition p, string DummyTaxa)
        {
            List <Quartet>   Q           = new List <Quartet>();
            List <Quartet>   QA          = new List <Quartet>();
            FinalPartionPair PartionPair = new FinalPartionPair();

            PartionPair._P = p;

            var vDiffered = inputQuatretList.FindAll(x => x._PartitionStatus == PartitionStatus.Differed);
            var vIsolated = inputQuatretList.FindAll(x => x._PartitionStatus == PartitionStatus.Isolated);

            if (vIsolated != null)
            {
                if (vIsolated.Count != 0)
                {
                    Q = vIsolated.ToList();
                }
            }

            if (vDiffered != null)
            {
                if (vDiffered.Count != 0)
                {
                    foreach (Quartet q in vDiffered.ToList())
                    {
                        Q.Add(q);
                    }
                }
            }

            if (Q.Count() != 0)
            {
                QA                        = GetQuatretWithDummy(p, Q, DummyTaxa);
                PartionPair._Q            = QA;
                PartionPair._InputQuatret = Q;
            }



            return(PartionPair);
        }
예제 #4
0
        public void generateDepthOneTreeRandomly(List <Taxa> TaxaList, string DummyTaxaCharacter, int Level, List <string> _VALID_TAXA_LIST, List <Quartet> inputQuatrets)
        {
            string DummyTaxa = DummyTaxaCharacter + Level.ToString();
            Taxa   TaxaDummy = new Taxa();

            TaxaDummy._Taxa_Value = DummyTaxa;

            FinalPartionPair PartionPair = new FinalPartionPair();
            List <Taxa>      _LeftPartTaxaList;
            List <Taxa>      _RightPartTaxaList;

            RandomTaxaListForCalculation = new List <Taxa>(TaxaList);
            RandomTaxaListForGeneration  = new List <Taxa>();
            if (CountValidTaxa(TaxaList, _VALID_TAXA_LIST) > 2)
            {
                _LeftPartTaxaList  = new List <Taxa>();
                _RightPartTaxaList = new List <Taxa>();

                //
                Random rnd    = new Random();
                int    count  = 0;
                int    isLeft = 0;

                for (int i = 0; i < TaxaList.Count; i++)
                {
                    getRandomTaxaFromListNew();
                }

                for (int i = 0; i < RandomTaxaListForGeneration.Count; i++)
                {
                    if (count == 0)
                    {
                        int r = rnd.Next(0, TaxaList.Count - 1);
                        if (r % 2 == 0)
                        {
                            _LeftPartTaxaList.Add(RandomTaxaListForGeneration[i]);
                            isLeft = 0;
                        }
                        else
                        {
                            _RightPartTaxaList.Add(RandomTaxaListForGeneration[i]);
                            isLeft = 1;
                        }
                        count++;
                    }
                    else
                    {
                        if (isLeft == 1)
                        {
                            _LeftPartTaxaList.Add(RandomTaxaListForGeneration[i]);
                            isLeft = 0;
                        }
                        else
                        {
                            _RightPartTaxaList.Add(RandomTaxaListForGeneration[i]);
                            isLeft = 1;
                        }
                    }
                }



                //RandomTaxaListForGeneration = new List<Taxa>();
                //RandomTaxaListForCalculation = new List<Taxa>();

                //


                _LeftPartTaxaList.Add(TaxaDummy);
                _RightPartTaxaList.Add(TaxaDummy);

                generateDepthOneTreeRandomly(_LeftPartTaxaList, DummyTaxaCharacter, Level + 1, _VALID_TAXA_LIST, inputQuatrets);
                generateDepthOneTreeRandomly(_RightPartTaxaList, DummyTaxaCharacter, Level + 1, _VALID_TAXA_LIST, inputQuatrets);
            }

            else
            {
                //RandomTaxaListForGeneration = new List<Taxa>();
                //RandomTaxaListForCalculation = new List<Taxa>();

                PartionPair               = new FinalPartionPair();
                PartionPair._Root         = TaxaList;
                PartionPair._Q            = GetQuatretWithRandomDividedTaxa(TaxaList, inputQuatrets);
                PartionPair._InputQuatret = inputQuatrets;
                _ListFinalPartionPairRandom.Add(PartionPair);
            }
        }
예제 #5
0
        public void generateDepthOneTreeRandomlyChanged(List <Taxa> TaxaList, string DummyTaxaCharacter, int Level, List <string> _VALID_TAXA_LIST, List <Quartet> inputQuatrets)
        {
            string DummyTaxa = DummyTaxaCharacter + Level.ToString();
            Taxa   TaxaDummy = new Taxa();

            TaxaDummy._Taxa_Value = DummyTaxa;

            FinalPartionPair PartionPair = new FinalPartionPair();
            List <Taxa>      _LeftPartTaxaList;
            List <Taxa>      _RightPartTaxaList;

            if (TaxaList.Count >= 4 && CountValidTaxa(TaxaList, _VALID_TAXA_LIST) > 0)
            {
                _LeftPartTaxaList  = new List <Taxa>();
                _RightPartTaxaList = new List <Taxa>();

                this.RandomTaxaListForGeneration = new List <Taxa>(TaxaList);

                int    randomValue = 0;
                Taxa   txRandom;
                Random rnd       = new Random();
                int    CountRand = 0;
                foreach (Taxa ttt in TaxaList)
                {
                    //randomValue = rnd.Next();
                    if (CountRand == 0)
                    {
                        randomValue = rnd.Next();
                    }
                    else
                    {
                        randomValue = CountRand;
                    }

                    if (randomValue % 2 == 0)
                    {
                        txRandom = getRandomTaxaFromList(this.RandomTaxaListForGeneration);
                        _LeftPartTaxaList.Add(txRandom);
                        this.RandomTaxaListForGeneration.Remove(txRandom);
                    }
                    else
                    {
                        txRandom = getRandomTaxaFromList(this.RandomTaxaListForGeneration);
                        _RightPartTaxaList.Add(txRandom);
                        this.RandomTaxaListForGeneration.Remove(txRandom);
                    }

                    randomValue++;
                    CountRand++;
                }

                this.RandomTaxaListForGeneration = new List <Taxa>();

                _LeftPartTaxaList.Add(TaxaDummy);
                generateDepthOneTreeRandomly(_LeftPartTaxaList, DummyTaxaCharacter, Level + 1, _VALID_TAXA_LIST, inputQuatrets);
                _RightPartTaxaList.Add(TaxaDummy);
                generateDepthOneTreeRandomly(_RightPartTaxaList, DummyTaxaCharacter, Level + 1, _VALID_TAXA_LIST, inputQuatrets);
            }

            else
            {
                PartionPair               = new FinalPartionPair();
                PartionPair._Root         = TaxaList;
                PartionPair._Q            = GetQuatretWithRandomDividedTaxa(TaxaList, inputQuatrets);
                PartionPair._InputQuatret = inputQuatrets;
                _ListFinalPartionPairRandom.Add(PartionPair);
            }
        }