Ejemplo n.º 1
0
        /// <summary>
        ///     Validate GenBank LTR features
        /// </summary>
        /// <param name="nodeName">XML node name</param>
        /// <param name="genMetadata">GenBank Metadata</param>
        private void ValidateGenBankLTRFeature(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<LongTerminalRepeat> LTRFeatureList =
                genMetadata.Features.LongTerminalRepeats;
            var locBuilder = new LocationBuilder();

            // Create a copy of Long Terminal Repeat feature.
            LongTerminalRepeat cloneLTR = LTRFeatureList[0].Clone();

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

            // Create a new LTR and validate.
            var ltr =
                new LongTerminalRepeat(expectedLocation);
            var ltrWithILoc = new LongTerminalRepeat(
                genMetadata.Features.LongTerminalRepeats[0].Location);

            // Set qualifiers and validate them.
            ltr.Allele = expectedAllele;
            ltr.GeneSymbol = geneSymbol;
            ltrWithILoc.GenomicMapPosition = expectedMap;
            Assert.AreEqual(ltr.GeneSymbol, geneSymbol);
            Assert.AreEqual(ltr.Allele, expectedAllele);
            Assert.AreEqual(ltrWithILoc.GenomicMapPosition,
                            expectedMap);
        }
Ejemplo n.º 2
0
        /// <summary>
        ///     Validate GenBank Operon features
        /// </summary>
        /// <param name="nodeName">XML node name</param>
        /// <param name="genMetadata">GenBank Metadata</param>
        private void ValidateGenBankOperon(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 expectedCitation = utilityObj.xmlUtil.GetTextValue(
                nodeName, Constants.CitationNode);
            string expectedExperiment = utilityObj.xmlUtil.GetTextValue(
                nodeName, Constants.ExperimentNode);
            string expectedInference = utilityObj.xmlUtil.GetTextValue(
                nodeName, Constants.InferenceNode);
            string expectedLabel = utilityObj.xmlUtil.GetTextValue(
                nodeName, Constants.LabelNode);
            string expectedNote = utilityObj.xmlUtil.GetTextValue(
                nodeName, Constants.Note);
            string expectedMap = utilityObj.xmlUtil.GetTextValue(
                nodeName, Constants.GenbankMapNode);

            List<OperonRegion> operonFeatureList =
                genMetadata.Features.OperonRegions;
            var locBuilder = new LocationBuilder();

            // Create a copy of Long Terminal Repeat feature.
            OperonRegion cloneOperon = operonFeatureList[0].Clone();

            // Validate Operon region qualifiers.
            Assert.AreEqual(operonFeatureList.Count.ToString((IFormatProvider) null),
                            featureCount);
            Assert.AreEqual(cloneOperon.DatabaseCrossReference[0],
                            expectedDbReference);
            Assert.AreEqual(operonFeatureList[0].Allele,
                            expectedAllele);
            Assert.AreEqual(operonFeatureList[0].Citation[0],
                            expectedCitation);
            Assert.AreEqual(operonFeatureList[0].Experiment[0],
                            expectedExperiment);
            Assert.AreEqual(operonFeatureList[0].GenomicMapPosition,
                            expectedMap);
            Assert.AreEqual(operonFeatureList[0].Inference[0],
                            expectedInference);
            Assert.AreEqual(operonFeatureList[0].Label,
                            expectedLabel);
            Assert.AreEqual(locBuilder.GetLocationString(
                genMetadata.Features.OperonRegions[0].Location),
                            expectedLocation);
            Assert.AreEqual(operonFeatureList[0].Note[0],
                            expectedNote);
            Assert.IsFalse(string.IsNullOrEmpty(operonFeatureList[0].Function.ToString()));
            Assert.AreEqual(operonFeatureList[0].GenomicMapPosition,
                            expectedMap);
            Assert.IsTrue(string.IsNullOrEmpty(operonFeatureList[0].Operon));
            Assert.IsFalse(string.IsNullOrEmpty(operonFeatureList[0].Phenotype.ToString()));
            Assert.IsTrue(string.IsNullOrEmpty(operonFeatureList[0].StandardName));
            Assert.IsFalse(operonFeatureList[0].Pseudo);

            // Create a new Operon feature using constructor.
            var operonRegion =
                new OperonRegion(expectedLocation);
            var operonRegionWithLoc = new OperonRegion(
                genMetadata.Features.OperonRegions[0].Location);

            // Set and validate qualifiers.
            operonRegion.Allele = expectedAllele;
            operonRegionWithLoc.GenomicMapPosition = expectedMap;
            Assert.AreEqual(operonRegionWithLoc.GenomicMapPosition,
                            expectedMap);
            Assert.AreEqual(operonRegion.Allele, expectedAllele);
        }
Ejemplo n.º 3
0
        public void ValidateGenBankMiscSignalFeatureQualifiers()
        {
            // Get Values from XML node.
            string filePath = utilityObj.xmlUtil.GetTextValue(
                Constants.GenBankMiscSignalNode, Constants.FilePathNode);
            string miscSignalLocation = utilityObj.xmlUtil.GetTextValue(
                Constants.GenBankMiscSignalNode, Constants.Location);
            string featureCount = utilityObj.xmlUtil.GetTextValue(
                Constants.GenBankMiscSignalNode, Constants.QualifierCount);
            string geneSymbol = utilityObj.xmlUtil.GetTextValue(
                Constants.GenBankMiscSignalNode, Constants.GeneSymbol);
            string function = utilityObj.xmlUtil.GetTextValue(
                Constants.GenBankMiscSignalNode, Constants.FunctionNode);
            string dbReferenceNode = utilityObj.xmlUtil.GetTextValue(
                Constants.GenBankMiscSignalNode, Constants.DbReferenceNode);

            // Parse a GenBank file.            
            ISequenceParser parserObj = new GenBankParser();
            {
                IEnumerable<ISequence> seqList = parserObj.Parse(filePath);
                var locBuilder = new LocationBuilder();

                // Validate Minus35Signal feature all qualifiers.
                var metadata =
                    (GenBankMetadata) seqList.ElementAt(0).Metadata[Constants.GenBank];
                List<MiscSignal> miscSignalList = metadata.Features.MiscSignals;

                // Create a clone of MiscSignal feature feature.
                MiscSignal cloneMiscSignal = miscSignalList[0].Clone();
                Assert.AreEqual(miscSignalList.Count.ToString((IFormatProvider) null), featureCount);
                Assert.AreEqual(cloneMiscSignal.GeneSymbol, geneSymbol);
                Assert.AreEqual(cloneMiscSignal.DatabaseCrossReference[0], dbReferenceNode);
                Assert.IsTrue(string.IsNullOrEmpty(miscSignalList[0].Allele.ToString(null)));
                Assert.IsFalse(string.IsNullOrEmpty(miscSignalList[0].Citation.ToString()));
                Assert.IsFalse(string.IsNullOrEmpty(miscSignalList[0].Experiment.ToString()));
                Assert.IsTrue(string.IsNullOrEmpty(miscSignalList[0].GenomicMapPosition));
                Assert.IsFalse(string.IsNullOrEmpty(miscSignalList[0].GeneSynonym.ToString()));
                Assert.IsFalse(string.IsNullOrEmpty(miscSignalList[0].Inference.ToString()));
                Assert.IsTrue(string.IsNullOrEmpty(miscSignalList[0].Label));
                Assert.AreEqual(locBuilder.GetLocationString(
                    metadata.Features.MiscSignals[0].Location), miscSignalLocation);
                Assert.IsFalse(string.IsNullOrEmpty(miscSignalList[0].Note.ToString()));
                Assert.IsFalse(string.IsNullOrEmpty(miscSignalList[0].OldLocusTag.ToString()));
                Assert.IsFalse(string.IsNullOrEmpty(miscSignalList[0].LocusTag.ToString()));
                Assert.AreEqual(miscSignalList[0].Function[0], function);
                Assert.IsTrue(string.IsNullOrEmpty(miscSignalList[0].Operon.ToString(null)));

                // Create a new MiscSignal signal and validate the same.
                var miscSignal = new MiscSignal(miscSignalLocation);
                var miscSignalWithIloc = new MiscSignal(
                    metadata.Features.MiscSignals[0].Location);

                // Set qualifiers and validate them.
                miscSignal.GeneSymbol = geneSymbol;
                miscSignalWithIloc.GeneSymbol = geneSymbol;
                Assert.AreEqual(miscSignal.GeneSymbol, geneSymbol);
                Assert.AreEqual(miscSignalWithIloc.GeneSymbol, geneSymbol);

                // Log VSTest GUI.
                ApplicationLog.WriteLine(
                    "GenBank Features P1: Successfully validated the GenBank Features");
            }
        }
