Пример #1
0
        /// <summary>
        /// Formats the Range/RangeGroup for different test cases based
        /// on Additional parameter
        /// </summary>
        /// <param name="nodeName">Xml Node name</param>
        /// <param name="addParam">Additional parameter</param>
        void FormatterGeneralTestCases(string nodeName,
                                       AdditionalParameters addParam)
        {
            IList <ISequenceRange> rangeList  = new List <ISequenceRange>();
            SequenceRangeGrouping  rangeGroup = new SequenceRangeGrouping();

            // Gets the file name.
            string filePath = utilityObj.xmlUtil.GetTextValue(
                nodeName, Constants.FilePathNode);

            // Condition to check if Parse() happens before Format()
            switch (addParam)
            {
            case AdditionalParameters.ParseRangeGroup:
            case AdditionalParameters.ParseRangeGroupTextWriter:
                BedParser initialParserGroupObj = new BedParser();
                rangeGroup =
                    initialParserGroupObj.ParseRangeGrouping(filePath);
                break;

            case AdditionalParameters.ParseRange:
            case AdditionalParameters.ParseRangeTextWriter:
                BedParser initialParserObj = new BedParser();
                rangeList = initialParserObj.ParseRange(filePath);
                break;

            default:
                // Gets all the expected values from xml.
                string expectedID = utilityObj.xmlUtil.GetTextValue(
                    nodeName, Constants.IDNode);
                string expectedStart = utilityObj.xmlUtil.GetTextValue(
                    nodeName, Constants.StartNode);
                string expectedEnd = utilityObj.xmlUtil.GetTextValue(
                    nodeName, Constants.EndNode);

                string[] expectedIDs    = expectedID.Split(',');
                string[] expectedStarts = expectedStart.Split(',');
                string[] expectedEnds   = expectedEnd.Split(',');

                // Gets the Range Group or Range based on the additional parameter
                switch (addParam)
                {
                case AdditionalParameters.RangeGroupTextWriter:
                case AdditionalParameters.RangeGroupFileName:
                    for (int i = 0; i < expectedIDs.Length; i++)
                    {
                        SequenceRange rangeObj1 =
                            new SequenceRange(expectedIDs[i],
                                              long.Parse(expectedStarts[i], (IFormatProvider)null),
                                              long.Parse(expectedEnds[i], (IFormatProvider)null));
                        rangeGroup.Add(rangeObj1);
                    }
                    break;

                default:
                    for (int i = 0; i < expectedIDs.Length; i++)
                    {
                        SequenceRange rangeObj2 =
                            new SequenceRange(expectedIDs[i],
                                              long.Parse(expectedStarts[i], (IFormatProvider)null),
                                              long.Parse(expectedEnds[i], (IFormatProvider)null));
                        rangeList.Add(rangeObj2);
                    }
                    break;
                }
                break;
            }

            BedFormatter formatterObj = new BedFormatter();

            // Gets the Range list/Range Group based on the parameters.
            switch (addParam)
            {
            case AdditionalParameters.RangeFileName:
            case AdditionalParameters.ParseRange:
                formatterObj.Format(rangeList, Constants.BedTempFileName);
                break;

            case AdditionalParameters.RangeTextWriter:
            case AdditionalParameters.ParseRangeTextWriter:
                using (TextWriter txtWriter =
                           new StreamWriter(Constants.BedTempFileName))
                {
                    formatterObj.Format(rangeList, txtWriter);
                }
                break;

            case AdditionalParameters.RangeGroupFileName:
            case AdditionalParameters.ParseRangeGroup:
                formatterObj.Format(rangeGroup, Constants.BedTempFileName);
                break;

            case AdditionalParameters.RangeGroupTextWriter:
            case AdditionalParameters.ParseRangeGroupTextWriter:
                using (TextWriter txtWriter =
                           new StreamWriter(Constants.BedTempFileName))
                {
                    formatterObj.Format(rangeGroup, txtWriter);
                }
                break;

            default:
                break;
            }

            // Reparse to validate the results
            BedParser parserObj = new BedParser();
            IList <ISequenceRange> newRangeList =
                parserObj.ParseRange(Constants.BedTempFileName);

            // Validation of all the properties.
            for (int i = 0; i < rangeList.Count; i++)
            {
                Assert.AreEqual(rangeList[0].ID, newRangeList[0].ID);
                Assert.AreEqual(rangeList[0].Start, newRangeList[0].Start);
                Assert.AreEqual(rangeList[0].End, newRangeList[0].End);
            }

            ApplicationLog.WriteLine(
                "Bed Formatter P1: Successfully validated the ID, Start and End Ranges");
            Console.WriteLine(
                "Bed Formatter P1: Successfully validated the ID, Start and End Ranges");

            // Cleanup the file.
            if (File.Exists(Constants.BedTempFileName))
            {
                File.Delete(Constants.BedTempFileName);
            }
        }
