public void ValidateProteinAlphabetAdd() { // Gets the actual sequence and the alphabet from the Xml string alphabetName = Utility._xmlUtil.GetTextValue( Constants.SimpleProteinAlphabetNode, Constants.AlphabetNameNode); string actualSequence = Utility._xmlUtil.GetTextValue( Constants.SimpleProteinAlphabetNode, Constants.ExpectedSingleChar); ISequence seq = new Sequence(Utility.GetAlphabet(alphabetName), actualSequence); ProteinAlphabet alp = ProteinAlphabet.Instance; try { alp.Add(seq[0]); Assert.Fail(); } catch (Exception) { // Logs to the NUnit GUI window ApplicationLog.WriteLine( "Alphabets BVT: Validation of Add() method completed successfully."); Console.WriteLine( "Alphabets BVT: Validation of Add() method completed successfully."); } }
public void TestAllAlphabetsToString() { DnaAlphabet dna = DnaAlphabet.Instance; RnaAlphabet rna = RnaAlphabet.Instance; ProteinAlphabet protein = ProteinAlphabet.Instance; AmbiguousDnaAlphabet dnaAmbiguous = AmbiguousDnaAlphabet.Instance; AmbiguousRnaAlphabet rnaAmbiguous = AmbiguousRnaAlphabet.Instance; AmbiguousProteinAlphabet proteinAmbiguous = AmbiguousProteinAlphabet.Instance; string dnaStringActual = dna.ToString(); string rnaStringActual = rna.ToString(); string proteinStringActual = protein.ToString(); string dnaAmbiguousStringActual = dnaAmbiguous.ToString(); string rnaAmbiguousStringActual = rnaAmbiguous.ToString(); string proteinAmbiguousStringActual = proteinAmbiguous.ToString(); string dnaStringExpected = "ACGT-"; string rnaStringExpected = "ACGU-"; string proteinStringExpected = "ACDEFGHIKLMNOPQRSTUVWY-*"; string dnaAmbiguousStringExpected = "ACGT-MRSWYKVHDBN"; string rnaAmbiguousStringExpected = "ACGU-NMRSWYKVHDB"; string proteinAmbiguousStringExpected = "ACDEFGHIKLMNOPQRSTUVWY-*XZBJ"; Assert.AreEqual(dnaStringExpected, dnaStringActual); Assert.AreEqual(rnaStringExpected, rnaStringActual); Assert.AreEqual(proteinStringExpected, proteinStringActual); Assert.AreEqual(dnaAmbiguousStringExpected, dnaAmbiguousStringActual); Assert.AreEqual(rnaAmbiguousStringExpected, rnaAmbiguousStringActual); Assert.AreEqual(proteinAmbiguousStringExpected, proteinAmbiguousStringActual); }
public void ValidateProAlphabetCompareSymbols() { ProteinAlphabet alp = ProteinAlphabet.Instance; Assert.IsTrue(alp.CompareSymbols(65, 65)); ApplicationLog.WriteLine( "Alphabets BVT: Validation of CompareSymbols() method completed successfully."); Console.WriteLine( "Alphabets BVT: Validation of CompareSymbols() method completed successfully."); }
public void ValidateProteinAlphabetLookupAll() { ProteinAlphabet alp = ProteinAlphabet.Instance; List <ISequenceItem> itm = alp.LookupAll(true, true, true, true); Assert.AreEqual(28, itm.Count); // Logs to the NUnit GUI window ApplicationLog.WriteLine( "Alphabets BVT: Validation of LookupAll() method completed successfully."); Console.WriteLine( "Alphabets BVT: Validation of LookupAll() method completed successfully."); }
public void ValidateProteinAlphabetCopyTo() { ISequence seq = new Sequence(Alphabets.Protein, "AAAAAAAAAAAAAAAAAAAAAAAAAAAAA"); ProteinAlphabet alp = ProteinAlphabet.Instance; ISequenceItem[] item = seq.ToArray(); alp.CopyTo(item, 0); Assert.AreEqual('A', item[0].Symbol); // Logs to the NUnit GUI window ApplicationLog.WriteLine( "Alphabets BVT: Validation of CopyTo() method completed successfully."); Console.WriteLine( "Alphabets BVT: Validation of CopyTo() method completed successfully."); }
protected override ValidationResult IsValid(object value, ValidationContext validationContext) { ProteinAlphabet proteinAlphabet = ProteinAlphabet.Instance; byte[] potentialProteinSymbols = Encoding.UTF8.GetBytes(Convert.ToString(value)); if (!proteinAlphabet.ValidateSequence(potentialProteinSymbols, 0, potentialProteinSymbols.Length)) { return(new ValidationResult(string.Format("{0} only accepts characters {1}", validationContext.DisplayName, proteinAlphabet.ToString()))); } else { return(null); } }
public void ValidateProteinAlphabetLookupBySymbol() { ProteinAlphabet alp = ProteinAlphabet.Instance; ISequenceItem itm = alp.LookupBySymbol("A"); Assert.AreEqual('A', itm.Symbol); itm = alp.LookupBySymbol("Ala"); Assert.AreEqual('A', itm.Symbol); // Logs to the NUnit GUI window ApplicationLog.WriteLine( "Alphabets BVT: Validation of LookupBySymbol() method completed successfully."); Console.WriteLine( "Alphabets BVT: Validation of LookupBySymbol() method completed successfully."); }
public void InValidateProteinAlphabetRemove() { try { ProteinAlphabet alp = ProteinAlphabet.Instance; alp.Remove(null as ISequenceItem); Assert.Fail(); } catch (Exception) { // Logs to the NUnit GUI window ApplicationLog.WriteLine( "Alphabets P2: Validation of Remove() method completed successfully."); Console.WriteLine( "Alphabets P2: Validation of Remove() method completed successfully."); } }
public void InValidateProteinAlphabetGetBasicSymbols() { ProteinAlphabet alp = ProteinAlphabet.Instance; try { alp.GetBasicSymbols(null); Assert.Fail(); } catch (ArgumentException) { // Logs to the NUnit GUI window ApplicationLog.WriteLine( "Alphabets P2: Validation of GetBasicSymbols() method completed successfully."); Console.WriteLine( "Alphabets P2: Validation of GetBasicSymbols() method completed successfully."); } }
public void ValidateProteinAlphabetAllProperties() { ProteinAlphabet alp = ProteinAlphabet.Instance; Assert.AreEqual(28, alp.Count); Assert.AreEqual('-', alp.DefaultGap.Symbol); Assert.IsTrue(alp.HasAmbiguity); Assert.IsTrue(alp.HasGaps); Assert.IsTrue(alp.HasTerminations); Assert.IsTrue(alp.IsReadOnly); Assert.AreEqual("Protein", alp.Name); // Logs to the NUnit GUI window ApplicationLog.WriteLine( "Alphabets BVT: Validation of All properties completed successfully."); Console.WriteLine( "Alphabets BVT: Validation of All properties method completed successfully."); }
public void ValidateProteinAlphabetClear() { ProteinAlphabet alp = ProteinAlphabet.Instance; try { alp.Clear(); Assert.Fail(); } catch (Exception) { // Logs to the NUnit GUI window ApplicationLog.WriteLine( "Alphabets BVT: Validation of Clear() method completed successfully."); Console.WriteLine( "Alphabets BVT: Validation of Clear() method completed successfully."); } }
public void InValidateProteinAlphabetLookupBySymbol() { ProteinAlphabet alp = ProteinAlphabet.Instance; try { ISequenceItem itm = alp.LookupBySymbol(""); Assert.IsNotNull(itm); Assert.Fail(); } catch (ArgumentException) { // Logs to the NUnit GUI window ApplicationLog.WriteLine( "Alphabets P2: Validation of LookupBySymbol() method completed successfully."); Console.WriteLine( "Alphabets P2: Validation of LookupBySymbol() method completed successfully."); } }
public void InValidateProteinAlphabetGetConsensusSymbol() { ProteinAlphabet alp = ProteinAlphabet.Instance; try { HashSet <ISequenceItem> hashSet = new HashSet <ISequenceItem>(); hashSet.Add(null); alp.GetConsensusSymbol(hashSet); Assert.Fail(); } catch (ArgumentException) { // Logs to the NUnit GUI window ApplicationLog.WriteLine( "Alphabets P2: Validation of GetConsensusSymbol() method completed successfully."); Console.WriteLine( "Alphabets P2: Validation of GetConsensusSymbol() method completed successfully."); } }
public void ValidateProteinAlphabetGetBasicSymbols() { ISequence seq = new Sequence(Alphabets.Protein, "AGCTX"); ProteinAlphabet alp = ProteinAlphabet.Instance; ISequenceItem item = seq[4]; Assert.IsNotNull(alp.GetBasicSymbols(item)); item = seq[3]; Assert.IsNotNull(alp.GetBasicSymbols(item)); item = seq[3]; Assert.IsNotNull(alp.GetBasicSymbols(item)); // Logs to the NUnit GUI window ApplicationLog.WriteLine( "Alphabets BVT: Validation of GetBasicSymbols() method completed successfully."); Console.WriteLine( "Alphabets BVT: Validation of GetBasicSymbols() method completed successfully."); }
public void ValidateProteinAlphabetGetConsensusSymbol() { ISequence seq = new Sequence(Alphabets.Protein, "AGCTA"); ProteinAlphabet alp = ProteinAlphabet.Instance; HashSet <ISequenceItem> hashSet = new HashSet <ISequenceItem>(); foreach (ISequenceItem item in seq) { hashSet.Add(item); } Assert.IsNotNull(alp.GetConsensusSymbol(hashSet)); seq = new Sequence(Alphabets.Protein, "AGCTX"); hashSet = new HashSet <ISequenceItem>(); foreach (ISequenceItem item in seq) { hashSet.Add(item); } Assert.IsNotNull(alp.GetConsensusSymbol(hashSet)); seq = new Sequence(Alphabets.Protein, "-"); hashSet = new HashSet <ISequenceItem>(); foreach (ISequenceItem item in seq) { hashSet.Add(item); } Assert.IsNotNull(alp.GetConsensusSymbol(hashSet)); // Logs to the NUnit GUI window ApplicationLog.WriteLine( "Alphabets BVT: Validation of GetBasicSymbols() method completed successfully."); Console.WriteLine( "Alphabets BVT: Validation of GetBasicSymbols() method completed successfully."); }
public void ValidateAllAlphabetsToString() { DnaAlphabet dna = DnaAlphabet.Instance; RnaAlphabet rna = RnaAlphabet.Instance; ProteinAlphabet protein = ProteinAlphabet.Instance; AmbiguousDnaAlphabet dnaAmbiguous = AmbiguousDnaAlphabet.Instance; AmbiguousRnaAlphabet rnaAmbiguous = AmbiguousRnaAlphabet.Instance; AmbiguousProteinAlphabet proteinAmbiguous = AmbiguousProteinAlphabet.Instance; string dnaStringActual = dna.ToString(); string rnaStringActual = rna.ToString(); string proteinStringActual = protein.ToString(); string dnaAmbiguousStringActual = dnaAmbiguous.ToString(); string rnaAmbiguousStringActual = rnaAmbiguous.ToString(); string proteinAmbiguousStringActual = proteinAmbiguous.ToString(); Assert.AreEqual("ACGT-", dnaStringActual); Assert.AreEqual("ACGU-", rnaStringActual); Assert.AreEqual("ACDEFGHIKLMNOPQRSTUVWY-*", proteinStringActual); Assert.AreEqual("ACGT-MRSWYKVHDBN", dnaAmbiguousStringActual); Assert.AreEqual("ACGU-NMRSWYKVHDB", rnaAmbiguousStringActual); Assert.AreEqual("ACDEFGHIKLMNOPQRSTUVWY-*XZBJ", proteinAmbiguousStringActual); }