Пример #1
0
        /// <summary>
        /// get the clusters
        /// </summary>
        /// <param name="matchExtensionList">List of Matches of a read.</param>
        /// <param name="sortedMatches">Flag to indicate that the matches are sorted or not.</param>
        /// <returns>List of clusters</returns>
        public IList <Cluster> GetClusters(List <MatchExtension> matchExtensionList, bool sortedMatches)
        {
            ClusterBuilder clusterBuilder = new ClusterBuilder();

            if (-1 < FixedSeparation)
            {
                clusterBuilder.FixedSeparation = FixedSeparation;
            }

            if (-1 < MaximumSeparation)
            {
                clusterBuilder.MaximumSeparation = MaximumSeparation;
            }

            if (-1 < MinimumScore)
            {
                clusterBuilder.MinimumScore = MinimumScore;
            }

            if (-1 < SeparationFactor)
            {
                clusterBuilder.SeparationFactor = SeparationFactor;
            }

            clusterBuilder.ScoreMethod = ScoreMethod;

            return(clusterBuilder.BuildClusters(matchExtensionList, sortedMatches));
        }
Пример #2
0
        /// <summary>
        /// get the clusters
        /// </summary>
        /// <param name="mumList">List of maximum unique matches</param>
        /// <returns>List of clusters</returns>
        protected override IList <Cluster> GetClusters(
            IList <MaxUniqueMatch> mumList)
        {
            IClusterBuilder clusterBuilder = new ClusterBuilder();

            if (-1 < FixedSeparation)
            {
                clusterBuilder.FixedSeparation = FixedSeparation;
            }

            if (-1 < MaximumSeparation)
            {
                clusterBuilder.MaximumSeparation = MaximumSeparation;
            }

            if (-1 < MinimumScore)
            {
                clusterBuilder.MinimumScore = MinimumScore;
            }

            if (-1 < SeparationFactor)
            {
                clusterBuilder.SeparationFactor = SeparationFactor;
            }

            return(clusterBuilder.BuildClusters(mumList));
        }
Пример #3
0
        /// <summary>
        /// get the clusters
        /// </summary>
        /// <param name="mumList">List of maximum unique matches</param>
        /// <returns>List of clusters</returns>
        private IList <Cluster> GetClusters(
            IList <MatchExtension> mumList)
        {
            IClusterBuilder clusterBuilder = new ClusterBuilder();

            if (-1 < FixedSeparation)
            {
                clusterBuilder.FixedSeparation = FixedSeparation;
            }

            if (-1 < MaximumSeparation)
            {
                clusterBuilder.MaximumSeparation = MaximumSeparation;
            }

            if (-1 < MinimumScore)
            {
                clusterBuilder.MinimumScore = MinimumScore;
            }

            if (-1 < SeparationFactor)
            {
                clusterBuilder.SeparationFactor = SeparationFactor;
            }

            return(clusterBuilder.BuildClusters(mumList));
        }
Пример #4
0
        /// <summary>
        /// get the clusters
        /// </summary>
        /// <param name="matchExtensionList">List of Matches of a read.</param>
        /// <param name="sortedMatches">Flag to indicate that the matches are sorted or not.</param>
        /// <returns>List of clusters</returns>
        public IList<Cluster> GetClusters(List<MatchExtension> matchExtensionList, bool sortedMatches)
        {
            ClusterBuilder clusterBuilder = new ClusterBuilder();

            if (-1 < FixedSeparation)
            {
                clusterBuilder.FixedSeparation = FixedSeparation;
            }

            if (-1 < MaximumSeparation)
            {
                clusterBuilder.MaximumSeparation = MaximumSeparation;
            }

            if (-1 < MinimumScore)
            {
                clusterBuilder.MinimumScore = MinimumScore;
            }

            if (-1 < SeparationFactor)
            {
                clusterBuilder.SeparationFactor = SeparationFactor;
            }

            clusterBuilder.ScoreMethod = ScoreMethod;

            return clusterBuilder.BuildClusters(matchExtensionList, sortedMatches);
        }
