예제 #1
0
        /// <summary>
        /// Gets the Delta for list of query sequences.
        /// </summary>
        /// <param name="referenceSequence">The reference sequence.</param>
        /// <param name="originalQuerySequences">The query sequence.</param>
        /// <returns>Returns list of IEnumerable Delta Alignment.</returns>
        private IEnumerable <IEnumerable <DeltaAlignment> > GetDelta(IEnumerable <ISequence> referenceSequence, IEnumerable <ISequence> originalQuerySequences)
        {
            IEnumerable <ISequence> querySequences =
                Forward ? originalQuerySequences
                : (Reverse
                    ? ReverseComplementSequenceList(originalQuerySequences)
                    : AddReverseComplementsToSequenceList(originalQuerySequences));

            foreach (ISequence refSeq in referenceSequence)
            {
                NUCmer nucmer = new NUCmer(refSeq)
                {
                    FixedSeparation   = FixedSeparation,
                    BreakLength       = BreakLength,
                    LengthOfMUM       = MinMatch,
                    MaximumSeparation = MaxGap,
                    MinimumScore      = MinCluster,
                    SeparationFactor  = (float)DiagFactor
                };

                foreach (ISequence qs in querySequences)
                {
                    _queryCount++;
                    yield return(nucmer.GetDeltaAlignments(qs, !MaxMatch, qs.IsMarkedAsReverseComplement()));
                }
            }
        }
예제 #2
0
        public void ValidateNUCmerGetClusters()
        {
            // Gets the reference sequence from the FastA file
            string filePath = utilityObj.xmlUtil.GetTextValue(Constants.MediumSizeSequenceNodeName,
                                                              Constants.FilePathNode);

            // Gets the query sequence from the FastA file
            string queryFilePath = utilityObj.xmlUtil.GetTextValue(Constants.MediumSizeSequenceNodeName,
                                                                   Constants.SearchSequenceFilePathNode);

            using (FastAParser parser1 = new FastAParser(filePath))
            {
                using (FastAParser parser2 = new FastAParser(queryFilePath))
                {
                    IEnumerable <ISequence> seqs1 = parser1.Parse();
                    IEnumerable <ISequence> seqs2 = parser2.Parse();
                    NUCmer nuc = new NUCmer((Sequence)seqs1.ElementAt(0));
                    nuc.LengthOfMUM  = 5;
                    nuc.MinimumScore = 0;
                    nuc.BreakLength  = 0;
                    IList <Cluster> clusts = nuc.GetClusters(seqs2.ElementAt(0), true);

                    string clustCount1 = utilityObj.xmlUtil.GetTextValue(Constants.MediumSizeSequenceNodeName,
                                                                         Constants.ClustCount1Node);

                    Assert.AreEqual(clustCount1, clusts.Count.ToString((IFormatProvider)null));
                }
            }
        }
예제 #3
0
        /// <summary>
        /// Gets the Delta for list of query sequences.
        /// </summary>
        /// <param name="referenceSequence">The reference sequence.</param>
        /// <param name="querySequence">The query sequence.</param>
        /// <returns>Returns list of IEnumerable Delta Alignment.</returns>
        private IList<List<IEnumerable<DeltaAlignment>>> GetDelta(IEnumerable<ISequence> referenceSequence, IEnumerable<ISequence> querySequence)
        {
            IList<List<IEnumerable<DeltaAlignment>>> delta;
            if (this.MaxMatch)
            {
                delta = referenceSequence.AsParallel().Select(sequence =>
                {
                    NUCmer nucmer = new NUCmer();
                    nucmer.BreakLength = BreakLength;
                    nucmer.LengthOfMUM = MinMatch;
                    nucmer.MaximumSeparation = MaxGap;
                    nucmer.MinimumScore = MinCluster;
                    nucmer.SeparationFactor = (float)DiagFactor;
                    return nucmer.GetDeltaAlignments(new List<ISequence> { sequence }, GetSequence(querySequence), false);
                }).ToList();
            }
            else
            {
                delta = referenceSequence.AsParallel().Select(sequence =>
                {
                    NUCmer nucmer = new NUCmer();
                    nucmer.BreakLength = BreakLength;
                    nucmer.LengthOfMUM = MinMatch;
                    nucmer.MaximumSeparation = MaxGap;
                    nucmer.MinimumScore = MinCluster;
                    nucmer.SeparationFactor = (float)DiagFactor;
                    return nucmer.GetDeltaAlignments(new List<ISequence> { sequence }, GetSequence(querySequence));
                }).ToList();
            }

            return delta;
        }