Пример #2
0
        /// <summary>
        ///     Formats the Range/RangeGroup for different test cases based
        ///     on Additional parameter
        /// </summary>
        /// <param name="nodeName">Xml Node name</param>
        /// <param name="addParam">Additional parameter</param>
        private void FormatterGeneralTestCases(string nodeName,
                                               AdditionalParameters addParam)
        {
            IList <ISequenceRange> rangeList = new List <ISequenceRange>();
            var rangeGroup = new SequenceRangeGrouping();

            // Gets the file name.
            string filePath = utilityObj.xmlUtil.GetTextValue(nodeName, Constants.FilePathNode).TestDir();

            // Condition to check if Parse() happens before Format()
            switch (addParam)
            {
            case AdditionalParameters.ParseRangeGroup:
                var initialParserGroupObj = new BedParser();
                rangeGroup =
                    initialParserGroupObj.ParseRangeGrouping(filePath);
                break;

            case AdditionalParameters.ParseRange:
                var initialParserObj = new BedParser();
                rangeList = initialParserObj.ParseRange(filePath);
                break;

            default:
                // Gets all the expected values from xml.
                string expectedID = utilityObj.xmlUtil.GetTextValue(
                    nodeName, Constants.IDNode);
                string expectedStart = utilityObj.xmlUtil.GetTextValue(
                    nodeName, Constants.StartNode);
                string expectedEnd = utilityObj.xmlUtil.GetTextValue(
                    nodeName, Constants.EndNode);

                string[] expectedIDs    = expectedID.Split(',');
                string[] expectedStarts = expectedStart.Split(',');
                string[] expectedEnds   = expectedEnd.Split(',');

                // Gets the Range Group or Range based on the additional parameter
                switch (addParam)
                {
                case AdditionalParameters.RangeGroupTextWriter:
                case AdditionalParameters.RangeGroupFileName:
                    for (int i = 0; i < expectedIDs.Length; i++)
                    {
                        var rangeObj1 = new SequenceRange(expectedIDs[i],
                                                          long.Parse(expectedStarts[i], null),
                                                          long.Parse(expectedEnds[i], null));
                        rangeGroup.Add(rangeObj1);
                    }
                    break;

                default:
                    for (int i = 0; i < expectedIDs.Length; i++)
                    {
                        var rangeObj2 = new SequenceRange(expectedIDs[i],
                                                          long.Parse(expectedStarts[i], null),
                                                          long.Parse(expectedEnds[i], null));
                        rangeList.Add(rangeObj2);
                    }
                    break;
                }
                break;
            }

            var formatterObj = new BedFormatter();

            // Gets the Range list/Range Group based on the parameters.
            switch (addParam)
            {
            case AdditionalParameters.RangeFileName:
            case AdditionalParameters.ParseRange:
                formatterObj.Format(rangeList, Constants.BedTempFileName);
                break;

            case AdditionalParameters.RangeTextWriter:
                using (var txtWriter =
                           File.Create(Constants.BedTempFileName))
                {
                    formatterObj.Format(txtWriter, rangeList);
                }
                break;

            case AdditionalParameters.RangeGroupFileName:
            case AdditionalParameters.ParseRangeGroup:
                formatterObj.Format(rangeGroup, Constants.BedTempFileName);
                break;

            case AdditionalParameters.RangeGroupTextWriter:
                using (var txtWriter =
                           File.Create(Constants.BedTempFileName))
                {
                    formatterObj.Format(txtWriter, rangeGroup);
                }
                break;

            default:
                break;
            }

            // Reparse to validate the results
            var parserObj = new BedParser();
            IList <ISequenceRange> newRangeList =
                parserObj.ParseRange(Constants.BedTempFileName);

            // Validation of all the properties.
            for (int i = 0; i < rangeList.Count; i++)
            {
                Assert.AreEqual(rangeList[i].ID, newRangeList[i].ID);
                Assert.AreEqual(rangeList[i].Start, newRangeList[i].Start);
                Assert.AreEqual(rangeList[i].End, newRangeList[i].End);

                // Validation of all metadata information.
                if (rangeList[i].Metadata.Count > 0)
                {
                    if (rangeList[i].Metadata.ContainsKey("Name"))
                    {
                        Assert.AreEqual(rangeList[i].Metadata["Name"],
                                        newRangeList[i].Metadata["Name"]);
                    }

                    if (rangeList[i].Metadata.ContainsKey("Score"))
                    {
                        Assert.AreEqual(rangeList[i].Metadata["Score"],
                                        newRangeList[i].Metadata["Score"]);
                    }

                    if (rangeList[i].Metadata.ContainsKey("Strand"))
                    {
                        Assert.AreEqual(rangeList[i].Metadata["Strand"],
                                        newRangeList[i].Metadata["Strand"]);
                    }

                    if (rangeList[i].Metadata.ContainsKey("ThickStart"))
                    {
                        Assert.AreEqual(rangeList[i].Metadata["ThickStart"],
                                        newRangeList[i].Metadata["ThickStart"]);
                    }

                    if (rangeList[i].Metadata.ContainsKey("ThickEnd"))
                    {
                        Assert.AreEqual(rangeList[i].Metadata["ThickEnd"],
                                        newRangeList[i].Metadata["ThickEnd"]);
                    }

                    if (rangeList[i].Metadata.ContainsKey("ItemRGB"))
                    {
                        Assert.AreEqual(rangeList[i].Metadata["ItemRGB"],
                                        newRangeList[i].Metadata["ItemRGB"]);
                    }

                    if (rangeList[i].Metadata.ContainsKey("BlockCount"))
                    {
                        Assert.AreEqual(rangeList[i].Metadata["BlockCount"],
                                        newRangeList[i].Metadata["BlockCount"]);
                    }

                    if (rangeList[i].Metadata.ContainsKey("BlockSizes"))
                    {
                        Assert.AreEqual(rangeList[i].Metadata["BlockSizes"],
                                        newRangeList[i].Metadata["BlockSizes"]);
                    }

                    if (rangeList[i].Metadata.ContainsKey("BlockStarts"))
                    {
                        Assert.AreEqual(rangeList[i].Metadata["BlockStarts"],
                                        newRangeList[i].Metadata["BlockStarts"]);
                    }

                    ApplicationLog.WriteLine(
                        "Bed Formatter BVT: Successfully validated all the metadata information");
                }
            }

            ApplicationLog.WriteLine(
                "Bed Formatter BVT: Successfully validated the ID, Start and End Ranges");

            // Cleanup the file.
            if (File.Exists(Constants.BedTempFileName))
            {
                File.Delete(Constants.BedTempFileName);
            }
        }
