public void TestSequenceAlignmentToString() { ISequenceAligner aligner = SequenceAligners.NeedlemanWunsch; IAlphabet alphabet = Alphabets.Protein; const string origSequence1 = "KRIPKSQNLRSIHSIFPFLEDKLSHLN"; const string origSequence2 = "LNIPSLITLNKSIYVFSKRKKRLSGFLHN"; // Create input sequences var inputSequences = new List <ISequence> { new Sequence(alphabet, origSequence1), new Sequence(alphabet, origSequence2) }; // Get aligned sequences IList <ISequenceAlignment> alignments = aligner.Align(inputSequences); ISequenceAlignment alignment = new SequenceAlignment(); foreach (var alignedSequence in alignments[0].AlignedSequences) { alignment.AlignedSequences.Add(alignedSequence); } const string expected = "XXIPXXXXLXXXXXXFXXXXXXLSXXLHN\r\n" + "KRIPKSQNLRSIHSIFPFLEDKLSHL--N\r\n" + "LNIPSLITLNKSIYVFSKRKKRLSGFLHN\r\n\r\n"; Assert.AreEqual(expected.Replace("\r\n", Environment.NewLine), alignment.ToString()); }
public void ValidateSequenceAlignmentToString() { ISequenceAligner aligner = SequenceAligners.NeedlemanWunsch; IAlphabet alphabet = Alphabets.Protein; string origSequence1 = "KRIPKSQNLRSIHSIFPFLEDKLSHLN"; string origSequence2 = "LNIPSLITLNKSIYVFSKRKKRLSGFLHN"; // Create input sequences var inputSequences = new List <ISequence>(); inputSequences.Add(new Sequence(alphabet, origSequence1)); inputSequences.Add(new Sequence(alphabet, origSequence2)); // Get aligned sequences IList <ISequenceAlignment> alignments = aligner.Align(inputSequences); ISequenceAlignment alignment = new SequenceAlignment(); for (int ialigned = 0; ialigned < alignments[0].AlignedSequences.Count; ialigned++) { alignment.AlignedSequences.Add(alignments[0].AlignedSequences[ialigned]); } foreach (string key in alignments[0].Metadata.Keys) { alignment.Metadata.Add(key, alignments[0].Metadata[key]); } string actualSequenceAlignmentString = alignment.ToString(); string ExpectedSequenceAlignmentString = this.utilityObj.xmlUtil.GetTextValue(Constants.ToStringNodeName, Constants .SequenceAlignmentExpectedNode); Assert.AreEqual(ExpectedSequenceAlignmentString.Replace("\\r\\n", ""), actualSequenceAlignmentString.Replace(System.Environment.NewLine, "")); }
public void TestSequenceAlignmentToString() { ISequenceAligner aligner = SequenceAligners.NeedlemanWunsch; IAlphabet alphabet = Alphabets.Protein; string origSequence1 = "KRIPKSQNLRSIHSIFPFLEDKLSHLN"; string origSequence2 = "LNIPSLITLNKSIYVFSKRKKRLSGFLHN"; // Create input sequences List <ISequence> inputSequences = new List <ISequence>(); inputSequences.Add(new Sequence(alphabet, origSequence1)); inputSequences.Add(new Sequence(alphabet, origSequence2)); // Get aligned sequences IList <ISequenceAlignment> alignments = aligner.Align(inputSequences); ISequenceAlignment alignment = new SequenceAlignment(); for (int ialigned = 0; ialigned < alignments[0].AlignedSequences.Count; ialigned++) { alignment.AlignedSequences.Add(alignments[0].AlignedSequences[ialigned]); } foreach (string key in alignments[0].Metadata.Keys) { alignment.Metadata.Add(key, alignments[0].Metadata[key]); } string actualSequenceAlignmentString = alignment.ToString(); string ExpectedSequenceAlignmentString = "XXIPXXXXLXXXXXXFXXXXXXLSGFXXN\r\nKRIPKSQNLRSIHSIFPFLEDKLS--HLN\r\nLNIPSLITLNKSIYVFSKRKKRLSGFLHN\r\n\r\n"; Assert.AreEqual(ExpectedSequenceAlignmentString, actualSequenceAlignmentString); }