Ejemplo n.º 4
0
        /// <summary>
        ///     Validate GenBank GCSignal features
        /// </summary>
        /// <param name="nodeName">XML node name</param>
        /// <param name="genMetadata">GenBank Metadata</param>
        private void ValidateGenBankGCSignalFeature(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 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<GcSingal> gcSignalFeatureList = genMetadata.Features.GCSignals;
            var locBuilder = new LocationBuilder();

            // Create a copy of GC_Signal feature.
            GcSingal cloneGCSignal = gcSignalFeatureList[0].Clone();

            // Validate GC_Signal qualifiers.
            Assert.AreEqual(gcSignalFeatureList.Count.ToString((IFormatProvider) null),
                            featureCount);
            Assert.AreEqual(cloneGCSignal.GeneSymbol,
                            geneSymbol);
            Assert.AreEqual(cloneGCSignal.DatabaseCrossReference[0],
                            expectedDbReference);
            Assert.AreEqual(gcSignalFeatureList[0].Allele,
                            expectedAllele);
            Assert.AreEqual(gcSignalFeatureList[0].Citation[0],
                            expectedCitation);
            Assert.AreEqual(gcSignalFeatureList[0].Experiment[0],
                            expectedExperiment);
            Assert.AreEqual(gcSignalFeatureList[0].GenomicMapPosition,
                            expectedMap);
            Assert.AreEqual(gcSignalFeatureList[0].GeneSynonym[0],
                            expectedGeneSynonym);
            Assert.AreEqual(gcSignalFeatureList[0].Inference[0],
                            expectedInference);
            Assert.AreEqual(gcSignalFeatureList[0].Label,
                            expectedLabel);
            Assert.AreEqual(locBuilder.GetLocationString(
                genMetadata.Features.GCSignals[0].Location),
                            expectedLocation);
            Assert.AreEqual(gcSignalFeatureList[0].Note[0],
                            expectedNote);
            Assert.AreEqual(gcSignalFeatureList[0].OldLocusTag[0],
                            expectedOldLocusTag);
            Assert.AreEqual(gcSignalFeatureList[0].LocusTag[0],
                            expectedLocusTag);

            // Create a new GCSignal and validate the same.
            var gcSignal = new GcSingal(expectedLocation);
            var gcSignalWithILoc = new GcSingal(
                genMetadata.Features.GCSignals[0].Location);

            // Set qualifiers and validate them.
            gcSignal.Allele = expectedAllele;
            gcSignal.GeneSymbol = geneSymbol;
            gcSignalWithILoc.GenomicMapPosition = expectedMap;
            Assert.AreEqual(gcSignal.GeneSymbol, geneSymbol);
            Assert.AreEqual(gcSignal.Allele, expectedAllele);
            Assert.AreEqual(gcSignalWithILoc.GenomicMapPosition,
                            expectedMap);
        }
Ejemplo n.º 5
0
        public void ValidateAdditionSingleGenBankQualifier()
        {
            // Get Values from XML node.
            string filePath = utilityObj.xmlUtil.GetTextValue(
                Constants.MediumSizeRNAGenBankFeaturesNode, Constants.FilePathNode);
            string addFirstKey = utilityObj.xmlUtil.GetTextValue(
                Constants.MediumSizeRNAGenBankFeaturesNode, Constants.FirstKey);
            string addFirstLocation = utilityObj.xmlUtil.GetTextValue(
                Constants.MediumSizeRNAGenBankFeaturesNode, Constants.FirstLocation);
            string addFirstQualifier = utilityObj.xmlUtil.GetTextValue(
                Constants.MediumSizeRNAGenBankFeaturesNode, Constants.FirstQualifier);
            string addSecondQualifier = utilityObj.xmlUtil.GetTextValue(
                Constants.MediumSizeRNAGenBankFeaturesNode, Constants.SecondQualifier);

            // Parse a GenBank file.            
            ISequenceParser parserObj = new GenBankParser();
            {
                IEnumerable<ISequence> seqList = parserObj.Parse(filePath);
                var locBuilder = new LocationBuilder();

                // Validate Minus35Signal feature all qualifiers.
                var metadata =
                    (GenBankMetadata) seqList.ElementAt(0).Metadata[Constants.GenBank];

                // Add a new features to Genbank features list.
                metadata.Features = new SequenceFeatures();
                var feature = new FeatureItem(addFirstKey, addFirstLocation);
                var qualifierValues = new List<string>();
                qualifierValues.Add(addFirstQualifier);
                qualifierValues.Add(addFirstQualifier);
                feature.Qualifiers.Add(addFirstQualifier, qualifierValues);
                metadata.Features.All.Add(feature);

                qualifierValues = new List<string>();
                qualifierValues.Add(addSecondQualifier);
                qualifierValues.Add(addSecondQualifier);
                feature.Qualifiers.Add(addSecondQualifier, qualifierValues);
                metadata.Features.All.Add(feature);

                // Validate added GenBank features.
                Assert.AreEqual(
                    metadata.Features.All[0].Key.ToString(null), addFirstKey);
                Assert.AreEqual(
                    locBuilder.GetLocationString(metadata.Features.All[0].Location),
                    addFirstLocation);
            }
        }
Ejemplo 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);
            }
        }
Ejemplo n.º 7
0
        /// <summary>
        ///     Validate GenBank Promoter feature qualifiers.
        /// </summary>
        /// <param name="nodeName">xml node name.</param>
        private void ValidateGenBankPromoterFeatureQualifiers(string nodeName)
        {
            // Get Values from XML node.
            string filePath = utilityObj.xmlUtil.GetTextValue(
                nodeName, Constants.FilePathNode);
            string expectedPromoterComplement = utilityObj.xmlUtil.GetTextValue(
                nodeName, Constants.PromoterComplement);
            string expectedPromoterCount = utilityObj.xmlUtil.GetTextValue(
                nodeName, Constants.PromoterCount);

            // Parse a GenBank file.            
            ISequenceParser parserObj = new GenBankParser();
            {
                IEnumerable<ISequence> seqList = parserObj.Parse(filePath);
                var locBuilder = new LocationBuilder();

                // Validate Misc feature all qualifiers.
                var metadata =
                    (GenBankMetadata) seqList.ElementAt(0).Metadata[Constants.GenBank];
                List<Promoter> promotersFeatureList =
                    metadata.Features.Promoters;
                Assert.AreEqual(locBuilder.GetLocationString(
                    metadata.Features.Promoters[0].Location),
                                expectedPromoterComplement);
                Assert.AreEqual(promotersFeatureList.Count.ToString((IFormatProvider) null),
                                expectedPromoterCount);
                Assert.IsTrue(string.IsNullOrEmpty(promotersFeatureList[0].GeneSymbol));
                Assert.IsTrue(string.IsNullOrEmpty(promotersFeatureList[0].Allele));
                Assert.IsFalse(string.IsNullOrEmpty(promotersFeatureList[0].Citation.ToString()));
                Assert.IsFalse(string.IsNullOrEmpty(promotersFeatureList[0].Experiment.ToString()));
                Assert.IsFalse(string.IsNullOrEmpty(promotersFeatureList[0].Function.ToString()));
                Assert.IsFalse(string.IsNullOrEmpty(promotersFeatureList[0].GeneSynonym.ToString()));
                Assert.IsTrue(string.IsNullOrEmpty(promotersFeatureList[0].GenomicMapPosition));
                Assert.IsFalse(string.IsNullOrEmpty(promotersFeatureList[0].Inference.ToString()));
                Assert.IsTrue(string.IsNullOrEmpty(promotersFeatureList[0].Label));
                Assert.IsFalse(string.IsNullOrEmpty(promotersFeatureList[0].OldLocusTag.ToString()));
                Assert.IsFalse(promotersFeatureList[0].Pseudo);
                Assert.IsTrue(string.IsNullOrEmpty(promotersFeatureList[0].StandardName));

                // Log VSTest GUI.
                ApplicationLog.WriteLine(
                    "GenBank Features P1: Successfully validated the GenBank Features");
            }
        }
