//public virtual boo public virtual string GetReferenceStructure(List <string> structures) { ClusterOutput clustOut; clustOut = jury.JuryOptWeights(structures); if (clustOut == null) { return(null); } //clustOut = jury.JuryOpt(structures); return(clustOut.juryLike[0].Key); }
private StatClust Calc(ClusterOutput outp,bool flag) { List <string> five=new List<string>(); List<string> listFiles = new List<string>(); //if (outp == null || outp.clusters == null) // return null; if(outp==null || outp.dirName==null) return null; string []aux=outp.dirName.Split(Path.DirectorySeparatorChar); string native=aux[aux.Length-1]+".pdb"; string dirM = ""; for (int i = 0; i < aux.Length - 1; i++) dirM += aux[i] + Path.DirectorySeparatorChar; native = dirM + native; if(!File.Exists(native)) return null; five.Add(native); // jury1D jury = new jury1D(outp.dirName, "", "C:\\data\\dcd\\SS_SA9internal.profiles"); // jury1D jury = new jury1D(outp.dirName, "", "C:\\data\\dcd\\SS3_SA9_jury_internal.profiles"); //jury1D jury = new jury1D(outp.dirName, "", "C:\\data\\dcd\\SS8_SA3_jury_internal.profiles"); jury1D jury; // jury1D jury = new jury1D(outp.dirName, "", "C:\\data\\dcd\\SS_Contact_jury_internal.profiles"); if(outp.clusters!=null) { outp.clusters.Sort((a,b)=>b.Count.CompareTo(a.Count)); int end = outp.clusters.Count; if (outp.clusters.Count > 5) end = 5; for (int i = 0; i < end; i++) { listFiles.Clear(); foreach (var item in outp.clusters[i]) { listFiles.Add(outp.dirName + Path.DirectorySeparatorChar+item); } // // //Sift sift = new Sift(listFiles); //ClusterOutput oo = sift.Shape(); if (flag) { DistanceMeasure distRmsd = new Rmsd(listFiles, "", false, uQlustCore.PDB.PDBMODE.ONLY_CA); distRmsd.InitMeasure(); string strName = distRmsd.GetReferenceStructure(outp.clusters[i]); five.Add(outp.dirName + Path.DirectorySeparatorChar + strName); } else { jury = new jury1D(); jury.PrepareJury(listFiles, "", "Z:\\dcd\\SS3_SA9_jury_internal.profiles"); ClusterOutput oo = jury.JuryOptWeights(outp.clusters[i]); if (oo == null) continue; five.Add(outp.dirName + Path.DirectorySeparatorChar + oo.juryLike[0].Key); } //five.Add(outp.dirName + Path.DirectorySeparatorChar + outp.clusters[i][0]); } } if (outp.hNode != null) { int end; List<List<string>> cli=outp.hNode.GetClusters(10); cli.Sort((a, b) => b.Count.CompareTo(a.Count)); outp.clusters = new List<List<string>>(); end = cli.Count; if (cli.Count > 5) end = 5; for (int i = 0; i < end; i++) { // listFiles.Clear(); //foreach (var item in cli[i]) //{ //listFiles.Add( //} listFiles.Clear(); foreach (var item in cli[i]) { listFiles.Add(outp.dirName + Path.DirectorySeparatorChar + item); } jury = new jury1D(); jury.PrepareJury(listFiles, "", "C:\\data\\dcd\\SS8_SA3_jury_internal.profiles"); outp.clusters.Add(cli[0]); //jury ClusterOutput oo = jury.JuryOptWeights(cli[i]); if (oo == null) continue; five.Add(outp.dirName + Path.DirectorySeparatorChar + cli[i][0]); //five.Add(outp.dirName + Path.DirectorySeparatorChar + strName); } } if (outp.juryLike != null) { int end = outp.juryLike.Count; if (outp.juryLike.Count > 5) end = 5; for (int i = 0; i < end; i++) five.Add(outp.dirName + Path.DirectorySeparatorChar + outp.juryLike[i].Key); } // DistanceMeasure dist; // dist = new Rmsd(five, "", false, PDB.PDBMODE.ONLY_CA); // dist = new MaxSub(five, "", false); Dictionary<string, double> cc = ReadScore(aux[aux.Length - 1]); if (cc == null) return null ; StatClust stCLust = new StatClust(); string[] tt1 = native.Split(Path.DirectorySeparatorChar); stCLust.native = tt1[tt1.Length - 1]; for (int i = 1; i < five.Count; i++) { string[] tt2 = five[i].Split(Path.DirectorySeparatorChar); // double rmsd = dist.GetDistance(tt1[tt1.Length-1], tt2[tt2.Length-1]) /100.0; double rmsd=0; if (cc.ContainsKey(tt2[tt2.Length-1])) rmsd = cc[tt2[tt2.Length - 1]]; if (rmsd > stCLust.rmsd) { if (outp.juryLike != null) stCLust.size = outp.juryLike.Count; else stCLust.size = outp.clusters[i - 1].Count; stCLust.rmsd = rmsd; string[] dd = five[i].Split(Path.DirectorySeparatorChar); stCLust.reference = dd[dd.Length-1]; } } if (stCLust.rmsd < 1000) { avrSum += stCLust.rmsd; avrCount++; } if (outp.hNode != null) { outp.clusters.Clear(); outp.clusters = null; } return stCLust; }
private void button2_Click(object sender, EventArgs e) { string[] aux; if(checkBox1.Checked) { if(jury1DSetup1.profileName==null || jury1DSetup1.profileName.Length==0) { MessageBox.Show("Profile name for 1djury must be specified!"); this.DialogResult = DialogResult.None; return; } jury1D jury = new jury1D(); jury.PrepareJury(structures, "",jury1DSetup1.profileName); List <string> prep=new List<string>(); foreach (var item in structures) { aux = item.Split(Path.DirectorySeparatorChar); prep.Add(aux[aux.Length - 1]); } ClusterOutput oc=jury.JuryOptWeights(prep); for(int i=0;i<selectBest1.bestNumber;i++) bestJuryStructures.Add(oc.juryLike[i].Key); } this.DialogResult = DialogResult.OK; if (selectBest1.getFileName != null && File.Exists(selectBest1.getFileName)) { DistanceMeasures measure = selectBest1.measure; structures.Add(selectBest1.getFileName); DistanceMeasure dist = null; switch (measure) { case DistanceMeasures.HAMMING: dist = new JuryDistance(structures, "", false, selectBest1.hammingProfile); break; case DistanceMeasures.MAXSUB: dist = new MaxSub(structures, "", false); break; case DistanceMeasures.RMSD: dist = new Rmsd(structures, "", false, selectBest1.CAtoms); break; } List<KeyValuePair<string, int>> distList = new List<KeyValuePair<string, int>>(); aux = selectBest1.getFileName.Split(Path.DirectorySeparatorChar); string native = aux[aux.Length - 1]; foreach (var item in structures) { aux = item.Split(Path.DirectorySeparatorChar); int val = dist.GetDistance(native, aux[aux.Length - 1]); distList.Add(new KeyValuePair<string, int>(aux[aux.Length - 1], val)); } distList.Sort((firstPair, nextPair) => { return firstPair.Value.CompareTo(nextPair.Value); }); for (int i = 0; i < selectBest1.bestNumber; i++) { bestStructures.Add(distList[i].Key); } } }
private StatClust Calc(ClusterOutput outp, bool flag) { List <string> five = new List <string>(); List <string> listFiles = new List <string>(); //if (outp == null || outp.clusters == null) // return null; if (outp == null || outp.dirName == null) { return(null); } string [] aux = outp.dirName.Split(Path.DirectorySeparatorChar); string native = aux[aux.Length - 1] + ".pdb"; string dirM = ""; for (int i = 0; i < aux.Length - 1; i++) { dirM += aux[i] + Path.DirectorySeparatorChar; } native = dirM + native; if (!File.Exists(native)) { return(null); } five.Add(native); jury1D jury; if (outp.clusters != null) { outp.clusters.Sort((a, b) => b.Count.CompareTo(a.Count)); int end = outp.clusters.Count; if (outp.clusters.Count > 5) { end = 5; } for (int i = 0; i < end; i++) { listFiles.Clear(); foreach (var item in outp.clusters[i]) { listFiles.Add(outp.dirName + Path.DirectorySeparatorChar + item); } // // //Sift sift = new Sift(listFiles); //ClusterOutput oo = sift.Shape(); if (flag) { DistanceMeasure distRmsd = new Rmsd(listFiles, "", false, uQlustCore.PDB.PDBMODE.ONLY_CA); distRmsd.InitMeasure(); string strName = distRmsd.GetReferenceStructure(outp.clusters[i]); five.Add(outp.dirName + Path.DirectorySeparatorChar + strName); } else { jury = new jury1D(); //jury.PrepareJury(listFiles, "", "Z:\\dcd\\SS3_SA9_jury_internal.profiles"); ClusterOutput oo = jury.JuryOptWeights(outp.clusters[i]); if (oo == null) { continue; } five.Add(outp.dirName + Path.DirectorySeparatorChar + oo.juryLike[0].Key); } //five.Add(outp.dirName + Path.DirectorySeparatorChar + outp.clusters[i][0]); } } if (outp.hNode != null) { int end; List <List <string> > cli = outp.hNode.GetClusters(10); cli.Sort((a, b) => b.Count.CompareTo(a.Count)); outp.clusters = new List <List <string> >(); end = cli.Count; if (cli.Count > 5) { end = 5; } for (int i = 0; i < end; i++) { // listFiles.Clear(); //foreach (var item in cli[i]) //{ //listFiles.Add( //} listFiles.Clear(); foreach (var item in cli[i]) { listFiles.Add(outp.dirName + Path.DirectorySeparatorChar + item); } jury = new jury1D(); jury.PrepareJury(listFiles, "", "C:\\data\\dcd\\SS8_SA3_jury_internal.profiles"); outp.clusters.Add(cli[0]); //jury ClusterOutput oo = jury.JuryOptWeights(cli[i]); if (oo == null) { continue; } five.Add(outp.dirName + Path.DirectorySeparatorChar + cli[i][0]); //five.Add(outp.dirName + Path.DirectorySeparatorChar + strName); } } if (outp.juryLike != null) { int end = outp.juryLike.Count; if (outp.juryLike.Count > 5) { end = 5; } for (int i = 0; i < end; i++) { five.Add(outp.dirName + Path.DirectorySeparatorChar + outp.juryLike[i].Key); } } // DistanceMeasure dist; // dist = new Rmsd(five, "", false, PDB.PDBMODE.ONLY_CA); // dist = new MaxSub(five, "", false); Dictionary <string, double> cc = ReadScore(aux[aux.Length - 1]); if (cc == null) { return(null); } StatClust stCLust = new StatClust(); string[] tt1 = native.Split(Path.DirectorySeparatorChar); stCLust.native = tt1[tt1.Length - 1]; for (int i = 1; i < five.Count; i++) { string[] tt2 = five[i].Split(Path.DirectorySeparatorChar); // double rmsd = dist.GetDistance(tt1[tt1.Length-1], tt2[tt2.Length-1]) /100.0; double rmsd = 0; if (cc.ContainsKey(tt2[tt2.Length - 1])) { rmsd = cc[tt2[tt2.Length - 1]]; } if (rmsd > stCLust.rmsd) { if (outp.juryLike != null) { stCLust.size = outp.juryLike.Count; } else { stCLust.size = outp.clusters[i - 1].Count; } stCLust.rmsd = rmsd; string[] dd = five[i].Split(Path.DirectorySeparatorChar); stCLust.reference = dd[dd.Length - 1]; } } if (stCLust.rmsd < 1000) { avrSum += stCLust.rmsd; avrCount++; } if (outp.hNode != null) { outp.clusters.Clear(); outp.clusters = null; } return(stCLust); }
private void Run1DJury(string name, string dirName, string alignFile=null, DCDFile dcd = null) { DateTime cpuPart1 = DateTime.Now; ClusterOutput output; jury1D ju=new jury1D(); progressDic.Add(name,ju); //DistanceMeasure distance = CreateMeasure(); if (opt.other.alignGenerate) opt.other.alignFileName = ""; if (alignFile != null) ju.PrepareJury(alignFile, opt.other.juryProfile); else if (dcd != null) ju.PrepareJury(dcd, alignFile, opt.other.juryProfile); else ju.PrepareJury(dirName, alignFile, opt.other.juryProfile); clType = ju.ToString(); DateTime cpuPart2 = DateTime.Now; //jury1D ju = new jury1D(opt.weightHE,opt.weightC,(JuryDistance) distance); //output = ju.JuryOpt(new List<string>(ju.stateAlign.Keys)); if (ju.alignKeys != null) { output = ju.JuryOptWeights(ju.alignKeys); } else { UpadateJobInfo(name, true, false); throw new Exception("Alignment is epmty! Check errors"); } UpdateOutput(name, dirName,alignFile, output,ju.ToString(), cpuPart1,cpuPart2, ju); }
public void CalcStat() { List<string> fileNames = new List<string>(); List<string> refStructures = new List<string>(); DistanceMeasures measure = distanceControl1.distDef; DistanceMeasure distTemp = null; double distRes=0; maxV = selected.Count; distList.Clear(); try { tableRes = new DataTable(); tableRes.Columns.Add("Cluster Size", typeof(int)); tableRes.Columns.Add("Reference structure", typeof(string)); tableRes.Columns.Add("Distance", typeof(double)); tableRes.Columns.Add("Hidden1", typeof(int)); tableRes.Columns.Add("Hidden2", typeof(string)); if (checkBoxSable.Checked) { tableRes.Columns.Add("Dist to Sable", typeof(double)); maxV *= 2; } if (checkBox1.Checked) { for (int i = 0; i < selected.Count; i++) maxV += selected[i].Count; } fileNames.Add(textBox1.Text); jury1D jury = new jury1D(); if (distanceControl1.reference) jury.PrepareJury(dirName, alignFile, distanceControl1.referenceProfile); refStructures.Clear(); selected.Sort(delegate(List<string> first, List<string> second) { return first.Count.CompareTo(second.Count); }); selected.Reverse(); // dataGridView1.Rows.Add(selected.Count); for (int i = 0; i < selected.Count; i++) { string refD = selected[i][0]; ClusterOutput juryO = null; if (distanceControl1.reference) { if (selected[i].Count > 5) { juryO = jury.JuryOptWeights(selected[i]); if (juryO == null) continue; refD = juryO.juryLike[0].Key; if (!fileNames.Contains(dirName + Path.DirectorySeparatorChar + juryO.juryLike[0].Key)) { fileNames.Add(dirName + Path.DirectorySeparatorChar + juryO.juryLike[0].Key); refStructures.Add(dirName + Path.DirectorySeparatorChar + refD); } } else if (!fileNames.Contains(dirName + Path.DirectorySeparatorChar + selected[i][0])) { fileNames.Add(dirName + Path.DirectorySeparatorChar + selected[i][0]); refStructures.Add(dirName + Path.DirectorySeparatorChar + selected[i][0]); } } else { dist = PrepareDistanceMeasure(selected[i], measure, dirName); distTemp = dist; refD = dist.GetReferenceStructure(selected[i]); fileNames.Add(dirName + Path.DirectorySeparatorChar + refD); refStructures.Add(dirName + Path.DirectorySeparatorChar + refD); } if (fileNames.Count == 2) { switch (measure) { case DistanceMeasures.HAMMING: dist = new JuryDistance(fileNames, alignFile, false, distanceControl1.profileName); break; case DistanceMeasures.MAXSUB: dist = new MaxSub(fileNames, null, false); break; case DistanceMeasures.RMSD: dist = new Rmsd(fileNames, null, false, distanceControl1.CAtoms); break; } dist.InitMeasure(); distRes = Convert.ToDouble(String.Format("{0:0.00}", dist.GetDistance(native, refD) / 100.0)); } fileNames.RemoveAt(fileNames.Count - 1); if (checkBoxSable.Checked && refStructures.Count > 0) tableRes.Rows.Add(selected[i].Count, refD, distRes, i, dirName, 0.0); else tableRes.Rows.Add(selected[i].Count, refD, distRes, i, dirName); currentV++; } if (checkBoxSable.Checked && refStructures.Count > 0) { Dictionary<string, double> res = null;// SableDist(refStructures); for (int i = 0; i < refStructures.Count; i++) { if (res.ContainsKey(Path.GetFileName(refStructures[i]))) { DataRow dr = tableDist.Rows[i]; dr[5] = Convert.ToDouble(String.Format("{0:0.00}", res[Path.GetFileName(refStructures[i])])); } } } if (checkBox1.Checked) { CalculateDistToAll(); } } catch(Exception ex) { exc = ex; } }
protected Dictionary <byte,int>[] JuryConsensusStates(Alignment alUse,List<string> structNames) { jury1D juryLocal = new jury1D(); juryLocal.PrepareJury(alUse,stateAlign); Dictionary <byte ,int>[] cons=new Dictionary<byte,int>[columns.Length]; ClusterOutput output = juryLocal.JuryOptWeights(structNames); if (output == null) return null; int i = 0; string result; if (structNames.Contains("consensus")) result = "consensus"; else result = output.juryLike[0].Key; foreach (var item in stateAlign[result]) { cons[i] = new Dictionary<byte, int>(); cons[i++].Add(item, 0); } return cons; }
private ClusterOutput PrepareClustersJuryLike(Dictionary<string, List<int>> dic, List<string> structures) { List<string> juryList = new List<string>(); ClusterOutput juryOut; jury1D jury = new jury1D(); jury.PrepareJury(al); foreach (var item in dic.Keys) { List<string> aux = new List<string>(dic[item].Count); foreach (var st in dic[item]) aux.Add(structures[st]); if (aux.Count > 3) { juryOut = jury.JuryOptWeights(aux); juryList.Add(dirName+Path.DirectorySeparatorChar+juryOut.juryLike[0].Key); } else juryList.Add(dirName + Path.DirectorySeparatorChar + aux[0]); } Sift sift = new Sift(); juryOut=sift.RunSift(juryList); //juryOut = jury.JuryOptWeights(juryList); return juryOut; }
public void CalcStat() { List <string> fileNames = new List <string>(); List <string> refStructures = new List <string>(); DistanceMeasures measure = distanceControl1.distDef; DistanceMeasure distTemp = null; double distRes = 0; maxV = selected.Count; distList.Clear(); try { tableRes = new DataTable(); tableRes.Columns.Add("Cluster Size", typeof(int)); tableRes.Columns.Add("Reference structure", typeof(string)); tableRes.Columns.Add("Distance", typeof(double)); tableRes.Columns.Add("Hidden1", typeof(int)); tableRes.Columns.Add("Hidden2", typeof(string)); if (checkBoxSable.Checked) { tableRes.Columns.Add("Dist to Sable", typeof(double)); maxV *= 2; } if (checkBox1.Checked) { for (int i = 0; i < selected.Count; i++) { maxV += selected[i].Count; } } fileNames.Add(textBox1.Text); jury1D jury = new jury1D(); if (distanceControl1.reference) { jury.PrepareJury(dirName, alignFile, distanceControl1.referenceProfile); } refStructures.Clear(); selected.Sort(delegate(List <string> first, List <string> second) { return(first.Count.CompareTo(second.Count)); }); selected.Reverse(); // dataGridView1.Rows.Add(selected.Count); for (int i = 0; i < selected.Count; i++) { string refD = selected[i][0]; ClusterOutput juryO = null; if (distanceControl1.reference) { if (selected[i].Count > 5) { juryO = jury.JuryOptWeights(selected[i]); if (juryO == null) { continue; } refD = juryO.juryLike[0].Key; if (!fileNames.Contains(dirName + Path.DirectorySeparatorChar + juryO.juryLike[0].Key)) { fileNames.Add(dirName + Path.DirectorySeparatorChar + juryO.juryLike[0].Key); refStructures.Add(dirName + Path.DirectorySeparatorChar + refD); } } else if (!fileNames.Contains(dirName + Path.DirectorySeparatorChar + selected[i][0])) { fileNames.Add(dirName + Path.DirectorySeparatorChar + selected[i][0]); refStructures.Add(dirName + Path.DirectorySeparatorChar + selected[i][0]); } } else { dist = PrepareDistanceMeasure(selected[i], measure, dirName); distTemp = dist; refD = dist.GetReferenceStructure(selected[i]); fileNames.Add(dirName + Path.DirectorySeparatorChar + refD); refStructures.Add(dirName + Path.DirectorySeparatorChar + refD); } if (fileNames.Count == 2) { switch (measure) { case DistanceMeasures.HAMMING: dist = new JuryDistance(fileNames, alignFile, false, distanceControl1.profileName); break; case DistanceMeasures.MAXSUB: dist = new MaxSub(fileNames, null, false); break; case DistanceMeasures.RMSD: dist = new Rmsd(fileNames, null, false, distanceControl1.CAtoms); break; } dist.InitMeasure(); distRes = Convert.ToDouble(String.Format("{0:0.00}", dist.GetDistance(native, refD) / 100.0)); } fileNames.RemoveAt(fileNames.Count - 1); if (checkBoxSable.Checked && refStructures.Count > 0) { tableRes.Rows.Add(selected[i].Count, refD, distRes, i, dirName, 0.0); } else { tableRes.Rows.Add(selected[i].Count, refD, distRes, i, dirName); } currentV++; } if (checkBoxSable.Checked && refStructures.Count > 0) { Dictionary <string, double> res = null;// SableDist(refStructures); for (int i = 0; i < refStructures.Count; i++) { if (res.ContainsKey(Path.GetFileName(refStructures[i]))) { DataRow dr = tableDist.Rows[i]; dr[5] = Convert.ToDouble(String.Format("{0:0.00}", res[Path.GetFileName(refStructures[i])])); } } } if (checkBox1.Checked) { CalculateDistToAll(); } } catch (Exception ex) { exc = ex; } }
public ClusterOutput DendrogUsingMeasures(List<string> structures) { jury1D juryLocal = new jury1D(); juryLocal.PrepareJury(al); ClusterOutput outC = null; Dictionary<string, List<int>> dic; //Console.WriteLine("Start after jury " + Process.GetCurrentProcess().PeakWorkingSet64); maxV = 4; currentV = 0; dic = PrepareKeys(structures,false); currentV++; //DebugClass.DebugOn(); //dic = HashEntropyCombine(dic, structures,input.reqClusters); //Console.WriteLine("Entropy ready after jury " + Process.GetCurrentProcess().PeakWorkingSet64); DebugClass.WriteMessage("Entropy ready"); //Alternative way to start of UQclust Tree must be finished //input.relClusters = 10000; input.relClusters = input.reqClusters; input.perData = 90; //dic = FastCombineKeys(dic, structures, false); dic = FastCombineKeys(dic, structures, true); DebugClass.WriteMessage("dic size" + dic.Count); currentV++; //Console.WriteLine("Combine ready after jury " + Process.GetCurrentProcess().PeakWorkingSet64); DebugClass.WriteMessage("Combine Keys ready"); Dictionary<string, string> translateToCluster = new Dictionary<string, string>(dic.Count); List<string> structuresToDendrogram = new List<string>(dic.Count); List<string> structuresFullPath = new List<string>(dic.Count); DebugClass.WriteMessage("Number of clusters: "+dic.Count); int cc = 0; foreach (var item in dic) { if (item.Value.Count > 2) { List<string> cluster = new List<string>(item.Value.Count); foreach (var str in item.Value) cluster.Add(structures[str]); ClusterOutput output = juryLocal.JuryOptWeights(cluster); structuresToDendrogram.Add(output.juryLike[0].Key); if(alignFile==null) structuresFullPath.Add(dirName + Path.DirectorySeparatorChar + output.juryLike[0].Key); else structuresFullPath.Add(output.juryLike[0].Key); translateToCluster.Add(output.juryLike[0].Key, item.Key); } else { structuresToDendrogram.Add(structures[item.Value[0]]); if(alignFile==null) structuresFullPath.Add(dirName + Path.DirectorySeparatorChar + structures[item.Value[0]]); else structuresFullPath.Add(structures[item.Value[0]]); translateToCluster.Add(structures[item.Value[0]], item.Key); } cc++; } currentV++; DebugClass.WriteMessage("Jury finished"); switch (dMeasure) { case DistanceMeasures.HAMMING: if (refJuryProfile == null || !jury1d) throw new Exception("Sorry but for jury measure you have to define 1djury profile to find reference structure"); else dist = new JuryDistance(structuresFullPath, alignFile, true, profileName, refJuryProfile); break; case DistanceMeasures.COSINE: dist = new CosineDistance(structuresFullPath, alignFile, jury1d, profileName, refJuryProfile); break; case DistanceMeasures.RMSD: dist = new Rmsd(structuresFullPath, "", jury1d, atoms, refJuryProfile); break; case DistanceMeasures.MAXSUB: dist = new MaxSub(structuresFullPath, "", jury1d, refJuryProfile); break; } // return new ClusterOutput(); DebugClass.WriteMessage("Start hierarchical"); //Console.WriteLine("Start hierarchical " + Process.GetCurrentProcess().PeakWorkingSet64); currentV = maxV; hk = new hierarchicalCluster(dist, linkageType, dirName); dist.InitMeasure(); //Now just add strctures to the leaves outC = hk.HierarchicalClustering(structuresToDendrogram); DebugClass.WriteMessage("Stop hierarchical"); List<HClusterNode> hLeaves = outC.hNode.GetLeaves(); foreach(var item in hLeaves) { if (translateToCluster.ContainsKey(item.setStruct[0])) { foreach (var str in dic[translateToCluster[item.setStruct[0]]]) if (item.setStruct[0] != structures[str]) item.setStruct.Add(structures[str]); } else throw new Exception("Cannot add structure. Something is wrong"); } outC.hNode.RedoSetStructures(); return outC; }
List<KeyValuePair<string,double>> CLusterRepresentJury(string dirName, List<string> targets,string profileName) { List<string> fileNames = new List<string>(targets.Count); foreach (var item in targets) fileNames.Add(dirName + Path.DirectorySeparatorChar + item); jury1D jury = new jury1D(); jury.PrepareJury(fileNames, null, profileName); ClusterOutput opt = jury.JuryOptWeights(targets); return opt.juryLike; }
private void button2_Click(object sender, EventArgs e) { string[] aux; if (checkBox1.Checked) { if (jury1DSetup1.profileName == null || jury1DSetup1.profileName.Length == 0) { MessageBox.Show("Profile name for 1djury must be specified!"); this.DialogResult = DialogResult.None; return; } jury1D jury = new jury1D(); jury.PrepareJury(structures, "", jury1DSetup1.profileName); List <string> prep = new List <string>(); foreach (var item in structures) { aux = item.Split(Path.DirectorySeparatorChar); prep.Add(aux[aux.Length - 1]); } ClusterOutput oc = jury.JuryOptWeights(prep); for (int i = 0; i < selectBest1.bestNumber; i++) { bestJuryStructures.Add(oc.juryLike[i].Key); } } this.DialogResult = DialogResult.OK; if (selectBest1.getFileName != null && File.Exists(selectBest1.getFileName)) { DistanceMeasures measure = selectBest1.measure; structures.Add(selectBest1.getFileName); DistanceMeasure dist = null; switch (measure) { case DistanceMeasures.HAMMING: dist = new JuryDistance(structures, "", false, selectBest1.hammingProfile); break; case DistanceMeasures.MAXSUB: dist = new MaxSub(structures, "", false); break; case DistanceMeasures.RMSD: dist = new Rmsd(structures, "", false, selectBest1.CAtoms); break; } List <KeyValuePair <string, int> > distList = new List <KeyValuePair <string, int> >(); aux = selectBest1.getFileName.Split(Path.DirectorySeparatorChar); dist.InitMeasure(); string native = aux[aux.Length - 1]; foreach (var item in structures) { aux = item.Split(Path.DirectorySeparatorChar); int val = dist.GetDistance(native, aux[aux.Length - 1]); distList.Add(new KeyValuePair <string, int>(aux[aux.Length - 1], val)); } distList.Sort((firstPair, nextPair) => { return(firstPair.Value.CompareTo(nextPair.Value)); }); for (int i = 0; i < selectBest1.bestNumber; i++) { bestStructures.Add(distList[i].Key); } } }