//This function reads datagridview4 and obtain its data. private List<Peptide> GetPeptidesFromTable() { List<Peptide> PP = new List<Peptide>(); for (int i = 0; i < PeptideGridView.Rows.Count; i++) { //if (Convert.ToInt32(dataGridView4.Rows[c].Cells[0].Value) == 0) // continue; Peptide pp = new Peptide(); pp.Selected = Convert.ToBoolean((PeptideGridView.Rows[i].Cells[0].Value)); pp.Mass = Convert.ToDouble(PeptideGridView.Rows[i].Cells[1].Value); pp.Modifications = Convert.ToString(PeptideGridView.Rows[i].Cells[2].Value); pp.StartAA = Convert.ToInt32(PeptideGridView.Rows[i].Cells[3].Value); pp.EndAA = Convert.ToInt32(PeptideGridView.Rows[i].Cells[4].Value); pp.MissedCleavages = Convert.ToInt32(PeptideGridView.Rows[i].Cells[5].Value); pp.Sequence = Convert.ToString(PeptideGridView.Rows[i].Cells[6].Value); pp.NumGlycosylations = Convert.ToInt32(PeptideGridView.Rows[i].Cells[7].Value); pp.ProteinID = Convert.ToString(PeptideGridView.Rows[i].Cells[8].Value); PP.Add(pp); } return PP; }
//This function reads tab delimited file. private List<Peptide> ReadTabDelimitedProteinProspecter(String currentpath) { List<Peptide> data = new List<Peptide>(); FileStream FS = new FileStream(currentpath, FileMode.Open, FileAccess.Read ); StreamReader read = new StreamReader(FS); //skip title line: read.ReadLine(); while (read.Peek() >= 0) { Peptide pp = new Peptide(); String line = read.ReadLine(); String[] Lines = line.Split('\t'); pp.PeptideIndex = Convert.ToInt32(Lines[0]); pp.Mass = Convert.ToDouble(Lines[1]); pp.Charge = Convert.ToInt32(Lines[3]); pp.Modifications = Convert.ToString(Lines[4]); pp.StartAA = Convert.ToInt32(Lines[5]); pp.EndAA = Convert.ToInt32(Lines[6]); pp.MissedCleavages = Convert.ToInt32(Lines[7]); pp.PreviousAA = Convert.ToString(Lines[8]); pp.Sequence = Convert.ToString(Lines[9]); pp.NextAA = Convert.ToString(Lines[10]); data.Add(pp); } read.Close(); FS.Close(); return data; }
private List<Peptide> genFalsePPMSD(String path) { Features fea = new Features(); List<Peptide> PP = fea.readtablim(path); CompositionHypothesisTabbedForm comp = new CompositionHypothesisTabbedForm(); String sequence = comp.GetSequenceFromCleavedPeptides(PP); List<int> forRandom = new List<int> { {0},{1},{2} }; List<int> forlength = new List<int> { {4},{5},{6},{7},{8},{9},{10},{11} }; List<Peptide> finalAns = new List<Peptide>(); Int32 StartAA = 0; Int32 EndAA = 0; while (EndAA != sequence.Count()) { forRandom.Shuffle(); if (forRandom[0] == 1) { //add in this fragment Peptide Ans = new Peptide(); forlength.Shuffle(); Int32 length = forlength[0]; EndAA = StartAA + length; if (EndAA > sequence.Count()) EndAA = sequence.Count(); String Fra = ""; Ans.StartAA = Convert.ToInt32(StartAA + 1); Ans.EndAA = Convert.ToInt32(EndAA + 1); for (int i = StartAA; i < EndAA; i++) { Fra = Fra + sequence[i]; } StartAA = StartAA + length; Ans.Selected = true; Ans.PeptideIndex = 1; Ans.Mass = getFragmentMass(Fra); Ans.Charge = 0; Ans.Modifications = ""; Ans.MissedCleavages = 0; Ans.PreviousAA = ""; Ans.NextAA = ""; forRandom.Shuffle(); Ans.NumGlycosylations = Convert.ToInt32(forRandom[0]); finalAns.Add(Ans); } else { //Skip this fragment forlength.Shuffle(); Int32 length = forlength[0]; EndAA = StartAA + length; if (EndAA > sequence.Count()) EndAA = sequence.Count(); StartAA = StartAA + length; } if (EndAA == sequence.Count() && finalAns.Count() == 0) { EndAA = 0; StartAA = 0; } } return finalAns; }