Exemple #1
0
        public void ValidateDerivedSeqInvalidRange()
        {
            // Pass protein sequences
            ISequence       seqObj     = new Sequence(Alphabets.DNA, "AAGGTT");
            DerivedSequence deriSeqObj = new DerivedSequence(seqObj);

            // Pass invalid index value and get the exception required
            try
            {
                deriSeqObj.Range(-1, -1);
                Assert.IsTrue(false);
            }
            catch (ArgumentOutOfRangeException)
            {
                ApplicationLog.WriteLine(
                    "DerivedSequenceP2TestCases : Successfully validated the exception for Range() method");
                Console.WriteLine(
                    "DerivedSequenceP2TestCases : Successfully validated the exception for Range() method");
            }

            // Pass length value lesser than zero.
            try
            {
                deriSeqObj.Range(1, -21);
                Assert.IsTrue(false);
            }
            catch (ArgumentOutOfRangeException)
            {
                ApplicationLog.WriteLine(
                    "DerivedSequenceP2TestCases : Successfully validated the exception for Range() method");
                Console.WriteLine(
                    "DerivedSequenceP2TestCases : Successfully validated the exception for Range() method");
            }

            // Pass invalid length and startPos value.
            try
            {
                deriSeqObj.Range(2, 6);
                Assert.IsTrue(false);
            }
            catch (ArgumentException)
            {
                ApplicationLog.WriteLine(
                    "DerivedSequenceP2TestCases : Successfully validated the exception for Range() method");
                Console.WriteLine(
                    "DerivedSequenceP2TestCases : Successfully validated the exception for Range() method");
            }
        }
Exemple #2
0
        /// <summary>
        /// Creates a dna derived sequence after adding and removing few items from original sequence.
        /// Get a sub sequence using Range() and validates it against expected sequence.
        /// </summary>
        /// <param name="nodeName"></param>
        private void ValidateDerivedSequenceRange(string nodeName)
        {
            // Get input and expected values from xml
            string expectedSequence = _utilityObj._xmlUtil.GetTextValue(
                nodeName, Constants.ExpectedSequence);
            string alphabetName = _utilityObj._xmlUtil.GetTextValue(
                nodeName, Constants.AlphabetNameNode);
            string removeRange = _utilityObj._xmlUtil.GetTextValue(
                nodeName, Constants.RemoveRange);
            string addSequence = _utilityObj._xmlUtil.GetTextValue(
                nodeName, Constants.AddSequence);
            string rangeSequence = _utilityObj._xmlUtil.GetTextValue(
                nodeName, Constants.RangeSequence);
            string    range    = _utilityObj._xmlUtil.GetTextValue(nodeName, Constants.Range);
            IAlphabet alphabet = Utility.GetAlphabet(alphabetName);

            // Create derived Sequence
            DerivedSequence derSequence = CreateDerivedSequence(
                alphabet, expectedSequence, addSequence, removeRange);

            string[] ranges   = range.Split(',');
            int      position = int.Parse(ranges[0], null);
            int      length   = int.Parse(ranges[1], null);

            ISequence sequence = derSequence.Range(position, length);

            // Validate range Sequence.
            Assert.AreEqual(rangeSequence, sequence.ToString());

            Console.WriteLine(
                "DerivedSequenceBvtTestCases:Validation of Range() of derived sequence completed successfully");
            ApplicationLog.WriteLine(
                "DerivedSequenceBvtTestCases:Validation of Range() of derived sequence completed successfully");
        }