Beispiel #1
0
        /// <summary>
        /// Validate BED Operations(Merge,Intersect)..
        /// </summary>
        /// <param name="nodeName">Xml Node name for different inputs.</param>
        /// <param name="operationPam">Different Bed operations.</param>
        /// <param name="overlappingBasePair">overlapping base pair</param>
        /// <param name="IsParentSeqRangeRequired">Is Parent Sequence Range required?</param>
        static void ValidateBedOperations(string nodeName,
                                          BedOperationsParameters operationPam,
                                          bool overlappingBasePair, bool IsParentSeqRangeRequired)
        {
            // Get values from xml.
            string expectedRangeIDs = Utility._xmlUtil.GetTextValue(
                nodeName, Constants.IDNode);
            string expectedStartIndex = Utility._xmlUtil.GetTextValue(
                nodeName, Constants.StartNode);
            string expectedEndIndex = Utility._xmlUtil.GetTextValue(
                nodeName, Constants.EndNode);
            string referenceFilePath = Utility._xmlUtil.GetTextValue(
                nodeName, Constants.FilePathNode);
            string queryFilePath = Utility._xmlUtil.GetTextValue(
                nodeName, Constants.QueryFilePath);
            string minimalOverlap = Utility._xmlUtil.GetTextValue(
                nodeName, Constants.OverlapValue);
            string rangeID      = string.Empty;
            string actualStarts = string.Empty;
            string actualEnds   = string.Empty;
            string actualIDs    = string.Empty;
            bool   result       = false;

            List <ISequenceRange> rangeList       = null;
            SequenceRangeGrouping operationResult = null;

            // Parse a BED file.
            BedParser             parserObj      = new BedParser();
            SequenceRangeGrouping referenceGroup = parserObj.ParseRangeGrouping(referenceFilePath);
            SequenceRangeGrouping queryGroup     = parserObj.ParseRangeGrouping(queryFilePath);

            IntersectOutputType intersectOutputType = IntersectOutputType.OverlappingIntervals;

            if (overlappingBasePair)
            {
                intersectOutputType = IntersectOutputType.OverlappingPiecesOfIntervals;
            }

            SubtractOutputType subtractOutputType = SubtractOutputType.NonOverlappingPiecesOfIntervals;

            if (overlappingBasePair)
            {
                subtractOutputType = SubtractOutputType.IntervalsWithNoOverlap;
            }

            switch (operationPam)
            {
            case BedOperationsParameters.Merge:
                operationResult = referenceGroup.MergeOverlaps();
                break;

            case BedOperationsParameters.MergeWithPam:
                operationResult = referenceGroup.MergeOverlaps(queryGroup,
                                                               0, IsParentSeqRangeRequired);
                break;

            case BedOperationsParameters.Intersect:

                operationResult = referenceGroup.Intersect(queryGroup,
                                                           long.Parse(minimalOverlap), intersectOutputType, IsParentSeqRangeRequired);
                break;

            case BedOperationsParameters.MergeQueryWithReference:
                operationResult = queryGroup.MergeOverlaps(referenceGroup,
                                                           0, IsParentSeqRangeRequired);
                break;

            case BedOperationsParameters.Subtract:
                operationResult = referenceGroup.Subtract(queryGroup,
                                                          long.Parse(minimalOverlap), subtractOutputType, IsParentSeqRangeRequired);
                break;

            default:
                break;
            }

            // Get a result SequenceGroup Id.
            IEnumerable <string> groupId = operationResult.GroupIDs;

            foreach (string grpID in groupId)
            {
                rangeID = grpID;

                rangeList = operationResult.GetGroup(rangeID);

                // Validate result sequence range.
                foreach (ISequenceRange range in rangeList)
                {
                    actualStarts = string.Concat(actualStarts, range.Start.ToString(), ",");
                    actualEnds   = string.Concat(actualEnds, range.End.ToString(), ",");
                    actualIDs    = string.Concat(actualIDs, range.ID.ToString(), ",");
                }
            }

            Assert.AreEqual(expectedRangeIDs, actualIDs.Substring(0, actualIDs.Length - 1));
            Assert.AreEqual(expectedStartIndex, actualStarts.Substring(0, actualStarts.Length - 1));
            Assert.AreEqual(expectedEndIndex, actualEnds.Substring(0, actualEnds.Length - 1));

            // Validate ParentSeqRange.
            result = ValidateParentSeqRange(operationResult, referenceGroup,
                                            queryGroup, IsParentSeqRangeRequired);
            Assert.IsTrue(result);

            ApplicationLog.WriteLine(
                "Bed Parser BVT: Successfully validated the BED SequenceID, Start and End Ranges");
        }
        /// <summary>
        ///     Validate BED Operations(Merge,Intersect)..
        /// </summary>
        /// <param name="nodeName">Xml Node name for different inputs.</param>
        /// <param name="operationPam">Different Bed operations.</param>
        /// <param name="overlappingBasePair">overlapping base pair</param>
        /// <param name="isParentSeqRangeRequired">Is Parent Sequence Range required?</param>
        private void ValidateBedOperations(string nodeName,
                                           BedOperationsParameters operationPam,
                                           bool overlappingBasePair, bool isParentSeqRangeRequired)
        {
            // Get values from xml.
            string expectedRangeIDs   = this.utilityObj.xmlUtil.GetTextValue(nodeName, Constants.IDNode);
            string expectedStartIndex = this.utilityObj.xmlUtil.GetTextValue(nodeName, Constants.StartNode);
            string expectedEndIndex   = this.utilityObj.xmlUtil.GetTextValue(nodeName, Constants.EndNode);
            string referenceFilePath  = this.utilityObj.xmlUtil.GetTextValue(nodeName, Constants.FilePathNode).TestDir();
            string queryFilePath      = this.utilityObj.xmlUtil.GetTextValue(nodeName, Constants.QueryFilePath).TestDir();
            string minimalOverlap     = this.utilityObj.xmlUtil.GetTextValue(nodeName, Constants.OverlapValue);

            SequenceRangeGrouping operationResult = null;

            // Parse a BED file.
            var parserObj = new BedParser();
            SequenceRangeGrouping referenceGroup = parserObj.ParseRangeGrouping(referenceFilePath);
            SequenceRangeGrouping queryGroup     = parserObj.ParseRangeGrouping(queryFilePath);

            var intersectOutputType = IntersectOutputType.OverlappingIntervals;

            if (overlappingBasePair)
            {
                intersectOutputType = IntersectOutputType.OverlappingPiecesOfIntervals;
            }

            var subtractOutputType = SubtractOutputType.NonOverlappingPiecesOfIntervals;

            if (overlappingBasePair)
            {
                subtractOutputType = SubtractOutputType.IntervalsWithNoOverlap;
            }

            switch (operationPam)
            {
            case BedOperationsParameters.Merge:
                operationResult = referenceGroup.MergeOverlaps();
                break;

            case BedOperationsParameters.MergeWithPam:
                operationResult = referenceGroup.MergeOverlaps(queryGroup,
                                                               0, isParentSeqRangeRequired);
                break;

            case BedOperationsParameters.Intersect:

                operationResult = referenceGroup.Intersect(queryGroup,
                                                           long.Parse(minimalOverlap, null), intersectOutputType,
                                                           isParentSeqRangeRequired);
                break;

            case BedOperationsParameters.MergeQueryWithReference:
                operationResult = queryGroup.MergeOverlaps(referenceGroup,
                                                           0, isParentSeqRangeRequired);
                break;

            case BedOperationsParameters.Subtract:
                operationResult = referenceGroup.Subtract(queryGroup,
                                                          long.Parse(minimalOverlap, null), subtractOutputType,
                                                          isParentSeqRangeRequired);
                break;

            default:
                break;
            }

            // Get a result SequenceGroup Id.
            IEnumerable <string> groupId = operationResult.GroupIDs;

            string[] expectedRangeIdsArray   = expectedRangeIDs.Split(',');
            string[] expectedStartIndexArray = expectedStartIndex.Split(',');
            string[] expectedEndIndexArray   = expectedEndIndex.Split(',');
            int      i = 0;

            foreach (string grpId in groupId)
            {
                string rangeId = grpId;

                List <ISequenceRange> rangeList = operationResult.GetGroup(rangeId);

                // Validate result sequence range.
                foreach (ISequenceRange range in rangeList)
                {
                    Assert.AreEqual(expectedRangeIdsArray[i], range.ID);
                    Assert.AreEqual(expectedStartIndexArray[i], range.Start.ToString((IFormatProvider)null));
                    Assert.AreEqual(expectedEndIndexArray[i], range.End.ToString((IFormatProvider)null));
                    i++;
                }
            }

            // Validate ParentSeqRange.
            bool result = ValidateParentSeqRange(operationResult, referenceGroup, queryGroup, isParentSeqRangeRequired);

            Assert.IsTrue(result);

            ApplicationLog.WriteLine("Bed Operations BVT: Successfully validated the BED SequenceID, Start and End Ranges");
        }
        /// <summary>
        ///     Validate BED Operations(Merge,Intersect)..
        /// </summary>
        /// <param name="nodeName">Xml Node name for different inputs.</param>
        /// <param name="operationPam">Different Bed operations.</param>
        /// <param name="overlappingBasePair">overlapping base pair</param>
        /// <param name="isParentSeqRangeRequired">Is Parent Sequence Range required?</param>
        private void ValidateBedOperations(string nodeName,
                                           BedOperationsParameters operationPam,
                                           bool overlappingBasePair, bool isParentSeqRangeRequired)
        {
            // Get values from xml.
            string expectedRangeIDs = this.utilityObj.xmlUtil.GetTextValue(nodeName, Constants.IDNode);
            string expectedStartIndex = this.utilityObj.xmlUtil.GetTextValue(nodeName, Constants.StartNode);
            string expectedEndIndex = this.utilityObj.xmlUtil.GetTextValue(nodeName, Constants.EndNode);
            string referenceFilePath = this.utilityObj.xmlUtil.GetTextValue(nodeName, Constants.FilePathNode);
            string queryFilePath = this.utilityObj.xmlUtil.GetTextValue(nodeName, Constants.QueryFilePath);
            string minimalOverlap = this.utilityObj.xmlUtil.GetTextValue(nodeName, Constants.OverlapValue);

            SequenceRangeGrouping operationResult = null;

            // Parse a BED file.
            var parserObj = new BedParser();
            SequenceRangeGrouping referenceGroup = parserObj.ParseRangeGrouping(referenceFilePath);
            SequenceRangeGrouping queryGroup = parserObj.ParseRangeGrouping(queryFilePath);

            var intersectOutputType = IntersectOutputType.OverlappingIntervals;
            if (overlappingBasePair)
            {
                intersectOutputType = IntersectOutputType.OverlappingPiecesOfIntervals;
            }

            var subtractOutputType = SubtractOutputType.NonOverlappingPiecesOfIntervals;
            if (overlappingBasePair)
            {
                subtractOutputType = SubtractOutputType.IntervalsWithNoOverlap;
            }

            switch (operationPam)
            {
                case BedOperationsParameters.Merge:
                    operationResult = referenceGroup.MergeOverlaps();
                    break;
                case BedOperationsParameters.MergeWithPam:
                    operationResult = referenceGroup.MergeOverlaps(queryGroup,
                                                                   0, isParentSeqRangeRequired);
                    break;
                case BedOperationsParameters.Intersect:

                    operationResult = referenceGroup.Intersect(queryGroup,
                                                               long.Parse(minimalOverlap, null), intersectOutputType,
                                                               isParentSeqRangeRequired);
                    break;
                case BedOperationsParameters.MergeQueryWithReference:
                    operationResult = queryGroup.MergeOverlaps(referenceGroup,
                                                               0, isParentSeqRangeRequired);
                    break;
                case BedOperationsParameters.Subtract:
                    operationResult = referenceGroup.Subtract(queryGroup,
                                                              long.Parse(minimalOverlap, null), subtractOutputType,
                                                              isParentSeqRangeRequired);
                    break;
                default:
                    break;
            }

            // Get a result SequenceGroup Id.
            IEnumerable<string> groupId = operationResult.GroupIDs;
            string[] expectedRangeIdsArray = expectedRangeIDs.Split(',');
            string[] expectedStartIndexArray = expectedStartIndex.Split(',');
            string[] expectedEndIndexArray = expectedEndIndex.Split(',');
            int i = 0;

            foreach (string grpId in groupId)
            {
                string rangeId = grpId;

                List<ISequenceRange> rangeList = operationResult.GetGroup(rangeId);

                // Validate result sequence range.
                foreach (ISequenceRange range in rangeList)
                {
                    Assert.AreEqual(expectedRangeIdsArray[i], range.ID);
                    Assert.AreEqual(expectedStartIndexArray[i], range.Start.ToString((IFormatProvider) null));
                    Assert.AreEqual(expectedEndIndexArray[i], range.End.ToString((IFormatProvider) null));
                    i++;
                }
            }

            // Validate ParentSeqRange.
            bool result = ValidateParentSeqRange(operationResult, referenceGroup, queryGroup, isParentSeqRangeRequired);
            Assert.IsTrue(result);

            ApplicationLog.WriteLine("Bed Operations BVT: Successfully validated the BED SequenceID, Start and End Ranges");
        }