예제 #4
0
        /// <summary>
        /// Returns the cluster.
        /// </summary>
        /// <param name="referenceSequence">The Reference sequences.</param>
        /// <param name="originalQuerySequences">The Query sequences.</param>
        /// <returns>Returns list of clusters.</returns>
        private IList <List <IList <Cluster> > > GetCluster(IEnumerable <ISequence> referenceSequence, IEnumerable <ISequence> originalQuerySequences)
        {
            var clusters  = new List <List <IList <Cluster> > >();
            var clusters1 = new List <IList <Cluster> >();

            IEnumerable <ISequence> querySequences =
                Forward ? originalQuerySequences
                        : (Reverse
                            ? ReverseComplementSequenceList(originalQuerySequences)
                            : AddReverseComplementsToSequenceList(originalQuerySequences));

            _queryCount += querySequences.Count();

            foreach (var sequence in referenceSequence)
            {
                NUCmer nucmer = new NUCmer(sequence)
                {
                    FixedSeparation   = FixedSeparation,
                    BreakLength       = BreakLength,
                    LengthOfMUM       = MinMatch,
                    MaximumSeparation = MaxGap,
                    MinimumScore      = MinCluster,
                    SeparationFactor  = (float)DiagFactor
                };

                clusters1.AddRange(querySequences.Select(qs => nucmer.GetClusters(qs, !MaxMatch, qs.IsMarkedAsReverseComplement())));
            }

            clusters.Add(clusters1);

            return(clusters);
        }
예제 #5
0
        /// <summary>
        /// Aligns reads to reference genome using NUCmer.
        /// </summary>
        /// <param name="referenceSequence">Sequence of reference genome.</param>
        /// <param name="reads">List of sequence reads.</param>
        /// <returns>Delta alignments after read alignment.</returns>
        private IList <IEnumerable <DeltaAlignment> > ReadAlignment(IEnumerable <ISequence> referenceSequence, IEnumerable <ISequence> reads)
        {
            IList <List <IEnumerable <DeltaAlignment> > > delta;
            List <IEnumerable <DeltaAlignment> >          deltaAlignments = new List <IEnumerable <DeltaAlignment> >();

            delta = referenceSequence.AsParallel().Select(sequence =>
            {
                NUCmer nucmer = new NUCmer();

                // TODO: Update these hardcoded values with the onces used in AMOSS while validating functionality with real data.
                nucmer.FixedSeparation   = 0;
                nucmer.MinimumScore      = 1;
                nucmer.SeparationFactor  = 0;
                nucmer.MaximumSeparation = 0;
                nucmer.BreakLength       = BreakLength;
                nucmer.LengthOfMUM       = LengthOfMum;
                return(nucmer.GetDeltaAlignments(new List <ISequence> {
                    sequence
                }, reads, false));
            }).ToList();

            foreach (var alignment in delta)
            {
                foreach (var align in alignment)
                {
                    deltaAlignments.Add(align);
                }
            }
            return(deltaAlignments);
        }
예제 #6
0
 public NucMerQueryable(Sequence touse)
 {
     ReferenceSequence = touse;
     nucmer            = new NUCmer(ReferenceSequence)
     {
         FixedSeparation   = FixedSeparation,
         BreakLength       = BreakLength,
         LengthOfMUM       = MinMatch,
         MaximumSeparation = MaxGap,
         MinimumScore      = 22,
         SeparationFactor  = (float)DiagFactor
     };
 }