Пример #3
0
        public void SubtractTest()
        {
            string                refSeqRangefile   = @"testdata\BED\Subtract\Subtract_ref.BED";
            string                querySeqRangefile = @"testdata\BED\Subtract\Subtract_query.BED";
            string                resultfilepath    = "tmp_mergeresult.bed";
            BedParser             parser            = new BedParser();
            BedFormatter          formatter         = new BedFormatter();
            SequenceRangeGrouping result            = null;
            bool resultvalue = false;

            SequenceRangeGrouping refSeqRange   = parser.ParseRangeGrouping(refSeqRangefile);
            SequenceRangeGrouping querySeqRange = parser.ParseRangeGrouping(querySeqRangefile);

            string expectedresultpath = @"testdata\BED\Subtract\Result_Subtract_minoverlap1.BED";

            result = refSeqRange.Subtract(querySeqRange, 1, SubtractOutputType.IntervalsWithNoOverlap);
            formatter.Format(result, resultfilepath);
            resultvalue = CompareBEDOutput(resultfilepath, expectedresultpath);
            Assert.IsTrue(resultvalue);
            resultvalue = ValidateParentSeqRange(result, refSeqRange, querySeqRange, 1, true);
            Assert.IsTrue(resultvalue);

            expectedresultpath = @"testdata\BED\Subtract\Result_Subtract_minoverlap0.BED";
            result             = refSeqRange.Subtract(querySeqRange, 0, SubtractOutputType.IntervalsWithNoOverlap);
            formatter.Format(result, resultfilepath);
            resultvalue = CompareBEDOutput(resultfilepath, expectedresultpath);
            Assert.IsTrue(resultvalue);
            resultvalue = ValidateParentSeqRange(result, refSeqRange, querySeqRange, 0, true);
            Assert.IsTrue(resultvalue);

            expectedresultpath = @"testdata\BED\Subtract\Result_Subtract_minoverlap1.BED";
            result             = refSeqRange.Subtract(querySeqRange, 1, SubtractOutputType.IntervalsWithNoOverlap, true);
            formatter.Format(result, resultfilepath);
            resultvalue = CompareBEDOutput(resultfilepath, expectedresultpath);
            Assert.IsTrue(resultvalue);
            resultvalue = ValidateParentSeqRange(result, refSeqRange, querySeqRange, 1, true);
            Assert.IsTrue(resultvalue);

            expectedresultpath = @"testdata\BED\Subtract\Result_Subtract_minoverlap0.BED";
            result             = refSeqRange.Subtract(querySeqRange, 0, SubtractOutputType.IntervalsWithNoOverlap, true);
            formatter.Format(result, resultfilepath);
            resultvalue = CompareBEDOutput(resultfilepath, expectedresultpath);
            Assert.IsTrue(resultvalue);
            resultvalue = ValidateParentSeqRange(result, refSeqRange, querySeqRange, 0, true);
            Assert.IsTrue(resultvalue);


            expectedresultpath = @"testdata\BED\Subtract\Result_Subtract_minoverlap1.BED";
            result             = refSeqRange.Subtract(querySeqRange, 1, SubtractOutputType.IntervalsWithNoOverlap, false);
            formatter.Format(result, resultfilepath);
            resultvalue = CompareBEDOutput(resultfilepath, expectedresultpath);
            Assert.IsTrue(resultvalue);
            resultvalue = ValidateParentSeqRange(result, refSeqRange, querySeqRange, 1, false);
            Assert.IsTrue(resultvalue);

            expectedresultpath = @"testdata\BED\Subtract\Result_Subtract_minoverlap0.BED";
            result             = refSeqRange.Subtract(querySeqRange, 0, SubtractOutputType.IntervalsWithNoOverlap, false);
            formatter.Format(result, resultfilepath);
            resultvalue = CompareBEDOutput(resultfilepath, expectedresultpath);
            Assert.IsTrue(resultvalue);
            resultvalue = ValidateParentSeqRange(result, refSeqRange, querySeqRange, 0, false);
            Assert.IsTrue(resultvalue);

            expectedresultpath = @"testdata\BED\Subtract\Result_Subtract_minoverlap0_NOnOverlappingPieces.BED";
            result             = refSeqRange.Subtract(querySeqRange, 0, SubtractOutputType.NonOverlappingPiecesOfIntervals, true);
            formatter.Format(result, resultfilepath);
            resultvalue = CompareBEDOutput(resultfilepath, expectedresultpath);
            Assert.IsTrue(resultvalue);
            resultvalue = ValidateParentSeqRange(result, refSeqRange, querySeqRange, 0, true);
            Assert.IsTrue(resultvalue);

            expectedresultpath = @"testdata\BED\Subtract\Result_Subtract_minoverlap1_NOnOverlappingPieces.BED";
            result             = refSeqRange.Subtract(querySeqRange, 1, SubtractOutputType.NonOverlappingPiecesOfIntervals, true);
            formatter.Format(result, resultfilepath);
            resultvalue = CompareBEDOutput(resultfilepath, expectedresultpath);
            Assert.IsTrue(resultvalue);
            resultvalue = ValidateParentSeqRange(result, refSeqRange, querySeqRange, 1, true);
            Assert.IsTrue(resultvalue);
        }
