示例#1
0
文件: StemLoop.cs 项目: cpatmoore/bio
 /// <summary>
 /// Private constructor for clone method.
 /// </summary>
 /// <param name="other">Other StemLoop instance.</param>
 private StemLoop(StemLoop other)
     : base(other) { }
        /// <summary>
        ///     Validate StemLoop features
        /// </summary>
        /// <param name="nodeName">XML node name</param>
        /// <param name="genMetadata">GenBank Metadata</param>
        private void ValidateGenBankStemLoopFeature(string nodeName,
                                                    GenBankMetadata genMetadata)
        {
            // Get Values from XML node.
            string expectedLocation = utilityObj.xmlUtil.GetTextValue(
                nodeName, Constants.Location);
            string expectedAllele = utilityObj.xmlUtil.GetTextValue(
                nodeName, Constants.AlleleNode);
            string featureCount = utilityObj.xmlUtil.GetTextValue(
                nodeName, Constants.QualifierCount);
            string expectedDbReference = utilityObj.xmlUtil.GetTextValue(
                nodeName, Constants.DbReferenceNode);
            string geneSymbol = utilityObj.xmlUtil.GetTextValue(
                nodeName, Constants.GeneSymbol);
            string expectedCitation = utilityObj.xmlUtil.GetTextValue(
                nodeName, Constants.CitationNode);
            string expectedExperiment = utilityObj.xmlUtil.GetTextValue(
                nodeName, Constants.ExperimentNode);
            string expectedFunction = utilityObj.xmlUtil.GetTextValue(
                nodeName, Constants.FunctionNode);
            string expectedGeneSynonym = utilityObj.xmlUtil.GetTextValue(
                nodeName, Constants.GeneSynonymNode);
            string expectedInference = utilityObj.xmlUtil.GetTextValue(
                nodeName, Constants.InferenceNode);
            string expectedLabel = utilityObj.xmlUtil.GetTextValue(
                nodeName, Constants.LabelNode);
            string expectedLocusTag = utilityObj.xmlUtil.GetTextValue(
                nodeName, Constants.LocusTagNode);
            string expectedNote = utilityObj.xmlUtil.GetTextValue(
                nodeName, Constants.Note);
            string expectedOldLocusTag = utilityObj.xmlUtil.GetTextValue(
                nodeName, Constants.OldLocusTagNode);
            string expectedMap = utilityObj.xmlUtil.GetTextValue(
                nodeName, Constants.GenbankMapNode);

            List<StemLoop> sLoopFeatureList = genMetadata.Features.StemLoops;
            var locBuilder = new LocationBuilder();

            // Create a copy of StemLoop feature.
            StemLoop cloneSLoop = sLoopFeatureList[0].Clone();

            // Validate transit peptide qualifiers.
            Assert.AreEqual(sLoopFeatureList.Count.ToString((IFormatProvider) null),
                            featureCount);
            Assert.AreEqual(cloneSLoop.GeneSymbol, geneSymbol);
            Assert.AreEqual(cloneSLoop.DatabaseCrossReference[0],
                            expectedDbReference);
            Assert.AreEqual(sLoopFeatureList[0].Allele,
                            expectedAllele);
            Assert.AreEqual(sLoopFeatureList[0].Citation[0],
                            expectedCitation);
            Assert.AreEqual(sLoopFeatureList[0].Experiment[0],
                            expectedExperiment);
            Assert.AreEqual(sLoopFeatureList[0].GenomicMapPosition,
                            expectedMap);
            Assert.AreEqual(sLoopFeatureList[0].GeneSynonym[0],
                            expectedGeneSynonym);
            Assert.AreEqual(sLoopFeatureList[0].Inference[0],
                            expectedInference);
            Assert.AreEqual(sLoopFeatureList[0].Label,
                            expectedLabel);
            Assert.AreEqual(locBuilder.GetLocationString(
                genMetadata.Features.StemLoops[0].Location),
                            expectedLocation);
            Assert.AreEqual(sLoopFeatureList[0].Note[0],
                            expectedNote);
            Assert.AreEqual(sLoopFeatureList[0].OldLocusTag[0],
                            expectedOldLocusTag);
            Assert.AreEqual(sLoopFeatureList[0].LocusTag[0],
                            expectedLocusTag);
            Assert.AreEqual(sLoopFeatureList[0].Function[0],
                            expectedFunction);
            Assert.IsTrue(string.IsNullOrEmpty(sLoopFeatureList[0].Operon));
            Assert.IsTrue(string.IsNullOrEmpty(sLoopFeatureList[0].StandardName));

            // Create a new StemLoop and validate the same.
            var stemLoop = new StemLoop(expectedLocation);
            var stemLoopWithILoc = new StemLoop(
                genMetadata.Features.StemLoops[0].Location);

            // Set qualifiers and validate them.
            stemLoop.Allele = expectedAllele;
            stemLoop.GeneSymbol = geneSymbol;
            stemLoopWithILoc.GenomicMapPosition = expectedMap;
            Assert.AreEqual(stemLoop.GeneSymbol, geneSymbol);
            Assert.AreEqual(stemLoop.Allele, expectedAllele);
            Assert.AreEqual(stemLoopWithILoc.GenomicMapPosition,
                            expectedMap);
        }