Ejemplo n.º 8
0
        /// <summary>
        ///     Validate GenBank Non Coding RNA features
        /// </summary>
        /// <param name="nodeName">XML node name</param>
        /// <param name="genMetadata">GenBank Metadata</param>
        private void ValidateGenBankNonCodingRNA(string nodeName,
                                                 GenBankMetadata genMetadata)
        {
            // Get Values from XML node.           
            string expectedLocation = utilityObj.xmlUtil.GetTextValue(
                nodeName, Constants.Location);
            string featureCount = utilityObj.xmlUtil.GetTextValue(
                nodeName, Constants.QualifierCount);
            string expectedLabel = utilityObj.xmlUtil.GetTextValue(
                nodeName, Constants.LabelNode);
            string expectedNonCodingRnaClass = utilityObj.xmlUtil.GetTextValue(
                nodeName, Constants.NonCodingRnaClassNode);

            List<NonCodingRna> nonCodingRNAFeatureList =
                genMetadata.Features.NonCodingRNAs;
            var locBuilder = new LocationBuilder();

            // Create a copy of Non coding RNA feature.
            NonCodingRna cloneNonCodingRNA =
                nonCodingRNAFeatureList[0].Clone();

            // Validate Non Coding RNA Region qualifiers.
            Assert.AreEqual(nonCodingRNAFeatureList.Count.ToString((IFormatProvider) null),
                            featureCount);
            Assert.AreEqual(nonCodingRNAFeatureList[0].NonCodingRnaClass,
                            expectedNonCodingRnaClass);
            Assert.AreEqual(cloneNonCodingRNA.Label,
                            expectedLabel);
            Assert.AreEqual(locBuilder.GetLocationString(
                genMetadata.Features.NonCodingRNAs[0].Location),
                            expectedLocation);

            // Create a non Coding RNA and validate the same.
            var nRNA =
                new NonCodingRna(genMetadata.Features.NonCodingRNAs[0].Location);
            var nRNAWithLocation =
                new NonCodingRna(expectedLocation);

            // Set properties 
            nRNA.NonCodingRnaClass = expectedNonCodingRnaClass;
            nRNAWithLocation.NonCodingRnaClass = expectedNonCodingRnaClass;

            // Validate created nRNA.
            Assert.AreEqual(nRNA.NonCodingRnaClass,
                            expectedNonCodingRnaClass);
            Assert.AreEqual(nRNAWithLocation.NonCodingRnaClass,
                            expectedNonCodingRnaClass);
        }
Ejemplo n.º 9
0
        public void ValidateGenBankRepeatRegionFeatureQualifiers()
        {
            // Get Values from XML node.
            string filePath = utilityObj.xmlUtil.GetTextValue(
                Constants.GenBankRepeatRegionQualifiersNode,
                Constants.FilePathNode);
            string repeatRegionCount = utilityObj.xmlUtil.GetTextValue(
                Constants.GenBankRepeatRegionQualifiersNode,
                Constants.ThreePrimeUTRCount);
            string expectedLocation = utilityObj.xmlUtil.GetTextValue(
                Constants.GenBankRepeatRegionQualifiersNode,
                Constants.RepeatRegionLocation);

            // Parse a GenBank file.
            ISequenceParser parserObj = new GenBankParser();
            {
                IEnumerable<ISequence> seqList = parserObj.Parse(filePath);
                var locBuilder = new LocationBuilder();

                // Validate RepeatRegion feature all qualifiers.
                var metadata =
                    (GenBankMetadata) seqList.ElementAt(0).Metadata[Constants.GenBank];
                List<RepeatRegion> repeatRegionsList =
                    metadata.Features.RepeatRegions;
                Assert.AreEqual(repeatRegionsList.Count.ToString((IFormatProvider) null),
                                repeatRegionCount);
                Assert.IsTrue(string.IsNullOrEmpty(repeatRegionsList[0].GeneSymbol));
                Assert.AreEqual(locBuilder.GetLocationString(
                    metadata.Features.RepeatRegions[0].Location),
                                expectedLocation);
                Assert.IsFalse(string.IsNullOrEmpty(repeatRegionsList[0].DatabaseCrossReference.ToString()));
                Assert.IsFalse(string.IsNullOrEmpty(repeatRegionsList[0].Note.ToString()));
                Assert.IsTrue(string.IsNullOrEmpty(repeatRegionsList[0].Allele));
                Assert.IsFalse(string.IsNullOrEmpty(repeatRegionsList[0].Citation.ToString()));
                Assert.IsFalse(string.IsNullOrEmpty(repeatRegionsList[0].Experiment.ToString()));
                Assert.IsFalse(string.IsNullOrEmpty(repeatRegionsList[0].GeneSynonym.ToString()));
                Assert.IsTrue(string.IsNullOrEmpty(repeatRegionsList[0].GenomicMapPosition));
                Assert.IsTrue(string.IsNullOrEmpty(repeatRegionsList[0].Label));
                Assert.IsFalse(string.IsNullOrEmpty(repeatRegionsList[0].OldLocusTag.ToString()));
                Assert.IsFalse(string.IsNullOrEmpty(repeatRegionsList[0].LocusTag.ToString()));

                // Log VSTest GUI.
                ApplicationLog.WriteLine(
                    "GenBank Features P1: Successfully validated the GenBank Features");
            }
        }
Ejemplo n.º 10
0
        /// <summary>
        ///     Validate GenBank tRNA features.
        /// </summary>
        /// <param name="nodeName">xml node name.</param>
        private void ValidateGenBanktRNAFeatureQualifiers(string nodeName)
        {
            // Get Values from XML node.
            string filePath = utilityObj.xmlUtil.GetTextValue(
                nodeName, Constants.FilePathNode);
            string tRNAsCount = utilityObj.xmlUtil.GetTextValue(
                nodeName, Constants.tRNACount);
            string tRNAGeneSymbol = utilityObj.xmlUtil.GetTextValue(
                nodeName, Constants.TRNAGeneSymbol);
            string tRNAComplement = utilityObj.xmlUtil.GetTextValue(
                nodeName, Constants.TRNAComplement);
            string tRNADBCount = utilityObj.xmlUtil.GetTextValue(
                nodeName, Constants.CDSCodonStart);

            // Parse a GenBank file.
            ISequenceParser parserObj = new GenBankParser();
            {
                IEnumerable<ISequence> seqList = parserObj.Parse(filePath);
                var locBuilder = new LocationBuilder();

                var metadata =
                    (GenBankMetadata) seqList.ElementAt(0).Metadata[Constants.GenBank];
                List<TransferRna> tRANsList =
                    metadata.Features.TransferRNAs;
                Assert.AreEqual(tRANsList.Count.ToString((IFormatProvider) null),
                                tRNAsCount);
                Assert.AreEqual(tRANsList[0].GeneSymbol.ToString(null),
                                tRNAGeneSymbol);
                Assert.AreEqual(tRANsList[0].DatabaseCrossReference.Count,
                                Convert.ToInt32(tRNADBCount, null));
                Assert.IsTrue(string.IsNullOrEmpty(tRANsList[0].Allele));
                Assert.IsFalse(string.IsNullOrEmpty(tRANsList[0].Citation.ToString()));
                Assert.IsFalse(string.IsNullOrEmpty(tRANsList[0].Experiment.ToString()));
                Assert.IsFalse(string.IsNullOrEmpty(tRANsList[0].Function.ToString()));
                Assert.IsFalse(string.IsNullOrEmpty(tRANsList[0].GeneSynonym.ToString()));
                Assert.IsTrue(string.IsNullOrEmpty(tRANsList[0].GenomicMapPosition));
                Assert.IsFalse(string.IsNullOrEmpty(tRANsList[0].Inference.ToString()));
                Assert.IsTrue(string.IsNullOrEmpty(tRANsList[0].Label));
                Assert.AreEqual(locBuilder.GetLocationString(
                    metadata.Features.TransferRNAs[0].Location),
                                tRNAComplement);
                Assert.IsFalse(string.IsNullOrEmpty(tRANsList[0].Note.ToString()));
                Assert.IsFalse(string.IsNullOrEmpty(tRANsList[0].OldLocusTag.ToString()));
                Assert.IsFalse(tRANsList[0].Pseudo);
                Assert.IsTrue(string.IsNullOrEmpty(tRANsList[0].StandardName));
                Assert.IsFalse(tRANsList[0].TransSplicing);

                // Log VSTest GUI.
                ApplicationLog.WriteLine(
                    "GenBank Features P1: Successfully validated the GenBank Features");
            }
        }