Пример #4
0
        public void MergeOperationTest()
        {
            string                filepath           = @"testdata\BED\Merge\Merge_single.BED";
            string                resultfilepath     = "tmp_mergeresult.bed";
            string                expectedresultpath = @"testdata\BED\Merge\Result_Merge_Single_MinLength0.BED";
            BedParser             parser             = new BedParser();
            BedFormatter          formatter          = new BedFormatter();
            SequenceRangeGrouping seqGrouping        = null;
            SequenceRangeGrouping result             = null;
            bool resultvalue = false;

            resultfilepath     = "tmp_mergeresult.bed";
            expectedresultpath = @"testdata\BED\Merge\Result_Merge_Single_MinLength0.BED";
            seqGrouping        = parser.ParseRangeGrouping(filepath);

            result = seqGrouping.MergeOverlaps();
            formatter.Format(result, resultfilepath);
            resultvalue = CompareBEDOutput(resultfilepath, expectedresultpath);
            Assert.IsTrue(resultvalue);
            resultvalue = ValidateParentSeqRange(result, seqGrouping, null, 0, false);
            Assert.IsTrue(resultvalue);

            expectedresultpath = @"testdata\BED\Merge\Result_Merge_Single_MinLength0.BED";
            result             = seqGrouping.MergeOverlaps(0, true);
            formatter.Format(result, resultfilepath);
            resultvalue = CompareBEDOutput(resultfilepath, expectedresultpath);
            Assert.IsTrue(resultvalue);
            resultvalue = ValidateParentSeqRange(result, seqGrouping, null, 0, true);
            Assert.IsTrue(resultvalue);

            expectedresultpath = @"testdata\BED\Merge\Result_Merge_Single_MinLength0.BED";
            result             = seqGrouping.MergeOverlaps(0, false);
            formatter.Format(result, resultfilepath);
            resultvalue = CompareBEDOutput(resultfilepath, expectedresultpath);
            Assert.IsTrue(resultvalue);
            resultvalue = ValidateParentSeqRange(result, seqGrouping, null, 0, false);
            Assert.IsTrue(resultvalue);

            expectedresultpath = @"testdata\BED\Merge\Result_Merge_Single_MinLength0.BED";
            result             = seqGrouping.MergeOverlaps(0);
            formatter.Format(result, resultfilepath);
            resultvalue = CompareBEDOutput(resultfilepath, expectedresultpath);
            Assert.IsTrue(resultvalue);
            resultvalue = ValidateParentSeqRange(result, seqGrouping, null, 0, false);
            Assert.IsTrue(resultvalue);

            expectedresultpath = @"testdata\BED\Merge\Result_Merge_Single_MinLength0.BED";
            result             = seqGrouping.MergeOverlaps(0, true);
            formatter.Format(result, resultfilepath);
            resultvalue = CompareBEDOutput(resultfilepath, expectedresultpath);
            Assert.IsTrue(resultvalue);
            resultvalue = ValidateParentSeqRange(result, seqGrouping, null, 0, true);
            Assert.IsTrue(resultvalue);

            expectedresultpath = @"testdata\BED\Merge\Result_Merge_Single_MinLength0.BED";
            result             = seqGrouping.MergeOverlaps(0, false);
            formatter.Format(result, resultfilepath);
            resultvalue = CompareBEDOutput(resultfilepath, expectedresultpath);
            Assert.IsTrue(resultvalue);
            resultvalue = ValidateParentSeqRange(result, seqGrouping, null, 0, false);
            Assert.IsTrue(resultvalue);

            expectedresultpath = @"testdata\BED\Merge\Result_Merge_Single_MinLength1.BED";
            result             = seqGrouping.MergeOverlaps(1);
            formatter.Format(result, resultfilepath);
            resultvalue = CompareBEDOutput(resultfilepath, expectedresultpath);
            Assert.IsTrue(resultvalue);
            resultvalue = ValidateParentSeqRange(result, seqGrouping, null, 1, false);
            Assert.IsTrue(resultvalue);


            expectedresultpath = @"testdata\BED\Merge\Result_Merge_Single_MinLength-1.BED";
            result             = seqGrouping.MergeOverlaps(-1);
            formatter.Format(result, resultfilepath);
            resultvalue = CompareBEDOutput(resultfilepath, expectedresultpath);
            Assert.IsTrue(resultvalue);
            resultvalue = ValidateParentSeqRange(result, seqGrouping, null, -1, false);
            Assert.IsTrue(resultvalue);


            expectedresultpath = @"testdata\BED\Merge\Result_Merge_Single_MinLength-3.BED";
            result             = seqGrouping.MergeOverlaps(-3);
            formatter.Format(result, resultfilepath);
            resultvalue = CompareBEDOutput(resultfilepath, expectedresultpath);
            Assert.IsTrue(resultvalue);
            resultvalue = ValidateParentSeqRange(result, seqGrouping, null, -3, false);
            Assert.IsTrue(resultvalue);

            string firstFile  = @"testdata\BED\Merge\Merge_twofiles_1.BED";
            string secondFile = @"testdata\BED\Merge\Merge_twofiles_2.BED";
            SequenceRangeGrouping refSeqRange   = parser.ParseRangeGrouping(firstFile);
            SequenceRangeGrouping querySeqRange = parser.ParseRangeGrouping(secondFile);

            expectedresultpath = @"testdata\BED\Merge\Result_Merge_Two_MinLength0.BED";
            result             = refSeqRange.MergeOverlaps(querySeqRange);
            formatter.Format(result, resultfilepath);
            resultvalue = CompareBEDOutput(resultfilepath, expectedresultpath);
            Assert.IsTrue(resultvalue);
            resultvalue = ValidateParentSeqRange(result, refSeqRange, querySeqRange, 0, false);
            Assert.IsTrue(resultvalue);

            result = refSeqRange.MergeOverlaps(querySeqRange, 0, false);
            formatter.Format(result, resultfilepath);
            resultvalue = CompareBEDOutput(resultfilepath, expectedresultpath);
            Assert.IsTrue(resultvalue);
            resultvalue = ValidateParentSeqRange(result, refSeqRange, querySeqRange, 0, false);
            Assert.IsTrue(resultvalue);

            result = refSeqRange.MergeOverlaps(querySeqRange, 0, true);
            formatter.Format(result, resultfilepath);
            resultvalue = CompareBEDOutput(resultfilepath, expectedresultpath);
            Assert.IsTrue(resultvalue);
            resultvalue = ValidateParentSeqRange(result, refSeqRange, querySeqRange, 0, true);
            Assert.IsTrue(resultvalue);

            result = refSeqRange.MergeOverlaps(querySeqRange, 0);
            formatter.Format(result, resultfilepath);
            resultvalue = CompareBEDOutput(resultfilepath, expectedresultpath);
            Assert.IsTrue(resultvalue);
            resultvalue = ValidateParentSeqRange(result, refSeqRange, querySeqRange, 0, false);
            Assert.IsTrue(resultvalue);

            result = refSeqRange.MergeOverlaps(querySeqRange, 0, true);
            formatter.Format(result, resultfilepath);
            resultvalue = CompareBEDOutput(resultfilepath, expectedresultpath);
            Assert.IsTrue(resultvalue);
            resultvalue = ValidateParentSeqRange(result, refSeqRange, querySeqRange, 0, true);
            Assert.IsTrue(resultvalue);

            result = refSeqRange.MergeOverlaps(querySeqRange, 0, false);
            formatter.Format(result, resultfilepath);
            resultvalue = CompareBEDOutput(resultfilepath, expectedresultpath);
            Assert.IsTrue(resultvalue);
            resultvalue = ValidateParentSeqRange(result, refSeqRange, querySeqRange, 0, false);
            Assert.IsTrue(resultvalue);

            expectedresultpath = @"testdata\BED\Merge\Result_Merge_Two_MinLength1.BED";
            result             = refSeqRange.MergeOverlaps(querySeqRange, 1, true);
            formatter.Format(result, resultfilepath);
            resultvalue = CompareBEDOutput(resultfilepath, expectedresultpath);
            Assert.IsTrue(resultvalue);
            resultvalue = ValidateParentSeqRange(result, refSeqRange, querySeqRange, 1, true);
            Assert.IsTrue(resultvalue);

            expectedresultpath = @"testdata\BED\Merge\Result_Merge_Two_MinLength-1.BED";
            result             = refSeqRange.MergeOverlaps(querySeqRange, -1, true);
            formatter.Format(result, resultfilepath);
            resultvalue = CompareBEDOutput(resultfilepath, expectedresultpath);
            Assert.IsTrue(resultvalue);
            resultvalue = ValidateParentSeqRange(result, refSeqRange, querySeqRange, -1, true);
            Assert.IsTrue(resultvalue);

            expectedresultpath = @"testdata\BED\Merge\Result_Merge_Two_MinLength-3.BED";
            result             = refSeqRange.MergeOverlaps(querySeqRange, -3, true);
            formatter.Format(result, resultfilepath);
            resultvalue = CompareBEDOutput(resultfilepath, expectedresultpath);
            Assert.IsTrue(resultvalue);
            resultvalue = ValidateParentSeqRange(result, refSeqRange, querySeqRange, -3, true);
            Assert.IsTrue(resultvalue);

            expectedresultpath = @"testdata\BED\Merge\Result_Merge_Two_MinLength2.BED";
            result             = refSeqRange.MergeOverlaps(querySeqRange, 2, true);
            formatter.Format(result, resultfilepath);
            resultvalue = CompareBEDOutput(resultfilepath, expectedresultpath);
            Assert.IsTrue(resultvalue);
            resultvalue = ValidateParentSeqRange(result, refSeqRange, querySeqRange, 2, true);
            Assert.IsTrue(resultvalue);

            expectedresultpath = @"testdata\BED\Merge\Result_Merge_Two_MinLength6.BED";
            result             = refSeqRange.MergeOverlaps(querySeqRange, 6, true);
            formatter.Format(result, resultfilepath);
            resultvalue = CompareBEDOutput(resultfilepath, expectedresultpath);
            Assert.IsTrue(resultvalue);
            resultvalue = ValidateParentSeqRange(result, refSeqRange, querySeqRange, 6, true);
            Assert.IsTrue(resultvalue);
        }