Пример #5
0
        /// <summary>
        ///     Validates the Cluster Builder Matches for the input provided.
        /// </summary>
        /// <param name="matches">Max Unique Match list</param>
        /// <param name="nodeName">Node name to be read from xml</param>
        /// <param name="propParam">Property parameters</param>
        /// <returns>True, if successfully validated</returns>
        private bool ValidateClusterBuilderMatches(IEnumerable<Match> matches, string nodeName, PropertyParameters propParam)
        {
            // Validates the Cluster builder MUMs
            string firstSeqOrderExpected = this.utilityObj.xmlUtil.GetTextValue(nodeName, Constants.ClustFirstSequenceMumOrderNode);
            string lengthExpected = this.utilityObj.xmlUtil.GetTextValue(nodeName, Constants.ClustLengthNode);
            string secondSeqOrderExpected = this.utilityObj.xmlUtil.GetTextValue(nodeName, Constants.ClustSecondSequenceMumOrderNode);

            var firstSeqOrderActual = new StringBuilder();
            var lengthActual = new StringBuilder();
            var secondSeqOrderActual = new StringBuilder();

            var cbObj = new ClusterBuilder {MinimumScore = 0};
            switch (propParam)
            {
                case PropertyParameters.MinimumScore:
                    cbObj.MinimumScore = int.Parse(this.utilityObj.xmlUtil.GetTextValue(nodeName, Constants.MinimumScoreNode), null);
                    break;
                case PropertyParameters.MaximumSeparation:
                    cbObj.MaximumSeparation = int.Parse(this.utilityObj.xmlUtil.GetTextValue(nodeName, Constants.MaximumSeparationNode), null);
                    break;
                case PropertyParameters.FixedSeparation:
                    cbObj.FixedSeparation = int.Parse(this.utilityObj.xmlUtil.GetTextValue(nodeName, Constants.FixedSeparationNode), null);
                    break;
                case PropertyParameters.SeparationFactor:
                    cbObj.SeparationFactor = int.Parse(this.utilityObj.xmlUtil.GetTextValue(nodeName, Constants.SeparationFactorNode), null);
                    break;
                case PropertyParameters.FixedSeparationAndSeparationFactor:
                    cbObj.SeparationFactor = int.Parse(this.utilityObj.xmlUtil.GetTextValue(nodeName, Constants.SeparationFactorNode), null);
                    cbObj.FixedSeparation = int.Parse(this.utilityObj.xmlUtil.GetTextValue(nodeName, Constants.FixedSeparationNode), null);
                    break;
                case PropertyParameters.MaximumFixedAndSeparationFactor:
                    cbObj.MaximumSeparation = int.Parse(this.utilityObj.xmlUtil.GetTextValue(nodeName, Constants.MaximumSeparationNode), null);
                    cbObj.SeparationFactor = int.Parse(this.utilityObj.xmlUtil.GetTextValue(nodeName, Constants.SeparationFactorNode), null);
                    cbObj.FixedSeparation = int.Parse(this.utilityObj.xmlUtil.GetTextValue(nodeName, Constants.FixedSeparationNode), null);
                    break;
                default:
                    break;
            }

            var meObj = matches.Select(m => new MatchExtension(m)).ToList();

            IEnumerable<Cluster> clusts = cbObj.BuildClusters(meObj);

            foreach (MatchExtension maxMatchExtension in clusts.SelectMany(clust => clust.Matches))
            {
                firstSeqOrderActual.Append(maxMatchExtension.ReferenceSequenceOffset);
                secondSeqOrderActual.Append(maxMatchExtension.QuerySequenceOffset);
                lengthActual.Append(maxMatchExtension.Length);
            }

            if ((0 != string.Compare(firstSeqOrderExpected.Replace(",", ""), firstSeqOrderActual.ToString(), true, CultureInfo.CurrentCulture))
             || (0 != string.Compare(lengthExpected.Replace(",", ""), lengthActual.ToString(), true, CultureInfo.CurrentCulture))
             || (0 != string.Compare(secondSeqOrderExpected.Replace(",", ""), secondSeqOrderActual.ToString(), true, CultureInfo.CurrentCulture)))
            {
                ApplicationLog.WriteLine("NUCmer P1 : Cluster builder match not matching");
                return false;
            }

            return true;
        }
