Exemplo n.º 1
0
        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"));
            }

        }
Exemplo n.º 2
0
        /// <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();
            }
        }
Exemplo n.º 3
0
        public void InValidateGenBankLocations()
        {
            // Build a location with invalid values
            ILocationBuilder locBuilder = new LocationBuilder();
            ILocation loc = null;
            try
            {
                loc = locBuilder.GetLocation(null);
                Assert.Fail();
            }
            catch (ArgumentNullException)
            {
                Assert.IsNull(loc);
                ApplicationLog.WriteLine(
                    "GenBankFeatures P2 : Validated the expected exception");
            }

            try
            {
                loc = locBuilder.GetLocation("Invalid");
                Assert.Fail();
            }
            catch (ArgumentException)
            {
                Assert.IsNull(loc);
                ApplicationLog.WriteLine(
                    "GenBankFeatures P2 : Validated the expected exception");
            }
        }
Exemplo n.º 4
0
        public void InValidateGenBankLocationPositions()
        {
            // Get Values from XML node.
            string location = utilityObj.xmlUtil.GetTextValue(
                Constants.LocationWithEndDataUsingOperatorNode, Constants.Location);
            string expectedEndData = utilityObj.xmlUtil.GetTextValue(
                Constants.LocationWithEndDataUsingOperatorNode, Constants.EndData);
            string expectedStartData = utilityObj.xmlUtil.GetTextValue(
                Constants.LocationWithEndDataUsingOperatorNode, Constants.StartData);
            string position = utilityObj.xmlUtil.GetTextValue(
                Constants.LocationWithEndDataUsingOperatorNode, Constants.Position);

            // Build a location.
            ILocationBuilder locBuilder = new LocationBuilder();
            Location loc = (Location)locBuilder.GetLocation(location);
            loc.Resolver = null;
            loc.EndData = expectedEndData;
            loc.StartData = expectedStartData;

            // Validate whether mentioned end data is present in the location
            // or not.
            try
            {
                loc.IsInEnd(Int32.Parse(position, (IFormatProvider)null));
                Assert.Fail();
            }
            catch (InvalidOperationException)
            {
                // Log to VSTest GUI.
                ApplicationLog.WriteLine(string.Format((IFormatProvider)null,
                    "GenBankFeatures P2 : Expected exception is verified"));
            }

            try
            {
                loc.IsInStart(Int32.Parse(position, (IFormatProvider)null));
                Assert.Fail();
            }
            catch (InvalidOperationException)
            {
                // Log to VSTest GUI.
                ApplicationLog.WriteLine(string.Format((IFormatProvider)null,
                    "GenBankFeatures P2 : Expected exception is verified"));
            }

            try
            {
                loc.IsInRange(Int32.Parse(position, (IFormatProvider)null));
                Assert.Fail();
            }
            catch (InvalidOperationException)
            {
                // Log to VSTest GUI.
                ApplicationLog.WriteLine(string.Format((IFormatProvider)null,
                    "GenBankFeatures P2 : Expected exception is verified"));
            }


        }
Exemplo n.º 5
0
        public void InValidateSubSequenceWithInvalidAccessionID()
        {
            // Get Values from XML node.
            string sequence = utilityObj.xmlUtil.GetTextValue(
                Constants.LocationWithDotOperatorNode,
                Constants.ExpectedSequence);
            string location = utilityObj.xmlUtil.GetTextValue(
                Constants.LocationWithDotOperatorNode,
                Constants.Location);
            string alphabet = utilityObj.xmlUtil.GetTextValue(
                Constants.LocationWithDotOperatorNode,
                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);
            loc.Accession = "Invalid";

            // Get sequence using location of the sequence with operator.
            try
            {
                loc.GetSubSequence(seqObj);
                Assert.Fail();
            }
            catch (ArgumentException)
            {
                ApplicationLog.WriteLine(string.Format((IFormatProvider)null,
                    "GenBankFeatures P2 : Validate the exception successfully"));
            }

            Dictionary<string, ISequence> refSeq = null;

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

        }