Пример #5
0
        public void IntersectOperationTest()
        {
            string       resultfilepath     = "tmp_mergeresult.bed";
            string       expectedresultpath = string.Empty;
            BedParser    parser             = new BedParser();
            BedFormatter formatter          = new BedFormatter();

            SequenceRangeGrouping result = null;
            bool resultvalue             = false;

            resultfilepath = "tmp_mergeresult.bed";

            string reffile   = @"testdata\BED\Intersect\Intersect_ref.BED";
            string queryFile = @"testdata\BED\Intersect\Intersect_query.BED";
            SequenceRangeGrouping refSeqRange   = parser.ParseRangeGrouping(reffile);
            SequenceRangeGrouping querySeqRange = parser.ParseRangeGrouping(queryFile);

            expectedresultpath = @"testdata\BED\Intersect\Result_Intersect_MinOverlap1_OverLappingBases.BED";
            result             = refSeqRange.Intersect(querySeqRange, 1, IntersectOutputType.OverlappingPiecesOfIntervals);
            formatter.Format(result, resultfilepath);
            resultvalue = CompareBEDOutput(resultfilepath, expectedresultpath);
            Assert.IsTrue(resultvalue);
            resultvalue = ValidateParentSeqRange(result, refSeqRange, querySeqRange, 1, true);
            Assert.IsTrue(resultvalue);

            expectedresultpath = @"testdata\BED\Intersect\Result_Intersect_MinOverlap1.BED";
            result             = refSeqRange.Intersect(querySeqRange, 1, IntersectOutputType.OverlappingIntervals);
            formatter.Format(result, resultfilepath);
            resultvalue = CompareBEDOutput(resultfilepath, expectedresultpath);
            Assert.IsTrue(resultvalue);
            resultvalue = ValidateParentSeqRange(result, refSeqRange, querySeqRange, 1, false);
            Assert.IsTrue(resultvalue);

            expectedresultpath = @"testdata\BED\Intersect\Result_Intersect_MinOverlap0_OverLappingBases.BED";
            result             = refSeqRange.Intersect(querySeqRange, 0, IntersectOutputType.OverlappingPiecesOfIntervals);
            formatter.Format(result, resultfilepath);
            resultvalue = CompareBEDOutput(resultfilepath, expectedresultpath);
            Assert.IsTrue(resultvalue);
            resultvalue = ValidateParentSeqRange(result, refSeqRange, querySeqRange, 0, true);
            Assert.IsTrue(resultvalue);

            expectedresultpath = @"testdata\BED\Intersect\Result_Intersect_MinOverlap0.BED";
            result             = refSeqRange.Intersect(querySeqRange, 0, IntersectOutputType.OverlappingIntervals);
            formatter.Format(result, resultfilepath);
            resultvalue = CompareBEDOutput(resultfilepath, expectedresultpath);
            Assert.IsTrue(resultvalue);
            resultvalue = ValidateParentSeqRange(result, refSeqRange, querySeqRange, 0, false);
            Assert.IsTrue(resultvalue);

            expectedresultpath = @"testdata\BED\Intersect\Result_Intersect_MinOverlap1_OverLappingBases.BED";
            result             = refSeqRange.Intersect(querySeqRange, 1, IntersectOutputType.OverlappingPiecesOfIntervals, true);
            formatter.Format(result, resultfilepath);
            resultvalue = CompareBEDOutput(resultfilepath, expectedresultpath);
            Assert.IsTrue(resultvalue);
            resultvalue = ValidateParentSeqRange(result, refSeqRange, querySeqRange, 1, true);
            Assert.IsTrue(resultvalue);

            expectedresultpath = @"testdata\BED\Intersect\Result_Intersect_MinOverlap1.BED";
            result             = refSeqRange.Intersect(querySeqRange, 1, IntersectOutputType.OverlappingIntervals, true);
            formatter.Format(result, resultfilepath);
            resultvalue = CompareBEDOutput(resultfilepath, expectedresultpath);
            Assert.IsTrue(resultvalue);
            resultvalue = ValidateParentSeqRange(result, refSeqRange, querySeqRange, 1, true);
            Assert.IsTrue(resultvalue);

            expectedresultpath = @"testdata\BED\Intersect\Result_Intersect_MinOverlap0_OverLappingBases.BED";
            result             = refSeqRange.Intersect(querySeqRange, 0, IntersectOutputType.OverlappingPiecesOfIntervals, true);
            formatter.Format(result, resultfilepath);
            resultvalue = CompareBEDOutput(resultfilepath, expectedresultpath);
            Assert.IsTrue(resultvalue);
            resultvalue = ValidateParentSeqRange(result, refSeqRange, querySeqRange, 0, true);
            Assert.IsTrue(resultvalue);


            expectedresultpath = @"testdata\BED\Intersect\Result_Intersect_MinOverlap0.BED";
            result             = refSeqRange.Intersect(querySeqRange, 0, IntersectOutputType.OverlappingIntervals, true);
            formatter.Format(result, resultfilepath);
            resultvalue = CompareBEDOutput(resultfilepath, expectedresultpath);
            Assert.IsTrue(resultvalue);
            resultvalue = ValidateParentSeqRange(result, refSeqRange, querySeqRange, 0, true);
            Assert.IsTrue(resultvalue);
        }