Ejemplo n.º 11
0
        public void ValidateGenBankMiscRNAFeatureQualifiers()
        {
            // Get Values from XML node.
            string filePath = utilityObj.xmlUtil.GetTextValue(
                Constants.ProteinGenBankMiscRNAQualifiersNode,
                Constants.FilePathNode);
            string miscRnaCount = utilityObj.xmlUtil.GetTextValue(
                Constants.ProteinGenBankMiscRNAQualifiersNode,
                Constants.FeaturesCount);
            string miscRnaLocation = utilityObj.xmlUtil.GetTextValue(
                Constants.ProteinGenBankMiscRNAQualifiersNode,
                Constants.Location);

            // Parse a GenBank file.            
            ISequenceParser parserObj = new GenBankParser();
            IEnumerable<ISequence> seqList = parserObj.Parse(filePath);
            var locBuilder = new LocationBuilder();

            // Validate MiscRNA feature all qualifiers.
            var metadata =
                (GenBankMetadata) seqList.ElementAt(0).Metadata[Constants.GenBank];
            List<MiscRna> miscRnaList = metadata.Features.MiscRNAs;

            // Create a clone of MiscRNA feature and validate
            MiscRna cloneMiscRna = miscRnaList[0].Clone();
            Assert.AreEqual(miscRnaList.Count.ToString((IFormatProvider) null), miscRnaCount);
            Assert.AreEqual(locBuilder.GetLocationString(
                metadata.Features.MiscRNAs[0].Location), miscRnaLocation);
            Assert.IsTrue(string.IsNullOrEmpty(cloneMiscRna.GeneSymbol));
            Assert.IsFalse(string.IsNullOrEmpty(cloneMiscRna.DatabaseCrossReference.ToString()));
            Assert.IsTrue(string.IsNullOrEmpty(miscRnaList[0].Allele));
            Assert.IsFalse(string.IsNullOrEmpty(miscRnaList[0].Citation.ToString()));
            Assert.IsFalse(string.IsNullOrEmpty(miscRnaList[0].Experiment.ToString()));
            Assert.IsFalse(string.IsNullOrEmpty(miscRnaList[0].GeneSynonym.ToString()));
            Assert.IsTrue(string.IsNullOrEmpty(miscRnaList[0].GenomicMapPosition));
            Assert.IsTrue(string.IsNullOrEmpty(miscRnaList[0].Label));
            Assert.IsFalse(string.IsNullOrEmpty(miscRnaList[0].OldLocusTag.ToString()));
            Assert.IsTrue(string.IsNullOrEmpty(miscRnaList[0].StandardName));
            Assert.IsFalse(string.IsNullOrEmpty(miscRnaList[0].LocusTag.ToString()));
            Assert.IsFalse(miscRnaList[0].Pseudo);
            Assert.IsFalse(string.IsNullOrEmpty(miscRnaList[0].Function.ToString()));
            Assert.IsTrue(string.IsNullOrEmpty(miscRnaList[0].Operon));

            // Log VSTest GUI.
            ApplicationLog.WriteLine(
                "GenBank Features P1: Successfully validated the GenBank Features");
        }
Ejemplo n.º 12
0
        public void ValidateGenBankInterveningDNAFeatureQualifiers()
        {
            // Get Values from XML node.
            string filePath = utilityObj.xmlUtil.GetTextValue(
                Constants.GenBankInterveningDNA, Constants.FilePathNode);
            string iDNALocation = utilityObj.xmlUtil.GetTextValue(
                Constants.GenBankInterveningDNA, Constants.Location);
            string featureCount = utilityObj.xmlUtil.GetTextValue(
                Constants.GenBankInterveningDNA, Constants.QualifierCount);

            // Parse a GenBank file.
            ISequenceParser parserObj = new GenBankParser();
            {
                IEnumerable<ISequence> seqList = parserObj.Parse(filePath);
                var locBuilder = new LocationBuilder();

                var metadata =
                    (GenBankMetadata) seqList.ElementAt(0).Metadata[Constants.GenBank];
                List<InterveningDna> iDNAList = metadata.Features.InterveningDNAs;

                // Create a clone copy and validate.
                InterveningDna iDNAClone = iDNAList[0].Clone();
                Assert.AreEqual(iDNAList.Count.ToString((IFormatProvider) null), featureCount);
                Assert.IsTrue(string.IsNullOrEmpty(iDNAClone.GeneSymbol.ToString(null)));
                Assert.IsFalse(string.IsNullOrEmpty(iDNAClone.DatabaseCrossReference.ToString()));
                Assert.IsTrue(string.IsNullOrEmpty(iDNAClone.Allele));
                Assert.IsFalse(string.IsNullOrEmpty(iDNAList[0].Citation.ToString()));
                Assert.IsFalse(string.IsNullOrEmpty(iDNAList[0].Experiment.ToString()));
                Assert.IsTrue(string.IsNullOrEmpty(iDNAList[0].GenomicMapPosition));
                Assert.IsFalse(string.IsNullOrEmpty(iDNAList[0].GeneSynonym.ToString()));
                Assert.IsFalse(string.IsNullOrEmpty(iDNAList[0].Inference.ToString()));
                Assert.IsTrue(string.IsNullOrEmpty(iDNAList[0].Label));
                Assert.AreEqual(locBuilder.GetLocationString(
                    metadata.Features.InterveningDNAs[0].Location), iDNALocation);
                Assert.IsFalse(string.IsNullOrEmpty(iDNAList[0].Note.ToString()));
                Assert.IsFalse(string.IsNullOrEmpty(iDNAList[0].OldLocusTag.ToString()));
                Assert.IsFalse(string.IsNullOrEmpty(iDNAList[0].LocusTag.ToString()));
                Assert.IsFalse(string.IsNullOrEmpty(iDNAList[0].OldLocusTag.ToString()));
                Assert.IsFalse(string.IsNullOrEmpty(iDNAList[0].Function.ToString()));
                Assert.IsTrue(string.IsNullOrEmpty(iDNAList[0].Number));
                Assert.IsTrue(string.IsNullOrEmpty(iDNAList[0].StandardName));

                // Create a new Intervening DNA signal and validate the same.
                var iDNA = new InterveningDna(iDNALocation);
                var iDNAWithIloc = new InterveningDna(
                    metadata.Features.DisplacementLoops[0].Location);

                // Set qualifiers and validate them.
                iDNA.GeneSymbol = iDNALocation;
                iDNAWithIloc.GeneSymbol = iDNALocation;
                Assert.AreEqual(iDNA.GeneSymbol, iDNALocation);
                Assert.AreEqual(iDNAWithIloc.GeneSymbol, iDNALocation);

                // Log VSTest GUI.
                ApplicationLog.WriteLine(
                    "GenBank Features P1: Successfully validated the GenBank Features");
            }
        }
Ejemplo n.º 13
0
        public void ValidateGenBankDLoopFeatureQualifiers()
        {
            // Get Values from XML node.
            string filePath = utilityObj.xmlUtil.GetTextValue(
                Constants.GenBankDLoopNode, Constants.FilePathNode);
            string dLoopLocation = utilityObj.xmlUtil.GetTextValue(
                Constants.GenBankDLoopNode, Constants.Location);
            string featureCount = utilityObj.xmlUtil.GetTextValue(
                Constants.GenBankDLoopNode, Constants.QualifierCount);
            string geneSymbol = utilityObj.xmlUtil.GetTextValue(
                Constants.GenBankDLoopNode, Constants.GeneSymbol);

            // Parse a GenBank file.
            ISequenceParser parserObj = new GenBankParser();
            {
                IEnumerable<ISequence> seqList = parserObj.Parse(filePath);
                var locBuilder = new LocationBuilder();

                var metadata =
                    (GenBankMetadata) seqList.ElementAt(0).Metadata[Constants.GenBank];
                List<DisplacementLoop> dLoopList = metadata.Features.DisplacementLoops;

                // Create a clone of DLoop feature feature.
                DisplacementLoop cloneDLoop = dLoopList[0].Clone();
                Assert.AreEqual(dLoopList.Count.ToString((IFormatProvider) null), featureCount);
                Assert.AreEqual(cloneDLoop.GeneSymbol, geneSymbol);
                Assert.IsFalse(string.IsNullOrEmpty(cloneDLoop.DatabaseCrossReference.ToString()));
                Assert.IsTrue(string.IsNullOrEmpty(dLoopList[0].Allele.ToString(null)));
                Assert.IsFalse(string.IsNullOrEmpty(dLoopList[0].Citation.ToString()));
                Assert.IsFalse(string.IsNullOrEmpty(dLoopList[0].Experiment.ToString()));
                Assert.IsTrue(string.IsNullOrEmpty(dLoopList[0].GenomicMapPosition));
                Assert.IsFalse(string.IsNullOrEmpty(dLoopList[0].GeneSynonym.ToString()));
                Assert.IsFalse(string.IsNullOrEmpty(dLoopList[0].Inference.ToString()));
                Assert.IsTrue(string.IsNullOrEmpty(dLoopList[0].Label));
                Assert.AreEqual(locBuilder.GetLocationString(
                    metadata.Features.DisplacementLoops[0].Location), dLoopLocation);
                Assert.IsFalse(string.IsNullOrEmpty(dLoopList[0].Note.ToString()));
                Assert.IsFalse(string.IsNullOrEmpty(dLoopList[0].OldLocusTag.ToString()));
                Assert.IsFalse(string.IsNullOrEmpty(dLoopList[0].LocusTag.ToString()));
                Assert.IsFalse(string.IsNullOrEmpty(dLoopList[0].OldLocusTag.ToString()));

                // Create a new DLoop signal and validate the same.
                var dLoop = new DisplacementLoop(dLoopLocation);
                var dLoopWithIloc = new DisplacementLoop(
                    metadata.Features.DisplacementLoops[0].Location);

                // Set qualifiers and validate them.
                dLoop.GeneSymbol = geneSymbol;
                dLoopWithIloc.GeneSymbol = geneSymbol;
                Assert.AreEqual(dLoop.GeneSymbol, geneSymbol);
                Assert.AreEqual(dLoopWithIloc.GeneSymbol, geneSymbol);

                // Log VSTest GUI.
                ApplicationLog.WriteLine(
                    "GenBank Features P1: Successfully validated the GenBank Features");
            }
        }
