private void GetKtuple(SequenceIntList sil, int k) { act(0, "\r\n\t正在计算ktuple\r\n\t......\r\n"); Stopwatch sp = new Stopwatch(); sp.Start(); //序列名字节点 //Parallel.ForEach(list, (item) => // { // string seqName = Path.GetFileNameWithoutExtension(item); // KtupleCount kc = new KtupleCount(item, k); // kc.GetKtupleList(); // dicKtuple[seqName].Add(k, kc.ListCount); // dicTotal[seqName].Add(k, kc.Total); // act(1, ""); // }); Parallel.For(0, sil.Count, (i) => { KtupleCount kc = new KtupleCount(sil.ListSequenceIntList[i], k); kc.GetKtupleList(); dicKtuple[sil.ListSeqName[i]].Add(k, kc.ListCount); dicTotal[sil.ListSeqName[i]].Add(k, kc.Total); act(1, ""); }); sp.Stop(); act(0, "\tk = " + k + " 计算完毕,用时 " + sp.ElapsedMilliseconds * 1.0 / 1000 + " s\r\n\r\n"); }
private void GetKtuple(TreeNode node, string oneSeqPath = "") { act(0, "\r\n\t正在计算ktuple\r\n\t......\r\n"); Stopwatch sp = new Stopwatch(); sp.Start(); //序列名字节点 List <string> list = new List <string>(); if (oneSeqPath != "") { list.Add(oneSeqPath); string seqName = Path.GetFileNameWithoutExtension(oneSeqPath); dicTotal.Add(seqName, new Dictionary <int, int>()); dicKtuple.Add(seqName, new Dictionary <int, List <int> >()); } foreach (TreeNode item in node.Nodes) { string tmp = (string)item.Tag; list.Add(tmp); string seqName = Path.GetFileNameWithoutExtension(tmp); dicTotal.Add(seqName, new Dictionary <int, int>()); dicKtuple.Add(seqName, new Dictionary <int, List <int> >()); } Parallel.ForEach(list, (item) => { string seqName = Path.GetFileNameWithoutExtension(item); for (int i = 0; i < listK.Count; i++) { KtupleCount kc = new KtupleCount(item, listK[i]); kc.GetKtupleList(); dicKtuple[seqName].Add(ListK[i], kc.ListCount); dicTotal[seqName].Add(ListK[i], kc.Total); act(1, ""); } }); sp.Stop(); act(0, "\t计算完毕,用时 " + sp.ElapsedMilliseconds * 1.0 / 1000 + " s\r\n\r\n"); }