示例#1
0
        public void VirtualSequenceClone()
        {
            VirtualSequence virtualSeq = new VirtualSequence(Alphabets.DNA);
            string          id         = Guid.NewGuid().ToString(String.Empty);

            virtualSeq.ID           = id;
            virtualSeq.DisplayID    = "Id to display";
            virtualSeq.MoleculeType = MoleculeType.DNA;

            // Test cloning of data in Metadata property.
            virtualSeq.Metadata.Add("NotCloneable", Alphabets.DNA);
            Sequence seqCloneable = new Sequence(Alphabets.RNA);

            virtualSeq.Metadata.Add("CloneableValue", seqCloneable);

            VirtualSequence cloneCopy1 = virtualSeq.Clone();

            Assert.AreNotSame(cloneCopy1, virtualSeq);
            Assert.AreEqual(virtualSeq.ID, cloneCopy1.ID);
            Assert.AreEqual(virtualSeq.DisplayID, cloneCopy1.DisplayID);
            Assert.AreEqual(virtualSeq.MoleculeType, cloneCopy1.MoleculeType);
            Assert.AreNotSame(virtualSeq.Metadata, cloneCopy1.Metadata);
            Assert.AreSame(virtualSeq.Metadata["NotCloneable"], cloneCopy1.Metadata["NotCloneable"]);
            Assert.AreNotSame(virtualSeq.Metadata["CloneableValue"], cloneCopy1.Metadata["CloneableValue"]);
        }
示例#2
0
        public void ValidateVirtualSequenceGetObjectData()
        {
            ISequence virSeq =
                new VirtualSequence(Alphabets.DNA);

            SerializationInfo info =
                new SerializationInfo(typeof(Sequence),
                                      new FormatterConverter());
            StreamingContext context =
                new StreamingContext(StreamingContextStates.All);

            // Serialize the target object
            virSeq.GetObjectData(info, context);

            Assert.IsNull(info.GetValue(
                              string.Format("{0}:{1}",
                                            Constants.VirtualSequence, Constants.Documentation),
                              typeof(object)));
            Assert.IsNotNull(info.GetValue(
                                 string.Format("{0}:{1}",
                                               Constants.VirtualSequence, Constants.SeqInfo),
                                 typeof(BasicSequenceInfo)));
            Assert.IsNotNull(info.GetValue(
                                 string.Format("{0}:{1}",
                                               Constants.VirtualSequence, Constants.MoleculeType),
                                 typeof(MoleculeType)));
            Assert.AreEqual(null, info.GetValue(
                                string.Format("{0}:{1}",
                                              Constants.VirtualSequence, Constants.Documentation),
                                typeof(object)));
            Assert.AreEqual(
                Constants.MBFBasicSequenceInfo,
                info.GetValue(
                    string.Format("{0}:{1}",
                                  Constants.VirtualSequence, Constants.SeqInfo),
                    typeof(BasicSequenceInfo)).ToString());
            Assert.AreEqual(MoleculeType.Invalid,
                            info.GetValue(
                                string.Format("{0}:{1}",
                                              Constants.VirtualSequence, Constants.MoleculeType),
                                typeof(MoleculeType)));

            // Create a copy of Virtual Sequence
            object seqClone = virSeq.Clone();

            Assert.IsNotNull(seqClone);
            Assert.IsNotNull(seqClone);
            Assert.AreEqual(
                ((MBF.VirtualSequence)(seqClone)).Alphabet, Alphabets.DNA);
            Assert.AreEqual(
                ((MBF.VirtualSequence)(seqClone)).Documentation, null);
            Assert.AreEqual(
                ((MBF.VirtualSequence)(seqClone)).IsReadOnly, true);
            Assert.AreEqual(
                ((MBF.VirtualSequence)(seqClone)).MoleculeType, MoleculeType.Invalid);
            Assert.AreEqual(
                ((MBF.VirtualSequence)(seqClone)).UseEncoding, false);
        }
示例#3
0
        /// <summary>
        /// General method to validate creation of clone virtual seqeunce.
        /// <param name="nodeName">xml node name.</param>
        /// </summary>
        void ValidateGeneralVirtualSequenceCloning(
            string nodeName)
        {
            // Gets alphabet and properties from the Xml
            string alphabet = _utilityObj._xmlUtil.GetTextValue(
                nodeName, Constants.AlphabetNameNode);
            string id = _utilityObj._xmlUtil.GetTextValue(
                nodeName, Constants.Id);
            string diplayId = _utilityObj._xmlUtil.GetTextValue(
                nodeName, Constants.DisplayId);
            string expectedDocumentaion = _utilityObj._xmlUtil.GetTextValue(
                nodeName, Constants.Documentaion);

            // Logs information to the log file
            ApplicationLog.WriteLine(string.Format((IFormatProvider)null,
                                                   "Virtual Sequence P1: Sequence {0} is expected.", alphabet));

            // Create virtual seqeunce for an alphabet.
            VirtualSequence virtualSeq = new VirtualSequence(
                Utility.GetAlphabet(alphabet));

            // Set the value to virtual sequences.
            virtualSeq.ID            = id;
            virtualSeq.DisplayID     = diplayId;
            virtualSeq.Documentation = expectedDocumentaion;

            // Create a copy of virtual seqeunce.
            VirtualSequence cloneVirtualSeq = virtualSeq.Clone();

            // Validate the created clone virtual Sequence
            Assert.AreEqual(virtualSeq.DisplayID, cloneVirtualSeq.DisplayID);
            Assert.AreEqual(virtualSeq.ID, cloneVirtualSeq.ID);
            Assert.AreEqual(virtualSeq.Documentation, cloneVirtualSeq.Documentation);
            Assert.AreNotSame(virtualSeq, cloneVirtualSeq);
            Assert.AreEqual(virtualSeq.Alphabet, cloneVirtualSeq.Alphabet);
            Assert.AreEqual(virtualSeq.Count, cloneVirtualSeq.Count);
            Assert.AreEqual(virtualSeq.Statistics, cloneVirtualSeq.Statistics);

            // Logs to the NUnit GUI (Console.Out) window
            Console.WriteLine(string.Format((IFormatProvider)null,
                                            " VirtualSequence P1: Clone Virtual Sequence ID {0} is as expected.",
                                            cloneVirtualSeq.ID.ToString((IFormatProvider)null)));
            Console.WriteLine(string.Format((IFormatProvider)null,
                                            " VirtualSequence P1: Clone Virtual Sequence Display ID {0} is as expected.",
                                            cloneVirtualSeq.DisplayID.ToString((IFormatProvider)null)));
            Console.WriteLine(string.Format((IFormatProvider)null,
                                            " VirtualSequence P1:Clone Virtual Sequence count {0} is as expected.",
                                            cloneVirtualSeq.Count.ToString((IFormatProvider)null)));

            // Logs to the NUnit GUI (Console.Out) window
            Console.WriteLine(
                "Virtual Sequence P1:Clone Virtual Sequence validation is completed successfully.");
        }