Пример #6
0
        /// <summary>
        /// Validates the Unique Matches for the input provided.
        /// </summary>
        /// <param name="matches">Max Unique Match list</param>
        /// <param name="nodeName">Node name to be read from xml</param>
        /// <param name="additionalParam">Unique Match/Sub level LIS/LIS</param>
        /// <param name="isFilePath">Nodes to be read from Text file?</param>
        /// <returns>True, if successfully validated</returns>
        bool ValidateUniqueMatches(IList<Match> matches,
            string nodeName, AdditionalParameters additionalParam, bool isFilePath)
        {
            switch (additionalParam)
            {
                case AdditionalParameters.PerformClusterBuilder:
                    // Validates the Cluster builder MUMs
                    string firstSeqOrderExpected =
                        this.utilityObj.xmlUtil.GetTextValue(nodeName, Constants.ClustFirstSequenceStartNode);
                    string lengthExpected =
                        this.utilityObj.xmlUtil.GetTextValue(nodeName, Constants.ClustLengthNode);
                    string secondSeqOrderExpected =
                        this.utilityObj.xmlUtil.GetTextValue(nodeName, Constants.ClustSecondSequenceStartNode);

                    StringBuilder firstSeqOrderActual = new StringBuilder();
                    StringBuilder lengthActual = new StringBuilder();
                    StringBuilder secondSeqOrderActual = new StringBuilder();

                    ClusterBuilder cb = new ClusterBuilder { MinimumScore = 0 };

                    List<MatchExtension> meObj = matches.Select(m => new MatchExtension(m)).ToList();

                    // Order the mum list with query sequence order and
                    // Assign query sequence to the MUM's
                    for (int index = 0; index < meObj.Count(); index++)
                    {
                        meObj.ElementAt(index).ReferenceSequenceMumOrder = index + 1;
                        meObj.ElementAt(index).QuerySequenceMumOrder = index + 1;
                    }

                    List<Cluster> clusts = cb.BuildClusters(meObj);

                    foreach (Cluster clust in clusts)
                    {
                        foreach (MatchExtension maxMatchExtension in clust.Matches)
                        {
                            firstSeqOrderActual.Append(maxMatchExtension.ReferenceSequenceMumOrder);
                            secondSeqOrderActual.Append(maxMatchExtension.QuerySequenceMumOrder);
                            lengthActual.Append(maxMatchExtension.Length);
                        }
                    }

                    if ((0 != string.Compare(firstSeqOrderExpected.Replace(",", ""),
                        firstSeqOrderActual.ToString(), true, CultureInfo.CurrentCulture))
                        || (0 != string.Compare(lengthExpected.Replace(",", ""),
                        lengthActual.ToString(), true, CultureInfo.CurrentCulture))
                        || (0 != string.Compare(secondSeqOrderExpected.Replace(",", ""),
                        secondSeqOrderActual.ToString(), true, CultureInfo.CurrentCulture)))
                    {
                        ApplicationLog.WriteLine("NUCmer BVT : Unique match not matching");
                        return false;
                    }
                    break;
                case AdditionalParameters.FindUniqueMatches:
                    // Gets all the unique matches properties to be validated as in xml.
                    string[] firstSeqOrder = null;
                    string[] length = null;
                    string[] secondSeqOrder = null;

                    if (isFilePath)
                    {
                        firstSeqOrder = this.utilityObj.xmlUtil.GetFileTextValue(nodeName,
                            Constants.FirstSequenceMumOrderNode).Split(',');
                        length = this.utilityObj.xmlUtil.GetFileTextValue(nodeName,
                            Constants.LengthNode).Split(',');
                        secondSeqOrder = this.utilityObj.xmlUtil.GetFileTextValue(nodeName,
                            Constants.SecondSequenceMumOrderNode).Split(',');
                    }
                    else
                    {
                        firstSeqOrder = this.utilityObj.xmlUtil.GetTextValue(nodeName,
                            Constants.FirstSequenceMumOrderNode).Split(',');
                        length = this.utilityObj.xmlUtil.GetTextValue(nodeName,
                            Constants.LengthNode).Split(',');
                        secondSeqOrder = this.utilityObj.xmlUtil.GetTextValue(nodeName,
                            Constants.SecondSequenceMumOrderNode).Split(',');
                    }

                    int i = 0;

                    IList<MatchExtension> meNewObj = matches.Select(m => new MatchExtension(m)).ToList();

                    // Order the mum list with query sequence order and
                    // Assign query sequence to the MUM's
                    for (int index = 0; index < meNewObj.Count(); index++)
                    {
                        meNewObj.ElementAt(index).ReferenceSequenceMumOrder = index + 1;
                        meNewObj.ElementAt(index).QuerySequenceMumOrder = index + 1;
                    }

                    // Loops through all the matches and validates the same.
                    foreach (MatchExtension match in meNewObj)
                    {
                        if ((0 != string.Compare(firstSeqOrder[i],
                            match.ReferenceSequenceMumOrder.ToString((IFormatProvider)null), true,
                            CultureInfo.CurrentCulture))
                            || (0 != string.Compare(length[i],
                            match.Length.ToString((IFormatProvider)null), true,
                            CultureInfo.CurrentCulture))
                            || (0 != string.Compare(secondSeqOrder[i],
                            match.QuerySequenceMumOrder.ToString((IFormatProvider)null), true,
                            CultureInfo.CurrentCulture)))
                        {
                            ApplicationLog.WriteLine(string.Format((IFormatProvider)null,
                                "NUCmer BVT : Unique match not matching at index '{0}'", i.ToString((IFormatProvider)null)));
                            return false;
                        }
                        i++;
                    }
                    break;
                default:
                    break;
            }
            return true;
        }