/// <summary>
 ///  Find if positions occur simultaneously of read in contig,
 ///  if contig is traced from left direction.
 /// </summary>
 /// <param name="map">Map from previous position of read.</param>
 /// <param name="readPosition">Position of read.</param>
 /// <param name="contigPosition">Position of contig.</param>
 /// <param name="length">Length of kmer.</param>
 /// <returns>True if continuous position of reads in contig.</returns>
 private static bool IsContinousLeft(
     ReadMap map,
     long readPosition,
     long contigPosition,
     int length)
 {
     return((map.Length - length + map.StartPositionOfRead + 1) == readPosition &&
            (map.StartPositionOfContig - 1) == contigPosition);
 }
示例#2
0
        /// <summary>
        /// Merge continuous positions of a read in kmer indexes.
        /// </summary>
        /// <param name="kmer">Position of contig kmer.</param>
        /// <param name="readMaps">Alignment between read and contig.</param>
        /// <param name="position">Position of kmer in read.</param>
        /// <param name="kmerLength">Length of kmer.</param>
        /// <param name="readLength">Length of the read.</param>
        private static void FindContinuous(
            KmerIndexer kmer,
            IList <ReadMap> readMaps,
            long position,
            int kmerLength,
            long readLength)
        {
            // Create new object ReadInformation as read is encountered first time.
            if (readMaps.Count == 0)
            {
                foreach (int pos in kmer.Positions)
                {
                    ReadMap readMap = new ReadMap();
                    readMap.StartPositionOfContig = pos;
                    readMap.StartPositionOfRead   = position;
                    readMap.Length = kmerLength;
                    SetReadContigOverlap(readLength, readMap);
                    readMaps.Add(readMap);
                }
            }
            else
            {
                // Merge current kmer node with previous kmer node of DeBruijn Graph,
                // if they are continuous in either right or left traversal of graph.
                bool isMerged = false;
                foreach (int pos in kmer.Positions)
                {
                    foreach (ReadMap read in readMaps)
                    {
                        if (IsContinousRight(read, position, pos, kmerLength) ||
                            IsContinousLeft(read, position, pos, kmerLength))
                        {
                            read.Length++;
                            if (read.StartPositionOfContig > pos)
                            {
                                read.StartPositionOfContig = pos;
                            }

                            SetReadContigOverlap(readLength, read);
                            isMerged = true;
                            break;
                        }
                    }

                    // If not continuous a new object ReadMap is created to store new overlap.
                    if (isMerged == false)
                    {
                        ReadMap readmap = new ReadMap();
                        readmap.StartPositionOfContig = pos;
                        readmap.StartPositionOfRead   = position;
                        readmap.Length = kmerLength;
                        SetReadContigOverlap(readLength, readmap);
                        readMaps.Add(readmap);
                    }
                }
            }
        }
 /// <summary>
 /// Determines whether read is full or partial overlap between read and contig.
 /// Overlap of read and contig
 /// FullOverlap
 /// ------------- Contig
 ///    ------     Read
 /// PartialOverlap
 /// -------------       Contig
 ///            ------   Read.
 /// </summary>
 /// <param name="length">Length of read.</param>
 /// <param name="read">Map of read to contig.</param>
 private static void SetReadContigOverlap(long length, ReadMap read)
 {
     if (length == read.Length)
     {
         read.ReadOverlap = ContigReadOverlapType.FullOverlap;
     }
     else
     {
         read.ReadOverlap = ContigReadOverlapType.PartialOverlap;
     }
 }
示例#4
0
 /// <summary>
 ///  Find if positions occur simultaneously of read in contig, 
 ///  if contig is traced from left direction.
 /// </summary>
 /// <param name="map">Map from previous position of read.</param>
 /// <param name="readPosition">Position of read.</param>
 /// <param name="contigPosition">Position of contig.</param>
 /// <param name="length">Length of kmer.</param>
 /// <returns>True if continuous position of reads in contig.</returns>
 private static bool IsContinousLeft(
     ReadMap map,
     int readPosition,
     int contigPosition,
     int length)
 {
     return (map.Length - length + map.StartPositionOfContig + 1) == contigPosition &&
         (map.StartPositionOfRead - 1) == readPosition;
 }
示例#5
0
        /// <summary>
        /// Merge continuous positions of a read in kmer indexes.
        /// </summary>
        /// <param name="kmer">Position of contig kmer.</param>
        /// <param name="readMaps">Alignment between read and contig.</param>
        /// <param name="position">Position of kmer in read.</param>
        /// <param name="kmerLength">Length of kmer.</param>
        private static void FindContinuous(
            KmerIndexer kmer,
            IList<ReadMap> readMaps,
            int position,
            int kmerLength)
        {
            // Create new object ReadInformation as read is encountered first time.
            if (readMaps.Count == 0)
            {
                foreach (int pos in kmer.Positions)
                {
                    ReadMap readMap = new ReadMap();
                    readMap.StartPositionOfContig = position;
                    readMap.StartPositionOfRead = pos;
                    readMap.Length = kmerLength;
                    readMaps.Add(readMap);
                }
            }
            else
            {
                // Merge current kmer node with previous kmer node of DeBruijn Graph, 
                // if they are continuous in either right or left traversal of graph.
                bool isMerged = false;
                foreach (int pos in kmer.Positions)
                {
                    foreach (ReadMap read in readMaps)
                    {
                        if (IsContinousRight(read, pos, position, kmerLength) ||
                            IsContinousLeft(read, pos, position, kmerLength))
                        {
                            read.Length++;
                            if (read.StartPositionOfRead > pos)
                            {
                                read.StartPositionOfRead = pos;
                            }

                            isMerged = true;
                            break;
                        }
                    }

                    // If not continuous a new object ReadMap is created to store new overlap.
                    if (isMerged == false)
                    {
                        ReadMap readmap = new ReadMap();
                        readmap.StartPositionOfContig = position;
                        readmap.StartPositionOfRead = pos;
                        readmap.Length = kmerLength;
                        readMaps.Add(readmap);
                    }
                }
            }
        }
示例#6
0
 /// <summary>
 /// Determines whether read is full or partial overlap between read and contig.
 /// Overlap of read and contig
 /// FullOverlap
 /// ------------- Contig
 ///    ------     Read
 /// PartialOverlap
 /// -------------       Contig
 ///            ------   Read.
 /// </summary>
 /// <param name="length">Length of read.</param>
 /// <param name="read">Map of read to contig.</param>
 private static void SetReadContigOverlap(long length, ReadMap read)
 {
     if (length == read.Length)
     {
         read.ReadOverlap = ContigReadOverlapType.FullOverlap;
     }
     else
     {
         read.ReadOverlap = ContigReadOverlapType.PartialOverlap;
     }
 }
示例#7
0
 /// <summary>
 ///  Find if positions occur simultaneously of read in contig, 
 ///  if contig is traced from right direction.
 /// </summary>
 /// <param name="map">Map from previous position of read.</param>
 /// <param name="readPosition">Position of read.</param>
 /// <param name="contigPosition">Position of contig.</param>
 /// <param name="length">Length of kmer.</param>
 /// <returns>True if continuous position of reads in contig.</returns>
 private static bool IsContinousRight(
     ReadMap map,
     long readPosition,
     long contigPosition,
     int length)
 {
     return (map.Length - length + map.StartPositionOfContig + 1) == contigPosition &&
             (map.StartPositionOfRead + map.Length - length + 1) == readPosition;
 }