private void AddButtonClick(object sender, EventArgs e) { if (openFileDialog1.ShowDialog() != DialogResult.OK) { return; } for (int i = 0; i < openFileDialog1.FileNames.Length; i++) { if (FileList.Items.IndexOf(openFileDialog1.FileNames[i]) == -1) { FileList.Items.Add(openFileDialog1.FileNames[i]); } } MakeOutName(); //loading PM = new ProtMatrix[FileList.Items.Count]; for (int i = 0; i < FileList.Items.Count; i++) { PM[i] = new ProtMatrix(FileList.Items[i].ToString()); } //count samples int CountSamples = 0; for (int i = 0; i < FileList.Items.Count; i++) { CountSamples += PM[i].Samples.Count; } textBox2.Text = (CountSamples - 1).ToString(); }
private void AddButtonClick(object sender, EventArgs e) { if(openFileDialog1.ShowDialog() != DialogResult.OK) { return; } for (int i = 0 ; i < openFileDialog1.FileNames.Length ; i++){ if (FileList.Items.IndexOf(openFileDialog1.FileNames[i]) == -1){ FileList.Items.Add(openFileDialog1.FileNames[i]); } } MakeOutName(); //loading PM = new ProtMatrix[FileList.Items.Count]; for (int i = 0 ; i < FileList.Items.Count ; i++ ){ PM[i] = new ProtMatrix(FileList.Items[i].ToString()); } //count samples int CountSamples = 0; for (int i = 0 ; i < FileList.Items.Count ; i++ ){ CountSamples += PM[i].Samples.Count; } textBox2.Text = (CountSamples - 1).ToString(); }
private void GoButton_Click(object sender, EventArgs e) { //merge by IPIs ProtMatrix Merged = new ProtMatrix(); //samples for (int i = 0; i < FileList.Items.Count; i++) { Merged.Samples.AddRange(PM[i].Samples); } //make a proterin list List <List <string> > ProteinsIPIs = new List <List <string> >(); if (radioButton1.Checked) { //skip proteins for (int i = 0; i < PM[0].Proteins.Count; i++) { List <string> PIPIs = PM[0].Proteins[i].IPIS; bool GlobalFlag = true; for (int j = 1; j < PM.GetLength(0); j++) { bool flag = false; foreach (Prot PS in PM[j].Proteins) { if (Cross(PIPIs, PS.IPIS)) { flag = true; break; } } GlobalFlag &= flag; } if (GlobalFlag) { ProteinsIPIs.Add(PIPIs); } } } else { //keep proteins for (int k = 0; k < PM.GetLength(0); k++) { for (int i = 0; i < PM[k].Proteins.Count; i++) { bool flag = false; foreach (List <string> PS in ProteinsIPIs) { if (Cross(PM[k].Proteins[i].IPIS, PS)) { flag = true; break; } } if (!flag) { ProteinsIPIs.Add(PM[k].Proteins[i].IPIS); } } } } //proteins for (int i = 0; i < ProteinsIPIs.Count; i++) { List <string> PL = ProteinsIPIs[i]; Prot P = null; for (int j = 0; j < PM.GetLength(0); j++) { bool flag = false; foreach (Prot PS in PM[j].Proteins) { if (Cross(PL, PS.IPIS)) { flag = true; if (P == null) { P = PS.Clone(); //leading zeroes for (int k = 0; k < j; k++) { foreach (string S in PM[k].Samples) { P.Abunds.Insert(0, 0.0); } } } else { P.Abunds.AddRange(PS.Abunds); } break; } } if (P != null && !flag) { foreach (string S in PM[j].Samples) { P.Abunds.Add(0.0); } } } if (P.Abunds.Count == Merged.Samples.Count) { //maximum zero filtering int ZeroCount = 0; for (int j = 0; j < P.Abunds.Count; j++) { ZeroCount += P.Abunds[j] == 0.0 ? 1 : 0; } if (ZeroCount < Convert.ToInt32(textBox2.Text)) { Merged.Proteins.Add(P); } } } //writing StreamWriter sw = new StreamWriter(OutFileBox.Text); //Caption sw.WriteLine(Text); sw.WriteLine("Original Fies:"); for (int i = 0; i < FileList.Items.Count; i++) { sw.WriteLine(FileList.Items[i].ToString()); } sw.WriteLine("Unique proteins has {0}; Maximum zeroes {1}.", radioButton1.Checked ? "skipped" : "kept", textBox2.Text); //Matrix Merged.Save(sw); sw.Close(); }
private void GoButton_Click(object sender, EventArgs e) { //merge by IPIs ProtMatrix Merged = new ProtMatrix(); //samples for (int i = 0 ; i < FileList.Items.Count ; i++ ){ Merged.Samples.AddRange(PM[i].Samples); } //make a proterin list List<List<string>> ProteinsIPIs = new List<List<string>>(); if (radioButton1.Checked){ //skip proteins for (int i = 0 ; i<PM[0].Proteins.Count ; i++ ){ List<string> PIPIs = PM[0].Proteins[i].IPIS; bool GlobalFlag = true; for (int j = 1 ; j < PM.GetLength(0) ; j++ ){ bool flag = false; foreach(Prot PS in PM[j].Proteins){ if (Cross(PIPIs,PS.IPIS)){ flag = true; break; } } GlobalFlag &= flag; } if (GlobalFlag) { ProteinsIPIs.Add(PIPIs); } } }else{ //keep proteins for (int k = 0 ; k < PM.GetLength(0) ; k++ ){ for (int i = 0 ; i<PM[k].Proteins.Count ; i++ ){ bool flag = false; foreach(List<string> PS in ProteinsIPIs){ if (Cross(PM[k].Proteins[i].IPIS,PS)){ flag = true; break; } } if (!flag){ ProteinsIPIs.Add(PM[k].Proteins[i].IPIS); } } } } //proteins for (int i = 0 ; i<ProteinsIPIs.Count ; i++ ){ List<string> PL = ProteinsIPIs[i]; Prot P = null; for (int j = 0 ; j < PM.GetLength(0) ; j++ ){ bool flag = false; foreach(Prot PS in PM[j].Proteins){ if (Cross(PL,PS.IPIS)){ flag = true; if (P == null){ P = PS.Clone(); //leading zeroes for (int k = 0; k < j ; k++){ foreach (string S in PM[k].Samples){ P.Abunds.Insert(0,0.0); } } }else{ P.Abunds.AddRange(PS.Abunds); } break; } } if (P!=null && !flag){ foreach (string S in PM[j].Samples){ P.Abunds.Add(0.0); } } } if (P.Abunds.Count == Merged.Samples.Count){ //maximum zero filtering int ZeroCount = 0; for (int j = 0; j < P.Abunds.Count; j++){ ZeroCount += P.Abunds[j] == 0.0 ? 1 : 0; } if (ZeroCount < Convert.ToInt32(textBox2.Text)){ Merged.Proteins.Add(P); } } } //writing StreamWriter sw = new StreamWriter(OutFileBox.Text); //Caption sw.WriteLine(Text); sw.WriteLine("Original Fies:"); for (int i = 0; i < FileList.Items.Count; i++ ){ sw.WriteLine(FileList.Items[i].ToString()); } sw.WriteLine("Unique proteins has {0}; Maximum zeroes {1}.", radioButton1.Checked ? "skipped" : "kept", textBox2.Text); //Matrix Merged.Save(sw); sw.Close(); }