Exemplo n.º 6
0
        /// <summary>
        ///     Validate general Location builder.
        /// </summary>
        /// <param name="operatorPam">Different operator parameter name</param>
        /// <param name="nodeName">Different location string node name</param>
        /// <param name="isOperator">True if operator else false.</param>
        private void ValidateLocationBuilder(string nodeName,
                                             LocationOperatorParameter operatorPam, bool isOperator)
        {
            // Get Values from XML node.
            string locationString = utilityObj.xmlUtil.GetTextValue(
                nodeName, Constants.LocationStringValue);
            string locationStartPosition = utilityObj.xmlUtil.GetTextValue(
                nodeName, Constants.LoocationStartNode);
            string locationEndPosition = utilityObj.xmlUtil.GetTextValue(
                nodeName, Constants.LoocationEndNode);
            string locationSeperatorNode = utilityObj.xmlUtil.GetTextValue(
                nodeName, Constants.LocationSeperatorNode);
            string expectedLocationString = string.Empty;
            string sublocationStartPosition = utilityObj.xmlUtil.GetTextValue(
                nodeName, Constants.SubLocationStart);
            string sublocationEndPosition = utilityObj.xmlUtil.GetTextValue(
                nodeName, Constants.SubLocationEnd);
            string sublocationSeperatorNode = utilityObj.xmlUtil.GetTextValue(
                nodeName, Constants.SubLocationSeperator);
            string subLocationsCount = utilityObj.xmlUtil.GetTextValue(
                nodeName, Constants.SubLocationCount);

            // Build a new location 
            ILocationBuilder locationBuilderObj = new LocationBuilder();

            ILocation location = locationBuilderObj.GetLocation(locationString);
            expectedLocationString = locationBuilderObj.GetLocationString(location);

            // Validate constructed location starts,end and location string.
            Assert.AreEqual(locationStartPosition, location.LocationStart.ToString((IFormatProvider) null));
            Assert.AreEqual(locationString, expectedLocationString);
            Assert.AreEqual(locationEndPosition, location.LocationEnd.ToString((IFormatProvider) null));

            switch (operatorPam)
            {
                case LocationOperatorParameter.Join:
                    Assert.AreEqual(LocationOperator.Join, location.Operator);
                    break;
                case LocationOperatorParameter.Complement:
                    Assert.AreEqual(LocationOperator.Complement, location.Operator);
                    break;
                case LocationOperatorParameter.Order:
                    Assert.AreEqual(LocationOperator.Order, location.Operator);
                    break;
                default:
                    Assert.AreEqual(LocationOperator.None, location.Operator);
                    Assert.AreEqual(locationSeperatorNode,
                                    location.Separator.ToString(null));
                    Assert.IsTrue(string.IsNullOrEmpty(location.Accession));
                    Assert.IsNotNull(location.SubLocations);
                    break;
            }

            if (isOperator)
            {
                Assert.IsTrue(string.IsNullOrEmpty(location.Separator));
                Assert.AreEqual(sublocationEndPosition,
                                location.SubLocations[0].LocationEnd.ToString((IFormatProvider) null));
                Assert.AreEqual(sublocationSeperatorNode,
                                location.SubLocations[0].Separator.ToString(null));
                Assert.AreEqual(Convert.ToInt32(subLocationsCount, null),
                                location.SubLocations.Count);
                Assert.AreEqual(sublocationStartPosition,
                                location.SubLocations[0].LocationStart.ToString((IFormatProvider) null));
                Assert.AreEqual(LocationOperator.None,
                                location.SubLocations[0].Operator);
                Assert.AreEqual(0,
                                location.SubLocations[0].SubLocations.Count);
            }
        }
Exemplo n.º 7
0
        /// <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"));
        }
Exemplo n.º 8
0
        /// <summary>
        ///     Validate Location builder and location resolver.
        /// </summary>
        /// <param name="nodeName">xml node name.</param>
        /// <param name="FeatureOperator">Name of the operator used in a location</param>
        /// <param name="isOperator">
        ///     True if location resolver validation with
        ///     operator
        /// </param>
        private void ValidateGenBankLocationResolver(string nodeName,
                                                     FeatureOperator operatorName, bool isOperator)
        {
            // Get Values from XML node.
            string sequence = utilityObj.xmlUtil.GetTextValue(
                nodeName, Constants.ExpectedSequence);
            string location = utilityObj.xmlUtil.GetTextValue(
                nodeName, Constants.Location);
            string alphabet = utilityObj.xmlUtil.GetTextValue(
                nodeName, Constants.AlphabetNameNode);
            string expectedSeq = utilityObj.xmlUtil.GetTextValue(
                nodeName, Constants.ExpSequenceWithOperator);

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

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

            if (isOperator)
            {
                switch (operatorName)
                {
                    case FeatureOperator.Complement:
                        loc.Operator = LocationOperator.Complement;
                        break;
                    case FeatureOperator.Join:
                        loc.Operator = LocationOperator.Join;
                        break;
                    case FeatureOperator.Order:
                        loc.Operator = LocationOperator.Order;
                        break;
                    default:
                        break;
                }
            }

            // Get sequence using location of the sequence with operator.
            expectedSeqWithLoc = loc.GetSubSequence(seqObj);

            var sequenceString = new string(expectedSeqWithLoc.Select(a => (char) a).ToArray());
            Assert.AreEqual(expectedSeq, sequenceString);

            // Log to VSTest GUI.
            ApplicationLog.WriteLine(string.Format(null,
                                                   "GenBankFeatures P1 : Expected sequence is verfied '{0}'.",
                                                   sequenceString));
        }
Exemplo n.º 9
0
        public void ValidateCompareGenBankLocationsObject()
        {
            // Get Values from XML node.
            string locationFirstInput = utilityObj.xmlUtil.GetTextValue(
                Constants.CompareLocationsNode, Constants.Location1Node);
            string locationSecondInput = utilityObj.xmlUtil.GetTextValue(
                Constants.CompareLocationsNode, Constants.Location2Node);
            string locationThirdInput = utilityObj.xmlUtil.GetTextValue(
                Constants.CompareLocationsNode, Constants.Location3Node);

            // Create two location instance.
            ILocationBuilder locBuilder = new LocationBuilder();
            ILocation loc1 = locBuilder.GetLocation(locationFirstInput);
            object loc2 = locBuilder.GetLocation(locationSecondInput);
            object loc3 = locBuilder.GetLocation(locationThirdInput);

            // Compare first and second location instances.
            Assert.AreEqual(0, loc1.CompareTo(loc2));

            // Compare first and third location which are not identical.
            Assert.AreEqual(-1, loc1.CompareTo(loc3));

            // Compare first and null location.
            Assert.AreEqual(1, loc1.CompareTo(null));

            ApplicationLog.WriteLine(
                "GenBank Features P1: Successfully validated the GenBank Features");
        }