Пример #6
0
        public void SubtractTest()
        {
            var                   direc             = System.IO.Path.Combine("TestUtils", "BED", "Subtract");
            string                refSeqRangefile   = System.IO.Path.Combine(direc, "Subtract_ref.BED").TestDir();
            string                querySeqRangefile = System.IO.Path.Combine(direc, "Subtract_query.BED").TestDir();
            string                resultfilepath    = "tmp_mergeresult.bed";
            BedParser             parser            = new BedParser();
            BedFormatter          formatter         = new BedFormatter();
            SequenceRangeGrouping result            = null;
            bool                  resultvalue       = false;

            SequenceRangeGrouping refSeqRange   = parser.ParseRangeGrouping(refSeqRangefile);
            SequenceRangeGrouping querySeqRange = parser.ParseRangeGrouping(querySeqRangefile);

            const string MinOverlap1        = "Result_Subtract_minoverlap1.bed";
            string       expectedresultpath = System.IO.Path.Combine(direc, MinOverlap1).TestDir();

            result = refSeqRange.Subtract(querySeqRange, 1, SubtractOutputType.IntervalsWithNoOverlap);
            formatter.Format(result, resultfilepath);
            resultvalue = CompareBEDOutput(resultfilepath, expectedresultpath);
            Assert.IsTrue(resultvalue);
            resultvalue = ValidateParentSeqRange(result, refSeqRange, querySeqRange, true);
            Assert.IsTrue(resultvalue);

            const string MinOverlap0 = "Result_subtract_minoverlap0.bed";

            expectedresultpath = System.IO.Path.Combine(direc, MinOverlap0).TestDir();
            result             = refSeqRange.Subtract(querySeqRange, 0, SubtractOutputType.IntervalsWithNoOverlap);
            formatter.Format(result, resultfilepath);
            resultvalue = CompareBEDOutput(resultfilepath, expectedresultpath);
            Assert.IsTrue(resultvalue);
            resultvalue = ValidateParentSeqRange(result, refSeqRange, querySeqRange, true);
            Assert.IsTrue(resultvalue);

            expectedresultpath = System.IO.Path.Combine(direc, MinOverlap1).TestDir();
            result             = refSeqRange.Subtract(querySeqRange, 1, SubtractOutputType.IntervalsWithNoOverlap, true);
            formatter.Format(result, resultfilepath);
            resultvalue = CompareBEDOutput(resultfilepath, expectedresultpath);
            Assert.IsTrue(resultvalue);
            resultvalue = ValidateParentSeqRange(result, refSeqRange, querySeqRange, true);
            Assert.IsTrue(resultvalue);

            expectedresultpath = System.IO.Path.Combine(direc, MinOverlap0).TestDir();
            result             = refSeqRange.Subtract(querySeqRange, 0, SubtractOutputType.IntervalsWithNoOverlap, true);
            formatter.Format(result, resultfilepath);
            resultvalue = CompareBEDOutput(resultfilepath, expectedresultpath);
            Assert.IsTrue(resultvalue);
            resultvalue = ValidateParentSeqRange(result, refSeqRange, querySeqRange, true);
            Assert.IsTrue(resultvalue);


            expectedresultpath = System.IO.Path.Combine(direc, MinOverlap1).TestDir();
            result             = refSeqRange.Subtract(querySeqRange, 1, SubtractOutputType.IntervalsWithNoOverlap, false);
            formatter.Format(result, resultfilepath);
            resultvalue = CompareBEDOutput(resultfilepath, expectedresultpath);
            Assert.IsTrue(resultvalue);
            resultvalue = ValidateParentSeqRange(result, refSeqRange, querySeqRange, false);
            Assert.IsTrue(resultvalue);

            expectedresultpath = System.IO.Path.Combine(direc, MinOverlap0).TestDir();
            result             = refSeqRange.Subtract(querySeqRange, 0, SubtractOutputType.IntervalsWithNoOverlap, false);
            formatter.Format(result, resultfilepath);
            resultvalue = CompareBEDOutput(resultfilepath, expectedresultpath);
            Assert.IsTrue(resultvalue);
            resultvalue = ValidateParentSeqRange(result, refSeqRange, querySeqRange, false);
            Assert.IsTrue(resultvalue);

            const string MinNoOverlap0 = "Result_Subtract_minoverlap0_NOnOverlappingPieces.BED";

            expectedresultpath = System.IO.Path.Combine(direc, MinNoOverlap0).TestDir();
            result             = refSeqRange.Subtract(querySeqRange, 0, SubtractOutputType.NonOverlappingPiecesOfIntervals, true);
            formatter.Format(result, resultfilepath);
            resultvalue = CompareBEDOutput(resultfilepath, expectedresultpath);
            Assert.IsTrue(resultvalue);
            resultvalue = ValidateParentSeqRange(result, refSeqRange, querySeqRange, true);
            Assert.IsTrue(resultvalue);

            const string MinNoOverlap1 = "Result_Subtract_minoverlap1_NOnOverlappingPieces.BED";

            expectedresultpath = System.IO.Path.Combine(direc, MinNoOverlap1).TestDir();
            result             = refSeqRange.Subtract(querySeqRange, 1, SubtractOutputType.NonOverlappingPiecesOfIntervals, true);
            formatter.Format(result, resultfilepath);
            resultvalue = CompareBEDOutput(resultfilepath, expectedresultpath);
            Assert.IsTrue(resultvalue);
            resultvalue = ValidateParentSeqRange(result, refSeqRange, querySeqRange, true);
            Assert.IsTrue(resultvalue);
        }
