Esempio n. 1
0
        // 将系统发生树展开。
        public static PhylogeneticTreeUnwind UnwindFrom(PhylogeneticTree tree)
        {
            PhylogeneticTreeUnwind unwind = new PhylogeneticTreeUnwind();

            _RecursiveFillAtoms(tree.Root, unwind._Evo.Atoms, unwind._Ref.Atoms);

            return(unwind);
        }
        // 重建系统发生树。
        public void RebuildTo(PhylogeneticTree tree)
        {
            // 先按照层次升序排序,用于确保总是先创建父类群
            // 再按照索引升序排序,用于确保每个类群的次序与原先相同
            var evoAtoms = from atom in _Evo.Atoms
                           where atom is not null
                           orderby atom.Level ascending,
                atom.Index ascending
            select atom;

            foreach (var evoAtom in evoAtoms)
            {
                evoAtom.ToTaxon().SetParent(_GetTaxonOfTree(tree, evoAtom.ParentsIndex));
            }
        }
Esempio n. 3
0
        private static Taxon _GetTaxonOfTree(PhylogeneticTree tree, IReadOnlyList <int> indexList)
        {
            if (tree is null || indexList is null)
            {
                throw new ArgumentNullException();
            }

            //

            Taxon taxon = tree.Root;

            foreach (var id in indexList)
            {
                taxon = taxon.Children[id];
            }

            return(taxon);
        }
Esempio n. 4
0
        // 重建系统发生树。
        public void RebuildTo(PhylogeneticTree tree)
        {
            // 先按照层次升序排序,用于确保总是先创建父类群
            // 再按照索引升序排序,用于确保每个类群的次序与原先相同
            var evoAtoms = from atom in _Evo.Atoms
                           where atom is not null
                           orderby atom.Level ascending,
                atom.Index ascending
            select atom;

            // 重建单系群关系
            foreach (var evoAtom in evoAtoms)
            {
                evoAtom.ToTaxon().SetParent(_GetTaxonOfTree(tree, evoAtom.ParentsIndex));
            }

            // 重建并系群、复系群关系
            foreach (var refAtom in _Ref.Atoms)
            {
                Common.IdStringToIndexList(refAtom.ID, out List <int> indexList);

                Taxon taxon = _GetTaxonOfTree(tree, indexList);

                foreach (var exclude in refAtom.Excludes)
                {
                    Common.IdStringToIndexList(exclude, out List <int> refIndexList);

                    taxon.AddExclude(_GetTaxonOfTree(tree, refIndexList));
                }

                foreach (var include in refAtom.Includes)
                {
                    Common.IdStringToIndexList(include, out List <int> refIndexList);

                    taxon.AddInclude(_GetTaxonOfTree(tree, refIndexList));
                }
            }
        }