private void Run() { string processName = ""; bool end = false; toolStripButton1.Enabled = false; ErrorBase.ClearErrors(); SetDataDirOptions(); do { GetProcessName gName = new GetProcessName(opt.clusterAlgorithm.ToString()); gName.ShowDialog(); if (gName.DialogResult == DialogResult.OK) { List <string> keys = new List <string>(manager.clOutput.Keys); Dictionary <string, int> dic = new Dictionary <string, int>(); foreach (var item in keys) { string [] aux = item.Split('_'); string l = ""; for (int i = 0; i < aux.Length - 1; i++) { l += aux[i]; } if (!dic.ContainsKey(l)) { dic.Add(l, 1); } } if (dic.ContainsKey(gName.name)) { MessageBox.Show("Process name: " + gName.name + " already exists"); } else { processName = gName.name; end = true; } } else { return; } }while (!end); manager.mUpdate = upMessage; try { TimeInterval.Start(); manager.RunJob(processName); } catch (Exception ex) { TimeInterval.Stop(); MessageBox.Show("Exception: " + ex.Message); } }
/* public override int Run(object processParams) * { * Dictionary<int, List<int>> contacts = new Dictionary<int, List<int>>(); * string fileName = ((ThreadFiles)(processParams)).fileName; * * List<string> files = threadingList[((ThreadFiles)(processParams)).threadNumber];// CheckFile(listFile); * if (files.Count == 0) * return 0; * StreamWriter wr; * * if (File.Exists(fileName)) * wr = File.AppendText(fileName); * else * wr = new StreamWriter(fileName); * * if (wr == null) * throw new Exception("Cannot open file: " + fileName); * * PDBFiles pdbs = new PDBFiles(); * PDBFiles pdbsNew = new PDBFiles(); * //Needed only for CATH * string []cathFiles=Directory.GetFiles("F:\\CATH"); * Dictionary<string, Dictionary<string, string>> aux = new Dictionary<string, Dictionary<string, string>>(); * foreach(var item in cathFiles) * { * if(item.Contains("COMBS")) * ReadCathFile(item, aux); * } * * * * //----------------------- * * * maxV = files.Count; * bool test=false; * try * { * foreach (var item in aux.Keys) * { * string strName; * * //if (!test && item.Contains("1vij")) * test = true; * * if (!test) * continue; * //strName = pdbs.AddPDB(item, PDBMODE.CA_CB); * strName = pdbs.AddPDB("F:\\cath_pdb\\"+item, PDBMODE.ONLY_CA,CHAIN_MODE.ALL); * * // if(aux.ContainsKey(pdbs.molDic)) * * if (strName != null) * { * if (!aux.ContainsKey(strName)) * Console.WriteLine("UPS"); * List<Chain> toRemove = new List<Chain>(); * chainId.Clear(); * pdbsNew.molDic.Clear(); * MolData mol=new MolData(); * mol.mol = new Molecule(); * pdbsNew.molDic=new Dictionary<string,MolData>(); * pdbsNew.molDic.Add(strName,mol); * char chStart = '0'; * foreach (var chains in aux[strName].Keys) * { * if (!chains.Contains("_")) * continue; * Console.WriteLine(chains); * Chain cc=pdbs.molDic[strName].mol.CuttMoleculeToSEQ(aux[strName][chains], chains.Substring(0, 1)[0]); * if(cc!=null) * { * cc.ChainIdentifier = chStart; * chainId.Add(chStart, chains); * chStart++; * pdbsNew.molDic[strName].mol.Chains.Add(cc); * } * } * if(pdbsNew.molDic[strName].mol.Chains.Count>0) * MakeProfiles(strName, pdbsNew.molDic[strName], wr); * } * pdbs.molDic.Clear(); * currentProgress++; * } * } * catch (Exception ex) * { * // wr.Close(); * throw new Exception(ex.Message); * } * * wr.Close(); * currentProgress = maxV; * return 0; * }*/ public override int Run(object processParams) { Dictionary <int, List <int> > contacts = new Dictionary <int, List <int> >(); string fileName = ((ThreadFiles)(processParams)).fileName; List <string> files = threadingList[((ThreadFiles)(processParams)).threadNumber];// CheckFile(listFile); if (files.Count == 0) { return(0); } StreamWriter wr; if (File.Exists(fileName)) { wr = File.AppendText(fileName); } else { wr = new StreamWriter(fileName); } if (wr == null) { throw new Exception("Cannot open file: " + fileName); } PDBFiles pdbs = new PDBFiles(); chunk = new float[dirSettings.numberOfCores][, ]; center = new float[dirSettings.numberOfCores][]; for (int i = 0; i < dirSettings.numberOfCores; i++) { chunk[i] = new float[fragBagLibrary[0].GetLength(0), fragBagLibrary[0].GetLength(1)]; center[i] = new float[3]; } maxV = files.Count; try { resetEvents = new ManualResetEvent[dirSettings.numberOfCores]; for (int i = 0; i < dirSettings.numberOfCores; i++) { resetEvents[i] = new ManualResetEvent(false); } foreach (var item in files) { string strName; //strName = pdbs.AddPDB(item, PDBMODE.CA_CB); if (dirSettings.mode == INPUTMODE.PROTEIN) { strName = pdbs.AddPDB(item, PDBMODE.ONLY_CA, CHAIN_MODE.ALL); } else { strName = pdbs.AddPDB(item, PDBMODE.ONLY_P, CHAIN_MODE.ALL); } // if(aux.ContainsKey(pdbs.molDic)) if (strName != null) { MakeProfiles(strName, pdbs.molDic[strName], wr); } pdbs.molDic.Clear(); ErrorBase.ClearErrors(); Interlocked.Increment(ref currentProgress); } } catch (Exception ex) { // wr.Close(); throw new Exception(ex.Message); } wr.Close(); // currentProgress = maxV; return(0); }