예제 #7
0
        /// <summary>
        /// Returns the cluster.
        /// </summary>
        /// <param name="referenceSequence">The Reference sequence.</param>
        /// <param name="querySequence">The Query sequence.</param>
        /// <returns>Returns list of clusters.</returns>
        private IList <List <IList <Cluster> > > GetCluster(IEnumerable <ISequence> referenceSequence, IEnumerable <ISequence> querySequence)
        {
            IList <List <IList <Cluster> > > clusters  = new List <List <IList <Cluster> > >();
            List <IList <Cluster> >          clusters1 = new List <IList <Cluster> >();

            if (this.MaxMatch)
            {
                Parallel.ForEach(referenceSequence, sequence =>
                {
                    NUCmer nucmer            = new NUCmer((Sequence)sequence);
                    nucmer.FixedSeparation   = FixedSeparation;
                    nucmer.BreakLength       = BreakLength;
                    nucmer.LengthOfMUM       = MinMatch;
                    nucmer.MaximumSeparation = MaxGap;
                    nucmer.MinimumScore      = MinCluster;
                    nucmer.SeparationFactor  = (float)DiagFactor;

                    foreach (ISequence qrySequence in querySequence)
                    {
                        clusters1.Add(nucmer.GetClusters(qrySequence, false));
                    }
                });

                clusters.Add(clusters1);
            }
            else
            {
                Parallel.ForEach(referenceSequence, sequence =>
                {
                    NUCmer nucmer            = new NUCmer((Sequence)sequence);
                    nucmer.FixedSeparation   = FixedSeparation;
                    nucmer.BreakLength       = BreakLength;
                    nucmer.LengthOfMUM       = MinMatch;
                    nucmer.MaximumSeparation = MaxGap;
                    nucmer.MinimumScore      = MinCluster;
                    nucmer.SeparationFactor  = (float)DiagFactor;

                    foreach (ISequence qrySequence in querySequence)
                    {
                        clusters1.Add(nucmer.GetClusters(qrySequence));
                    }
                });

                clusters.Add(clusters1);
            }

            return(clusters);
        }
예제 #8
0
        /// <summary>
        /// Gets the Delta for list of query sequences.
        /// </summary>
        /// <param name="referenceSequence">The reference sequence.</param>
        /// <param name="querySequence">The query sequence.</param>
        /// <returns>Returns list of IEnumerable Delta Alignment.</returns>
        private IEnumerable <IEnumerable <DeltaAlignment> > GetDelta(IEnumerable <ISequence> referenceSequence, IEnumerable <ISequence> querySequence)
        {
            if (this.MaxMatch)
            {
                foreach (ISequence refSeq in referenceSequence)
                {
                    NUCmer nucmer = new NUCmer((Sequence)refSeq);
                    nucmer.FixedSeparation   = FixedSeparation;
                    nucmer.BreakLength       = BreakLength;
                    nucmer.LengthOfMUM       = MinMatch;
                    nucmer.MaximumSeparation = MaxGap;
                    nucmer.MinimumScore      = MinCluster;
                    nucmer.SeparationFactor  = (float)DiagFactor;

                    foreach (ISequence qrySequence in querySequence)
                    {
                        queryCount++;
                        yield return(nucmer.GetDeltaAlignments(qrySequence, false));
                    }
                }
            }
            else
            {
                foreach (ISequence refSeq in referenceSequence)
                {
                    NUCmer nucmer = new NUCmer((Sequence)refSeq);
                    nucmer.FixedSeparation   = FixedSeparation;
                    nucmer.BreakLength       = BreakLength;
                    nucmer.LengthOfMUM       = MinMatch;
                    nucmer.MaximumSeparation = MaxGap;
                    nucmer.MinimumScore      = MinCluster;
                    nucmer.SeparationFactor  = (float)DiagFactor;

                    foreach (ISequence qrySequence in querySequence)
                    {
                        queryCount++;
                        yield return(nucmer.GetDeltaAlignments(qrySequence));
                    }
                }
            }
        }
예제 #9
0
        /// <summary>
        /// Aligns reads to reference genome using NUCmer.
        /// </summary>
        /// <param name="referenceSequence">Sequence of reference genome.</param>
        /// <param name="reads">List of sequence reads.</param>
        /// <returns>Delta alignments after read alignment.</returns>
        private IEnumerable <DeltaAlignment> ReadAlignment(IEnumerable <ISequence> referenceSequence, IEnumerable <ISequence> reads)
        {
            foreach (ISequence sequence in referenceSequence)
            {
                NUCmer nucmer = new NUCmer((Sequence)sequence);

                nucmer.FixedSeparation   = this.FixedSeparation;
                nucmer.MinimumScore      = this.MinimumScore;
                nucmer.SeparationFactor  = this.SeparationFactor;
                nucmer.MaximumSeparation = this.MaximumSeparation;
                nucmer.BreakLength       = this.BreakLength;
                nucmer.LengthOfMUM       = this.LengthOfMum;

                foreach (ISequence qrySequence in reads)
                {
                    foreach (DeltaAlignment delta in nucmer.GetDeltaAlignments(qrySequence, false))
                    {
                        yield return(delta);
                    }
                }
            }
        }