Пример #7
0
        public void IntersectOperationTest()
        {
            string       resultfilepath     = "tmp_mergeresult.bed";
            string       expectedresultpath = string.Empty;
            BedParser    parser             = new BedParser();
            BedFormatter formatter          = new BedFormatter();

            SequenceRangeGrouping result = null;
            bool resultvalue             = false;

            resultfilepath = "tmp_mergeresult.bed";
            string direc = Path.Combine("TestUtils", "BED", "Intersect");

            string reffile   = Path.Combine(direc, "Intersect_ref.BED").TestDir();
            string queryFile = Path.Combine(direc, "Intersect_query.BED").TestDir();
            SequenceRangeGrouping refSeqRange   = parser.ParseRangeGrouping(reffile);
            SequenceRangeGrouping querySeqRange = parser.ParseRangeGrouping(queryFile);

            expectedresultpath = Path.Combine(direc, "Result_Intersect_MinOverlap1_OverLappingBases.BED").TestDir();
            result             = refSeqRange.Intersect(querySeqRange, 1, IntersectOutputType.OverlappingPiecesOfIntervals);
            formatter.Format(result, resultfilepath);
            resultvalue = CompareBEDOutput(resultfilepath, expectedresultpath);
            Assert.IsTrue(resultvalue);
            resultvalue = ValidateParentSeqRange(result, refSeqRange, querySeqRange, true);
            Assert.IsTrue(resultvalue);

            expectedresultpath = Path.Combine(direc, "Result_Intersect_MinOverlap1.BED").TestDir();
            result             = refSeqRange.Intersect(querySeqRange, 1, IntersectOutputType.OverlappingIntervals);
            formatter.Format(result, resultfilepath);
            resultvalue = CompareBEDOutput(resultfilepath, expectedresultpath);
            Assert.IsTrue(resultvalue);
            resultvalue = ValidateParentSeqRange(result, refSeqRange, querySeqRange, false);
            Assert.IsTrue(resultvalue);

            expectedresultpath = Path.Combine(direc, "Result_Intersect_MinOverlap0_OverLappingBases.BED").TestDir();
            result             = refSeqRange.Intersect(querySeqRange, 0, IntersectOutputType.OverlappingPiecesOfIntervals);
            formatter.Format(result, resultfilepath);
            resultvalue = CompareBEDOutput(resultfilepath, expectedresultpath);
            Assert.IsTrue(resultvalue);
            resultvalue = ValidateParentSeqRange(result, refSeqRange, querySeqRange, true);
            Assert.IsTrue(resultvalue);

            expectedresultpath = Path.Combine(direc, "Result_Intersect_MinOverlap0.BED").TestDir();
            result             = refSeqRange.Intersect(querySeqRange, 0, IntersectOutputType.OverlappingIntervals);
            formatter.Format(result, resultfilepath);
            resultvalue = CompareBEDOutput(resultfilepath, expectedresultpath);
            Assert.IsTrue(resultvalue);
            resultvalue = ValidateParentSeqRange(result, refSeqRange, querySeqRange, false);
            Assert.IsTrue(resultvalue);

            expectedresultpath = Path.Combine(direc, "Result_Intersect_MinOverlap1_OverLappingBases.BED").TestDir();
            result             = refSeqRange.Intersect(querySeqRange, 1, IntersectOutputType.OverlappingPiecesOfIntervals, true);
            formatter.Format(result, resultfilepath);
            resultvalue = CompareBEDOutput(resultfilepath, expectedresultpath);
            Assert.IsTrue(resultvalue);
            resultvalue = ValidateParentSeqRange(result, refSeqRange, querySeqRange, true);
            Assert.IsTrue(resultvalue);

            expectedresultpath = Path.Combine(direc, "Result_Intersect_MinOverlap1.BED").TestDir();
            result             = refSeqRange.Intersect(querySeqRange, 1, IntersectOutputType.OverlappingIntervals, true);
            formatter.Format(result, resultfilepath);
            resultvalue = CompareBEDOutput(resultfilepath, expectedresultpath);
            Assert.IsTrue(resultvalue);
            resultvalue = ValidateParentSeqRange(result, refSeqRange, querySeqRange, true);
            Assert.IsTrue(resultvalue);

            expectedresultpath = Path.Combine(direc, "Result_Intersect_MinOverlap0_OverLappingBases.BED").TestDir();
            result             = refSeqRange.Intersect(querySeqRange, 0, IntersectOutputType.OverlappingPiecesOfIntervals, true);
            formatter.Format(result, resultfilepath);
            resultvalue = CompareBEDOutput(resultfilepath, expectedresultpath);
            Assert.IsTrue(resultvalue);
            resultvalue = ValidateParentSeqRange(result, refSeqRange, querySeqRange, true);
            Assert.IsTrue(resultvalue);


            expectedresultpath = Path.Combine(direc, "Result_Intersect_MinOverlap0.BED").TestDir();
            result             = refSeqRange.Intersect(querySeqRange, 0, IntersectOutputType.OverlappingIntervals, true);
            formatter.Format(result, resultfilepath);
            resultvalue = CompareBEDOutput(resultfilepath, expectedresultpath);
            Assert.IsTrue(resultvalue);
            resultvalue = ValidateParentSeqRange(result, refSeqRange, querySeqRange, true);
            Assert.IsTrue(resultvalue);
            File.Delete(resultfilepath);
        }