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 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); }
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); } }