private List <string> GenerateGlycoPeptide() { List <ProteinInfo> PInfos = FastaReader.ReadFasta(_fastaFile); List <string> GlycoPeptide = new List <string>(); foreach (ProteinInfo Prot in PInfos) { GlycoPeptide.AddRange(Prot.NGlycopeptide(_MissCLeavage, _ProteaseType, _peptideMutation)); } return(GlycoPeptide); }
public Prot Clone() { Prot P = new Prot(); P.ID = ID; P.Desc = Desc; P.RefAbunds = RefAbunds; P.Peptides = Peptides; P.IPIS = new List <string>(); P.IPIS.AddRange(IPIS); P.Abunds = new List <double>(); P.Abunds.AddRange(Abunds); return(P); }
public static extern int mprotect(IntPtr addr, UIntPtr len, Prot prot);
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(); }
public void Load(string ProtMatrFile) { //отбрасываем заголовки StreamReader sr = new StreamReader(ProtMatrFile); List <string> tokens = new List <string>(); while (!sr.EndOfStream) { string Caption = sr.ReadLine(); tokens = Caption.Split(new char[] { '\t' }).ToList(); if (tokens.Count > 2) { break; } } int[] Delims = new int[5]; Delims[0] = tokens.IndexOf("PROTEIN ID"); Delims[1] = tokens.IndexOf("DESCRIPTION"); Delims[2] = tokens.IndexOf("PEPTIDES"); Delims[3] = tokens.IndexOf("PROTEIN IDs"); Delims[4] = tokens.IndexOf("REF ABUNDANCE"); int Shift = 5; for (int i = 0; i < 5; i++) { if (Delims[i] == -1) { Shift--; } } int Count = tokens.Count - Shift; for (int i = 0; i < Count; i++) { if (tokens[i + Shift] == "") { Count = i; break; } Samples.Add(tokens[i + Shift]); } while (!sr.EndOfStream) { string str = sr.ReadLine(); tokens = str.Split(new char[] { '\t' }).ToList(); Prot P = new Prot(); if (Delims[0] != -1) { P.ID = tokens[Delims[0]]; } if (Delims[1] != -1) { P.Desc = tokens[Delims[1]]; } if (Delims[2] != -1) { P.Peptides = Convert.ToInt32(tokens[Delims[2]]); } if (Delims[3] != -1) { P.IPIS = (tokens[Delims[3]].Split(new char[] { ';' })).ToList(); } if (Delims[4] != -1) { P.RefAbunds = Convert.ToDouble(tokens[Delims[4]]); } P.Abunds = new List <double>(); for (int i = 0; i < Count; i++) { //if empty if (tokens[i + Shift] == "") { P.Abunds.Add(0.0); continue; } //if 1 if (Convert.ToDouble(tokens[i + Shift]) == 1.0) { //if all alternativbe are 0.0 - then 1.0 otherwise 0.0 bool flag = true; for (int j = 0; j < Count; j++) { if (i != j) { flag &= Convert.ToDouble(tokens[i + Shift]) == 0.0; } } P.Abunds.Add(flag?1.0:0.0); } else { //if normal value P.Abunds.Add(Convert.ToDouble(tokens[i + Shift])); } } Proteins.Add(P); } }
public void Load(string ProtMatrFile) { //отбрасываем заголовки StreamReader sr = new StreamReader(ProtMatrFile); List<string> tokens = new List<string>(); while (!sr.EndOfStream){ string Caption = sr.ReadLine(); tokens = Caption.Split(new char[] {'\t'}).ToList(); if (tokens.Count > 2) break; } int[] Delims = new int[5]; Delims[0] = tokens.IndexOf("PROTEIN ID"); Delims[1] = tokens.IndexOf("DESCRIPTION"); Delims[2] = tokens.IndexOf("PEPTIDES"); Delims[3] = tokens.IndexOf("PROTEIN IDs"); Delims[4] = tokens.IndexOf("REF ABUNDANCE"); int Shift = 5; for (int i = 0 ; i < 5 ; i++){ if (Delims[i] == -1){ Shift--; } } int Count = tokens.Count - Shift; for ( int i = 0 ; i < Count ; i++ ){ if (tokens[i+Shift] == ""){ Count = i; break; } Samples.Add(tokens[i+Shift]); } while (!sr.EndOfStream){ string str = sr.ReadLine(); tokens = str.Split(new char[] {'\t'}).ToList(); Prot P = new Prot(); if (Delims[0]!=-1){ P.ID = tokens[Delims[0]]; } if (Delims[1]!=-1){ P.Desc = tokens[Delims[1]]; } if (Delims[2]!=-1){ P.Peptides = Convert.ToInt32(tokens[Delims[2]]); } if (Delims[3]!=-1){ P.IPIS = (tokens[Delims[3]].Split(new char[] {';'})).ToList(); } if (Delims[4]!=-1){ P.RefAbunds = Convert.ToDouble(tokens[Delims[4]]); } P.Abunds = new List<double>(); for ( int i = 0 ; i < Count ; i++){ //if empty if (tokens[i+Shift] == ""){ P.Abunds.Add(0.0); continue; } //if 1 if (Convert.ToDouble(tokens[i+Shift]) == 1.0){ //if all alternativbe are 0.0 - then 1.0 otherwise 0.0 bool flag = true; for ( int j = 0 ; j < Count ; j++){ if (i!=j){ flag &= Convert.ToDouble(tokens[i + Shift]) == 0.0; } } P.Abunds.Add(flag?1.0:0.0); }else{ //if normal value P.Abunds.Add(Convert.ToDouble(tokens[i+Shift])); } } Proteins.Add(P); } }
public Prot Clone() { Prot P = new Prot(); P.ID = ID; P.Desc = Desc; P.RefAbunds = RefAbunds; P.Peptides = Peptides; P.IPIS = new List<string>(); P.IPIS.AddRange(IPIS); P.Abunds = new List<double>(); P.Abunds.AddRange(Abunds); return P; }