示例#1
0
        /// <summary>
        /// Checks if 'node' can be added to 'path' without causing a loop.
        /// If yes, adds node to path and returns true. If not, returns false.
        /// </summary>
        /// <param name="contigPath">List of graph nodes corresponding to contig path.</param>
        /// <param name="contigSequence">Sequence of contig being assembled.</param>
        /// <param name="nextNode">Next node on the path to be added.</param>
        /// <param name="isForwardDirection">Boolean indicating direction.</param>
        /// <param name="isSameOrientation">Boolean indicating orientation.</param>
        /// <param name="createContigSequences">Boolean indicating whether contig sequences are to be created or not.</param>
        /// <returns>Boolean indicating if path was updated successfully.</returns>
        private bool CheckAndAddNode(
            List <DeBruijnNode> contigPath,
            List <byte> contigSequence,
            DeBruijnNode nextNode,
            bool isForwardDirection,
            bool isSameOrientation,
            bool createContigSequences)
        {
            // Since ambiguous extensions have been removed, the only way a link could be in the list
            // is if the first item in the list points to this item

            if (contigPath.Count > 0 && contigPath.Contains(nextNode)) //contigPath[0]==nextNode)
            {
                // there is a loop in this link
                // Return false indicating no update has been made
                return(false);
            }

            // Add node to contig list
            contigPath.Add(nextNode);

            if (createContigSequences)
            {
                // Update contig sequence with sequence from next node
                byte symbol = _graph.GetNextSymbolFrom(nextNode, isForwardDirection, isSameOrientation);

                if (isForwardDirection)
                {
                    contigSequence.Add(symbol);
                }
                else
                {
                    contigSequence.Insert(0, symbol);
                }
            }

            return(true);
        }