Ejemplo n.º 14
0
        /// <summary>
        ///     Validate GenBank UnsureSequenceRegion features
        /// </summary>
        /// <param name="nodeName">XML node name</param>
        /// <param name="genMetadata">GenBank Metadata</param>
        private void ValidateGenBankUnsureSequenceRegion(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 expectedInference = utilityObj.xmlUtil.GetTextValue(
                nodeName, Constants.InferenceNode);
            string expectedLabel = utilityObj.xmlUtil.GetTextValue(
                nodeName, Constants.LabelNode);
            string expectedNote = utilityObj.xmlUtil.GetTextValue(
                nodeName, Constants.Note);
            string expectedMap = utilityObj.xmlUtil.GetTextValue(
                nodeName, Constants.GenbankMapNode);

            List<UnsureSequenceRegion> unsureSeqRegionFeatureList =
                genMetadata.Features.UnsureSequenceRegions;

            // Create a copy of Unsure Seq Region feature.
            UnsureSequenceRegion cloneUnSureSeqRegion =
                unsureSeqRegionFeatureList[0].Clone();
            var locBuilder = new LocationBuilder();

            // Validate Unsure Seq Region qualifiers.
            Assert.AreEqual(unsureSeqRegionFeatureList.Count.ToString((IFormatProvider) null)
                            , featureCount);
            Assert.AreEqual(cloneUnSureSeqRegion.DatabaseCrossReference[0],
                            expectedDbReference);
            Assert.AreEqual(cloneUnSureSeqRegion.GeneSymbol,
                            geneSymbol);
            Assert.AreEqual(unsureSeqRegionFeatureList[0].Allele,
                            expectedAllele);
            Assert.AreEqual(unsureSeqRegionFeatureList[0].Citation[0],
                            expectedCitation);
            Assert.AreEqual(unsureSeqRegionFeatureList[0].Experiment[0],
                            expectedExperiment);
            Assert.AreEqual(unsureSeqRegionFeatureList[0].GenomicMapPosition,
                            expectedMap);
            Assert.AreEqual(unsureSeqRegionFeatureList[0].Inference[0],
                            expectedInference);
            Assert.AreEqual(unsureSeqRegionFeatureList[0].Label,
                            expectedLabel);
            Assert.AreEqual(locBuilder.GetLocationString(
                genMetadata.Features.UnsureSequenceRegions[0].Location),
                            expectedLocation);
            Assert.AreEqual(unsureSeqRegionFeatureList[0].Note[0],
                            expectedNote);
            Assert.AreEqual(unsureSeqRegionFeatureList[0].GenomicMapPosition,
                            expectedMap);
            Assert.IsFalse(string.IsNullOrEmpty(unsureSeqRegionFeatureList[0].Compare.ToString()));
            Assert.IsTrue(string.IsNullOrEmpty(unsureSeqRegionFeatureList[0].Replace));

            // Create a new Unsure feature using constructor.
            var unsureRegion =
                new UnsureSequenceRegion(expectedLocation);
            var unsureRegionWithLoc =
                new UnsureSequenceRegion(
                    genMetadata.Features.UnsureSequenceRegions[0].Location);

            // Set and validate qualifiers.
            unsureRegion.Allele = expectedAllele;
            unsureRegionWithLoc.GeneSymbol = geneSymbol;
            unsureRegionWithLoc.GenomicMapPosition = expectedMap;
            Assert.AreEqual(unsureRegionWithLoc.GenomicMapPosition,
                            expectedMap);
            Assert.AreEqual(unsureRegion.Allele, expectedAllele);
            Assert.AreEqual(unsureRegionWithLoc.GeneSymbol,
                            geneSymbol);
        }
Ejemplo n.º 15
0
        /// <summary>
        ///     Validate TrnsitPeptide features
        /// </summary>
        /// <param name="nodeName">XML node name</param>
        /// <param name="genMetadata">GenBank Metadata</param>
        private void ValidateGenBankTrnsitPeptideFeature(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<TransitPeptide> tansitPeptideFeatureList =
                genMetadata.Features.TransitPeptides;
            var locBuilder = new LocationBuilder();

            // Create a copy of transit peptide features.
            TransitPeptide cloneTransit = tansitPeptideFeatureList[0].Clone();

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

            // Create a new TransitPeptide and validate the same.
            var tPeptide = new TransitPeptide(expectedLocation);
            var tPeptideWithILoc = new TransitPeptide(
                genMetadata.Features.TransitPeptides[0].Location);

            // Set qualifiers and validate them.
            tPeptide.Allele = expectedAllele;
            tPeptide.GeneSymbol = geneSymbol;
            tPeptideWithILoc.GenomicMapPosition = expectedMap;
            Assert.AreEqual(tPeptide.GeneSymbol, geneSymbol);
            Assert.AreEqual(tPeptide.Allele, expectedAllele);
            Assert.AreEqual(tPeptideWithILoc.GenomicMapPosition,
                            expectedMap);
        }
Ejemplo n.º 16
0
        /// <summary>
        ///     Validate GenBank RibosomeBindingSite features
        /// </summary>
        /// <param name="nodeName">XML node name</param>
        /// <param name="genMetadata">GenBank Metadata</param>
        private void ValidateGenBankRibosomeBindingSite(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 expectedInference = utilityObj.xmlUtil.GetTextValue(
                nodeName, Constants.InferenceNode);
            string expectedLabel = utilityObj.xmlUtil.GetTextValue(
                nodeName, Constants.LabelNode);
            string expectedNote = utilityObj.xmlUtil.GetTextValue(
                nodeName, Constants.Note);
            string expectedMap = utilityObj.xmlUtil.GetTextValue(
                nodeName, Constants.GenbankMapNode);

            List<RibosomeBindingSite> ribosomeSite =
                genMetadata.Features.RibosomeBindingSites;

            // Create a copy of RibosomeBindigSite  Region feature.
            RibosomeBindingSite cloneRibosomeSite =
                ribosomeSite[0].Clone();
            var locBuilder = new LocationBuilder();

            // Validate RibosomeBindigSite qualifiers.
            Assert.AreEqual(ribosomeSite.Count.ToString((IFormatProvider) null)
                            , featureCount);
            Assert.AreEqual(cloneRibosomeSite.DatabaseCrossReference[0],
                            expectedDbReference);
            Assert.AreEqual(cloneRibosomeSite.GeneSymbol,
                            geneSymbol);
            Assert.AreEqual(ribosomeSite[0].Allele,
                            expectedAllele);
            Assert.AreEqual(ribosomeSite[0].Citation[0],
                            expectedCitation);
            Assert.AreEqual(ribosomeSite[0].Experiment[0],
                            expectedExperiment);
            Assert.AreEqual(ribosomeSite[0].Inference[0],
                            expectedInference);
            Assert.AreEqual(ribosomeSite[0].Label,
                            expectedLabel);
            Assert.AreEqual(locBuilder.GetLocationString(
                genMetadata.Features.RibosomeBindingSites[0].Location),
                            expectedLocation);
            Assert.AreEqual(ribosomeSite[0].Note[0],
                            expectedNote);
            Assert.AreEqual(ribosomeSite[0].GenomicMapPosition,
                            expectedMap);
            Assert.IsNotNull(ribosomeSite[0].OldLocusTag[0]);
            Assert.IsNotNull(ribosomeSite[0].LocusTag[0]);
            Assert.IsNotNull(ribosomeSite[0].StandardName);

            // Create a new RibosomeBindingSite feature using constructor.
            var ribosomeBindingSite =
                new RibosomeBindingSite(expectedLocation);
            var ribosomeBindingSiteLoc =
                new RibosomeBindingSite(
                    genMetadata.Features.RibosomeBindingSites[0].Location);

            // Set and validate qualifiers.
            ribosomeBindingSite.Allele = expectedAllele;
            ribosomeBindingSiteLoc.GeneSymbol = geneSymbol;
            ribosomeBindingSiteLoc.GenomicMapPosition = expectedMap;
            Assert.AreEqual(ribosomeBindingSiteLoc.GenomicMapPosition,
                            expectedMap);
            Assert.AreEqual(ribosomeBindingSite.Allele, expectedAllele);
            Assert.AreEqual(ribosomeBindingSiteLoc.GeneSymbol,
                            geneSymbol);
        }
