public void InValidateSubSequenceWithComplimentOperator()
        {
            // Get Values from XML node.
            string sequence = utilityObj.xmlUtil.GetTextValue(
                Constants.InvalidLocationWithComplementOperatorNode,
                Constants.ExpectedSequence);
            string location = utilityObj.xmlUtil.GetTextValue(
                Constants.InvalidLocationWithComplementOperatorNode,
                Constants.Location);
            string alphabet = utilityObj.xmlUtil.GetTextValue(
                Constants.InvalidLocationWithComplementOperatorNode,
                Constants.AlphabetNameNode);

            // Create a sequence object.
            ISequence seqObj = new Sequence(Utility.GetAlphabet(alphabet),
                sequence);

            // Build a location.
            ILocationBuilder locBuilder = new LocationBuilder();
            ILocation loc = locBuilder.GetLocation(location);
            LocationResolver locResolver = new LocationResolver();

            // Get sequence using location of the sequence with operator.
            try
            {
                loc.GetSubSequence(seqObj);
                Assert.Fail();
            }
            catch (ArgumentException)
            {
                LogExceptionMessage();
            }

            // Validate sub sequence exception for an invalid sequence.
            try
            {
                locResolver.GetSubSequence(loc, null);
                Assert.Fail();
            }
            catch (ArgumentNullException)
            {
                LogExceptionMessage();
            }

            // Validate GetSubSequence method with null location.
            try
            {
                locResolver.GetSubSequence(null, seqObj);
                Assert.Fail();
            }
            catch (ArgumentNullException)
            {
                LogExceptionMessage();
            }

            // Validate sub sequence exception for an invalid sequence.
            try
            {
                locResolver.GetSubSequence(loc, null, null);
                Assert.Fail();
            }
            catch (ArgumentNullException)
            {
                LogExceptionMessage();
            }

            // Validate GetSubSequence method with null location.
            try
            {
                locResolver.GetSubSequence(null, seqObj, null);
                Assert.Fail();
            }
            catch (ArgumentNullException)
            {
                LogExceptionMessage();
            }

            // Validate GetSubSequence method with null location.
            try
            {
                loc.GetSubSequence(null);
                Assert.Fail();
            }
            catch (ArgumentNullException)
            {
                ApplicationLog.WriteLine(string.Format((IFormatProvider)null,
                       "GenBankFeatures P2 : Validate the exception successfully"));
            }

        }
        /// <summary>
        /// InValidate GenBank location with invalid Start location data.
        /// <param name="endData">Start data used for different test cases.</param>
        /// </summary>
        private static void InValidateLocationStartData(string startData)
        {
            // Build a location.
            LocationResolver locResolver = new LocationResolver();
            string location = "123.125";
            ILocationBuilder locBuilder = new LocationBuilder();
            ILocation loc = locBuilder.GetLocation(location);

            // Set Invalid end data Validate GetStart method exception.
            loc.StartData = startData;
            try
            {
                locResolver.IsInStart(loc, 124);
                Assert.Fail();
            }
            catch (IndexOutOfRangeException)
            {
                LogExceptionMessage();
            }
            catch (FormatException)
            {
                LogExceptionMessage();
            }
        }
        public void InValidateGenBankLocationEndData()
        {
            // Get Values from XML node.
            string position = utilityObj.xmlUtil.GetTextValue(
                Constants.LocationWithEndDataNode, Constants.Position);

            // Build a location.
            LocationResolver locResolver = new LocationResolver();

            // Validate whether mentioned end data is present in the location
            // or not.
            try
            {
                locResolver.IsInEnd(null, Int32.Parse(position, (IFormatProvider)null));
                Assert.Fail();
            }
            catch (ArgumentNullException)
            {
                ApplicationLog.WriteLine(string.Format((IFormatProvider)null,
                    "GenBankFeatures P2 : Validate the exception successfully"));
            }

            // Validate IsInStart method exception.
            try
            {
                locResolver.IsInStart(null, Int32.Parse(position, (IFormatProvider)null));
                Assert.Fail();
            }
            catch (ArgumentNullException)
            {
                LogExceptionMessage();
            }

            // Validate IsInRange method exception.
            try
            {
                locResolver.IsInRange(null, Int32.Parse(position, (IFormatProvider)null));
                Assert.Fail();
            }
            catch (ArgumentNullException)
            {
                LogExceptionMessage();
            }

        }
        public void InValidateGenBankLocationGetStart()
        {
            // Build a location.
            LocationResolver locResolver = new LocationResolver();

            // Validate GetStart method exception.
            try
            {
                locResolver.GetStart(null);
                Assert.Fail();
            }
            catch (ArgumentNullException)
            {
                LogExceptionMessage();
            }

            // Validate GetEnd method exception.
            try
            {
                locResolver.GetEnd(null);
                Assert.Fail();
            }
            catch (ArgumentNullException)
            {
                LogExceptionMessage();
            }
        }
