public int Color_flag = 2; //0:N_color, 1:C_color, 2:A_color public MS2_Denovol_Setting(MS2_Help ms2_help, Denovol_Help den_help) { InitializeComponent(); this.Ms2_help = ms2_help; this.Denovol_help = den_help; if (Display_Help.IsEqual(this.Denovol_help.b_color, this.Denovol_help.current_color)) { Color_flag = 0; } else if (Display_Help.IsEqual(this.Denovol_help.y_color, this.Denovol_help.current_color)) { Color_flag = 1; } else if (Display_Help.IsEqual(this.Denovol_help.default_color, this.Denovol_help.current_color)) { Color_flag = 2; } Color n_color = Color.FromArgb(this.Denovol_help.b_color.A, this.Denovol_help.b_color.R, this.Denovol_help.b_color.G, this.Denovol_help.b_color.B); Color c_color = Color.FromArgb(this.Denovol_help.y_color.A, this.Denovol_help.y_color.R, this.Denovol_help.y_color.G, this.Denovol_help.y_color.B); Color a_color = Color.FromArgb(this.Denovol_help.default_color.A, this.Denovol_help.default_color.R, this.Denovol_help.default_color.G, this.Denovol_help.default_color.B); this.N_btn.Background = new SolidColorBrush(n_color); this.C_btn.Background = new SolidColorBrush(c_color); this.A_btn.Background = new SolidColorBrush(a_color); }
public Model_Window(PlotModel Model, Display_Help dis_help, double width, double height) //绘制二级匹配图 { InitializeComponent(); this.scale_width = Ladder_Help.Scale_Width; this.scale_height = Ladder_Help.Scale_Height; this.width = width; this.height = height; this.Model = Model; MS2_Help ms2_help = new MS2_Help(Model, dis_help, scale_width, scale_height); this.Model.Axes[1].AxisChanged += (s, e) => { ms2_help = new MS2_Help(Model, dis_help, scale_width, scale_height); ms2_help.window_sizeChg_Or_ZoomPan(); }; this.dis_help = dis_help; this.model.Model = this.Model; ms2_help.window_sizeChg_Or_ZoomPan(); this.SizeChanged += Window_sizeChg; this.Title = "PSM Figure"; }
public Model_Window_DeNovo(MainWindow mainW, PlotModel Model, Display_Help dis_help, double width, double height) //绘制二级匹配图 { InitializeComponent(); this.scale_width = Ladder_Help.Scale_Width; this.scale_height = Ladder_Help.Scale_Height; this.width = width; this.height = height; this.Model = Model; this.mainW = mainW; ms2_help = new MS2_Help(Model, dis_help, scale_width, scale_height); ms2_help.Den_help.isDenovol = true; this.Model.Axes[1].AxisChanged += (s, e) => { //ms2_help = new MS2_Help(Model, dis_help, scale_width, scale_height); //ms2_help.isDenovol = true; ms2_help.window_sizeChg_Or_ZoomPan(); }; this.dis_help = dis_help; this.model.Model = this.Model; ms2_help.window_sizeChg_Or_ZoomPan(); this.SizeChanged += Window_sizeChg; this.Title = "De novol"; this.Original_Peaks = new List <PEAK>(dis_help.Psm_help.Spec.Peaks); }
private void compare_btn_clk(object sender, RoutedEventArgs e) { if (this.all_tasks_lv.Items.Count <= 1 || this.all_tasks_lv.Items.Count >= 4) { MessageBox.Show(Message_Help.TASK_COMPARE_WRONG); return; } List <Task> tasks = new List <Task>(); List <List <string> > rawss_path = new List <List <string> >(); for (int i = 0; i < this.all_tasks_lv.Items.Count; ++i) { Task task = new Task(this.all_tasks_lv.Items[i] as string, "pTop"); tasks.Add(task); rawss_path.Add(task.get_raws_path()); } bool is_right = true; for (int i = 0; i < rawss_path.Count; ++i) { for (int j = i + 1; j < rawss_path.Count; ++j) { if (is_not_equal(rawss_path[i], rawss_path[j])) { string caption = "Warning"; string wrong_message = Message_Help.TASK_NOT_EQUAL + "\r\n"; for (int k = 0; k < rawss_path.Count; ++k) { wrong_message += (k + 1) + ":\r\n"; for (int p = 0; p < rawss_path[k].Count; ++p) { wrong_message += rawss_path[k][p] + "\r\n"; } } //MessageBoxButton buttons = MessageBoxButton.YesNo; //MessageBoxImage icon = MessageBoxImage.Warning; //if (MessageBox.Show(wrong_message, caption, buttons, icon) == MessageBoxResult.Yes) //{ // is_right = true; //} //else //{ // is_right=false; //} } } } if (!is_right) { return; } //对比List<task>的结果 int raws_number = rawss_path[0].Count; System.Collections.Hashtable raw_index = new System.Collections.Hashtable(); for (int i = 0; i < raws_number; ++i) { raw_index[rawss_path[0][i]] = i; } List <Task_Compare_Sample> task_compares = new List <Task_Compare_Sample>(); for (int i = 0; i < tasks.Count; ++i) { Task_Compare_Sample tcs = new Task_Compare_Sample(tasks[i], rawss_path[i].Count); for (int j = 0; j < rawss_path[i].Count; ++j) { string raw_path = rawss_path[i][j]; string raw_name = raw_path.Split('\\').Last(); raw_name = raw_name.Split('.').First(); tcs.update_psms((int)raw_index[rawss_path[i][j]], raw_name); } task_compares.Add(tcs); } //分RAW来进行比较 if (task_compares.Count == 2) //两个任务的比较 { Task_Compare_Sample ta = task_compares[0]; Task_Compare_Sample tb = task_compares[1]; string result = ""; List <int> numbers = new List <int>(); for (int i = 0; i < raws_number; ++i) { List <PSM> ta_psms = ta.psms[i]; List <PSM> tb_psms = tb.psms[i]; int same_number = get_same_number(ta_psms, tb_psms); string raw_name = ta_psms[0].Title.Split('.')[0] + ".raw"; result += "---------------------" + "\r\n"; result += raw_name + " :\r\n"; result += "A: " + ta_psms.Count + "\r\n"; result += "B: " + tb_psms.Count + "\r\n"; result += "A&B: " + same_number + "\r\n"; result += "---------------------" + "\r\n"; numbers.Add(ta_psms.Count); numbers.Add(tb_psms.Count); numbers.Add(same_number); } Display_Help dh = new Display_Help(); //有两个任务,有多个RAW的结果,每个RAW的结果都有一张图 PlotModel model = dh.display_compare_result(numbers); Plot oxyplot = new Plot(); oxyplot.Model = model; oxyplot.Width = 400; oxyplot.Height = 400; this.compare_result_sp.Children.Add(oxyplot); MessageBox.Show(result); } else if (task_compares.Count == 3) //三个任务的比较 { Task_Compare_Sample ta = task_compares[0]; Task_Compare_Sample tb = task_compares[1]; Task_Compare_Sample tc = task_compares[2]; string result = ""; List <int> numbers = new List <int>(); for (int i = 0; i < raws_number; ++i) { List <PSM> ta_psms = ta.psms[i]; List <PSM> tb_psms = tb.psms[i]; List <PSM> tc_psms = tc.psms[i]; int same_number1 = get_same_number(ta_psms, tb_psms); int same_number2 = get_same_number(ta_psms, tc_psms); int same_number3 = get_same_number(tb_psms, tc_psms); int same_number4 = get_same_number(ta_psms, tb_psms, tc_psms); string raw_name = ta_psms[0].Title.Split('.')[0] + ".raw"; result += "---------------------" + "\r\n"; result += raw_name + " :\r\n"; result += "A: " + ta_psms.Count + "\r\n"; result += "B: " + tb_psms.Count + "\r\n"; result += "C: " + tc_psms.Count + "\r\n"; result += "A&B: " + same_number1 + "\r\n"; result += "A&C: " + same_number2 + "\r\n"; result += "B&C: " + same_number3 + "\r\n"; result += "A&B&C: " + same_number4 + "\r\n"; result += "---------------------" + "\r\n"; numbers.Add(ta_psms.Count); numbers.Add(tb_psms.Count); numbers.Add(tc_psms.Count); numbers.Add(same_number1); numbers.Add(same_number2); numbers.Add(same_number3); numbers.Add(same_number4); } Display_Help dh = new Display_Help(); //有三个任务,有多个RAW的结果,每个RAW的结果都有一张图 PlotModel model = dh.display_compare_result2(numbers); Plot oxyplot = new Plot(); oxyplot.Model = model; oxyplot.Width = 400; oxyplot.Height = 400; this.compare_result_sp.Children.Add(oxyplot); MessageBox.Show(result); } }
private void raw_select(object sender, SelectionChangedEventArgs e) { this.Cursor = Cursors.Wait; string raw_name = this.raw_comboBox.SelectedItem as string; List <string> pf_paths = mainW.task.get_raws_path(); string pf_path = ""; for (int i = 0; i < pf_paths.Count; ++i) { int index = pf_paths[i].LastIndexOf('\\'); int index2 = pf_paths[i].LastIndexOf('.'); if (pf_paths[i].Substring(index + 1, index2 - index - 1) == raw_name) { pf_path = pf_paths[i].Substring(0, index2) + ".pf1"; break; } } if (MS1_Ratio == 0) { List <List <Spectra_MS1> > ms1_list = File_Help.load_ms1(pf_path, raw_name, mainW); Display_Help dh = new Display_Help(ms1_list, this.mainW); this.Model = dh.display_heat_map(); } else if (MS1_Ratio == 1) { if (!mainW.task.has_ratio) { MessageBox.Show("No ratio!"); return; } double max_scan = double.MinValue; double min_scan = double.MaxValue; for (int i = 0; i < mainW.psms.Count; ++i) { string title = mainW.psms[i].Title.Split('.')[0]; if (title != raw_name) { continue; } double scan = mainW.psms[i].get_scan(); if (max_scan < scan) { max_scan = scan; } if (min_scan > scan) { min_scan = scan; } } int bin_number = 49; double scan_width = (max_scan - min_scan) / bin_number; //打分宽度,让最终形成50个bin double cur_scan = min_scan; List <double> all_scans = new List <double>(); List <int> scan_bin_list = new List <int>(); while (cur_scan <= max_scan) { all_scans.Add(cur_scan); cur_scan += scan_width; scan_bin_list.Add(0); } for (int i = 0; i < mainW.psms.Count; ++i) { string title = mainW.psms[i].Title.Split('.')[0]; if (title != raw_name) { continue; } double ratio = mainW.psms[i].Ratio; if (ratio >= 1024 || ratio <= 0.001) { continue; } int index = (int)((mainW.psms[i].get_scan() - min_scan) / scan_width); if (index < scan_bin_list.Count) { ++scan_bin_list[index]; } } Display_Help dh = new Display_Help(all_scans, scan_bin_list, this.mainW); this.Model = dh.display_scan_ratio_graph(); } this.model.Model = this.Model; this.Cursor = null; }
private void compare_btn_clk(object sender, RoutedEventArgs e) { if (this.all_tasks_lv.Items.Count != 1 || this.all_tasks_lv2.Items.Count != 1) { return; } StreamReader sr_max = new StreamReader(all_tasks_lv2.Items[0] as string); StreamWriter sw_same = new StreamWriter("same.txt"); StreamWriter sw_notSame = new StreamWriter("MaxQuant_pFindNot.txt"); List <string> max_str = new List <string>(); List <string> find_str = new List <string>(); string line = sr_max.ReadLine(); string[] titles = line.Split('\t'); int raw_index = -1, scan_index = -1, sq_index = -1; for (int i = 0; i < titles.Length; ++i) { if (titles[i] == "Raw file") { raw_index = i; } else if (titles[i] == "Scan number") { scan_index = i; } else if (titles[i] == "Sequence") { sq_index = i; } } if (raw_index == -1 || scan_index == -1 || sq_index == -1) { return; } while (!sr_max.EndOfStream) { line = sr_max.ReadLine(); if (line.Trim() == "") { continue; } string[] strs = line.Split('\t'); //9 scan,11 sq string sq = strs[sq_index]; sq = sq.Replace('L', 'I'); string scan_sq = strs[raw_index] + "@" + strs[scan_index] + "@" + sq; //raw@scan@sq max_str.Add(scan_sq); } sr_max.Close(); string pfind_task_path = all_tasks_lv.Items[0] as string; Task task = new Task(pfind_task_path, "pTop"); StreamReader sr_find = new StreamReader(task.identification_file); while (!sr_find.EndOfStream) { line = sr_find.ReadLine(); if (line.Trim() == "") { continue; } string[] strs = line.Split('\t'); //1 scan, 5 sq string sq = strs[5]; string title = strs[0]; string[] strs2 = title.Split('.'); sq = sq.Replace('L', 'I'); string scan_sq = strs2[0] + "@" + strs[1] + "@" + sq; double q_value = double.Parse(strs[4]); if (q_value > 0.01) { continue; } find_str.Add(scan_sq); } sr_find.Close(); max_str.Sort(); find_str.Sort(); int same_num = 0; int mi = 0, fi = 0; while (mi < max_str.Count && fi < find_str.Count) { if (string.Compare(max_str[mi], find_str[fi]) < 0) { sw_notSame.WriteLine(max_str[mi]); ++mi; } else if (string.Compare(max_str[mi], find_str[fi]) > 0) { ++fi; } else { sw_same.WriteLine(max_str[mi]); ++same_num; ++mi; ++fi; } } sw_same.Flush(); sw_same.Close(); sw_notSame.Flush(); sw_notSame.Close(); string msg = "Same: " + same_num; msg += "\r\nMaxQuant: " + max_str.Count; msg += "\r\npFind 3.0: " + find_str.Count; List <int> numbers = new List <int>(); numbers.Add(find_str.Count); numbers.Add(max_str.Count); numbers.Add(same_num); Display_Help dh = new Display_Help(); //有两个任务,有多个RAW的结果,每个RAW的结果都有一张图 PlotModel model = dh.display_compare_result(numbers); Plot oxyplot = new Plot(); oxyplot.Model = model; oxyplot.Width = 400; oxyplot.Height = 400; this.compare_result_sp.Children.Add(oxyplot); MessageBox.Show(msg); }