/// <summary> /// Loads a scoring matrix from the predefined set of matrices inside Salsa.Core.Bio.Algorithms.Matrices /// </summary> /// <param name="matrixName">The name of the matrix</param> /// <param name="moleculeType"> /// Type of molecule for which this matrix is designed. /// Must be DNA, RNA (may have variants like tRNA, mRNA, etc.) or Protein</param> /// <returns>The SimilarityMatrix</returns> public SimilarityMatrix LoadSimilarityMatrix(string matrixName, MoleculeType moleculeType) { /* * MBF 2.0 requires the format of the matrix to be as (without angle brackets), * <Name> * <MoleculeType> * <Alphabet> * <ScoreRow0> * <ScoreRow1> * ... * ... * <ScoreRowN> */ if (moleculeType == MoleculeType.DNA || moleculeType == MoleculeType.mRNA || moleculeType == MoleculeType.RNA || moleculeType == MoleculeType.rRNA || moleculeType == MoleculeType.snoRNA || moleculeType == MoleculeType.snRNA || moleculeType == MoleculeType.tRNA || moleculeType == MoleculeType.uRNA || moleculeType == MoleculeType.Protein) { using ( Stream stream = Assembly.GetExecutingAssembly().GetManifestResourceStream( "Salsa.Core.Bio.Algorithms.Matrices." + matrixName)) { using (var reader = new StreamReader(stream)) { char commentStarter = '#'; string line; // Skip comments while ((line = reader.ReadLine()) != null && line.Trim()[0] == commentStarter) { ; } var sb = new StringBuilder(); sb.AppendLine(matrixName); // Matrix name string mt = moleculeType.ToString(); sb.AppendLine((moleculeType == MoleculeType.Protein) ? mt : mt.Substring(mt.Length - 3)); // Molecule Type sb.AppendLine(line); // Alphabet line while ((line = reader.ReadLine()) != null) { sb.AppendLine(line.Substring(1).Trim()); // ScoreRow i (ignores the first symbol in current file format) } return(new SimilarityMatrix(new StringReader(sb.ToString()))); } } } else { throw new Exception("Unsupported molecule type: " + moleculeType); } }
/// <summary> /// Validate the Profile Aligner GenerateEString() method using profiles of sub trees. /// </summary> /// <param name="nodeName">xml node name</param> /// <param name="moleculeType">Molecule Type</param> /// <param name="edgeIndex">Edge index to cut tree.</param> private void ValidateGenerateProfileAlignmentWithProfiles(string nodeName, MoleculeType moleculeType, int edgeIndex) { switch (moleculeType) { case MoleculeType.DNA: Initialize(Constants.MuscleDnaSequenceNode, Constants.ExpectedScoreNode); InitializeStage2Variables(Constants.MuscleDnaSequenceNode); break; case MoleculeType.Protein: Initialize(Constants.MuscleProteinSequenceNode, Constants.ExpectedScoreNode); InitializeStage2Variables(Constants.MuscleProteinSequenceNode); break; case MoleculeType.RNA: Initialize(Constants.MuscleRnaSequenceNode, Constants.ExpectedScoreNode); InitializeStage2Variables(Constants.MuscleRnaSequenceNode); break; } ; BinaryGuideTree binaryTree = GetStage2BinaryTree(moleculeType); // Cut the tree List<int>[] leafNodeIndices = binaryTree.SeparateSequencesByCuttingTree(edgeIndex); // separate the profiles List<int>[] removedPositions = null; IProfileAlignment[] separatedProfileAlignments = ProfileAlignment.ProfileExtraction( stage2ExpectedSequences, leafNodeIndices[0], leafNodeIndices[1], out removedPositions); // Now again get combined profile IProfileAlignment profile = ProfileAlignment.GenerateProfileAlignment(separatedProfileAlignments[0], separatedProfileAlignments[0]); // Validate the profile alignment string expectedColSize = utilityObj.xmlUtil.GetTextValue(nodeName, Constants.ColumnSize); string expectedRowSize = utilityObj.xmlUtil.GetTextValue(nodeName, Constants.RowSize); Assert.AreEqual(profile.ProfilesMatrix.ColumnSize.ToString((IFormatProvider) null), expectedColSize); Assert.AreEqual(profile.ProfilesMatrix.RowSize.ToString((IFormatProvider) null), expectedRowSize); ApplicationLog.WriteLine(String.Format(null, @"PamsamP1Test:: Validation and generation of subtrees profiles using profile aligner GenerateProfileAlignment() completed successfully for moleculetype{0}", moleculeType.ToString())); }
/// <summary> /// Validate the Profile Aligner GenerateEString() method using profiles of sub trees. /// </summary> /// <param name="nodeName">xml node name</param> /// <param name="moleculeType">Molecule Type</param> private void ValidateGenerateProfileAlignmentWithSequences(string nodeName, MoleculeType moleculeType) { switch (moleculeType) { case MoleculeType.DNA: Initialize(Constants.MuscleDnaSequenceNode, Constants.ExpectedScoreNode); break; case MoleculeType.Protein: Initialize(Constants.MuscleProteinSequenceNode, Constants.ExpectedScoreNode); break; case MoleculeType.RNA: Initialize(Constants.MuscleRnaSequenceNode, Constants.ExpectedScoreNode); break; } List<ISequence> stage1AlignedSequences = GetStage1AlignedSequence(moleculeType); IProfileAlignment profile = ProfileAlignment.GenerateProfileAlignment(stage1AlignedSequences); // Validate the profile alignment string expectedColSize = utilityObj.xmlUtil.GetTextValue(nodeName, Constants.ColumnSize); string expectedRowSize = utilityObj.xmlUtil.GetTextValue(nodeName, Constants.RowSize); Assert.AreEqual(profile.ProfilesMatrix.ColumnSize.ToString((IFormatProvider) null), expectedColSize); Assert.AreEqual(profile.ProfilesMatrix.RowSize.ToString((IFormatProvider) null), expectedRowSize); ApplicationLog.WriteLine(String.Format(null, @"PamsamP1Test:: Validation and generation of stage1 aligned sequences profile using profile aligner GenerateProfileAlignment() completed successfully for moleculetype{0}", moleculeType.ToString())); }
/// <summary> /// Validate the Profile Aligner GenerateEString() method using profiles of sub trees. /// </summary> /// <param name="nodeName">xml node name</param> /// <param name="moleculeType">Molecule Type</param> /// <param name="edgeIndex">Edge index to cut tree.</param> private void ValidateProfileExtraction(string nodeName, MoleculeType moleculeType, int edgeIndex) { switch (moleculeType) { case MoleculeType.DNA: Initialize(Constants.MuscleDnaSequenceNode, Constants.ExpectedScoreNode); break; case MoleculeType.Protein: Initialize(Constants.MuscleProteinSequenceNode, Constants.ExpectedScoreNode); break; case MoleculeType.RNA: Initialize(Constants.MuscleRnaSequenceNode, Constants.ExpectedScoreNode); break; } // Get Stage2 Binary Tree List<ISequence> stage1AlignedSequences = GetStage1AlignedSequence(moleculeType); IDistanceMatrix matrix = GetKimuraDistanceMatrix(stage1AlignedSequences); IHierarchicalClustering hierarcicalClustering = GetHierarchicalClustering(matrix); BinaryGuideTree binaryTree = GetBinaryTree(hierarcicalClustering); // Cut Tree at an edge and get sequences. List<int>[] leafNodeIndices = binaryTree.SeparateSequencesByCuttingTree(edgeIndex); // Extract profiles. List<int>[] removedPositions = null; IProfileAlignment[] separatedProfileAlignments = ProfileAlignment.ProfileExtraction(stage1AlignedSequences, leafNodeIndices[0], leafNodeIndices[1], out removedPositions); // Validate the profiles. string expectedColSize = utilityObj.xmlUtil.GetTextValue(nodeName, Constants.ColumnSize); string expectedProfileCount = utilityObj.xmlUtil.GetTextValue(nodeName, Constants.ProfileMatrix); Assert.AreEqual(expectedColSize, separatedProfileAlignments[0].ProfilesMatrix.ColumnSize.ToString((IFormatProvider) null)); Assert.IsTrue( expectedProfileCount.Contains( separatedProfileAlignments[0].ProfilesMatrix.ProfilesMatrix.Count.ToString((IFormatProvider) null))); ApplicationLog.WriteLine(String.Format(null, @"PamsamP1Test:: Validation and generation of stage1 aligned sequences subtrees profile using profile aligner ProfileExtraction() completed successfully for moleculetype{0}", moleculeType.ToString())); }
/// <summary> /// Validate the Profile Aligner GenerateEString() method using profiles of sub trees. /// </summary> /// <param name="nodeName">xml node name</param> /// <param name="edgeIndex">Edge index to cut tree.</param> /// <param name="moleculeType">Molecule Type</param> private void ValidateProfileAlignerGenerateEString(string nodeName, MoleculeType moleculeType, int edgeIndex) { switch (moleculeType) { case MoleculeType.DNA: Initialize(Constants.MuscleDnaSequenceNode, Constants.ExpectedScoreNode); InitializeStage2Variables(Constants.MuscleDnaSequenceNode); break; case MoleculeType.Protein: Initialize(Constants.MuscleProteinSequenceNode, Constants.ExpectedScoreNode); InitializeStage2Variables(Constants.MuscleProteinSequenceNode); break; case MoleculeType.RNA: Initialize(Constants.MuscleRnaSequenceNode, Constants.ExpectedScoreNode); InitializeStage2Variables(Constants.MuscleRnaSequenceNode); break; } ; // Get Stage2 Binary Tree List<ISequence> stage1AlignedSequences = GetStage1AlignedSequence(moleculeType); IDistanceMatrix matrix = GetKimuraDistanceMatrix(stage1AlignedSequences); IHierarchicalClustering hierarcicalClustering = GetHierarchicalClustering(matrix); BinaryGuideTree binaryTree = GetBinaryTree(hierarcicalClustering); // Get profiles GetAlignedProfiles(edgeIndex, binaryTree, stage1AlignedSequences); // Get id's of edges and root using two profiles List<int> eStringSubtreeEdge = profileAligner.GenerateEString(profileAligner.AlignedA); List<int> eStringSubtreeRoot = profileAligner.GenerateEString(profileAligner.AlignedB); string expectedTreeEdges = utilityObj.xmlUtil.GetTextValue(nodeName, Constants.SubTreeEdges); string expectedTreeRoot = utilityObj.xmlUtil.GetTextValue(nodeName, Constants.SubTreeRoots); for (int index = 0; index < eStringSubtreeEdge.Count; index++) { Assert.IsTrue(expectedTreeEdges.Contains(eStringSubtreeEdge[index].ToString((IFormatProvider) null))); } Assert.IsTrue(expectedTreeRoot.Contains(eStringSubtreeRoot[0].ToString((IFormatProvider) null))); ApplicationLog.WriteLine(String.Format(null, @"PamsamP1Test:: Validation and generation of subtrees roots and edges using profile aligner GenerateEString() completed successfully for moleculetype{0}", moleculeType.ToString())); }
/// <summary> /// Validate Progressive Alignment of Stage 1 /// </summary> /// <param name="nodeName">xml node name.</param> /// <param name="moleculeType">Molecule Type.</param> private void ValidateProgressiveAlignmentStage1(string nodeName, MoleculeType moleculeType) { Initialize(nodeName, Constants.ExpectedScoreNode); InitializeStage1Variables(nodeName); IDistanceMatrix matrix = GetKmerDistanceMatrix(kmerLength); IHierarchicalClustering hierarcicalClustering = GetHierarchicalClustering(matrix); BinaryGuideTree binaryTree = GetBinaryTree(hierarcicalClustering); List<ISequence> alignedSequences = GetProgressiveAlignerAlignedSequences( lstSequences, binaryTree, moleculeType); // Validate the aligned Sequence of stage1 string expectedSeqString = string.Empty; foreach (ISequence seq in expectedSequences) { expectedSeqString += new string(seq.Select(a => (char) a).ToArray()) + ","; } // Validate expected sequence foreach (ISequence seq in alignedSequences) { Assert.IsTrue(expectedSeqString.Contains(new string(seq.Select(a => (char) a).ToArray()))); } ApplicationLog.WriteLine(String.Format(null, @"PamsamP1Test:: Validation and generation of stage1 aligned sequences using progressivealignment completed successfully for moleculetype {0}", moleculeType.ToString())); }
/// <summary> /// Validate Muscle multiple sequence alignment with different /// profiler and profile score function name. /// </summary> /// <param name="nodeName">xml node name.</param> /// <param name="moleculeType">molecule type of sequences</param> /// <param name="expectedScoreNode">expected score xml node</param> /// <param name="profileName">SW/NW profiler</param> /// <param name="profileScoreFunctionName">Profile score function name</param> private void ValidatePamsamAlignWithProfileScoreFunctionName(string nodeName, MoleculeType moleculeType, string expectedScoreNode, ProfileAlignerNames profileName, ProfileScoreFunctionNames profileScoreFunctionName) { ValidatePamsamAlign(nodeName, moleculeType, expectedScoreNode, UpdateDistanceMethodsTypes.Average, DistanceFunctionTypes.EuclideanDistance, profileName, profileScoreFunctionName, kmerLength, false, false); ApplicationLog.WriteLine(String.Format(null, @"PamsamP1Test:: Pamsam alignment validation completed successfully for {0} moleculetype with different profile score function name {1}", moleculeType.ToString(), profileScoreFunctionName.ToString())); }
/// <summary> /// Validate the binary tree leaves, root using unaligned sequences. /// </summary> /// <param name="initNodeName">Init Node name</param> /// <param name="nodeName">xml node name</param> /// <param name="kmrLength">kmer length to generate distance matrix</param> /// <param name="moleculeType">molecule type of sequences</param> private void ValidateBinaryTreeNodesandEdges(string initNodeName, string nodeName, int kmrLength, MoleculeType moleculeType) { Initialize(initNodeName, Constants.ExpectedScoreNode); IDistanceMatrix matrix = GetKmerDistanceMatrix(kmrLength); IHierarchicalClustering hierarcicalClustering = GetHierarchicalClustering(matrix); BinaryGuideTree binaryTree = GetBinaryTree(hierarcicalClustering); ValidateBinaryTree(binaryTree, nodeName); ApplicationLog.WriteLine(String.Format(null, @"PamsamP1Test:: Validation of binary tree nodes and edges completed successfully for {0} moleculetype", moleculeType.ToString())); }
/// <summary> /// Validate Hierarchical Clustering for stage1 using kmer distance matrix /// </summary> /// <param name="nodeName">xml node name</param> /// <param name="moleculeType">molecule type of sequences</param> /// <param name="kmrlength">kmer length to generate distance matrix</param> private void ValidateHierarchicalClusteringStage1(string nodeName, int kmrlength, MoleculeType moleculeType) { switch (moleculeType) { case MoleculeType.DNA: Initialize(Constants.MuscleDnaSequenceNode, Constants.ExpectedScoreNode); break; case MoleculeType.Protein: Initialize(Constants.MuscleProteinSequenceNode, Constants.ExpectedScoreNode); break; case MoleculeType.RNA: Initialize(Constants.MuscleRnaSequenceNode, Constants.ExpectedScoreNode); break; default: break; } // Get kmer distance matrix IDistanceMatrix matrix = GetKmerDistanceMatrix(kmrlength); // Get hierarchical clustering IHierarchicalClustering hierarcicalClustering = GetHierarchicalClustering(matrix); // Validate the hierarchical clustering ValidateHierarchicalClustering(nodeName, hierarcicalClustering.Nodes, hierarcicalClustering.Edges); ApplicationLog.WriteLine(String.Format(null, @"PamsamP1Test:: hierarchical clustering stage1 nodes and edges generation and validation completed successfully for {0} moleculetype with default params", moleculeType.ToString())); }
/// <summary> /// Validate Hierarchical Clustering for stage2 using kimura distance matrix /// and hierarchical method name /// </summary> /// <param name="nodeName">xml node name</param> /// <param name="moleculeType">molecule type of sequences</param> /// <param name="hierarchicalMethodName">hierarchical method name</param> private void ValidateHierarchicalClusteringStage2(string nodeName, MoleculeType moleculeType, UpdateDistanceMethodsTypes hierarchicalMethodName) { switch (moleculeType) { case MoleculeType.DNA: Initialize(Constants.MuscleDnaSequenceNode, Constants.ExpectedScoreNode); break; case MoleculeType.Protein: Initialize(Constants.MuscleProteinSequenceNode, Constants.ExpectedScoreNode); break; case MoleculeType.RNA: Initialize(Constants.MuscleRnaSequenceNode, Constants.ExpectedScoreNode); break; default: break; } List<ISequence> stage1AlignedSequences = GetStage1AlignedSequence(moleculeType); // Get kimura distance matrix IDistanceMatrix matrix = GetKimuraDistanceMatrix(stage1AlignedSequences); // Get hierarchical clustering using method name IHierarchicalClustering hierarcicalClustering = GetHierarchicalClustering(matrix, hierarchicalMethodName); ValidateHierarchicalClustering(nodeName, hierarcicalClustering.Nodes, hierarcicalClustering.Edges); ApplicationLog.WriteLine(String.Format(null, @"PamsamP1Test:: hierarchical clustering stage2 nodes and edges generation and validation completed success for {0} moleculetype with different hierarchical clustering method name {1}", moleculeType.ToString(), hierarchicalMethodName.ToString())); }
/// <summary> /// Validate DistanceMatrix at stage1 using different DistanceFunction names. /// </summary> /// <param name="nodeName">Xml Node Name</param> /// <param name="kmrlength">Kmer length</param> /// <param name="moleculeType">Molecule type</param> /// <param name="distanceFunctionName">Distance function name</param> private void ValidateKmerDistanceMatrixStage1(string nodeName, int kmrlength, MoleculeType moleculeType, DistanceFunctionTypes distanceFunctionName) { switch (moleculeType) { case MoleculeType.DNA: Initialize(Constants.MuscleDnaSequenceNode, Constants.ExpectedScoreNode); break; case MoleculeType.Protein: Initialize(Constants.MuscleProteinSequenceNode, Constants.ExpectedScoreNode); break; case MoleculeType.RNA: Initialize(Constants.MuscleRnaSequenceNode, Constants.ExpectedScoreNode); break; default: break; } // Get the kmer distance matrix using default params IDistanceMatrix matrix = GetKmerDistanceMatrix(kmrlength, moleculeType, distanceFunctionName); // Validate the matrix ValidateDistanceMatrix(nodeName, matrix); ApplicationLog.WriteLine(String.Format(null, @"PamsamP1Test:: kmer distance matrix generation and validation completed success for {0} moleculetype with different distance method name {1}", moleculeType.ToString(), distanceFunctionName.ToString())); }
/// <summary> /// Validate Stage 3 aligned sequences and score of Muscle multiple sequence alignment. /// </summary> /// <param name="nodeName">xml node name</param> /// <param name="moleculeType">molecule type</param> /// <param name="expectedScoreNode">Expected score node</param> /// <param name="hierarchicalClusteringMethodName">hierarchical clustering method name</param> /// <param name="distanceFunctionName">kmerdistancematrix method name.</param> /// <param name="profileAlignerName">SW/NW profiler</param> /// <param name="profileScoreName">Profile score function name.</param> /// <param name="IsStageAlignment">True for release stage3 validations</param> private void ValidatePamsamAlignStage3(string nodeName, MoleculeType moleculeType, string expectedScoreNode, UpdateDistanceMethodsTypes hierarchicalClusteringMethodName, DistanceFunctionTypes distanceFunctionName, ProfileAlignerNames profileAlignerName, ProfileScoreFunctionNames profileScoreName, bool IsStageAlignment) { Initialize(nodeName, expectedScoreNode); InitializeStage3Variables(nodeName); // MSA aligned sequences. var msa = new PAMSAMMultipleSequenceAligner(lstSequences, kmerLength, distanceFunctionName, hierarchicalClusteringMethodName, profileAlignerName, profileScoreName, similarityMatrix, gapOpenPenalty, gapExtendPenalty, 2, 2); // Validate the aligned Sequence and score of stage2 Assert.AreEqual(stage3ExpectedSequences.Count, msa.AlignedSequences.Count); int index = 0; foreach (ISequence seq in msa.AlignedSequencesC) { if (IsStageAlignment) { Assert.AreEqual(new string(stage3ExpectedSequences[index].Select(a => (char) a).ToArray()), new string(seq.Select(a => (char) a).ToArray())); index++; } } Assert.IsTrue(stage3ExpectedScore.Contains(msa.AlignmentScoreC.ToString((IFormatProvider) null))); ApplicationLog.WriteLine(String.Format(null, "PamsamP1Test:: Pamsam stage3 alignment completed successfully for {0} moleculetype with all default params", moleculeType.ToString())); }
/// <summary> /// Validate Muscle multiple sequence alignment with default values. /// </summary> /// <param name="nodeName">xml node name.</param> /// <param name="moleculeType">Molecule Type.</param> /// <param name="expectedScoreNode">expected score xml node</param> /// <param name="profileName">Profile name</param> private void ValidatePamsamAlignOneLineSequences(string nodeName, MoleculeType moleculeType, string expectedScoreNode, ProfileAlignerNames profileName) { // Use different kmerlength = 3 for one line sequences ValidatePamsamAlign(nodeName, moleculeType, expectedScoreNode, UpdateDistanceMethodsTypes.Average, DistanceFunctionTypes.EuclideanDistance, profileName, ProfileScoreFunctionNames.WeightedInnerProduct, 3, true, false); ApplicationLog.WriteLine(String.Format(null, @"PamsamP1Test:: Pamsam alignment validation completed successfully with one line sequences for {0} moleculetype with all default params", moleculeType.ToString())); }
/// <summary> /// Validate the Profile Aligner GenerateSequenceString() method using profiles of sub trees. /// </summary> /// <param name="nodeName">xml node name</param> /// <param name="moleculeType">Molecule Type</param> /// <param name="edgeIndex">Edge index to cut tree.</param> private void ValidateProfileAlignerGenerateSequenceString(string nodeName, MoleculeType moleculeType, int edgeIndex) { switch (moleculeType) { case MoleculeType.DNA: Initialize(Constants.MuscleDnaSequenceNode, Constants.ExpectedScoreNode); InitializeStage2Variables(Constants.MuscleDnaSequenceNode); break; case MoleculeType.Protein: Initialize(Constants.MuscleProteinSequenceNode, Constants.ExpectedScoreNode); InitializeStage2Variables(Constants.MuscleProteinSequenceNode); break; case MoleculeType.RNA: Initialize(Constants.MuscleRnaSequenceNode, Constants.ExpectedScoreNode); InitializeStage2Variables(Constants.MuscleRnaSequenceNode); break; } ; // Get Stage2 Binary Tree List<ISequence> stage1AlignedSequences = GetStage1AlignedSequence(moleculeType); IDistanceMatrix matrix = GetKimuraDistanceMatrix(stage1AlignedSequences); IHierarchicalClustering hierarcicalClustering = GetHierarchicalClustering(matrix); BinaryGuideTree binaryTree = GetBinaryTree(hierarcicalClustering); GetAlignedProfiles(edgeIndex, binaryTree, stage1AlignedSequences); // Get id's of edges and root using two profiles List<int> eStringSubtreeEdge = profileAligner.GenerateEString(profileAligner.AlignedA); string expectedSequence = utilityObj.xmlUtil.GetTextValue(nodeName, Constants.GenerateSequenceString); ISequence sequence = profileAligner.GenerateSequenceFromEString( eStringSubtreeEdge, stage1AlignedSequences[0]); Assert.IsTrue(expectedSequence.Contains(new string(sequence.Select(a => (char) a).ToArray()))); ApplicationLog.WriteLine(String.Format(null, @"PamsamP1Test:: Validation and generation of subtrees sequences using profile aligner GenerateSequenceFromEString() completed successfully for moleculetype{0}", moleculeType.ToString())); }
/// <summary> /// Validate the binary tree leaves, root using unaligned sequences. /// </summary> /// <param name="nodeName">xml node name</param> /// <param name="kmrLength">kmer length to generate distance matrix</param> /// <param name="moleculeType">molecule type of sequences</param> private void ValidateBinaryTreeFindSmallestTreeDifference(string nodeName, int kmrLength, MoleculeType moleculeType) { Initialize(Constants.MuscleDnaSequenceNode, Constants.ExpectedScoreNode); IDistanceMatrix matrix = GetKmerDistanceMatrix(kmrLength); IHierarchicalClustering hierarcicalClustering = GetHierarchicalClustering(matrix); BinaryGuideTree binaryTree = GetBinaryTree(hierarcicalClustering); BinaryGuideTreeNode node = BinaryGuideTree.FindSmallestTreeDifference( binaryTree.Nodes[binaryTree.Nodes.Count - 1], binaryTree.Nodes[0]); // Validate the node string expectedNodesLeftChild = utilityObj.xmlUtil.GetTextValue(nodeName, Constants.NodesLeftChild); string expectedNodesRightChild = utilityObj.xmlUtil.GetTextValue(nodeName, Constants.NodesRightChild); string expectednode = utilityObj.xmlUtil.GetTextValue(nodeName, Constants.Nodes); Assert.AreEqual(node.ID.ToString((IFormatProvider) null), expectednode); Assert.AreEqual(node.LeftChildren.ID.ToString((IFormatProvider) null), expectedNodesLeftChild); Assert.AreEqual(node.RightChildren.ID.ToString((IFormatProvider) null), expectedNodesRightChild); ApplicationLog.WriteLine(String.Format(null, @"PamsamP1Test:: Find smallest nodes between two subtrees and Validation of smallest node completed successfully for moleculetype {0}", moleculeType.ToString())); }
/// <summary> /// Validate the kimura distance matrix using stage 1 aligned sequences. /// </summary> /// <param name="nodeName">xml node name.</param> /// <param name="moleculeType">Molecule Type.</param> private void ValidateKimuraDistanceMatrix(string nodeName, MoleculeType moleculeType) { switch (moleculeType) { case MoleculeType.DNA: Initialize(Constants.MuscleDnaSequenceNode, Constants.ExpectedScoreNode); break; case MoleculeType.Protein: Initialize(Constants.MuscleProteinSequenceNode, Constants.ExpectedScoreNode); break; case MoleculeType.RNA: Initialize(Constants.MuscleRnaSequenceNode, Constants.ExpectedScoreNode); break; } List<ISequence> stage1AlignedSequences = GetStage1AlignedSequence(moleculeType); IDistanceMatrix matrix = GetKimuraDistanceMatrix(stage1AlignedSequences); ValidateDistanceMatrix(nodeName, matrix); ApplicationLog.WriteLine(String.Format(null, @"PamsamP1Test:: kimura distance matrix generation and validation completed success for {0} moleculetype with default params", moleculeType.ToString())); }
/// <summary> /// Compare the two tree and validate the nodes whcih needs realignment. /// </summary> /// <param name="nodeName">xml node name.</param> /// <param name="kmrLength">kmr length to generate distance matrix.</param> /// <param name="moleculeType">Molecule Type</param> private void ValidateBinaryTreeCompareTrees(string nodeName, int kmrLength, MoleculeType moleculeType) { BinaryGuideTree stage1BinaryTree = GetStage1BinaryTree(kmrLength, moleculeType); BinaryGuideTree stage2BinaryTree = GetStage2BinaryTree(moleculeType); BinaryGuideTree.CompareTwoTrees(stage1BinaryTree, stage2BinaryTree); string expectednode = utilityObj.xmlUtil.GetTextValue(nodeName, Constants.Nodes); string[] expectedNodes = expectednode.Split(','); int index = 0; foreach (BinaryGuideTreeNode node in stage1BinaryTree.Nodes) { if (node.NeedReAlignment) { Assert.AreEqual(node.ID.ToString((IFormatProvider) null), expectedNodes[index]); } index++; } ApplicationLog.WriteLine(String.Format(null, @"PamsamP1Test:: Comparison and Validation of stage1 and stage2 binary tree completed successfully for moleculetype {0}", moleculeType.ToString())); }
public void Connect(MoleculeType type) { Console.WriteLine("CONNECT " + type.ToString()); }
/// <summary> /// Validate Muscle multiple sequence alignment with different profiler and hierarchical clustering method name. /// </summary> /// <param name="nodeName">xml node name.</param> /// <param name="moleculeType">molecule type of sequences</param> /// <param name="expectedScoreNode">Expected score node</param> /// <param name="hierarchicalClusteringMethodName">hierarchical clustering method name</param> /// <param name="profileName">SW/NW profiler</param> private void ValidatePamsamAlignWithUpdateDistanceMethodTypes(string nodeName, MoleculeType moleculeType, string expectedScoreNode, UpdateDistanceMethodsTypes hierarchicalClusteringMethodName, ProfileAlignerNames profileName) { ValidatePamsamAlign(nodeName, moleculeType, expectedScoreNode, hierarchicalClusteringMethodName, DistanceFunctionTypes.EuclideanDistance, profileName, ProfileScoreFunctionNames.WeightedInnerProduct, kmerLength, false, false); ApplicationLog.WriteLine( String.Format(null, "PamsamP1Test:: Pamsam alignment validation completed successfully for {0} moleculetype with different hierarchical clustering method name {1}", moleculeType.ToString(), hierarchicalClusteringMethodName.ToString())); }