Ejemplo n.º 17
0
        /// <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);
        }
Ejemplo n.º 18
0
        /// <summary>
        ///     Validate GenBank CDS features
        /// </summary>
        /// <param name="nodeName">XML node name</param>
        /// <param name="genMetadata">GenBank Metadata</param>
        private void ValidateGenBankCDSFeatures(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 expectedInference = utilityObj.xmlUtil.GetTextValue(
                nodeName, Constants.InferenceNode);
            string expectedLabel = utilityObj.xmlUtil.GetTextValue(
                nodeName, Constants.LabelNode);
            string expectedNote = utilityObj.xmlUtil.GetTextValue(
                nodeName, Constants.Note);
            string expectedMap = utilityObj.xmlUtil.GetTextValue(
                nodeName, Constants.GenbankMapNode);
            string expectedTranslation = utilityObj.xmlUtil.GetTextValue(
                nodeName, Constants.GenbankTranslationNode);
            string expectedCodonStart = utilityObj.xmlUtil.GetTextValue(
                nodeName, Constants.CodonStartNode);

            List<CodingSequence> codingSequenceFeatureList =
                genMetadata.Features.CodingSequences;
            var locBuilder = new LocationBuilder();

            // Create a copy of Coding Seq Region feature.
            CodingSequence cloneCDS = codingSequenceFeatureList[0].Clone();

            // Validate Unsure Seq Region qualifiers.
            Assert.AreEqual(codingSequenceFeatureList.Count.ToString((IFormatProvider) null),
                            featureCount);
            Assert.AreEqual(cloneCDS.DatabaseCrossReference[0],
                            expectedDbReference);
            Assert.AreEqual(cloneCDS.GeneSymbol, geneSymbol);
            Assert.AreEqual(codingSequenceFeatureList[0].Allele,
                            expectedAllele);
            Assert.AreEqual(codingSequenceFeatureList[0].Citation[0],
                            expectedCitation);
            Assert.AreEqual(codingSequenceFeatureList[0].Experiment[0],
                            expectedExperiment);
            Assert.AreEqual(codingSequenceFeatureList[0].GenomicMapPosition,
                            expectedMap);
            Assert.AreEqual(codingSequenceFeatureList[0].Inference[0],
                            expectedInference);
            Assert.AreEqual(codingSequenceFeatureList[0].Label,
                            expectedLabel);
            Assert.AreEqual(locBuilder.GetLocationString(
                genMetadata.Features.CodingSequences[0].Location),
                            expectedLocation);
            Assert.AreEqual(codingSequenceFeatureList[0].Note[0],
                            expectedNote);
            Assert.AreEqual(codingSequenceFeatureList[0].GenomicMapPosition,
                            expectedMap);
            Assert.AreEqual(codingSequenceFeatureList[0].CodonStart[0],
                            expectedCodonStart);
            Assert.AreEqual(codingSequenceFeatureList[0].Translation,
                            expectedTranslation);
            Assert.IsFalse(string.IsNullOrEmpty(codingSequenceFeatureList[0].Codon.ToString()));
            Assert.IsTrue(string.IsNullOrEmpty(codingSequenceFeatureList[0].EnzymeCommissionNumber));
            Assert.IsTrue(string.IsNullOrEmpty(codingSequenceFeatureList[0].Number));
            Assert.IsTrue(string.IsNullOrEmpty(codingSequenceFeatureList[0].Operon));
            Assert.IsFalse(codingSequenceFeatureList[0].Pseudo);
            Assert.IsFalse(codingSequenceFeatureList[0].RibosomalSlippage);
            Assert.IsTrue(string.IsNullOrEmpty(codingSequenceFeatureList[0].StandardName));
            Assert.IsFalse(string.IsNullOrEmpty(codingSequenceFeatureList[0].TranslationalExcept.ToString()));
            Assert.IsTrue(string.IsNullOrEmpty(codingSequenceFeatureList[0].TranslationTable));
            Assert.IsFalse(codingSequenceFeatureList[0].TransSplicing);
            Assert.IsTrue(string.IsNullOrEmpty(codingSequenceFeatureList[0].Exception));

            // Create a new CDS feature using constructor.
            var cds = new CodingSequence(expectedLocation);
            var cdsWithLoc = new CodingSequence(
                genMetadata.Features.CodingSequences[0].Location);
            Sequence seq = cds.GetTranslation();
            Assert.IsNotNull(seq);

            // Set and validate qualifiers.
            cds.Allele = expectedAllele;
            cdsWithLoc.GeneSymbol = geneSymbol;
            cdsWithLoc.GenomicMapPosition = expectedMap;
            Assert.AreEqual(cdsWithLoc.GenomicMapPosition, expectedMap);
            Assert.AreEqual(cds.Allele, expectedAllele);
            Assert.AreEqual(cdsWithLoc.GeneSymbol, geneSymbol);
        }
Ejemplo n.º 19
0
        /// <summary>
        ///     Validate ModifiedBase features
        /// </summary>
        /// <param name="nodeName">XML node name</param>
        /// <param name="genMetadata">GenBank Metadata</param>
        private void ValidateGenBankModifiedBaseFeature(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 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<ModifiedBase> modifiedBaseFeatureList =
                genMetadata.Features.ModifiedBases;
            var locBuilder = new LocationBuilder();

            // Create a copy of Modified base feature.
            ModifiedBase cloneModifiedBase = modifiedBaseFeatureList[0].Clone();

            // Validate Modified Base qualifiers.
            Assert.AreEqual(modifiedBaseFeatureList.Count.ToString((IFormatProvider) null),
                            featureCount);
            Assert.AreEqual(cloneModifiedBase.GeneSymbol,
                            geneSymbol);
            Assert.AreEqual(cloneModifiedBase.DatabaseCrossReference[0],
                            expectedDbReference);
            Assert.AreEqual(modifiedBaseFeatureList[0].Allele,
                            expectedAllele);
            Assert.AreEqual(modifiedBaseFeatureList[0].Citation[0],
                            expectedCitation);
            Assert.AreEqual(modifiedBaseFeatureList[0].Experiment[0],
                            expectedExperiment);
            Assert.AreEqual(modifiedBaseFeatureList[0].GenomicMapPosition,
                            expectedMap);
            Assert.AreEqual(modifiedBaseFeatureList[0].GeneSynonym[0],
                            expectedGeneSynonym);
            Assert.AreEqual(modifiedBaseFeatureList[0].Inference[0],
                            expectedInference);
            Assert.AreEqual(modifiedBaseFeatureList[0].Label,
                            expectedLabel);
            Assert.AreEqual(locBuilder.GetLocationString(
                genMetadata.Features.ModifiedBases[0].Location),
                            expectedLocation);
            Assert.AreEqual(modifiedBaseFeatureList[0].Note[0],
                            expectedNote);
            Assert.AreEqual(modifiedBaseFeatureList[0].OldLocusTag[0],
                            expectedOldLocusTag);
            Assert.AreEqual(modifiedBaseFeatureList[0].LocusTag[0],
                            expectedLocusTag);
            Assert.IsFalse(string.IsNullOrEmpty(modifiedBaseFeatureList[0].ModifiedNucleotideBase.ToString()));

            // Create a new ModifiedBase and validate the same.
            var modifiedBase = new ModifiedBase(expectedLocation);
            var modifiedBaseWithILoc = new ModifiedBase(
                genMetadata.Features.ModifiedBases[0].Location);

            // Set qualifiers and validate them.
            modifiedBase.Allele = expectedAllele;
            modifiedBase.GeneSymbol = geneSymbol;
            modifiedBaseWithILoc.GenomicMapPosition = expectedMap;
            Assert.AreEqual(modifiedBase.GeneSymbol, geneSymbol);
            Assert.AreEqual(modifiedBase.Allele, expectedAllele);
            Assert.AreEqual(modifiedBaseWithILoc.GenomicMapPosition,
                            expectedMap);
        }
