public void SimpleConsensusWithMakeConsensusMethod() { IOverlapDeNovoAssembly assembly = this.GetSequenceAssembly("consensus"); string contigConsensus = this.utilityObj.xmlUtil.GetTextValue(Constants.AssemblyAlgorithmNodeName, Constants.ContigConsensusNode); double consensusThreshold = double.Parse(this.utilityObj.xmlUtil.GetTextValue( Constants.AssemblyAlgorithmNodeName, Constants.ConsensusThresholdNode), null); IAlphabet alphabet = Utility.GetAlphabet(this.utilityObj.xmlUtil.GetTextValue( Constants.AssemblyAlgorithmNodeName, Constants.AlphabetNameNode)); // Read the contig from Contig method. Contig contigReadForConsensus = assembly.Contigs[0]; contigReadForConsensus.Consensus = null; var simpleSeqAssembler = new OverlapDeNovoAssembler(); simpleSeqAssembler.ConsensusResolver = new SimpleConsensusResolver(consensusThreshold); simpleSeqAssembler.MakeConsensus(alphabet, contigReadForConsensus); Assert.AreEqual(contigConsensus, new String(contigReadForConsensus.Consensus.Select(a => (char) a).ToArray())); // Log the required info. ApplicationLog.WriteLine(string.Format(null, "SimpleConsensusMethod BVT : Consensus read is '{0}'.", contigReadForConsensus.Consensus)); }
/// <summary> /// Validates the Sequence Assembler for all the general test cases. /// </summary> /// <param name="nodeName">Xml Node Name</param> /// <param name="additionalParameter"> /// Additional Parameter based /// on which the validations are done. /// </param> /// <param name="isSeqAssemblyctr">True if Default contructor is validated or else false.</param> private void ValidateSequenceAssemblerGeneral(string nodeName, AssemblyParameters additionalParameter, bool isSeqAssemblyctr) { // Get the parameters from Xml int matchScore = int.Parse(this.utilityObj.xmlUtil.GetTextValue(nodeName, Constants.MatchScoreNode), null); int mismatchScore = int.Parse(this.utilityObj.xmlUtil.GetTextValue(nodeName, Constants.MisMatchScoreNode), null); int gapCost = int.Parse(this.utilityObj.xmlUtil.GetTextValue(nodeName, Constants.GapCostNode), null); double mergeThreshold = double.Parse(this.utilityObj.xmlUtil.GetTextValue(nodeName, Constants.MergeThresholdNode), null); double consensusThreshold = double.Parse(this.utilityObj.xmlUtil.GetTextValue(nodeName, Constants.ConsensusThresholdNode), null); string[] sequences = this.utilityObj.xmlUtil.GetTextValues(nodeName, Constants.SequencesNode); IAlphabet alphabet = Utility.GetAlphabet(this.utilityObj.xmlUtil.GetTextValue(nodeName, Constants.AlphabetNameNode)); string documentation = this.utilityObj.xmlUtil.GetTextValue(nodeName, Constants.DocumentaionNode); var info = new SerializationInfo(typeof (OverlapDeNovoAssembly), new FormatterConverter()); var context = new StreamingContext(StreamingContextStates.All); var inputs = new List<ISequence>(); switch (additionalParameter) { case AssemblyParameters.Consensus: for (int i = 0; i < sequences.Length; i++) { // Logs the sequences ApplicationLog.WriteLine(string.Format(null, "SimpleConsensusMethod P1 : Sequence '{0}' used is '{1}'.", i, sequences[i])); var seq = new Sequence(alphabet, sequences[i]); inputs.Add(seq); } break; default: for (int i = 0; i < sequences.Length; i++) { // Logs the sequences ApplicationLog.WriteLine(string.Format(null, "SequenceAssembly P1 : Sequence '{0}' used is '{1}'.", i, sequences[i])); var seq = new Sequence(alphabet, sequences[i]); inputs.Add(seq); } break; } // here is how the above sequences should align: // TATAAAGCGCCAA // GCCAAAATTTAGGC // AGGCACCCGCGGTATT <= reversed // // TATAAAGCGCCAAAATTTAGGCACCCGCGGTATT var assembler = new OverlapDeNovoAssembler { MergeThreshold = mergeThreshold, OverlapAlgorithm = new PairwiseOverlapAligner() }; switch (additionalParameter) { case AssemblyParameters.DiagonalSM: (assembler.OverlapAlgorithm).SimilarityMatrix = new DiagonalSimilarityMatrix(matchScore, mismatchScore); break; case AssemblyParameters.SimilarityMatrix: string blosumFilePath = this.utilityObj.xmlUtil.GetTextValue(nodeName, Constants.BlosumFilePathNode); (assembler.OverlapAlgorithm).SimilarityMatrix = new SimilarityMatrix(new StreamReader(blosumFilePath)); break; default: (assembler.OverlapAlgorithm).SimilarityMatrix = new DiagonalSimilarityMatrix(matchScore, mismatchScore); break; } (assembler.OverlapAlgorithm).GapOpenCost = gapCost; assembler.ConsensusResolver = new SimpleConsensusResolver(consensusThreshold); assembler.AssumeStandardOrientation = false; // Assembles all the sequences. IOverlapDeNovoAssembly assembly = (IOverlapDeNovoAssembly) assembler.Assemble(inputs); // Set Documentation property. assembly.Documentation = documentation; // Get the parameters from Xml in general int contigSequencesCount = int.Parse(this.utilityObj.xmlUtil.GetTextValue(nodeName, Constants.ContigSequencesCountNode), null); string contigConsensus = this.utilityObj.xmlUtil.GetTextValue(nodeName, Constants.ContigConsensusNode); switch (additionalParameter) { case AssemblyParameters.Consensus: // Read the contig from Contig method. Contig contigReadForConsensus = assembly.Contigs[0]; contigReadForConsensus.Consensus = null; var simpleSeqAssembler = new OverlapDeNovoAssembler { ConsensusResolver = new SimpleConsensusResolver(consensusThreshold) }; simpleSeqAssembler.MakeConsensus(alphabet, contigReadForConsensus); // Log the required info. ApplicationLog.WriteLine(string.Format(null, "SimpleConsensusMethod BVT : Consensus read is '{0}'.", contigReadForConsensus.Consensus)); Assert.AreEqual(contigConsensus, new String(contigReadForConsensus.Consensus.Select(a => (char) a).ToArray())); break; default: // Get the parameters from Xml for Assemble() method test cases. int unMergedCount = int.Parse(this.utilityObj.xmlUtil.GetTextValue(nodeName, Constants.UnMergedSequencesCountNode), null); int contigsCount = int.Parse(this.utilityObj.xmlUtil.GetTextValue(nodeName, Constants.ContigsCountNode), null); Assert.AreEqual(unMergedCount, assembly.UnmergedSequences.Count); Assert.AreEqual(contigsCount, assembly.Contigs.Count); Assert.AreEqual(documentation, assembly.Documentation); Contig contigRead = assembly.Contigs[0]; // Logs the consensus ApplicationLog.WriteLine(string.Format(null, "SequenceAssembly BVT : Un Merged Sequences Count is '{0}'.", assembly.UnmergedSequences.Count)); ApplicationLog.WriteLine(string.Format(null, "SequenceAssembly BVT : Contigs Count is '{0}'.", assembly.Contigs.Count)); ApplicationLog.WriteLine(string.Format(null, "SequenceAssembly BVT : Contig Sequences Count is '{0}'.", contigRead.Sequences.Count)); ApplicationLog.WriteLine(string.Format(null, "SequenceAssembly BVT : Consensus read is '{0}'.", contigRead.Consensus)); Assert.AreEqual(contigConsensus, new String(contigRead.Consensus.Select(a => (char) a).ToArray())); Assert.AreEqual(contigSequencesCount, contigRead.Sequences.Count); break; } }