public static string VectorProteinInterfaceWholeTreeHeader(VectorProteinInterfaceWhole a) { if (a == null) { throw new ArgumentNullException(nameof(a)); } return(Newick.TreeHeaderSafeName(a.FullProteinInterfaceId.ToString() + "_" + (a.ReversedSequence ? "R_" : "F_") + (a.ReversedInteractions ? "RI_" : "") + string.Join("", a.InteractionBools().Select(Convert.ToInt32)) + "_" + (a.VectorProteinInterfacePartList.Count(b => b.InteractionToNonProteinInterface) > 0 ? 1 : 0))); }
public void TestUpgma() { //decimal[,] distanceMatrix1 = //{ // { 0, 0, 0, 0, 0 }, // { 0, 0, 1, 1, 1 }, // { 0, 1, 0, 2, 2 }, // { 0, 1, 2, 0, 3 }, // { 0, 1, 2, 3, 0 }, //}; //var result = UpgmaClustering.Upgma(distanceMatrix1); decimal[,] distanceMatrix2 = { { 0, 19, 27, 8, 33, 18, 13 }, { 19, 0, 31, 18, 36, 1, 13 }, { 27, 31, 0, 26, 41, 32, 29 }, { 8, 18, 26, 0, 31, 17, 14 }, { 33, 36, 41, 31, 0, 35, 28 }, { 18, 1, 32, 17, 35, 0, 12 }, { 13, 13, 29, 14, 28, 12, 0 } }; var names = new List <string>(); for (var i = 0; i < distanceMatrix2.GetLength(0); i++) { names.Add("" + i); } List <string> vectorNames = new List <string>(); var maxVectorLength = distanceMatrix2.GetLength(0) > distanceMatrix2.GetLength(1) ? distanceMatrix2.GetLength(0) : distanceMatrix2.GetLength(1); for (var i = 0; i < maxVectorLength; i++) { vectorNames.Add(SpreadsheetFileHandler.AlphabetLetterRollOver(i) + i); } List <List <UpgmaNode> > nodeList; List <List <string> > treeList; var minimumOutputTreeLeafs = 1; List <string> finalTreeLeafOrderList; UpgmaClustering.Upgma(distanceMatrix2, vectorNames, minimumOutputTreeLeafs, out nodeList, out treeList, out finalTreeLeafOrderList); CheckUpgmaDistanceConsistency(nodeList[nodeList.Count - 1]); List <string> treeLeafOrderList; var tree = Newick.NewickTreeFormat(nodeList[nodeList.Count - 1].ToList <GenericNode>(), names, out treeLeafOrderList, minimumOutputTreeLeafs); Console.WriteLine(tree); }