private DistanceMeasure CreateMeasureForDCD(DCDFile dcd, DistanceMeasures measure, PDB.PDBMODE atoms, bool jury1d, string alignFileName, string profileName = null, string refJuryProfile = null) { DistanceMeasure dist = null; switch (measure) { 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(dcd, alignFileName, true, profileName, refJuryProfile); } break; case DistanceMeasures.RMSD: dist = new Rmsd(dcd, alignFileName, jury1d, atoms, refJuryProfile); break; case DistanceMeasures.MAXSUB: dist = new MaxSub(dcd, alignFileName, jury1d, refJuryProfile); break; case DistanceMeasures.GDT_TS: dist = new GDT_TS(dcd, alignFileName, jury1d, refJuryProfile); break; } dist.InitMeasure(); return(dist); }
public void MakeProfiles(DCDFile dcd = null) { int active = 0; List <profileNode> prof = GetActiveProfiles(); if (prof == null) { return; } profilesNum = GetActiveProfiles().Count; profilesProgress = new List <double>(profilesNum); active = GenerateActiveProfiles(masterNode, dcd); foreach (var item in profiles) { foreach (var it in item.Value) { if (it.Value.profile.Count == 0) { throw new Exception("Failed to generate profiles!"); } } } if (active == 0) { throw new Exception("Error: there are no active profiles!"); } }
void RunHTree(string name, string dirName, string alignmentFile = null, DCDFile dcd = null) { DateTime cpuPart1 = DateTime.Now; HashCluster hCluster; if (dcd != null) { hCluster = new HashCluster(dcd, opt.hash); } else if (alignmentFile != null) { hCluster = new HashCluster("", alignmentFile, opt.hash); } else { hCluster = new HashCluster(dirName, null, opt.hash); } HTree h = new HTree(dirName, alignmentFile, hCluster); beginJob(currentProcessName, h.ToString(), dirName, "HAMMING"); progressDic.Add(name, h); hCluster.InitHashCluster(); DateTime cpuPart2 = DateTime.Now; ClusterOutput output = new ClusterOutput(); output = h.RunHTree(); UpdateOutput(name, dirName, alignmentFile, output, "NONE", cpuPart1, cpuPart2, h); }
protected void InitMeasure(DCDFile dcd, string alignFile, bool flag, PDBMODE allAtoms, string refJuryProfile = null) { base.InitMeasure(dcd, alignFile, flag, refJuryProfile); DCDReader readDCD = new DCDReader(dcd); pdbs = new PDBFiles(); readDCD.DCDPrepareReading(dcd.dcdFile, dcd.pdbFile); int counter = 0; bool cont = true; do { MemoryStream mStream = new MemoryStream(); StreamWriter wStream = new StreamWriter(mStream); cont=readDCD.ReadAndSavePDB(wStream); string name = "Model" + counter++; mStream.Position = 0; pdbs.AddPDB(mStream, allAtoms, name); } while(cont); readDCD.FinishDCDReading(); pdbs.FindReferenceSeq(); pdbs.MakeAlignment(alignFile); structNames = CheckAvailableStructures(); atomDic=pdbs.MakeAllAtomsDic(); }
public HashCluster(DCDFile dcd, HashCInput input) { this.dcd = dcd; this.input = input; currentV = 0; maxV = 4; threadNumbers = dirSettings.numberOfCores; }
public HashClusterDendrog(DCDFile dcd, HashCInput input, HierarchicalCInput dendrogOpt) : base(dcd, input) { this.dMeasure = dendrogOpt.distance; this.linkageType = dendrogOpt.linkageType; this.atoms = dendrogOpt.atoms; this.jury1d = dendrogOpt.reference1DjuryH; this.profileName = dendrogOpt.hammingProfile; this.refJuryProfile = dendrogOpt.jury1DProfileH; hier = dendrogOpt; }
public Rmsd(DCDFile dcd, string alignFile, bool flag, PDBMODE allAtoms, string refJuryProfile = null) { order = true; dirSettings.Load(); this.dcd = dcd; this.alignFile=alignFile; this.flag=flag; this.allAtoms=allAtoms; this.refJuryProfile = refJuryProfile; }
public HashClusterDendrog(DCDFile dcd, HashCInput input,DistanceMeasures dMeasure, AglomerativeType linkageType,PDB.PDBMODE atoms,bool jury1d,string alignFileName, string profileName=null,string refJuryProfile=null):base(dcd,input) { this.dMeasure=dMeasure; this.linkageType=linkageType; this.atoms = atoms; this.jury1d = jury1d; this.profileName = profileName; this.refJuryProfile = refJuryProfile; }
private void Run1DJury(string name, string dirName, string alignFile = null, DCDFile dcd = null) { DateTime cpuPart1 = DateTime.Now; ClusterOutput output; jury1D ju = new jury1D(); if (beginJob != null) { beginJob(currentProcessName, ju.ToString(), dirName, "NONE"); } 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 PrepareProfiles(DCDFile dcd) { profiles = new Dictionary <string, Dictionary <string, protInfo> >(); RemoveOutFiles(); MakeProfiles(dcd); if (File.Exists(listFile)) { File.Delete(listFile); } }
private void RunSift(string name, string dirName, DCDFile dcd = null) { DateTime cpuStart = DateTime.Now; ClusterOutput output = null; Sift s = new Sift(); if (beginJob != null) { beginJob(currentProcessName, s.ToString(), dirName, "NONE"); } progressDic.Add(name, s); clType = s.ToString(); output = s.RunSift(dirName); UpdateOutput(name, dirName, null, output, "Sift", cpuStart, DateTime.Now, s); }
private void RunKMeans(string name, string dirName, string alignFile = null, DCDFile dcd = null) { DateTime cpuPart1 = DateTime.Now; ClusterOutput clustOut; DistanceMeasure distance = null; if (dcd == null) { distance = CreateMeasure(name, dirName, opt.kmeans.kDistance, opt.kmeans.kAtoms, opt.kmeans.reference1Djury, alignFile, opt.kmeans.hammingProfile, opt.kmeans.jury1DProfile); } else { distance = CreateMeasureForDCD(dcd, opt.kmeans.kDistance, opt.kmeans.kAtoms, opt.kmeans.reference1Djury, opt.kmeans.alignmentFileName, opt.kmeans.hammingProfile, opt.kmeans.jury1DProfile); } kMeans km; km = new kMeans(distance, opt.kmeans.kMeans_init); if (beginJob != null) { beginJob(currentProcessName, km.ToString(), dirName, distance.ToString()); } progressDic.Add(name, km); distance.InitMeasure(); DateTime cpuPart2 = DateTime.Now; clType = km.ToString(); if ((int)opt.kmeans.maxK <= 1) { throw new Exception("k in k-Means must be bigger then 1, right now is: " + (int)opt.kmeans.maxK); } if (distance.structNames.Count < 10) { throw new Exception("Number of structures to cluster must be bigger then 10 right now is: " + distance.structNames.Count); } clustOut = km.kMeansLevel((int)opt.kmeans.maxK, opt.kmeans.maxIter, new List <string>(distance.structNames.Keys)); UpdateOutput(name, dirName, alignFile, clustOut, distance.ToString(), cpuPart1, cpuPart2, km); GC.SuppressFinalize(distance); }
private void StartAlignment(Settings dirSettings, string profName, DCDFile dcd, string dirName, List<string> fileNames ) { DebugClass.WriteMessage("Start align"); string refFile = null; this.dirSettings = dirSettings; // r = new ProfileTree(); r.LoadProfiles(profName); if (dcd != null) { DebugClass.WriteMessage("profiles gen started"); r.PrepareProfiles(dcd); } else if (dirName != null) { refFile = dirName + ".ref"; DebugClass.WriteMessage("profiles gen started"); r.PrepareProfiles(dirName); DebugClass.WriteMessage("finished"); refSeq=ReadRefSeq(refFile); } else { maxV = fileNames.Count; string name = fileNames[0]; if(fileNames[0].Contains("|")) { string[] aux = fileNames[0].Split('|'); name = aux[0]; } refFile = Directory.GetParent(name).ToString() + ".ref"; DebugClass.WriteMessage("profiles gen started"); r.PrepareProfiles(fileNames); DebugClass.WriteMessage("finished"); refSeq = ReadRefSeq(refFile); } DebugClass.WriteMessage("Prfofiles end"); }
private void StartAlignment(Settings dirSettings, string profName, DCDFile dcd, string dirName, List <string> fileNames) { DebugClass.WriteMessage("Start align"); string refFile = null; this.dirSettings = dirSettings; // r = new ProfileTree(); r.LoadProfiles(profName); if (dcd != null) { DebugClass.WriteMessage("profiles gen started"); r.PrepareProfiles(dcd); } else if (dirName != null) { refFile = dirName + ".ref"; DebugClass.WriteMessage("profiles gen started"); r.PrepareProfiles(dirName); DebugClass.WriteMessage("finished"); refSeq = ReadRefSeq(refFile); } else { maxV = fileNames.Count; string name = fileNames[0]; if (fileNames[0].Contains("|")) { string[] aux = fileNames[0].Split('|'); name = aux[0]; } refFile = Directory.GetParent(name).ToString() + ".ref"; DebugClass.WriteMessage("profiles gen started"); r.PrepareProfiles(fileNames); DebugClass.WriteMessage("finished"); refSeq = ReadRefSeq(refFile); } DebugClass.WriteMessage("Prfofiles end"); }
private void Run3DJury(string name, string dirName, string alignFile = null, DCDFile dcd = null) { DateTime cpuStart = DateTime.Now; ClusterOutput output; DistanceMeasure distance = null; if (alignFile != null) { distance = CreateMeasure(name, null, opt.other.oDistance, opt.other.oAtoms, opt.other.reference1Djury, alignFile, opt.other.hammingProfile, opt.other.referenceProfile); } else if (dirName != null) { distance = CreateMeasure(name, dirName, opt.other.oDistance, opt.other.oAtoms, opt.other.reference1Djury, alignFile, opt.other.hammingProfile, opt.other.referenceProfile); } else { distance = CreateMeasureForDCD(dcd, opt.other.oDistance, opt.other.oAtoms, opt.other.reference1Djury, opt.other.alignFileName, opt.other.hammingProfile, opt.other.referenceProfile); } Jury3D ju = new Jury3D(distance); if (beginJob != null) { beginJob(currentProcessName, ju.ToString(), dirName, distance.ToString()); } progressDic.Add(name, ju); distance.InitMeasure(); clType = ju.ToString(); output = ju.Run3DJury(); UpdateOutput(name, dirName, alignFile, output, distance.ToString(), cpuStart, DateTime.Now, ju); progressDic.Remove(name); }
public void Prepare(DCDFile dcd, Settings dirSettings, string profName) { StartAlignment(dirSettings, profName, dcd, null, null); }
private void RunFastHCluster(string name, string dirName, string alignFile = null, DCDFile dcd = null) { DateTime cpuPart1 = DateTime.Now; ClusterOutput clustOut = null; DistanceMeasure distance = null; if (dcd == null) { distance = CreateMeasure(name, dirName, opt.hierarchical.distance, opt.hierarchical.atoms, opt.hierarchical.reference1DjuryFast, alignFile, opt.hierarchical.hammingProfile, opt.hierarchical.jury1DProfileFast); } else { distance = CreateMeasureForDCD(dcd, opt.hierarchical.distance, opt.hierarchical.atoms, opt.hierarchical.reference1DjuryFast, opt.hierarchical.alignmentFileName, opt.hierarchical.hammingProfile, opt.hierarchical.jury1DProfileFast); } FastDendrog km; km = new FastDendrog(distance, opt.hierarchical, dirName); if (beginJob != null) { beginJob(currentProcessName, km.ToString(), dirName, distance.ToString()); } progressDic.Add(name, km); distance.InitMeasure(); DateTime cpuPart2 = DateTime.Now; clType = km.ToString(); clustOut = km.Run(new List <string>(distance.structNames.Keys)); UpdateOutput(name, dirName, alignFile, clustOut, distance.ToString(), cpuPart1, cpuPart2, km); }
public DCDReader(DCDFile dcdFile) { this.dcdFile = dcdFile; }
private void RunFastHCluster(string name, string dirName, string alignFile=null, DCDFile dcd = null) { DateTime cpuPart1 = DateTime.Now; ClusterOutput clustOut = null; DistanceMeasure distance = null; if(dcd==null) distance = CreateMeasure(name,dirName,opt.hierarchical.distance, opt.hierarchical.atoms, opt.hierarchical.reference1DjuryFast, alignFile, opt.hierarchical.hammingProfile, opt.hierarchical.jury1DProfileFast); else distance =CreateMeasureForDCD(dcd, opt.hierarchical.distance, opt.hierarchical.atoms, opt.hierarchical.reference1DjuryFast, opt.hierarchical.alignmentFileName, opt.hierarchical.hammingProfile, opt.hierarchical.jury1DProfileFast); FastDendrog km; km = new FastDendrog(distance, opt.hierarchical,dirName); progressDic.Add(name, km); distance.InitMeasure(); DateTime cpuPart2 = DateTime.Now; clType = km.ToString(); clustOut = km.Run(new List<string>(distance.structNames.Keys)); UpdateOutput(name, dirName,alignFile, clustOut, distance.ToString(), cpuPart1, cpuPart2, km); }
private void RunHierarchicalCluster(string name, string dirName,string alignFile=null, DCDFile dcd=null) { DateTime cpuPart1 = DateTime.Now; DistanceMeasure distance = null; //distance.CalcDistMatrix(distance.structNames); // opt.hierarchical.atoms = PDB.PDBMODE.ALL_ATOMS; if(dcd!=null) distance = CreateMeasureForDCD(dcd, opt.hierarchical.distance, opt.hierarchical.atoms, opt.hierarchical.reference1DjuryAglom, opt.hierarchical.alignmentFileName, opt.hierarchical.hammingProfile, opt.hierarchical.jury1DProfileAglom); else distance = CreateMeasure(name,dirName,opt.hierarchical.distance, opt.hierarchical.atoms, opt.hierarchical.reference1DjuryAglom, alignFile, opt.hierarchical.hammingProfile, opt.hierarchical.jury1DProfileAglom); DebugClass.WriteMessage("Measure Created"); hierarchicalCluster hk = new hierarchicalCluster(distance, opt.hierarchical.linkageType,dirName); clType = hk.ToString(); ClusterOutput output; progressDic.Add(name, hk); distance.InitMeasure(); DateTime cpuPart2 = DateTime.Now; output = hk.HierarchicalClustering(new List<string>(distance.structNames.Keys)); UpdateOutput(name, dirName, alignFile,output, distance.ToString(), cpuPart1, cpuPart2, hk); }
private void RunHierarchicalCluster(string name, string dirName, string alignFile = null, DCDFile dcd = null) { DateTime cpuPart1 = DateTime.Now; DistanceMeasure distance = null; //distance.CalcDistMatrix(distance.structNames); // opt.hierarchical.atoms = PDB.PDBMODE.ALL_ATOMS; if (dcd != null) { distance = CreateMeasureForDCD(dcd, opt.hierarchical.distance, opt.hierarchical.atoms, opt.hierarchical.reference1DjuryAglom, opt.hierarchical.alignmentFileName, opt.hierarchical.hammingProfile, opt.hierarchical.jury1DProfileAglom); } else { distance = CreateMeasure(name, dirName, opt.hierarchical.distance, opt.hierarchical.atoms, opt.hierarchical.reference1DjuryAglom, alignFile, opt.hierarchical.hammingProfile, opt.hierarchical.jury1DProfileAglom); } DebugClass.WriteMessage("Measure Created"); hierarchicalCluster hk = new hierarchicalCluster(distance, opt.hierarchical, dirName); if (beginJob != null) { beginJob(currentProcessName, hk.ToString(), dirName, distance.ToString()); } clType = hk.ToString(); ClusterOutput output; progressDic.Add(name, hk); distance.InitMeasure(); DateTime cpuPart2 = DateTime.Now; output = hk.HierarchicalClustering(new List <string>(distance.structNames.Keys)); UpdateOutput(name, dirName, alignFile, output, distance.ToString(), cpuPart1, cpuPart2, hk); }
private void RunHashDendrog(string name, string dirName, string alignmentFile = null, DCDFile dcd = null) { DateTime cpuPart1 = DateTime.Now; HashCluster hk = null; if (dcd != null) { hk = new HashCluster(dcd, opt.hash); } else if (alignmentFile != null) { hk = new HashCluster("", alignmentFile, opt.hash); } else { hk = new HashCluster(dirName, null, opt.hash); } progressDic.Add(name, hk); hk.InitHashCluster(); DateTime cpuPart2 = DateTime.Now; ClusterOutput output; output = hk.RunHashDendrog(); UpdateOutput(name, dirName, alignmentFile, output, "NONE", cpuPart1, cpuPart2, hk); }
private DistanceMeasure CreateMeasureForDCD(DCDFile dcd, DistanceMeasures measure, PDB.PDBMODE atoms, bool jury1d, string alignFileName, string profileName = null, string refJuryProfile = null) { DistanceMeasure dist=null; switch (measure) { 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(dcd, alignFileName, true, profileName, refJuryProfile); break; case DistanceMeasures.RMSD: dist = new Rmsd(dcd, alignFileName, jury1d, atoms, refJuryProfile); break; case DistanceMeasures.MAXSUB: dist = new MaxSub(dcd, alignFileName, jury1d, refJuryProfile); break; case DistanceMeasures.GDT_TS: dist = new GDT_TS(dcd, alignFileName, jury1d, refJuryProfile); break; } dist.InitMeasure(); return dist; }
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); }
private void RunBakerCluster(string name, string dirName, string alignFile=null,DCDFile dcd = null) { DateTime cpuPart1 = DateTime.Now; ClusterOutput output = null; DistanceMeasure distance = null; if(dcd==null) distance = CreateMeasure(name,dirName,opt.threshold.hDistance, opt.threshold.hAtoms, opt.threshold.reference1Djury, alignFile, opt.threshold.hammingProfile, null); else distance = CreateMeasureForDCD(dcd, opt.threshold.hDistance, opt.threshold.hAtoms, opt.threshold.reference1Djury, opt.threshold.alignmentFileName, opt.threshold.hammingProfile, null); ThresholdCluster bk = new ThresholdCluster(distance, opt.threshold.distThresh, opt.threshold.bakerNumberofStruct); progressDic.Add(name, bk); distance.InitMeasure(); DateTime cpuPart2 = DateTime.Now; clType = bk.ToString(); output = bk.OrgClustering(); UpdateOutput(name, dirName,alignFile, output, distance.ToString(), cpuPart1, cpuPart2,bk); }
void PrepareForDCD(DCDFile dcd, HashCInput input) { dirSettings.Load(); this.dcd = dcd; al = new Alignment(); al.Prepare(dcd, dirSettings, input.profileName); al.MyAlign(alignFile); stateAlign = al.GetStateAlign(); if (input.regular) { if (input.profileName == input.profileNameReg) stateAlignReg = stateAlign; else { Alignment alReg = new Alignment(); alReg.Prepare(dcd, dirSettings, input.profileNameReg); alReg.MyAlign(alignFile); stateAlignReg = alReg.GetStateAlign(); } } this.input = input; }
public MaxSub(DCDFile dcd, string alignFile, bool flag, string refJuryProfile = null) : base(dcd, alignFile, flag, PDBMODE.ONLY_CA,refJuryProfile) { order = true; maxSimilarity = 0.0; }
private void RunHashCluster(string name, string dirName, string alignmentFile = null, DCDFile dcd = null) { DateTime cpuPart1 = DateTime.Now; HashCluster hk = null; if (dcd != null) { hk = new HashCluster(dcd, opt.hash); } else if (alignmentFile != null) { hk = new HashCluster("", alignmentFile, opt.hash); } else { hk = new HashCluster(dirName, null, opt.hash); } progressDic.Add(name, hk); if (beginJob != null) { beginJob(currentProcessName, hk.ToString(), dirName, "HAMMING"); } hk.InitHashCluster(); DateTime cpuPart2 = DateTime.Now; ClusterOutput output; output = hk.RunHashCluster(); UpdateOutput(name, dirName, alignmentFile, output, "HAMMING", cpuPart1, cpuPart2, hk); }
public JuryDistance(DCDFile dcd, string alignFile, bool flag, string profileName, string refJuryProfile = null) :base(dcd, alignFile, flag, profileName, refJuryProfile) { }
private void RunHKMeans(string name, string dirName, string alignFile = null, DCDFile dcd = null) { DateTime cpuPart1 = DateTime.Now; ClusterOutput clustOut = null; DistanceMeasure distance = null; if (dcd == null) { distance = CreateMeasure(name, dirName, opt.hierarchical.distance, opt.hierarchical.atoms, opt.hierarchical.reference1DjuryKmeans, alignFile, opt.hierarchical.hammingProfile, opt.hierarchical.jury1DProfileKmeans); } else { distance = CreateMeasureForDCD(dcd, opt.hierarchical.distance, opt.hierarchical.atoms, opt.hierarchical.reference1DjuryKmeans, opt.hierarchical.alignmentFileName, opt.hierarchical.hammingProfile, opt.hierarchical.jury1DProfileKmeans); } kMeans km; km = new kMeans(distance, true); if (beginJob != null) { beginJob(currentProcessName, km.ToString(), dirName, distance.ToString()); } progressDic.Add(name, km); DateTime cpuPart2 = DateTime.Now; distance.InitMeasure(); clType = km.ToString(); km.BMIndex = opt.hierarchical.indexDB; km.threshold = opt.hierarchical.numberOfStruct; km.maxRepeat = opt.hierarchical.repeatTime; km.maxK = opt.hierarchical.maxK; clustOut = km.HierarchicalKMeans(); UpdateOutput(name, dirName, alignFile, clustOut, distance.ToString(), cpuPart1, cpuPart2, km); }
public void PrepareJury(DCDFile dcd, string alignFile, string profile = null) { currentProfile = profile; al.Prepare(dcd, set, currentProfile); CommonConstr(alignFile, profile); }
private void RunHashDendrogCombine(string name, string dirName, string alignmentFile = null, DCDFile dcd = null) { DateTime cpuPart1 = DateTime.Now; HashClusterDendrog hk = null; if (dcd != null) hk = new HashClusterDendrog(dcd, opt.hierarchical.hash, opt.hierarchical.distance, opt.hierarchical.linkageType, opt.hierarchical.atoms, opt.hierarchical.reference1DjuryH, opt.hierarchical.alignmentFileName, opt.hierarchical.hammingProfile, opt.hierarchical.jury1DProfileH); else if (alignmentFile != null) hk = new HashClusterDendrog(null, alignmentFile, opt.hierarchical.hash, opt.hierarchical.distance, opt.hierarchical.linkageType, opt.hierarchical.atoms, opt.hierarchical.reference1DjuryH, opt.hierarchical.alignmentFileName, opt.hierarchical.hammingProfile, opt.hierarchical.jury1DProfileH); else hk = new HashClusterDendrog(dirName, null, opt.hierarchical.hash, opt.hierarchical.distance, opt.hierarchical.linkageType, opt.hierarchical.atoms, opt.hierarchical.reference1DjuryH, opt.hierarchical.alignmentFileName, opt.hierarchical.hammingProfile, opt.hierarchical.jury1DProfileH); ClusterOutput output; progressDic.Add(name, hk); hk.InitHashCluster(); DateTime cpuPart2 = DateTime.Now; output = hk.RunHashDendrogCombine(); UpdateOutput(name, dirName,alignmentFile, output, hk.UsedMeasure(), cpuPart1, cpuPart2, hk); }
public int GenerateActiveProfiles(Dictionary <string, profileNode> node, DCDFile dcd = null) { int activeProfiles = 0; if (node == null) { node = masterNode; } if (profiles == null) { profiles = new Dictionary <string, Dictionary <string, protInfo> >(); } DebugClass.WriteMessage("Profiling started"); foreach (var item in node.Values) { if (item.active) { Dictionary <string, protInfo> profString; mgr.ResetProgress(); if (item.GetNumberofStates() == 0) { if (item.profProgram.Length > 0) { if (!profiles.ContainsKey(item.profName)) { activeProfiles++; if (File.Exists(item.OutFileName)) { File.Delete(item.OutFileName); } GenerateProfile(item); FileInfo f = new FileInfo(item.OutFileName); if (!File.Exists(item.OutFileName) || f == null || f.Length == 0) { throw new Exception("Error: profile " + item.profName + " did not generate output " + item.OutFileName); } } } } else { DebugClass.WriteMessage("Run profiling"); if (dcd == null) { mgr.RunProfile(item.internalName, listFile); } else { mgr.RunProfile(item.internalName, dcd); } activeProfiles++; } if (item.childrens.Count > 0) { activeProfiles += GenerateActiveProfiles(item.childrens); } else { if (!profiles.ContainsKey(item.profName)) { if (item.GetNumberofStates() == 0) { profString = ReadProfile(item); } else { if (dcd == null) { profString = mgr.GetProfile(item, listFile); } else { profString = InternalProfilesManager.GetProfile(item, dcd); } } if (profString != null && profString.Count > 0) { profiles.Add(item.profName, profString); } else { throw new Exception("For profile " + item.profName + " profiles has not been generated!"); } } } profilesProgress.Add(mgr.ProgressUpdate()); } } progressObject = null; return(activeProfiles); }
private void RunHKMeans(string name, string dirName, string alignFile=null,DCDFile dcd = null) { DateTime cpuPart1 = DateTime.Now; ClusterOutput clustOut = null; DistanceMeasure distance = null; if(dcd==null) distance = CreateMeasure(name,dirName,opt.hierarchical.distance, opt.hierarchical.atoms, opt.hierarchical.reference1DjuryKmeans, alignFile, opt.hierarchical.hammingProfile, opt.hierarchical.jury1DProfileKmeans); else distance = CreateMeasureForDCD(dcd, opt.hierarchical.distance, opt.hierarchical.atoms, opt.hierarchical.reference1DjuryKmeans, opt.hierarchical.alignmentFileName, opt.hierarchical.hammingProfile, opt.hierarchical.jury1DProfileKmeans); kMeans km; km = new kMeans(distance,true); progressDic.Add(name, km); DateTime cpuPart2 = DateTime.Now; distance.InitMeasure(); clType = km.ToString(); km.BMIndex = opt.hierarchical.indexDB; km.threshold = opt.hierarchical.numberOfStruct; km.maxRepeat = opt.hierarchical.repeatTime; km.maxK = opt.hierarchical.maxK; clustOut = km.HierarchicalKMeans(); UpdateOutput(name, dirName,alignFile,clustOut, distance.ToString(), cpuPart1, cpuPart2, km); }
private void RunBakerCluster(string name, string dirName, string alignFile = null, DCDFile dcd = null) { DateTime cpuPart1 = DateTime.Now; ClusterOutput output = null; DistanceMeasure distance = null; if (dcd == null) { distance = CreateMeasure(name, dirName, opt.threshold.hDistance, opt.threshold.hAtoms, opt.threshold.reference1Djury, alignFile, opt.threshold.hammingProfile, null); } else { distance = CreateMeasureForDCD(dcd, opt.threshold.hDistance, opt.threshold.hAtoms, opt.threshold.reference1Djury, opt.threshold.alignmentFileName, opt.threshold.hammingProfile, null); } ThresholdCluster bk = new ThresholdCluster(distance, opt.threshold.distThresh, opt.threshold.bakerNumberofStruct); if (beginJob != null) { beginJob(currentProcessName, bk.ToString(), dirName, distance.ToString()); } progressDic.Add(name, bk); distance.InitMeasure(); DateTime cpuPart2 = DateTime.Now; clType = bk.ToString(); output = bk.OrgClustering(); UpdateOutput(name, dirName, alignFile, output, distance.ToString(), cpuPart1, cpuPart2, bk); }
private void RunKMeans(string name, string dirName, string alignFile=null, DCDFile dcd = null) { DateTime cpuPart1 = DateTime.Now; ClusterOutput clustOut; DistanceMeasure distance = null; if(dcd==null) distance = CreateMeasure(name,dirName,opt.kmeans.kDistance, opt.kmeans.kAtoms, opt.kmeans.reference1Djury, alignFile, opt.kmeans.hammingProfile, opt.kmeans.jury1DProfile); else distance =CreateMeasureForDCD(dcd, opt.kmeans.kDistance, opt.kmeans.kAtoms, opt.kmeans.reference1Djury, opt.kmeans.alignmentFileName, opt.kmeans.hammingProfile, opt.kmeans.jury1DProfile); kMeans km; km = new kMeans(distance, opt.kmeans.kMeans_init); progressDic.Add(name, km); distance.InitMeasure(); DateTime cpuPart2 = DateTime.Now; clType = km.ToString(); if ((int)opt.kmeans.maxK <= 1) throw new Exception("k in k-Means must be bigger then 1, right now is: " + (int)opt.kmeans.maxK); if (distance.structNames.Count < 10) throw new Exception("Number of structures to cluster must be bigger then 10 right now is: " + distance.structNames.Count); clustOut = km.kMeansLevel((int)opt.kmeans.maxK, opt.kmeans.maxIter,new List <string>(distance.structNames.Keys)); UpdateOutput(name, dirName,alignFile, clustOut, distance.ToString(), cpuPart1, cpuPart2,km); GC.SuppressFinalize(distance); }
public void ReadOptionFile(string fileName) { if (File.Exists(fileName)) { string line; MemberInfo memB; StreamReader r = new StreamReader(fileName); // DebugClass.DebugOn(); DebugClass.WriteMessage("Start reading " + fileName); while (!r.EndOfStream) { line = r.ReadLine(); if (line.Contains("#####")) { if (line.Contains("Parameters hierarchical")) { hierarchical.ReadOptionFile(r); } else if (line.Contains("Parameters threshold")) { threshold.ReadOptionFile(r); } else if (line.Contains("Parameters other")) { other.ReadOptionFile(r); } else if (line.Contains("Parameters Hash")) { hash.ReadOptionFile(r); } else if (line.Contains("Parameters kmeans")) { kmeans.ReadOptionFile(r); } } line = line.Replace("# ", "#"); line = line.TrimEnd(new char [] { '\r', '\n' }); string[] strTab = line.Split('#'); if (strTab[1].Length == 0) { continue; } if (dicField.ContainsKey(strTab[0])) { if (dicField[strTab[0]].Contains("Generic.List")) { if (strTab[1].EndsWith(";")) { strTab[1] = strTab[1].Remove(strTab[1].Length - 1, 1); } string[] aux = strTab[1].Split(';'); if (strTab[0].Contains("dcd")) { dcdFiles.Clear(); foreach (var item in aux) { string[] tmp = item.Split(','); DCDFile dcd = new DCDFile(); dcd.dcdFile = tmp[0]; dcd.pdbFile = tmp[1]; dcd.tempDir = tmp[2]; dcdFiles.Add(dcd); } } else { if (strTab[0].Contains("prof")) { profileFiles.Clear(); foreach (var item in aux) { profileFiles.Add(item); } } if (strTab[0].Contains("algorithm")) { clusterAlgorithm.Clear(); foreach (var item in aux) { clusterAlgorithm.Add((ClusterAlgorithm)Enum.Parse(typeof(ClusterAlgorithm), item)); } } if (strTab[0].Contains("data")) { dataDir.Clear(); foreach (var item in aux) { dataDir.Add(item); } } continue; } } memB = dicMem[strTab[0]]; string ww = memB.ReflectedType.GetField(memB.Name).FieldType.Name; switch (ww) { case "string": case "String": memB.ReflectedType.GetField(memB.Name).SetValue(this, strTab[1]); break; case "Boolean": memB.ReflectedType.GetField(memB.Name).SetValue(this, Convert.ToBoolean(strTab[1])); break; case "Single": memB.ReflectedType.GetField(memB.Name).SetValue(this, Convert.ToSingle(strTab[1])); break; case "Int32": memB.ReflectedType.GetField(memB.Name).SetValue(this, Convert.ToInt32(strTab[1])); break; case "Initialization": memB.ReflectedType.GetField(memB.Name).SetValue(this, Enum.Parse(typeof(Initialization), strTab[1])); break; case "PDBMODE": memB.ReflectedType.GetField(memB.Name).SetValue(this, Enum.Parse(typeof(PDB.PDBMODE), strTab[1])); break; case "ClusterAlgorithm": memB.ReflectedType.GetField(memB.Name).SetValue(this, Enum.Parse(typeof(ClusterAlgorithm), strTab[1])); break; case "DistanceMeasures": memB.ReflectedType.GetField(memB.Name).SetValue(this, Enum.Parse(typeof(DistanceMeasures), strTab[1])); break; case "AglomerativeType": memB.ReflectedType.GetField(memB.Name).SetValue(this, Enum.Parse(typeof(AglomerativeType), strTab[1])); break; case "COL_SELECTION": memB.ReflectedType.GetField(memB.Name).SetValue(this, Enum.Parse(typeof(COL_SELECTION), strTab[1])); break; } //SetValue(this, strTab[1]); } else { DebugClass.WriteMessage("Not recognized: " + strTab[0]); } } r.Close(); } else { throw new Exception("Config file not found"); } DebugClass.WriteMessage("Reading finished"); }
private void RunSift(string name, string dirName,DCDFile dcd = null) { DateTime cpuStart = DateTime.Now; ClusterOutput output = null; Sift s = new Sift(); progressDic.Add(name, s); clType = s.ToString(); output=s.RunSift(dirName); UpdateOutput(name, dirName, null,output, "Sift",cpuStart,DateTime.Now, s); }
public void Prepare(DCDFile dcd,Settings dirSettings, string profName) { StartAlignment(dirSettings, profName, dcd, null, null); }
private void Run3DJury(string name, string dirName, string alignFile=null, DCDFile dcd = null) { DateTime cpuStart = DateTime.Now; ClusterOutput output; DistanceMeasure distance = null; if(alignFile!=null) distance = CreateMeasure(name,null,opt.other.oDistance, opt.other.oAtoms, opt.other.reference1Djury, alignFile, opt.other.hammingProfile, opt.other.referenceProfile); else if(dirName!=null) distance = CreateMeasure(name,dirName,opt.other.oDistance, opt.other.oAtoms, opt.other.reference1Djury, alignFile, opt.other.hammingProfile, opt.other.referenceProfile); else distance = CreateMeasureForDCD(dcd, opt.other.oDistance, opt.other.oAtoms, opt.other.reference1Djury, opt.other.alignFileName, opt.other.hammingProfile, opt.other.referenceProfile); Jury3D ju = new Jury3D(distance); progressDic.Add(name, ju); distance.InitMeasure(); clType = ju.ToString(); output = ju.Run3DJury(); UpdateOutput(name, dirName,alignFile,output, distance.ToString(), cpuStart, DateTime.Now,ju); progressDic.Remove(name); }
public void ReadOptionFile(string fileName) { if (File.Exists(fileName)) { string line; MemberInfo memB; StreamReader r = new StreamReader(fileName); // DebugClass.DebugOn(); DebugClass.WriteMessage("Start reading " + fileName); while(!r.EndOfStream) { line = r.ReadLine(); if (line.Contains("#####")) { if (line.Contains("Parameters hierarchical")) hierarchical.ReadOptionFile(r); else if (line.Contains("Parameters threshold")) threshold.ReadOptionFile(r); else if (line.Contains("Parameters other")) other.ReadOptionFile(r); else if (line.Contains("Parameters Hash")) hash.ReadOptionFile(r); else if(line.Contains("Parameters kmeans")) kmeans.ReadOptionFile(r); } line=line.Replace("# ", "#"); line=line.TrimEnd(new char []{'\r','\n'}); string[] strTab = line.Split('#'); if (strTab[1].Length == 0) continue; if (dicField.ContainsKey(strTab[0])) { if (dicField[strTab[0]].Contains("Generic.List")) { if(strTab[1].EndsWith(";")) strTab[1] = strTab[1].Remove(strTab[1].Length - 1, 1); string[] aux = strTab[1].Split(';'); if (strTab[0].Contains("dcd")) { dcdFiles.Clear(); foreach (var item in aux) { string[] tmp = item.Split(','); DCDFile dcd = new DCDFile(); dcd.dcdFile = tmp[0]; dcd.pdbFile = tmp[1]; dcd.tempDir = tmp[2]; dcdFiles.Add(dcd); } } else { if (strTab[0].Contains("prof")) { profileFiles.Clear(); foreach (var item in aux) profileFiles.Add(item); } if(strTab[0].Contains("algorithm")) { clusterAlgorithm.Clear(); foreach (var item in aux) { clusterAlgorithm.Add((ClusterAlgorithm)Enum.Parse(typeof(ClusterAlgorithm), item)); } } if(strTab[0].Contains("data")) { dataDir.Clear(); foreach (var item in aux) dataDir.Add(item); } continue; } } memB = dicMem[strTab[0]]; string ww = memB.ReflectedType.GetField(memB.Name).FieldType.Name; switch (ww) { case "string": case "String": memB.ReflectedType.GetField(memB.Name).SetValue(this, strTab[1]); break; case "Boolean": memB.ReflectedType.GetField(memB.Name).SetValue(this, Convert.ToBoolean(strTab[1])); break; case "Single": memB.ReflectedType.GetField(memB.Name).SetValue(this, Convert.ToSingle(strTab[1])); break; case "Int32": memB.ReflectedType.GetField(memB.Name).SetValue(this, Convert.ToInt32(strTab[1])); break; case "Initialization": memB.ReflectedType.GetField(memB.Name).SetValue(this, Enum.Parse(typeof(Initialization), strTab[1])); break; case "PDBMODE": memB.ReflectedType.GetField(memB.Name).SetValue(this, Enum.Parse(typeof(PDB.PDBMODE), strTab[1])); break; case "ClusterAlgorithm": memB.ReflectedType.GetField(memB.Name).SetValue(this, Enum.Parse(typeof(ClusterAlgorithm), strTab[1])); break; case "DistanceMeasures": memB.ReflectedType.GetField(memB.Name).SetValue(this, Enum.Parse(typeof(DistanceMeasures), strTab[1])); break; case "AglomerativeType": memB.ReflectedType.GetField(memB.Name).SetValue(this, Enum.Parse(typeof(AglomerativeType), strTab[1])); break; case "COL_SELECTION": memB.ReflectedType.GetField(memB.Name).SetValue(this, Enum.Parse(typeof(COL_SELECTION), strTab[1])); break; } //SetValue(this, strTab[1]); } else DebugClass.WriteMessage("Not recognized: " + strTab[0]); } r.Close(); } else throw new Exception("Config file not found"); DebugClass.WriteMessage("Reading finished"); }
private void RunHashCluster(string name, string dirName, string alignmentFile=null,DCDFile dcd = null) { DateTime cpuPart1 = DateTime.Now; HashCluster hk = null; if (dcd != null) hk = new HashCluster(dcd, opt.hash); else if(alignmentFile!=null) hk = new HashCluster("", alignmentFile, opt.hash); else hk = new HashCluster(dirName, null, opt.hash); progressDic.Add(name, hk); hk.InitHashCluster(); DateTime cpuPart2 = DateTime.Now; ClusterOutput output; output = hk.RunHashCluster(); UpdateOutput(name, dirName,alignmentFile, output, "NONE", cpuPart1, cpuPart2, hk); }
private void RunHashDendrogCombine(string name, string dirName, string alignmentFile = null, DCDFile dcd = null) { DateTime cpuPart1 = DateTime.Now; HashClusterDendrog hk = null; if (dcd != null) { hk = new HashClusterDendrog(dcd, opt.hash, opt.hierarchical); } else if (alignmentFile != null) { hk = new HashClusterDendrog(null, alignmentFile, opt.hash, opt.hierarchical); } else { hk = new HashClusterDendrog(dirName, null, opt.hash, opt.hierarchical); } ClusterOutput output; if (beginJob != null) { beginJob(currentProcessName, hk.ToString(), dirName, "NONE"); } progressDic.Add(name, hk); hk.InitHashCluster(); DateTime cpuPart2 = DateTime.Now; output = hk.RunHashDendrogCombine(); UpdateOutput(name, dirName, alignmentFile, output, hk.UsedMeasure(), cpuPart1, cpuPart2, hk); }