Ejemplo n.º 20
0
        /// <summary>
        /// Gives out string array of metadata and features just below metadata.
        /// </summary>
        /// <param name="metadata">GenBank Metadata</param>
        /// <returns>string array of metadata</returns>
        public static string[,] GenBankMetadataToRange(GenBankMetadata metadata)
        {
            List<string[]> excelData = new List<string[]>();
            List<string> excelRow = new List<string>();

            // Add the metadata headers
            excelRow.Add(Properties.Resources.GenbankMetadataHeader);
            excelData.Add(excelRow.ToArray());
            excelRow.Clear();

            if (metadata.Locus != null)
            {
                excelData.Add(new[] { Properties.Resources.GenbankMetadataLocus });
                AddNameValuePair(excelData, 1, Properties.Resources.GenbankMetadataName, metadata.Locus.Name);
                AddNameValuePair(excelData, 1, Properties.Resources.GenbankMetadataSeqLength, metadata.Locus.SequenceLength.ToString());
                AddNameValuePair(excelData, 1, Properties.Resources.GenbankMetadataSeqType, metadata.Locus.SequenceType);
                AddNameValuePair(excelData, 1, Properties.Resources.GenbankMetadataStrandType, Helper.GetStrandType(metadata.Locus.Strand));
                AddNameValuePair(excelData, 1, Properties.Resources.GenbankMetadataMoleculeType, metadata.Locus.MoleculeType.ToString());
                AddNameValuePair(excelData, 1, Properties.Resources.GenbankMetadataStrandTopology, Helper.GetStrandTopology(metadata.Locus.StrandTopology));
                AddNameValuePair(excelData, 1, Properties.Resources.GenbankMetadataDivisionCode, metadata.Locus.DivisionCode.ToString());
                AddNameValuePair(excelData, 1, Properties.Resources.GenbankMetadataDate, metadata.Locus.Date.ToString("dd-MMM-yyyy").ToUpper());
            }

            if (!string.IsNullOrWhiteSpace(metadata.Definition))
            {
                AddNameValuePair(excelData, 0, Properties.Resources.GenbankMetadataDefinition, "", metadata.Definition);
            }

            if (metadata.Accession != null)
            {
                string secondaryAccession = string.Empty;
                foreach (string accession2 in metadata.Accession.Secondary)
                {
                    secondaryAccession += accession2 == null ? " " : " " + accession2;
                }
                AddNameValuePair(excelData, 0, Properties.Resources.GenbankMetadataAccession, "", metadata.Accession.Primary + secondaryAccession);
            }

            if (metadata.DbLinks != null)
            {
                foreach (var link in metadata.DbLinks)
                {
                    string linkNumbers = string.Empty;
                    foreach (string linkNumber in link.Numbers)
                    {
                        linkNumbers += linkNumber + ",";
                    }
                    AddNameValuePair(excelData, 0, Properties.Resources.GenbankMetadataDBLink, "", link.Type.ToString() + ":" + linkNumbers);
                }
            }

            if (!string.IsNullOrWhiteSpace(metadata.DbSource))
            {
                AddNameValuePair(excelData, 0, Properties.Resources.GenbankMetadataDBSource, "", metadata.DbSource);
            }

            if (metadata.Version != null)
            {
                AddNameValuePair(excelData, 0, Properties.Resources.GenbankMetadataVersion, "", (metadata.Version.Accession ?? string.Empty) + "." + 
                                    (metadata.Version.Version ?? string.Empty) + " " + Properties.Resources.GenbankMetadataGI + (metadata.Version.GiNumber ?? string.Empty));
            }

            if (metadata.Segment != null)
            {
                AddNameValuePair(excelData, 0, Properties.Resources.GenbankMetadataSegment, "", metadata.Segment.Current + " of " + metadata.Segment.Count);
            }

            AddNameValuePair(excelData, 0, Properties.Resources.GenbankMetadataKeywords, "", metadata.Keywords);

            if (metadata.Source != null)
            {
                AddNameValuePair(excelData, 0, Properties.Resources.GenbankMetadataSource, "", metadata.Source.CommonName ?? string.Empty);
                AddNameValuePair(excelData, 1, Properties.Resources.GenbankMetadataOrganism, (metadata.Source.Organism.Genus ?? string.Empty) + " " + (metadata.Source.Organism.Species ?? string.Empty));
                AddNameValuePair(excelData, 1, Properties.Resources.GenbankMetadataClassLevels, metadata.Source.Organism.ClassLevels ?? string.Empty);
            }

            foreach (CitationReference reference in metadata.References)
            {
                AddNameValuePair(excelData, 0, Properties.Resources.GenbankMetadataReference, "", reference.Number.ToString() + " (" + reference.Location + ")");
                AddNameValuePair(excelData, 1, Properties.Resources.GenbankMetadataAuthors, reference.Authors);
                AddNameValuePair(excelData, 1, Properties.Resources.GenbankMetadataTitle, reference.Title);
                AddNameValuePair(excelData, 1, Properties.Resources.GenbankMetadataJournal, reference.Journal);
                AddNameValuePair(excelData, 1, Properties.Resources.GenbankMetadataConsortiums, reference.Consortiums);
                AddNameValuePair(excelData, 1, Properties.Resources.GenbankMetadataMedLine, reference.Medline);
                AddNameValuePair(excelData, 1, Properties.Resources.GenbankMetadataPubMed, reference.PubMed);
                AddNameValuePair(excelData, 1, Properties.Resources.GenbankMetadataRemarks, reference.Remarks);
            }

            if (!string.IsNullOrWhiteSpace(metadata.Primary))
            {
                AddNameValuePair(excelData, 0, Properties.Resources.GenbankMetadataPrimary, "", metadata.Primary);
            }

            if (metadata.Comments != null && metadata.Comments.Count > 0)
            {
                StringBuilder strbuilder = null;

                foreach (string str in metadata.Comments)
                {
                    if (strbuilder == null)
                    {
                        strbuilder = new StringBuilder();
                    }
                    else
                    {
                        strbuilder.Append(Environment.NewLine);
                    }

                    strbuilder.Append(str);
                }

                if (strbuilder != null)
                {
                    AddNameValuePair(excelData, 0, Properties.Resources.GenbankMetadataComment, "", strbuilder.ToString());
                }
            }

            if (metadata.Features != null)
            {
                // Add the metadata headers
                excelRow.Add(Properties.Resources.GenbankFeaturesHeader);
                excelData.Add(excelRow.ToArray());
                excelRow.Clear();

                IList<FeatureItem> featureList = metadata.Features.All;
                foreach (FeatureItem featureItem in featureList)
                {
                    LocationBuilder locBuilder = new LocationBuilder();
                    // Add the feature headers
                    excelRow.Add(featureItem.Key);
                    //excelRow.Add(""); // skip one column
                    excelRow.Add(locBuilder.GetLocationString(featureItem.Location));
                    excelData.Add(excelRow.ToArray());
                    excelRow.Clear();

                    foreach (string key in featureItem.Qualifiers.Keys)
                    {
                        foreach (string value in featureItem.Qualifiers[key])
                        {
                            AddNameValuePair(excelData, 1, key, value);
                        }
                    }
                }
            }

            if (!string.IsNullOrWhiteSpace(metadata.BaseCount))
            {
                AddNameValuePair(excelData, 0, Properties.Resources.GenbankMetadataBaseCount, "", metadata.BaseCount);
            }

            return ConvertToArray(excelData);
        }
