Esempio n. 1
0
        /// <summary>
        /// Combine cluster nextA and nextB into a new cluster
        /// </summary>
        private void CreateCluster()
        {
            BinaryGuideTreeNode _node = new BinaryGuideTreeNode(++_currentClusterID);

            // link the two nodes nextA and nextB with the new node
            _node.LeftChildren   = Nodes[_nextA];
            _node.RightChildren  = Nodes[_nextB];
            Nodes[_nextA].Parent = _node;
            Nodes[_nextB].Parent = _node;

            // use the leftmost leave's sequenceID
            _node.SequenceID = Nodes[_nextA].SequenceID;

            Nodes.Add(_node);

            BinaryGuideTreeEdge _edge1 = new BinaryGuideTreeEdge(Nodes[_nextA].ID);
            BinaryGuideTreeEdge _edge2 = new BinaryGuideTreeEdge(Nodes[_nextB].ID);

            _edge1.ParentNode = _node;
            _edge2.ParentNode = _node;
            _edge1.ChildNode  = Nodes[_nextA];
            _edge2.ChildNode  = Nodes[_nextB];

            // the length of the edge is the percent identity of two node sequences
            // or the average of identities between two sets of sequences
            //_edge1.Length = KimuraDistanceScoreCalculator.calculateDistanceScore(
            //    seqs[nodes[next1].sequenceID], seqs[nodes[next2].sequenceID]);

            // modified: define kimura distance as sequence distance
            _edge1.Length = _smallestDistance;
            _edge2.Length = _smallestDistance;

            _edges.Add(_edge1);
            _edges.Add(_edge2);
        }
Esempio n. 2
0
        /// <summary>
        /// Combine cluster nextA and nextB into a new cluster
        /// </summary>
        /// <param name="distanceMatrix">distance matrix</param>
        private void CreateCluster(IDistanceMatrix distanceMatrix)
        {
            BinaryGuideTreeNode node = new BinaryGuideTreeNode(++_currentClusterID);

            // link the two nodes nextA and nextB with the new node
            node.LeftChildren    = Nodes[_nextA];
            node.RightChildren   = Nodes[_nextB];
            Nodes[_nextA].Parent = node;
            Nodes[_nextB].Parent = node;

            // use the leftmost leave's sequenceID
            int next = Math.Min(_nextA, _nextB);

            node.SequenceID = Nodes[next].SequenceID;
            _indexToCluster[node.SequenceID] = _currentClusterID;

            Nodes.Add(node);

            // Add edges
            BinaryGuideTreeEdge edgeA = new BinaryGuideTreeEdge(Nodes[_nextA].ID);
            BinaryGuideTreeEdge edgeB = new BinaryGuideTreeEdge(Nodes[_nextB].ID);

            edgeA.ParentNode = node;
            edgeB.ParentNode = node;
            edgeA.ChildNode  = Nodes[_nextA];
            edgeB.ChildNode  = Nodes[_nextB];

            Nodes[_nextA].ParentEdge = edgeA;
            Nodes[_nextB].ParentEdge = edgeB;

            // the length of the edge is the percent identity of two node sequences
            // or the average of identities between two sets of sequences
            //_edge1.Length = KimuraDistanceScoreCalculator.calculateDistanceScore(
            //    seqs[nodes[nextA].sequenceID], seqs[nodes[nextB].sequenceID]);

            // modified: define kimura distance as sequence distance
            edgeA.Length = _smallestDistance;
            edgeB.Length = _smallestDistance;

            _edges.Add(edgeA);
            _edges.Add(edgeB);
        }