Beispiel #5
0
 /// <summary>
 /// Default constructor.
 /// </summary>
 public Location()
 {
     SubLocations = new List <ILocation>();
     Resolver     = new LocationResolver();
 }
Beispiel #6
0
 /// <summary>
 /// Default constructor.
 /// </summary>
 public Location()
 {
     SubLocations = new List<ILocation>();
     Resolver = new LocationResolver();
 }
        /// <summary>
        ///     Validate location resolver end data.
        /// </summary>
        /// <param name="nodeName">xml node name.</param>
        private void ValidateLocationEndData(string nodeName)
        {
            // Get Values from XML node.
            string location = utilityObj.xmlUtil.GetTextValue(
                nodeName, Constants.Location);
            string expectedEndData = utilityObj.xmlUtil.GetTextValue(
                nodeName, Constants.EndData);
            string position = utilityObj.xmlUtil.GetTextValue(
                nodeName, Constants.Position);

            bool result = false;

            // Build a location.
            var locResolver = new LocationResolver();
            ILocationBuilder locBuilder = new LocationBuilder();
            ILocation loc = locBuilder.GetLocation(location);
            loc.EndData = expectedEndData;

            // Validate whether mentioned end data is present in the location
            // or not.
            result = locResolver.IsInEnd(loc, Int32.Parse(position, null));
            Assert.IsTrue(result);

            // Log to VSTest GUI.
            ApplicationLog.WriteLine(string.Format(null,
                                                   "GenBankFeatures P1 : Expected sequence is verified"));
        }
        public void ValidateGenBankLocationStartAndEndRange()
        {
            // Get Values from XML node.
            string filePath = utilityObj.xmlUtil.GetTextValue(
                Constants.GenBankRepeatRegionQualifiersNode,
                Constants.FilePathNode);
            bool startLocResult = false;
            bool endLocResult = false;
            bool rangeLocResult = false;

            // Parse a GenBank file.
            ISequenceParser parserObj = new GenBankParser();
            {
                ISequence sequence = parserObj.ParseOne(filePath);
                ILocationResolver locResolver = new LocationResolver();

                // Validate Start,End and Range of Gene feature location.
                var metadata =
                    (GenBankMetadata) sequence.Metadata[Constants.GenBank];
                startLocResult =
                    locResolver.IsInStart(metadata.Features.Genes[0].Location, 289);
                endLocResult =
                    locResolver.IsInEnd(metadata.Features.Genes[0].Location, 1647);
                rangeLocResult =
                    locResolver.IsInRange(metadata.Features.Genes[0].Location, 300);

                Assert.IsTrue(startLocResult);
                Assert.IsTrue(endLocResult);
                Assert.IsTrue(rangeLocResult);

                // Log VSTest GUI.
                ApplicationLog.WriteLine(
                    "GenBank Features P1: Successfully validated the location resolver Gene feature start End and IsInRange methods");
            }
        }
        public void ValidateGenBankSubSequence()
        {
            // Get Values from XML node.
            string filePath = utilityObj.xmlUtil.GetTextValue(
                Constants.GenBankRepeatRegionQualifiersNode,
                Constants.FilePathNode);
            string expectedSubSequence = utilityObj.xmlUtil.GetTextValue(
                Constants.GenBankRepeatRegionQualifiersNode,
                Constants.ExpectedFeatureSubSequence);

            // Parse a GenBank file.
            ISequenceParser parserObj = new GenBankParser();
            {
                ISequence sequence = parserObj.ParseOne(filePath);
                ILocationResolver locResolver = new LocationResolver();

                // Get repeatregion subsequence.
                var metadata =
                    (GenBankMetadata) sequence.Metadata[Constants.GenBank];
                ISequence subSeq = locResolver.GetSubSequence(
                    metadata.Features.RepeatRegions[0].Location, sequence);
                var sequenceString = new string(subSeq.Select(a => (char) a).ToArray());

                // Validate repeat region subsequence.
                Assert.AreEqual(sequenceString, expectedSubSequence);

                // Log VSTest GUI.
                ApplicationLog.WriteLine(
                    "GenBank Features P1: Successfully validated the GenBank subSequence");
            }
        }