Ejemplo n.º 21
0
        /// <summary>
        ///     Validate PrecursorRNA features
        /// </summary>
        /// <param name="nodeName">XML node name</param>
        /// <param name="genMetadata">GenBank Metadata</param>
        private void ValidateGenBankPrecursorRNAFeature(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<PrecursorRna> precursorRNAFeatureList =
                genMetadata.Features.PrecursorRNAs;
            var locBuilder = new LocationBuilder();

            // Create a copy of Precursor RNA feature.
            PrecursorRna clonePrecursorRNA =
                precursorRNAFeatureList[0].Clone();

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

            // Create a new Precursor RNA and validate the same.
            var precursorRNA = new PrecursorRna(expectedLocation);
            var precursorRNAWithILoc = new PrecursorRna(
                genMetadata.Features.PrecursorRNAs[0].Location);

            // Set qualifiers and validate them.
            precursorRNA.Allele = expectedAllele;
            precursorRNA.GeneSymbol = geneSymbol;
            precursorRNAWithILoc.GenomicMapPosition = expectedMap;
            Assert.AreEqual(precursorRNA.GeneSymbol, geneSymbol);
            Assert.AreEqual(precursorRNA.Allele, expectedAllele);
            Assert.AreEqual(precursorRNAWithILoc.GenomicMapPosition, expectedMap);
        }
Ejemplo n.º 22
0
        /// <summary>
        ///     Validate addition of GenBank features.
        /// </summary>
        /// <param name="nodeName">xml node name.</param>
        private void ValidateAdditionGenBankFeatures(string nodeName)
        {
            // Get Values from XML node.
            string filePath = utilityObj.xmlUtil.GetTextValue(
                nodeName, Constants.FilePathNode);
            string alphabetName = utilityObj.xmlUtil.GetTextValue(
                nodeName, Constants.AlphabetNameNode);
            string expectedSequence = utilityObj.xmlUtil.GetTextValue(
                nodeName, Constants.ExpectedSequenceNode);
            string addFirstKey = utilityObj.xmlUtil.GetTextValue(
                nodeName, Constants.FirstKey);
            string addSecondKey = utilityObj.xmlUtil.GetTextValue(
                nodeName, Constants.SecondKey);
            string addFirstLocation = utilityObj.xmlUtil.GetTextValue(
                nodeName, Constants.FirstLocation);
            string addSecondLocation = utilityObj.xmlUtil.GetTextValue(
                nodeName, Constants.SecondLocation);
            string addFirstQualifier = utilityObj.xmlUtil.GetTextValue(
                nodeName, Constants.FirstQualifier);
            string addSecondQualifier = utilityObj.xmlUtil.GetTextValue(
                nodeName, Constants.SecondQualifier);

            ISequenceParser parser1 = new GenBankParser();
            {
                IEnumerable<ISequence> seqList1 = parser1.Parse(filePath);
                var localBuilderObj = new LocationBuilder();

                string tempFileName = Path.GetTempFileName();
                string expectedUpdatedSequence =
                    expectedSequence.Replace("\r", "").Replace("\n", "").Replace(" ", "");
                var orgSeq = new Sequence(Utility.GetAlphabet(alphabetName),
                                          expectedUpdatedSequence);
                orgSeq.ID = seqList1.ElementAt(0).ID;

                orgSeq.Metadata.Add(Constants.GenBank,
                                    seqList1.ElementAt(0).Metadata[Constants.GenBank]);

                ISequenceFormatter formatterObj = new GenBankFormatter();
                {
                    formatterObj.Format(orgSeq, tempFileName);

                    // parse GenBank file.
                    var parserObj = new GenBankParser();
                    {
                        IEnumerable<ISequence> seqList = parserObj.Parse(tempFileName);

                        ISequence seq = seqList.ElementAt(0);
                        var metadata = (GenBankMetadata) seq.Metadata[Constants.GenBank];

                        // Add a new features to Genbank features list.
                        metadata.Features = new SequenceFeatures();
                        var feature = new FeatureItem(addFirstKey, addFirstLocation);
                        var qualifierValues = new List<string>();
                        qualifierValues.Add(addFirstQualifier);
                        qualifierValues.Add(addFirstQualifier);
                        feature.Qualifiers.Add(addFirstQualifier, qualifierValues);
                        metadata.Features.All.Add(feature);

                        feature = new FeatureItem(addSecondKey, addSecondLocation);
                        qualifierValues = new List<string>();
                        qualifierValues.Add(addSecondQualifier);
                        qualifierValues.Add(addSecondQualifier);
                        feature.Qualifiers.Add(addSecondQualifier, qualifierValues);
                        metadata.Features.All.Add(feature);

                        // Validate added GenBank features.
                        Assert.AreEqual(metadata.Features.All[0].Key.ToString(null), addFirstKey);
                        Assert.AreEqual(
                            localBuilderObj.GetLocationString(metadata.Features.All[0].Location),
                            addFirstLocation);
                        Assert.AreEqual(metadata.Features.All[1].Key.ToString(null), addSecondKey);
                        Assert.AreEqual(localBuilderObj.GetLocationString(metadata.Features.All[1].Location),
                                        addSecondLocation);

                        parserObj.Close();
                    }

                    File.Delete(tempFileName);
                }
            }
        }
Ejemplo n.º 23
0
        public void ValidateGenBankAttenuatorFeatureQualifiers()
        {
            // Get Values from XML node.
            string filePath = utilityObj.xmlUtil.GetTextValue(
                Constants.GenBankAttenuatorQualifiers, Constants.FilePathNode);
            string attenuatorLocation = utilityObj.xmlUtil.GetTextValue(
                Constants.GenBankAttenuatorQualifiers, Constants.Location);
            string featureCount = utilityObj.xmlUtil.GetTextValue(
                Constants.GenBankAttenuatorQualifiers, Constants.QualifierCount);

            // Parse a GenBank file.
            ISequenceParser parserObj = new GenBankParser();
            IEnumerable<ISequence> seqList = parserObj.Parse(filePath);
            var locBuilder = new LocationBuilder();

            var metadata =
                (GenBankMetadata) seqList.ElementAt(0).Metadata[Constants.GenBank];

            List<Attenuator> attenuatorList = metadata.Features.Attenuators;

            // Create a clone of attenuator feature.
            Attenuator attenuatorClone = attenuatorList[0].Clone();
            Assert.AreEqual(attenuatorList.Count.ToString((IFormatProvider) null), featureCount);
            Assert.IsTrue(string.IsNullOrEmpty(attenuatorList[0].GeneSymbol));
            Assert.IsFalse(string.IsNullOrEmpty(attenuatorClone.DatabaseCrossReference.ToString()));
            Assert.IsTrue(string.IsNullOrEmpty(attenuatorClone.Allele));
            Assert.IsFalse(string.IsNullOrEmpty(attenuatorList[0].ToString()));
            Assert.IsFalse(string.IsNullOrEmpty(attenuatorClone.Experiment.ToString()));
            Assert.IsTrue(string.IsNullOrEmpty(attenuatorList[0].GenomicMapPosition));
            Assert.IsFalse(string.IsNullOrEmpty(attenuatorList[0].GeneSynonym.ToString()));
            Assert.IsFalse(string.IsNullOrEmpty(attenuatorList[0].Inference.ToString()));
            Assert.IsTrue(string.IsNullOrEmpty(attenuatorList[0].Label));
            Assert.AreEqual(locBuilder.GetLocationString(
                metadata.Features.Attenuators[0].Location), attenuatorLocation);
            Assert.IsFalse(string.IsNullOrEmpty(attenuatorList[0].Note.ToString()));
            Assert.IsTrue(string.IsNullOrEmpty(attenuatorList[0].Operon));
            Assert.IsFalse(string.IsNullOrEmpty(attenuatorList[0].OldLocusTag.ToString()));
            Assert.IsFalse(string.IsNullOrEmpty(attenuatorList[0].Phenotype.ToString()));
            Assert.IsFalse(string.IsNullOrEmpty(attenuatorList[0].LocusTag.ToString()));
            Assert.IsFalse(string.IsNullOrEmpty(attenuatorList[0].OldLocusTag.ToString()));

            // Create a new Attenuator and validate the same.
            var attenuator = new Attenuator(attenuatorLocation);
            var attenuatorWithILoc = new Attenuator(
                metadata.Features.Attenuators[0].Location);

            // Set qualifiers and validate them.
            attenuator.Allele = attenuatorLocation;
            attenuator.GeneSymbol = string.Empty;
            attenuatorWithILoc.GenomicMapPosition = string.Empty;
            Assert.IsTrue(string.IsNullOrEmpty(attenuator.GeneSymbol));
            Assert.AreEqual(attenuator.Allele, attenuatorLocation);
            Assert.IsTrue(string.IsNullOrEmpty(attenuatorWithILoc.GenomicMapPosition));

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