public void NUCmerAlignWithIsAlignAndGaps() { IList<ISequence> seqList = new List<ISequence>(); seqList.Add(new Sequence(Alphabets.DNA, Encoding.ASCII.GetBytes("CAAAAGGGATTGC---TGTTGGAGTGAATGCCATTACCTACCGGCTAGGAGGAGTAGTACAAAGGAGC"))); seqList.Add(new Sequence(Alphabets.DNA, Encoding.ASCII.GetBytes("CAAAAGGGATTGC---"))); seqList.Add(new Sequence(Alphabets.DNA, Encoding.ASCII.GetBytes("TAGTAGTTCTGCTATATACATTTG"))); seqList.Add(new Sequence(Alphabets.DNA, Encoding.ASCII.GetBytes("GTTATCATGCGAACAATTCAACAGACACTGTAGA"))); var num = new NucmerPairwiseAligner { BreakLength = 8, FixedSeparation = 0, MinimumScore = 0, MaximumSeparation = 0, SeparationFactor = 0, LengthOfMUM = 8 }; IList<ISequence> sequenceList = seqList; IList<ISequenceAlignment> alignmentObj = num.Align(sequenceList); var alignedSeqs = (AlignedSequence) alignmentObj[0].AlignedSequences[0]; Assert.AreEqual("CAAAAGGGATTGC---", new string(alignedSeqs.Sequences[0].Select(a => (char) a).ToArray())); Assert.AreEqual("CAAAAGGGATTGC---", new string(alignedSeqs.Sequences[1].Select(a => (char) a).ToArray())); ApplicationLog.WriteLine("Successfully validated Align method with IsAlign and Gaps"); }
public void TestNUCmer3CustomBreakLength() { var referenceSeqs = new List<ISequence> { new Sequence(Alphabets.DNA, "CAAAAGGGATTGCAAATGTTGGAGTGAATGCCATTACCTACCGGCTAGGAGGAGT") { ID = "R1" }, new Sequence(Alphabets.DNA, "CCCCCCCCC") { ID = "R2" }, new Sequence(Alphabets.DNA, "TTTTT") { ID = "R3" }, }; var searchSeqs = new List<ISequence> { new Sequence(Alphabets.DNA, "CATTAATGATAAAGGGAAAGAAGTCCTCGTGCTATGGGGCATTCACCATCCATCTACTAGTGCTGACCAA") { ID = "Q1" }, new Sequence(Alphabets.DNA, "CAAAGTCTCTATCAGAATGCAGATGCAGATGTTTTTGTGGGGTCATCAAGATATAGCAAGAAGTTCAAGC") { ID = "Q2" }, new Sequence(Alphabets.DNA, "AAGCAAAATTAAACAGAGAAGAAATAGATGGGGTAAAGCTGGAATCAACAAGGATTTACCAGATTTTGGC") { ID = "Q3" }, }; NucmerPairwiseAligner nucmer = new NucmerPairwiseAligner { MaximumSeparation = 0, MinimumScore = 2, SeparationFactor = 0.12F, LengthOfMUM = 5, BreakLength = 2, ForwardOnly = true }; var result = nucmer.Align(referenceSeqs, searchSeqs) .Select(a => a as IPairwiseSequenceAlignment) .ToList(); // Check if output is not null Assert.IsNotNull(result); var expectedOutput = new List<IPairwiseSequenceAlignment>(); IPairwiseSequenceAlignment align = new PairwiseSequenceAlignment(); align.PairwiseAlignedSequences.Add(new PairwiseAlignedSequence { FirstSequence = new Sequence(Alphabets.DNA, "AAAGGGA"), SecondSequence = new Sequence(Alphabets.DNA, "AAAGGGA"), Consensus = new Sequence(Alphabets.DNA, "AAAGGGA"), Score = 21, FirstOffset = 8, SecondOffset = 0 }); align.PairwiseAlignedSequences.Add(new PairwiseAlignedSequence { FirstSequence = new Sequence(Alphabets.DNA, "CATTA"), SecondSequence = new Sequence(Alphabets.DNA, "CATTA"), Consensus = new Sequence(Alphabets.DNA, "CATTA"), Score = 15, FirstOffset = 0, SecondOffset = 31 }); expectedOutput.Add(align); align = new PairwiseSequenceAlignment(); align.PairwiseAlignedSequences.Add(new PairwiseAlignedSequence { FirstSequence = new Sequence(Alphabets.DNA, "ATGTT"), SecondSequence = new Sequence(Alphabets.DNA, "ATGTT"), Consensus = new Sequence(Alphabets.DNA, "ATGTT"), Score = 15, FirstOffset = 13, SecondOffset = 0 }); align.PairwiseAlignedSequences.Add(new PairwiseAlignedSequence { FirstSequence = new Sequence(Alphabets.DNA, "GAATGC"), SecondSequence = new Sequence(Alphabets.DNA, "GAATGC"), Consensus = new Sequence(Alphabets.DNA, "GAATGC"), Score = 18, FirstOffset = 0, SecondOffset = 11 }); align.PairwiseAlignedSequences.Add(new PairwiseAlignedSequence { FirstSequence = new Sequence(Alphabets.DNA, "TTTTT"), SecondSequence = new Sequence(Alphabets.DNA, "TTTTT"), Consensus = new Sequence(Alphabets.DNA, "TTTTT"), Score = 15, FirstOffset = 31, SecondOffset = 0 }); expectedOutput.Add(align); align = new PairwiseSequenceAlignment(); align.PairwiseAlignedSequences.Add(new PairwiseAlignedSequence { FirstSequence = new Sequence(Alphabets.DNA, "CAAAA"), SecondSequence = new Sequence(Alphabets.DNA, "CAAAA"), Consensus = new Sequence(Alphabets.DNA, "CAAAA"), Score = 15, FirstOffset = 3, SecondOffset = 0 }); align.PairwiseAlignedSequences.Add(new PairwiseAlignedSequence { FirstSequence = new Sequence(Alphabets.DNA, "GGATT"), SecondSequence = new Sequence(Alphabets.DNA, "GGATT"), Consensus = new Sequence(Alphabets.DNA, "GGATT"), Score = 15, FirstOffset = 45, SecondOffset = 0 }); align.PairwiseAlignedSequences.Add(new PairwiseAlignedSequence { FirstSequence = new Sequence(Alphabets.DNA, "GCAAA"), SecondSequence = new Sequence(Alphabets.DNA, "GCAAA"), Consensus = new Sequence(Alphabets.DNA, "GCAAA"), Score = 15, FirstOffset = 0, SecondOffset = 9 }); align.PairwiseAlignedSequences.Add(new PairwiseAlignedSequence { FirstSequence = new Sequence(Alphabets.DNA, "TTACC"), SecondSequence = new Sequence(Alphabets.DNA, "TTACC"), Consensus = new Sequence(Alphabets.DNA, "TTACC"), Score = 15, FirstOffset = 22, SecondOffset = 0 }); expectedOutput.Add(align); Assert.IsTrue(AlignmentHelpers.CompareAlignment(result, expectedOutput)); }
private void ValidateNUCmerAlignGeneralTestCases(string nodeName, bool isFilePath, bool isAlignList, AdditionalParameters addParam, PropertyParameters propParam, bool isAmbiguous) { IList<ISequence> refSeqList = new List<ISequence>(); IList<ISequence> searchSeqList = new List<ISequence>(); if (isFilePath) { // Gets the reference sequence from the FastA file string filePath = this.utilityObj.xmlUtil.GetTextValue(nodeName, Constants.FilePathNode); Assert.IsNotNull(filePath); ApplicationLog.WriteLine(string.Format(null, "NUCmer P1 : Successfully validated the File Path '{0}'.", filePath)); var fastaparserobj = new FastAParser(); IEnumerable<ISequence> referenceSeqList = fastaparserobj.Parse(filePath); foreach (ISequence seq in referenceSeqList) { refSeqList.Add(seq); } // Gets the query sequence from the FastA file string queryFilePath = this.utilityObj.xmlUtil.GetTextValue(nodeName, Constants.SearchSequenceFilePathNode); Assert.IsNotNull(queryFilePath); ApplicationLog.WriteLine(string.Format(null, "NUCmer P1 : Successfully validated the File Path '{0}'.", queryFilePath)); var queryParserobj = new FastAParser(); IEnumerable<ISequence> serSeqList = queryParserobj.Parse(queryFilePath); foreach (ISequence seq in serSeqList) { searchSeqList.Add(seq); } } else { // Gets the reference & search sequences from the configuration file string[] referenceSequences = this.utilityObj.xmlUtil.GetTextValues(nodeName, Constants.ReferenceSequencesNode); string[] searchSequences = this.utilityObj.xmlUtil.GetTextValues(nodeName, Constants.SearchSequencesNode); IAlphabet seqAlphabet = Utility.GetAlphabet(this.utilityObj.xmlUtil.GetTextValue(nodeName, Constants.AlphabetNameNode)); IAlphabet ambAlphabet = null; if (isAmbiguous) { switch (seqAlphabet.Name.ToLower(CultureInfo.CurrentCulture)) { case "dna": case "ambiguousdna": ambAlphabet = AmbiguousDnaAlphabet.Instance; break; case "rna": case "ambiguousrna": ambAlphabet = AmbiguousRnaAlphabet.Instance; break; case "protein": case "ambiguousprotein": ambAlphabet = AmbiguousProteinAlphabet.Instance; break; default: break; } } else { ambAlphabet = seqAlphabet; } for (int i = 0; i < referenceSequences.Length; i++) { ISequence referSeq = new Sequence(ambAlphabet, Encoding.ASCII.GetBytes(referenceSequences[i])); referSeq.ID = "ref " + i; refSeqList.Add(referSeq); } for (int i = 0; i < searchSequences.Length; i++) { ISequence searchSeq = new Sequence(ambAlphabet, Encoding.ASCII.GetBytes(searchSequences[i])); searchSeq.ID = "qry " + i; searchSeqList.Add(searchSeq); } } // Gets the mum length from the xml string mumLength = this.utilityObj.xmlUtil.GetTextValue(nodeName, Constants.MUMAlignLengthNode); var nucmerObj = new NucmerPairwiseAligner(); // Check for additional parameters and update the object accordingly switch (addParam) { case AdditionalParameters.AlignSimilarityMatrix: nucmerObj.SimilarityMatrix = new SimilarityMatrix(SimilarityMatrix.StandardSimilarityMatrix.Blosum50); break; default: break; } // Update other values for NUCmer object nucmerObj.MaximumSeparation = 0; nucmerObj.MinimumScore = 2; nucmerObj.SeparationFactor = 0.12f; nucmerObj.BreakLength = 2; nucmerObj.LengthOfMUM = long.Parse(mumLength, null); switch (propParam) { case PropertyParameters.MinimumScore: nucmerObj.MinimumScore = int.Parse( this.utilityObj.xmlUtil.GetTextValue(nodeName, Constants.MinimumScoreNode), null); break; case PropertyParameters.MaximumSeparation: nucmerObj.MaximumSeparation = int.Parse( this.utilityObj.xmlUtil.GetTextValue(nodeName, Constants.MaximumSeparationNode), null); break; case PropertyParameters.FixedSeparation: nucmerObj.FixedSeparation = int.Parse( this.utilityObj.xmlUtil.GetTextValue(nodeName, Constants.FixedSeparationNode), null); break; case PropertyParameters.SeparationFactor: nucmerObj.SeparationFactor = int.Parse( this.utilityObj.xmlUtil.GetTextValue(nodeName, Constants.SeparationFactorNode), null); break; case PropertyParameters.FixedSeparationAndSeparationFactor: nucmerObj.SeparationFactor = int.Parse( this.utilityObj.xmlUtil.GetTextValue(nodeName, Constants.SeparationFactorNode), null); nucmerObj.FixedSeparation = int.Parse( this.utilityObj.xmlUtil.GetTextValue(nodeName, Constants.FixedSeparationNode), null); break; case PropertyParameters.MaximumFixedAndSeparationFactor: nucmerObj.MaximumSeparation = int.Parse( this.utilityObj.xmlUtil.GetTextValue(nodeName, Constants.MaximumSeparationNode), null); nucmerObj.SeparationFactor = int.Parse( this.utilityObj.xmlUtil.GetTextValue(nodeName, Constants.SeparationFactorNode), null); nucmerObj.FixedSeparation = int.Parse( this.utilityObj.xmlUtil.GetTextValue(nodeName, Constants.FixedSeparationNode), null); break; default: break; } IList<ISequenceAlignment> align = null; if (isAlignList) { var listOfSeq = new List<ISequence> {refSeqList.ElementAt(0), searchSeqList.ElementAt(0)}; align = nucmerObj.Align(listOfSeq); } else { align = nucmerObj.Align(refSeqList, searchSeqList); } string expectedSequences = isFilePath ? this.utilityObj.xmlUtil.GetFileTextValue(nodeName, Constants.ExpectedSequencesNode) : this.utilityObj.xmlUtil.GetTextValue(nodeName, Constants.ExpectedSequencesNode); string[] expSeqArray = expectedSequences.Split(','); // Gets all the aligned sequences in comma separated format foreach (IPairwiseSequenceAlignment seqAlignment in align) { foreach (PairwiseAlignedSequence alignedSeq in seqAlignment) { var actualStr = alignedSeq.FirstSequence.ConvertToString(); Assert.IsTrue(expSeqArray.Contains(actualStr)); actualStr = alignedSeq.SecondSequence.ConvertToString(); Assert.IsTrue(expSeqArray.Contains(actualStr)); } } ApplicationLog.WriteLine("NUCmer P1 : Successfully validated all the aligned sequences."); }
public void NUCmerAlignGreaterMumLength() { // Gets the reference & search sequences from the configuration file string[] referenceSequences = this.utilityObj.xmlUtil.GetTextValues(Constants.GreaterMumLengthSequence, Constants.ReferenceSequencesNode); string[] searchSequences = this.utilityObj.xmlUtil.GetTextValues(Constants.GreaterMumLengthSequence, Constants.SearchSequencesNode); IAlphabet seqAlphabet = Utility.GetAlphabet(this.utilityObj.xmlUtil.GetTextValue(Constants.GreaterMumLengthSequence, Constants.AlphabetNameNode)); var refSeqList = referenceSequences.Select(t => new Sequence(seqAlphabet, Encoding.ASCII.GetBytes(t))).Cast<ISequence>().ToList(); var searchSeqList = searchSequences.Select(t => new Sequence(seqAlphabet, Encoding.ASCII.GetBytes(t))).Cast<ISequence>().ToList(); string mumLength = this.utilityObj.xmlUtil.GetTextValue(Constants.GreaterMumLengthSequence, Constants.MUMLengthNode); var nucmerObj = new NucmerPairwiseAligner { MaximumSeparation = 0, SeparationFactor = 0.12f, BreakLength = 2, LengthOfMUM = long.Parse(mumLength, null), MinimumScore = int.Parse(this.utilityObj.xmlUtil.GetTextValue(Constants.GreaterMumLengthSequence, Constants.MinimumScoreNode), null) }; IList<ISequenceAlignment> seqAlign = nucmerObj.Align(refSeqList, searchSeqList); Assert.AreEqual(0, seqAlign.Count); }
public void TestNUCmer3MultipleReferencesAndQueries() { Sequence referenceSeq = null; Sequence searchSeq = null; List<ISequence> referenceSeqs = null; List<ISequence> searchSeqs = null; referenceSeqs = new List<ISequence>(); string reference = "ATGCGCATCCCC"; referenceSeq = new Sequence(Alphabets.DNA, reference); referenceSeq.ID = "R1"; referenceSeqs.Add(referenceSeq); reference = "TAGCT"; referenceSeq = new Sequence(Alphabets.DNA, reference); referenceSeq.ID = "R11"; referenceSeqs.Add(referenceSeq); searchSeqs = new List<ISequence>(); string search = "CCGCGCCCCCTC"; searchSeq = new Sequence(Alphabets.DNA, search); searchSeq.ID = "Q1"; searchSeqs.Add(searchSeq); search = "AGCT"; searchSeq = new Sequence(Alphabets.DNA, search); searchSeq.ID = "Q11"; searchSeqs.Add(searchSeq); NucmerPairwiseAligner nucmer = new NucmerPairwiseAligner(); nucmer.FixedSeparation = 0; nucmer.MinimumScore = 2; nucmer.SeparationFactor = -1; nucmer.LengthOfMUM = 3; nucmer.ForwardOnly = true; IList<IPairwiseSequenceAlignment> result = nucmer.Align(referenceSeqs, searchSeqs).Select(a => a as IPairwiseSequenceAlignment).ToList(); // Check if output is not null Assert.AreNotEqual(null, result); IList<IPairwiseSequenceAlignment> expectedOutput = new List<IPairwiseSequenceAlignment>(); IPairwiseSequenceAlignment align = new PairwiseSequenceAlignment(); PairwiseAlignedSequence alignedSeq = new PairwiseAlignedSequence(); alignedSeq.FirstSequence = new Sequence(Alphabets.DNA, "GCGCATCCCC"); alignedSeq.SecondSequence = new Sequence(Alphabets.DNA, "GCGC--CCCC"); alignedSeq.Consensus = new Sequence(Alphabets.DNA, "GCGCATCCCC"); alignedSeq.Score = -5; alignedSeq.FirstOffset = 0; alignedSeq.SecondOffset = 0; align.PairwiseAlignedSequences.Add(alignedSeq); expectedOutput.Add(align); align = new PairwiseSequenceAlignment(); alignedSeq = new PairwiseAlignedSequence(); alignedSeq.FirstSequence = new Sequence(Alphabets.DNA, "AGCT"); alignedSeq.SecondSequence = new Sequence(Alphabets.DNA, "AGCT"); alignedSeq.Consensus = new Sequence(Alphabets.DNA, "AGCT"); alignedSeq.Score = 12; alignedSeq.FirstOffset = 0; alignedSeq.SecondOffset = 1; align.PairwiseAlignedSequences.Add(alignedSeq); expectedOutput.Add(align); Assert.IsTrue(AlignmentHelpers.CompareAlignment(result, expectedOutput)); }
/// <summary> /// Validates the NUCmer align method for several test cases for the parameters passed. /// </summary> /// <param name="sequenceList">List of Input Sequences</param> private static void ValidateNUCmerEmptyAlignGeneralTestCases(IEnumerable<ISequence> sequenceList) { var nucmerObj = new NucmerPairwiseAligner(); try { IList<ISequenceAlignment> result = nucmerObj.Align(sequenceList); ApplicationLog.WriteLine("NUCmer P2 : Exception not thrown"); Assert.Fail("ArgumentNullException not thrown."); } catch (ArgumentNullException) { ApplicationLog.WriteLine("NUCmer P2: Successfully validated empty SequenceList"); } }
/// <summary> /// Validates the NUCmer align method for several test cases for the parameters passed. /// </summary> /// <param name="nodeName">Node name to be read from xml</param> private void ValidateNUCmerAlignGeneralTestCases(string nodeName) { // Gets the reference & search sequences from the configuration file string[] referenceSequences = this.utilityObj.xmlUtil.GetTextValues(nodeName, Constants.ReferenceSequencesNode); string[] searchSequences = this.utilityObj.xmlUtil.GetTextValues(nodeName, Constants.SearchSequencesNode); IAlphabet seqAlphabet = Utility.GetAlphabet(this.utilityObj.xmlUtil.GetTextValue(nodeName, Constants.AlphabetNameNode)); var refSeqList = referenceSequences.Select(t => new Sequence(seqAlphabet, Encoding.ASCII.GetBytes(t))).Cast<ISequence>().ToList(); var searchSeqList = searchSequences.Select(t => new Sequence(seqAlphabet, Encoding.ASCII.GetBytes(t))).Cast<ISequence>().ToList(); var nucmerObj = new NucmerPairwiseAligner(); string mumLength = this.utilityObj.xmlUtil.GetTextValue(nodeName, Constants.MUMLengthNode); // Update other values for NUCmer object nucmerObj.MaximumSeparation = 0; nucmerObj.MinimumScore = 2; nucmerObj.SeparationFactor = 0.12f; nucmerObj.BreakLength = 2; nucmerObj.LengthOfMUM = long.Parse(mumLength, null); nucmerObj.MinimumScore = int.Parse(this.utilityObj.xmlUtil.GetTextValue(nodeName, Constants.MinimumScoreNode), null); try { nucmerObj.Align(refSeqList, searchSeqList); Assert.Fail("Expected Exception: ArgumentException"); } catch (ArgumentException) { } }
public void ValidateAlignedSequenceToString() { IList<ISequence> seqList = new List<ISequence>(); string actualAlignedSeqString = this.utilityObj.xmlUtil.GetTextValue(Constants.ToStringNodeName, Constants.AlignedSeqActualNode); seqList.Add(new Sequence(Alphabets.DNA, actualAlignedSeqString)); seqList.Add(new Sequence(Alphabets.DNA, "CAAAAGGGATTGC---")); seqList.Add(new Sequence(Alphabets.DNA, "TAGTAGTTCTGCTATATACATTTG")); seqList.Add(new Sequence(Alphabets.DNA, "GTTATCATGCGAACAATTCAACAGACACTGTAGA")); var num = new NucmerPairwiseAligner(); num.BreakLength = 8; num.FixedSeparation = 0; num.MinimumScore = 0; num.MaximumSeparation = 0; num.SeparationFactor = 0; num.LengthOfMUM = 8; IList<ISequence> sequenceList = seqList; IList<ISequenceAlignment> alignmentObj = num.Align(sequenceList); var alignedSeqs = (AlignedSequence) alignmentObj[0].AlignedSequences[0]; string actualString = alignedSeqs.ToString(); string expectedString = this.utilityObj.xmlUtil.GetTextValue(Constants.ToStringNodeName, Constants.AlignedSeqExpectedNode); Assert.AreEqual(actualString, expectedString.Replace("\\r\\n", System.Environment.NewLine)); }
/// <summary> /// Validates the NUCmer align method for several test cases for the parameters passed. /// </summary> /// <param name="nodeName">Node name to be read from xml</param> /// <param name="isFilePath">Is Sequence saved in File</param> void ValidateNUCmerAlignGeneralTestCases(string nodeName, bool isFilePath) { IList<ISequence> refSeqList, searchSeqList; if (isFilePath) { // Gets the reference sequence from the FastA file string filePath = this.utilityObj.xmlUtil.GetTextValue(nodeName, Constants.FilePathNode); Assert.IsNotNull(filePath); Assert.IsTrue(File.Exists(filePath)); ApplicationLog.WriteLine(string.Format(null, "NUCmer BVT : Successfully validated the File Path '{0}'.", filePath)); FastAParser parser = new FastAParser(); refSeqList = parser.Parse(filePath).ToList(); // Gets the query sequence from the FastA file string queryFilePath = this.utilityObj.xmlUtil.GetTextValue(nodeName, Constants.SearchSequenceFilePathNode); Assert.IsNotNull(queryFilePath); Assert.IsTrue(File.Exists(queryFilePath)); ApplicationLog.WriteLine(string.Format(null, "NUCmer BVT : Successfully validated the File Path '{0}'.", queryFilePath)); searchSeqList = parser.Parse(queryFilePath).ToList(); } else { // Gets the reference & search sequences from the configuration file IAlphabet seqAlphabet = Utility.GetAlphabet(this.utilityObj.xmlUtil.GetTextValue(nodeName, Constants.AlphabetNameNode)); string[] sequences = this.utilityObj.xmlUtil.GetTextValues(nodeName, Constants.ReferenceSequencesNode); refSeqList = sequences.Select((t, i) => new Sequence(seqAlphabet, this.encodingObj.GetBytes(t)) {ID = "ref " + i}).Cast<ISequence>().ToList(); sequences = this.utilityObj.xmlUtil.GetTextValues(nodeName, Constants.SearchSequencesNode); searchSeqList = sequences.Select((t, i) => new Sequence(seqAlphabet, this.encodingObj.GetBytes(t)) { ID = "qry " + i }).Cast<ISequence>().ToList(); } var aligner = new NucmerPairwiseAligner { MaximumSeparation = 0, MinimumScore = 2, SeparationFactor = 0.12f, BreakLength = 2, LengthOfMUM = long.Parse(this.utilityObj.xmlUtil.GetTextValue(nodeName, Constants.MUMAlignLengthNode), null) }; IList<ISequenceAlignment> align = aligner.Align(refSeqList, searchSeqList); string expectedSequences = isFilePath ? this.utilityObj.xmlUtil.GetFileTextValue(nodeName, Constants.ExpectedSequencesNode) : this.utilityObj.xmlUtil.GetTextValue(nodeName, Constants.ExpectedSequencesNode); string[] expSeqArray = expectedSequences.Split(','); // Gets all the aligned sequences in comma separated format foreach (IPairwiseSequenceAlignment seqAlignment in align) { foreach (PairwiseAlignedSequence alignedSeq in seqAlignment) { string actualStr = alignedSeq.FirstSequence.ConvertToString(); Assert.IsTrue(expSeqArray.Contains(actualStr)); actualStr = alignedSeq.SecondSequence.ConvertToString(); Assert.IsTrue(expSeqArray.Contains(actualStr)); } } }
public void NUCmerAlignSmallSizeAlignSequence() { // Gets the reference sequence from the FastA file string filePath = this.utilityObj.xmlUtil.GetTextValue(Constants.SmallSizeSequenceNodeName, Constants.FilePathNode); Assert.IsNotNull(filePath); FastAParser parser = new FastAParser(); IEnumerable<ISequence> refSeqList = parser.Parse(filePath); // Gets the query sequence from the FastA file string queryFilePath = this.utilityObj.xmlUtil.GetTextValue(Constants.SmallSizeSequenceNodeName, Constants.SearchSequenceFilePathNode); Assert.IsNotNull(queryFilePath); FastAParser queryParser = new FastAParser(); IEnumerable<ISequence> searchSeqList = queryParser.Parse(queryFilePath); string mumLength = this.utilityObj.xmlUtil.GetTextValue(Constants.SmallSizeSequenceNodeName, Constants.MUMAlignLengthNode); NucmerPairwiseAligner nucmerObj = new NucmerPairwiseAligner { MaximumSeparation = 0, MinimumScore = 2, SeparationFactor = 0.12f, BreakLength = 2, LengthOfMUM = long.Parse(mumLength, null) }; IList<ISequenceAlignment> align = nucmerObj.Align(refSeqList.ElementAt(0), searchSeqList); string expectedSequences = this.utilityObj.xmlUtil.GetFileTextValue(Constants.SmallSizeSequenceNodeName, Constants.ExpectedSequencesNode); string[] expSeqArray = expectedSequences.Split(','); int j = 0; // Gets all the aligned sequences in comma separated format foreach (IPairwiseSequenceAlignment seqAlignment in align) { foreach (PairwiseAlignedSequence alignedSeq in seqAlignment) { Assert.AreEqual(expSeqArray[j], alignedSeq.FirstSequence.ConvertToString()); ++j; Assert.AreEqual(expSeqArray[j], alignedSeq.SecondSequence.ConvertToString()); j++; } } }
public void ValidatePairwiseAlignedSequenceMultipleRefQuery() { var referenceSeqs = new List<ISequence>() { new Sequence(Alphabets.DNA, "ATGCGCATCCCC") {ID = "R1"}, new Sequence(Alphabets.DNA, "TAGCT") {ID = "R2"} }; var searchSeqs = new List<ISequence>() { new Sequence(Alphabets.DNA, "CCGCGCCCCCTC") {ID = "Q1"}, new Sequence(Alphabets.DNA, "AGCT") {ID = "Q2"} }; var nucmer = new NucmerPairwiseAligner { FixedSeparation = 0, MinimumScore = 2, SeparationFactor = -1, LengthOfMUM = 3, ForwardOnly = true, }; IList<IPairwiseSequenceAlignment> result = nucmer.Align(referenceSeqs, searchSeqs).Select(a => a as IPairwiseSequenceAlignment).ToList(); // Check if output is not null Assert.AreNotEqual(null, result); IList<IPairwiseSequenceAlignment> expectedOutput = new List<IPairwiseSequenceAlignment>(); IPairwiseSequenceAlignment align = new PairwiseSequenceAlignment(); var alignedSeq = new PairwiseAlignedSequence { FirstSequence = new Sequence(Alphabets.DNA, "GCGCATCCCC"), SecondSequence = new Sequence(Alphabets.DNA, "GCGC--CCCC"), Consensus = new Sequence(Alphabets.DNA, "GCGCATCCCC"), Score = -5, FirstOffset = 0, SecondOffset = 0 }; align.PairwiseAlignedSequences.Add(alignedSeq); expectedOutput.Add(align); align = new PairwiseSequenceAlignment(); alignedSeq = new PairwiseAlignedSequence { FirstSequence = new Sequence(Alphabets.DNA, "AGCT"), SecondSequence = new Sequence(Alphabets.DNA, "AGCT"), Consensus = new Sequence(Alphabets.DNA, "AGCT"), Score = 12, FirstOffset = 0, SecondOffset = 1 }; align.PairwiseAlignedSequences.Add(alignedSeq); expectedOutput.Add(align); Assert.IsTrue(AlignmentHelpers.CompareAlignment(result, expectedOutput)); ApplicationLog.WriteLine("PairwiseAlignedSequence P1: Successfully validated Sequence with Multiple Reference."); }
public void TestAlignedSequenceToString() { var seqList = new List<ISequence> { new Sequence(Alphabets.DNA,"CAAAAGGGATTGC---TGTTGGAGTGAATGCCATTACCTACCGGCTAGGAGGAGTAGTACAAAGGAGC"), new Sequence(Alphabets.DNA, "CAAAAGGGATTGC---"), new Sequence(Alphabets.DNA, "TAGTAGTTCTGCTATATACATTTG"), new Sequence(Alphabets.DNA, "GTTATCATGCGAACAATTCAACAGACACTGTAGA") }; NucmerPairwiseAligner num = new NucmerPairwiseAligner { BreakLength = 8, FixedSeparation = 0, MinimumScore = 0, MaximumSeparation = 0, SeparationFactor = 0, LengthOfMUM = 8 }; IList<ISequence> sequenceList = seqList; IList<ISequenceAlignment> alignmentObj = num.Align(sequenceList); Assert.AreNotEqual(0, alignmentObj.Count); var alignedSeqs = (AlignedSequence) alignmentObj[0].AlignedSequences[0]; string actualString = alignedSeqs.ToString(); string ExpectedString = "CAAAAGGGATTGC---\r\nCAAAAGGGATTGC---\r\nCAAAAGGGATTGC---\r\n".Replace("\r\n", Environment.NewLine); Assert.AreEqual(ExpectedString, actualString); }