/// <summary> /// Initializes a new instance of the GenBankParser class. /// </summary> /// <param name="filename">Name of the File.</param> public GenBankParser(string filename) { if (string.IsNullOrEmpty(filename)) { throw new InvalidDataException(); } Filename = filename; LocationBuilder = new LocationBuilder(); }
/// <summary> /// Default constructor chooses default encoding based on alphabet. /// </summary> public GenBankParser() { LocationBuilder = new LocationBuilder(); }
/// <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); } }
/// <summary> /// Default constructor. /// </summary> public GenBankFormatter() { LocationBuilder = new LocationBuilder(); }
/// <summary> /// Constructor for setting the encoding. /// </summary> /// <param name="encoding">The encoding to use for parsed ISequence objects.</param> public GenBankParser(IEncoding encoding) : base(encoding) { LocationBuilder = new LocationBuilder(); }
/// <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); }
public void ValidateCompareGenBankLocationsObject() { // Get Values from XML node. string locationFirstInput = utilityObj.xmlUtil.GetTextValue( Constants.CompareLocationsNode, Constants.Location1Node); string locationSecondInput = utilityObj.xmlUtil.GetTextValue( Constants.CompareLocationsNode, Constants.Location2Node); string locationThirdInput = utilityObj.xmlUtil.GetTextValue( Constants.CompareLocationsNode, Constants.Location3Node); // Create two location instance. ILocationBuilder locBuilder = new LocationBuilder(); ILocation loc1 = locBuilder.GetLocation(locationFirstInput); object loc2 = locBuilder.GetLocation(locationSecondInput); object loc3 = locBuilder.GetLocation(locationThirdInput); // Compare first and second location instances. Assert.AreEqual(0, loc1.CompareTo(loc2)); // Compare first and third location which are not identical. Assert.AreEqual(-1, loc1.CompareTo(loc3)); // Compare first and null location. Assert.AreEqual(1, loc1.CompareTo(null)); ApplicationLog.WriteLine( "GenBank Features P1: Successfully validated the GenBank Features"); }
/// <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); }
/// <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); }
/// <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); }
/// <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"); } }
/// <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"); } }
public void InValidateGenBankLocations() { // Build a location with invalid values ILocationBuilder locBuilder = new LocationBuilder(); ILocation loc = null; try { loc = locBuilder.GetLocation(null); Assert.Fail(); } catch (ArgumentNullException) { Assert.IsNull(loc); ApplicationLog.WriteLine( "GenBankFeatures P2 : Validated the expected exception"); } try { loc = locBuilder.GetLocation("Invalid"); Assert.Fail(); } catch (ArgumentException) { Assert.IsNull(loc); ApplicationLog.WriteLine( "GenBankFeatures P2 : Validated the expected exception"); } }
/// <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); }
public void InValidateSubSequenceWithComplimentOperator() { // Get Values from XML node. string sequence = utilityObj.xmlUtil.GetTextValue( Constants.InvalidLocationWithComplementOperatorNode, Constants.ExpectedSequence); string location = utilityObj.xmlUtil.GetTextValue( Constants.InvalidLocationWithComplementOperatorNode, Constants.Location); string alphabet = utilityObj.xmlUtil.GetTextValue( Constants.InvalidLocationWithComplementOperatorNode, Constants.AlphabetNameNode); // Create a sequence object. ISequence seqObj = new Sequence(Utility.GetAlphabet(alphabet), sequence); // Build a location. ILocationBuilder locBuilder = new LocationBuilder(); ILocation loc = locBuilder.GetLocation(location); LocationResolver locResolver = new LocationResolver(); // Get sequence using location of the sequence with operator. try { loc.GetSubSequence(seqObj); Assert.Fail(); } catch (ArgumentException) { LogExceptionMessage(); } // Validate sub sequence exception for an invalid sequence. try { locResolver.GetSubSequence(loc, null); Assert.Fail(); } catch (ArgumentNullException) { LogExceptionMessage(); } // Validate GetSubSequence method with null location. try { locResolver.GetSubSequence(null, seqObj); Assert.Fail(); } catch (ArgumentNullException) { LogExceptionMessage(); } // Validate sub sequence exception for an invalid sequence. try { locResolver.GetSubSequence(loc, null, null); Assert.Fail(); } catch (ArgumentNullException) { LogExceptionMessage(); } // Validate GetSubSequence method with null location. try { locResolver.GetSubSequence(null, seqObj, null); Assert.Fail(); } catch (ArgumentNullException) { LogExceptionMessage(); } // Validate GetSubSequence method with null location. try { loc.GetSubSequence(null); Assert.Fail(); } catch (ArgumentNullException) { ApplicationLog.WriteLine(string.Format((IFormatProvider)null, "GenBankFeatures P2 : Validate the exception successfully")); } }
/// <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); }
/// <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); }
/// <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); }
/// <summary> /// Initializes a new instance of the GenBankFormatter class. /// </summary> /// <param name="filename">Name of the File.</param> public GenBankFormatter(string filename) { Filename = filename; writer = new StreamWriter(filename); LocationBuilder = new LocationBuilder(); }
/// <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); }
/// <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); }
/// <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); }
/// <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); }
/// <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); } } }
/// <summary> /// Validate Location builder and location resolver. /// </summary> /// <param name="nodeName">xml node name.</param> /// <param name="FeatureOperator">Name of the operator used in a location</param> /// <param name="isOperator"> /// True if location resolver validation with /// operator /// </param> private void ValidateGenBankLocationResolver(string nodeName, FeatureOperator operatorName, bool isOperator) { // Get Values from XML node. string sequence = utilityObj.xmlUtil.GetTextValue( nodeName, Constants.ExpectedSequence); string location = utilityObj.xmlUtil.GetTextValue( nodeName, Constants.Location); string alphabet = utilityObj.xmlUtil.GetTextValue( nodeName, Constants.AlphabetNameNode); string expectedSeq = utilityObj.xmlUtil.GetTextValue( nodeName, Constants.ExpSequenceWithOperator); // Create a sequence object. ISequence seqObj = new Sequence(Utility.GetAlphabet(alphabet), sequence); ISequence expectedSeqWithLoc; // Build a location. ILocationBuilder locBuilder = new LocationBuilder(); ILocation loc = locBuilder.GetLocation(location); if (isOperator) { switch (operatorName) { case FeatureOperator.Complement: loc.Operator = LocationOperator.Complement; break; case FeatureOperator.Join: loc.Operator = LocationOperator.Join; break; case FeatureOperator.Order: loc.Operator = LocationOperator.Order; break; default: break; } } // Get sequence using location of the sequence with operator. expectedSeqWithLoc = loc.GetSubSequence(seqObj); var sequenceString = new string(expectedSeqWithLoc.Select(a => (char) a).ToArray()); Assert.AreEqual(expectedSeq, sequenceString); // Log to VSTest GUI. ApplicationLog.WriteLine(string.Format(null, "GenBankFeatures P1 : Expected sequence is verfied '{0}'.", sequenceString)); }
public void InValidateSubSequenceWithInvalidAccessionID() { // Get Values from XML node. string sequence = utilityObj.xmlUtil.GetTextValue( Constants.LocationWithDotOperatorNode, Constants.ExpectedSequence); string location = utilityObj.xmlUtil.GetTextValue( Constants.LocationWithDotOperatorNode, Constants.Location); string alphabet = utilityObj.xmlUtil.GetTextValue( Constants.LocationWithDotOperatorNode, Constants.AlphabetNameNode); // Create a sequence object. ISequence seqObj = new Sequence(Utility.GetAlphabet(alphabet), sequence); // Build a location. ILocationBuilder locBuilder = new LocationBuilder(); ILocation loc = locBuilder.GetLocation(location); loc.Accession = "Invalid"; // Get sequence using location of the sequence with operator. try { loc.GetSubSequence(seqObj); Assert.Fail(); } catch (ArgumentException) { ApplicationLog.WriteLine(string.Format((IFormatProvider)null, "GenBankFeatures P2 : Validate the exception successfully")); } Dictionary<string, ISequence> refSeq = null; // Validate GetSubSequence method with null location. try { loc.GetSubSequence(null, refSeq); Assert.Fail(); } catch (ArgumentNullException) { ApplicationLog.WriteLine(string.Format((IFormatProvider)null, "GenBankFeatures P2 : Validate the exception successfully")); } }
/// <summary> /// Validate location resolver end data. /// </summary> /// <param name="nodeName">xml node name.</param> private void ValidateLocationEndData(string nodeName) { // Get Values from XML node. string location = utilityObj.xmlUtil.GetTextValue( nodeName, Constants.Location); string expectedEndData = utilityObj.xmlUtil.GetTextValue( nodeName, Constants.EndData); string position = utilityObj.xmlUtil.GetTextValue( nodeName, Constants.Position); bool result = false; // Build a location. var locResolver = new LocationResolver(); ILocationBuilder locBuilder = new LocationBuilder(); ILocation loc = locBuilder.GetLocation(location); loc.EndData = expectedEndData; // Validate whether mentioned end data is present in the location // or not. result = locResolver.IsInEnd(loc, Int32.Parse(position, null)); Assert.IsTrue(result); // Log to VSTest GUI. ApplicationLog.WriteLine(string.Format(null, "GenBankFeatures P1 : Expected sequence is verified")); }
public void InValidateGenBankLocationPositions() { // Get Values from XML node. string location = utilityObj.xmlUtil.GetTextValue( Constants.LocationWithEndDataUsingOperatorNode, Constants.Location); string expectedEndData = utilityObj.xmlUtil.GetTextValue( Constants.LocationWithEndDataUsingOperatorNode, Constants.EndData); string expectedStartData = utilityObj.xmlUtil.GetTextValue( Constants.LocationWithEndDataUsingOperatorNode, Constants.StartData); string position = utilityObj.xmlUtil.GetTextValue( Constants.LocationWithEndDataUsingOperatorNode, Constants.Position); // Build a location. ILocationBuilder locBuilder = new LocationBuilder(); Location loc = (Location)locBuilder.GetLocation(location); loc.Resolver = null; loc.EndData = expectedEndData; loc.StartData = expectedStartData; // Validate whether mentioned end data is present in the location // or not. try { loc.IsInEnd(Int32.Parse(position, (IFormatProvider)null)); Assert.Fail(); } catch (InvalidOperationException) { // Log to VSTest GUI. ApplicationLog.WriteLine(string.Format((IFormatProvider)null, "GenBankFeatures P2 : Expected exception is verified")); } try { loc.IsInStart(Int32.Parse(position, (IFormatProvider)null)); Assert.Fail(); } catch (InvalidOperationException) { // Log to VSTest GUI. ApplicationLog.WriteLine(string.Format((IFormatProvider)null, "GenBankFeatures P2 : Expected exception is verified")); } try { loc.IsInRange(Int32.Parse(position, (IFormatProvider)null)); Assert.Fail(); } catch (InvalidOperationException) { // Log to VSTest GUI. ApplicationLog.WriteLine(string.Format((IFormatProvider)null, "GenBankFeatures P2 : Expected exception is verified")); } }
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); } }
/// <summary> /// InValidate GenBank location with invalid Start location data. /// <param name="endData">Start data used for different test cases.</param> /// </summary> private static void InValidateLocationStartData(string startData) { // Build a location. LocationResolver locResolver = new LocationResolver(); string location = "123.125"; ILocationBuilder locBuilder = new LocationBuilder(); ILocation loc = locBuilder.GetLocation(location); // Set Invalid end data Validate GetStart method exception. loc.StartData = startData; try { locResolver.IsInStart(loc, 124); Assert.Fail(); } catch (IndexOutOfRangeException) { LogExceptionMessage(); } catch (FormatException) { LogExceptionMessage(); } }
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"); } }