public ParseSpectraFile(string mzmlPath, HashSet <int> scanNumSet, string ext) { int currentScanNum = -1; try { MSDataFile msd = new MSDataFile(mzmlPath); SpectrumList spectrumList = msd.run.spectrumList; for (int i = 0; i < spectrumList.size(); ++i) { Spectrum spectrum = spectrumList.spectrum(i, true); if (int.Parse(spectrum.cvParams[0].value) == 2) { Match match = scanNumPattern.Match(spectrum.id); currentScanNum = int.Parse(match.Groups[1].Value); if (scanNumSet.Contains(currentScanNum)) { MZIntensityPairList mzIntensityPairs = new MZIntensityPairList(); spectrum.getMZIntensityPairs(ref mzIntensityPairs); Dictionary <float, int> originalPeakList = new Dictionary <float, int>(mzIntensityPairs.Count); foreach (MZIntensityPair mzIntensity in mzIntensityPairs) { originalPeakList[(float)mzIntensity.mz] = (int)mzIntensity.intensity; } spectraMap[currentScanNum] = originalPeakList; } } } } catch (Exception ex) { MessageBox.Show(ex.Message + ": " + currentScanNum, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); Application.Exit(); } }
///<summary> ///original code for grabbing the required ions ///get pepSequence,source,scanID, write into a csv file. ///have tons of information: theretical ion intensity, pep info, chargeLabel... ///</summary> public static List<string> idpReader_original(string idpXMLFile, string mzMLFile, double TicCutoffPercentage, int z, List<string> pepList, List<string> output) { //get the path and filename of output csv file: string fileName = Path.GetFileNameWithoutExtension(idpXMLFile); string filePath = Path.GetDirectoryName(idpXMLFile); IDPicker.Workspace workspace = new IDPicker.Workspace(); Package.loadWorkspace(ref workspace, idpXMLFile); MSDataFile foo = new MSDataFile(mzMLFile); SpectrumList sl = foo.run.spectrumList; foreach (IDPicker.SourceGroupList.MapPair groupItr in workspace.groups) foreach (IDPicker.SourceInfo source in groupItr.Value.getSources(true)) foreach (IDPicker.SpectrumList.MapPair sItr in source.spectra) { IDPicker.ResultInstance ri = sItr.Value.results[1]; IDPicker.VariantInfo vi = ri.info.peptides.Min; string ss = vi.ToString() + "," + sItr.Value.id.source.name + "," + sItr.Value.nativeID; bool boolCharge = sItr.Value.id.charge.Equals(z); if (boolCharge) { string rawPepSequence = vi.ToString(); string pepSequence = vi.peptide.sequence; int len = pepSequence.Length; //make sure that the peptide is what we want if (pepList.Contains(pepSequence)) { // Look up the index with nativeID object idOrIndex = null; if (sItr.Value.nativeID != null && sItr.Value.nativeID.Length > 0) idOrIndex = sItr.Value.nativeID; int spectrumIndex = sl.find(idOrIndex as string); // Trust the local index, if the nativeID lookup fails if (spectrumIndex >= sl.size()) spectrumIndex = sItr.Value.id.index; // Bail of the loca index is larger than the spectrum list size if (spectrumIndex >= sl.size()) throw new Exception("Can't find spectrum associated with the index."); //Console.WriteLine(idOrIndex.ToString()); //get base peak and TIC and converted to string Spectrum spec1 = sl.spectrum(spectrumIndex, true); MZIntensityPairList peaks = new MZIntensityPairList(); spec1.getMZIntensityPairs(ref peaks); Set<Peak> peakList = new Set<Peak>(); //get base peak and TIC double basePeakValue = 0; double TICValue = 0; CVParamList list = spec1.cvParams; foreach (CVParam CVP in list) { if (CVP.name == "base peak intensity") { basePeakValue = CVP.value; } if (CVP.name == "total ion current") { TICValue = CVP.value; } } string basePeak = basePeakValue.ToString(); string TIC = TICValue.ToString(); //very important. Surendra put them here //to change those with modifications {} into a format //that fragment method will accept. string interpretation = vi.ToSimpleString(); Peptide peptide = new Peptide(interpretation, ModificationParsing.ModificationParsing_Auto, ModificationDelimiter.ModificationDelimiter_Brackets); Fragmentation fragmentation = peptide.fragmentation(true, true); //prepare the qualified peaklist double intenThreshhold = 0; int totalIntenClass = 0; double[] intenArray = new double[peaks.Count]; //used during the foreach loop int indexPeaks = 0; //get all the peaks no matter how small they are //then calculate the threshhold TIC //test here foreach (MZIntensityPair mzIntensity in peaks) { //Peak p = new Peak(mzIntensity.mz, mzIntensity.intensity); //peakList.Add(p); intenArray[indexPeaks] = mzIntensity.intensity; indexPeaks++; } Array.Sort(intenArray); Array.Reverse(intenArray, 0, peaks.Count); //if currTIC>=cutoff, then break double currTIC = 0; double cutOffTIC = TicCutoffPercentage * TICValue; foreach (double inten in intenArray) { currTIC = currTIC + inten; if (currTIC < cutOffTIC) { intenThreshhold = inten; totalIntenClass++; } else break; } //then based on that, generate a new peaklist that contains only ABC peaks //then calculate the intensity classes foreach (MZIntensityPair mzIntensity in peaks) { if (mzIntensity.intensity >= intenThreshhold) { Peak p = new Peak(mzIntensity.mz, mzIntensity.intensity); peakList.Add(p); } } //rowDic contains row information of each peptide bond Dictionary<int, string> rowDic = new Dictionary<int, string>(); //intensityDic contains intensity information of fragment ions for each peptide bond Dictionary<int, List<double>> intensityDic = new Dictionary<int, List<double>>(); //commonList contains the common intensities List<double> duplicateList = new List<double>(); //call the method List<double> completeIntensityList = new List<double>(); for (int k = 1; k < len; k++) { List<double> intensityList = new List<double>(); string bion = pepSequence.Substring(0, k); string yion = pepSequence.Substring(k, len - k); int NR = Package.parseAAResidues(bion, 'R'); int NK = Package.parseAAResidues(bion, 'K'); int NH = Package.parseAAResidues(bion, 'H'); int NL = k; int CR = Package.parseAAResidues(yion, 'R'); int CK = Package.parseAAResidues(yion, 'K'); int CH = Package.parseAAResidues(yion, 'H'); int CL = len - k; int R = NR - CR; int K = NK - CK; int H = NH - CH; int L = NL - CL; int pepBond = k; int NBasicAA = NR + NK + NH; int CBasicAA = CR + CK + CH; string AA = NBasicAA + "," + CBasicAA + "," + NR + "," + NK + "," + NH + "," + NL + "," + CR + "," + CK + "," + CH + "," + CL + "," + R + "," + K + "," + H + "," + L; double[] bCharge = new double[z + 1]; double[] yCharge = new double[z + 1]; double[] bIntensity = new double[z + 1]; double[] yIntensity = new double[z + 1]; string bIonIntensity = ""; string yIonIntensity = ""; //to judge if the sum of intensities are 0 //so to exclude the case with all "0s" double sumIntensity = 0; //return the b ion charge 1 Intensity, if matched for (int i = 1; i <= z; i++) { bCharge[i] = fragmentation.b(k, i); yCharge[i] = fragmentation.y(len - k, i); //change for Q-star purposes. Peak bmatched = Package.findClose(peakList, bCharge[i], 70 * bCharge[i] * Math.Pow(10, -6)); Peak ymatched = Package.findClose(peakList, yCharge[i], 70 * yCharge[i] * Math.Pow(10, -6)); if (bmatched != null) { bIntensity[i] = bmatched.rankOrIntensity; intensityList.Add(bmatched.rankOrIntensity); completeIntensityList.Add(bmatched.rankOrIntensity); } else bIntensity[i] = 0; if (ymatched != null) { yIntensity[i] = ymatched.rankOrIntensity; intensityList.Add(ymatched.rankOrIntensity); completeIntensityList.Add(ymatched.rankOrIntensity); } else yIntensity[i] = 0; sumIntensity = sumIntensity + bIntensity[i] + yIntensity[i]; //record b/y ion intensity information into a string bIonIntensity = bIonIntensity + "," + bIntensity[i]; yIonIntensity = yIonIntensity + "," + yIntensity[i]; } intensityDic.Add(pepBond, intensityList); //to determine charge label, need to split by precursor charge //first need to make a metric to determine if all intensities are "0" if (z == 3) { if (sumIntensity != 0) { //////////////////////////////////////////////// //set the ambiguity label as follows: //-3: (0/+3) y3 only //-2: (0/+3, +1/+2) y3, b1y2 //-1: (+1/+2): b1y2 //0: (+1/+2, +2/+1): b1y2, b2y1 //1: (+2/+1): b2y1 //2: (+2/+1, +3/0): b2y1, b3 //3: (+3/0): b3 only //////////////////////////////////////////////// double b1 = bIntensity[1]; double b2 = bIntensity[2]; double y1 = yIntensity[1]; double y2 = yIntensity[2]; double b3 = bIntensity[3]; double y3 = yIntensity[3]; double b1y2 = b1 + y2; double b2y1 = b2 + y1; string ambiguityLabel = ""; //first part: set the intensity group: y3, b1y2, b2y1, b3 //if one group was found, set the label //if two were found, but adjacent to each other, then ambiguity label is set if (y3 != 0 && (b1y2 + b2y1 + b3) == 0) ambiguityLabel = "-3"; else if (y3 != 0 && b1y2 != 0 && (b2y1 + b3) == 0) ambiguityLabel = "-2"; else if (b1y2 != 0 && (y3 + b2y1 + b3) == 0) ambiguityLabel = "-1"; else if (b1y2 != 0 && b2y1 != 0 && (y3 + b3) == 0) ambiguityLabel = "0"; else if (b2y1 != 0 && (y3 + b1y2 + b3) == 0) ambiguityLabel = "1"; else if (b2y1 != 0 && b3 != 0 && (y3 + b1y2) == 0) ambiguityLabel = "2"; else if (b3 != 0 && (y3 + b1y2 + b2y1) == 0) ambiguityLabel = "3"; else ambiguityLabel = "error"; string finalString = idOrIndex + "," + pepSequence + "," + basePeak + "," + TIC + bIonIntensity + yIonIntensity + "," + len + "," + pepBond + "," + AA + "," + ambiguityLabel; rowDic.Add(pepBond, finalString); } } }//end for each peptide bond //now we have: rowDic, intensityDic for each pep bond //and we have: and completeIntensityList for each peptide //the purpose of this is to remove such rows with duplicate matches duplicateList = Package.findCommon(completeIntensityList); foreach (int bond in rowDic.Keys) { bool unique = true; foreach (double inten in duplicateList) { if (intensityDic[bond].Contains(inten)) { unique = false; Console.WriteLine("kick"); break; } } if (unique) { output.Add(rowDic[bond]); } } }//end of if peplist contains pepsequence }//end if z==3 }//end foreach peptide return output; }
//get pepSequence,source,scanID, write into a csv file. //have tons of information: theretical ion intensity, pep info, chargeLabel... public static void idpReader(string idpXMLFile, string mzMLFile, double TicCutoffPercentage, int z, int model) { //get the path and filename of output csv file: string fileName = Path.GetFileNameWithoutExtension(idpXMLFile); string filePath = Path.GetDirectoryName(idpXMLFile); string csvFile = Path.Combine(filePath, fileName) + "_" + z.ToString() + ".csv"; IDPicker.Workspace workspace = new IDPicker.Workspace(); Package.loadWorkspace(ref workspace, idpXMLFile); using (StreamWriter file = new StreamWriter(csvFile)) { //TODO idOrIndex + "," + pepSequence + "," + pepBond + "," + AA + "," + bIons + "," + yIons; file.WriteLine("nativeID,pepSequence,bond,b1,b2,y1,y2"); MSDataFile foo = new MSDataFile(mzMLFile); SpectrumList sl = foo.run.spectrumList; foreach (IDPicker.SourceGroupList.MapPair groupItr in workspace.groups) foreach (IDPicker.SourceInfo source in groupItr.Value.getSources(true)) foreach (IDPicker.SpectrumList.MapPair sItr in source.spectra) { IDPicker.ResultInstance ri = sItr.Value.results[1]; IDPicker.VariantInfo vi = ri.info.peptides.Min; string ss = vi.ToString() + "," + sItr.Value.id.source.name + "," + sItr.Value.nativeID; bool boolCharge = sItr.Value.id.charge.Equals(z); if (boolCharge) { string rawPepSequence = vi.ToString(); string pepSequence = vi.peptide.sequence; int len = pepSequence.Length; // Look up the index with nativeID object idOrIndex = null; if( sItr.Value.nativeID != null && sItr.Value.nativeID.Length > 0 ) idOrIndex = sItr.Value.nativeID; int spectrumIndex = sl.find(idOrIndex as string); // Trust the local index, if the nativeID lookup fails if( spectrumIndex >= sl.size() ) spectrumIndex = sItr.Value.id.index; // Bail of the loca index is larger than the spectrum list size if( spectrumIndex >= sl.size() ) throw new Exception( "Can't find spectrum associated with the index." ); //get base peak and TIC and converted to string Spectrum spec1 = sl.spectrum(spectrumIndex, true); MZIntensityPairList peaks = new MZIntensityPairList(); spec1.getMZIntensityPairs(ref peaks); Set<Peak> peakList = new Set<Peak>(); //get base peak and TIC double basePeakValue = 0; double TICValue = 0; CVParamList list = spec1.cvParams; foreach (CVParam CVP in list) { if (CVP.name == "base peak intensity") { basePeakValue = CVP.value; } if (CVP.name == "total ion current") { TICValue = CVP.value; } } string basePeak = basePeakValue.ToString(); string TIC = TICValue.ToString(); //very important. Surendra put them here //to change those with modifications {} into a format //that fragment method will accept. string interpretation = vi.ToSimpleString(); Peptide peptide = new Peptide(interpretation, ModificationParsing.ModificationParsing_Auto, ModificationDelimiter.ModificationDelimiter_Brackets); Fragmentation fragmentation = peptide.fragmentation(true, true); //prepare the qualified peaklist double intenThreshhold = 0; int totalIntenClass = 0; double[] intenArray = new double[peaks.Count]; //used during the foreach loop int indexPeaks = 0; //get all the peaks no matter how small they are //then calculate the threshhold TIC //test here foreach (MZIntensityPair mzIntensity in peaks) { //Peak p = new Peak(mzIntensity.mz, mzIntensity.intensity); //peakList.Add(p); intenArray[indexPeaks] = mzIntensity.intensity; indexPeaks++; } Array.Sort(intenArray); Array.Reverse(intenArray, 0, peaks.Count); //if currTIC>=cutoff, then break double currTIC = 0; double cutOffTIC = TicCutoffPercentage * TICValue; foreach (double inten in intenArray) { currTIC = currTIC + inten; if (currTIC < cutOffTIC) { intenThreshhold = inten; totalIntenClass++; } else break; } //then based on that, generate a new peaklist that contains only ABC peaks //then calculate the intensity classes foreach (MZIntensityPair mzIntensity in peaks) { if (mzIntensity.intensity >= intenThreshhold) { //note 0 here. This is to tell people that the orbiorbi fragment charge is unknown. //the peaklist will be updated later. Peak p = new Peak(mzIntensity.mz, mzIntensity.intensity,0); peakList.Add(p); } } Console.WriteLine("nativeID: =============" + idOrIndex); //update peaklist for charge states. peakList = Package.chargeAssignment(peakList); //int ones = 0; //int twos = 0; //foreach (var peak in peakList) //{ // //Console.WriteLine(peak.fragmentCharge); // if (peak.fragmentCharge == 1) ones++; // else if (peak.fragmentCharge == 2) twos++; //} //Console.WriteLine("charge 1: " + ones); //Console.WriteLine("charge 2: " + twos); //rowDic contains row information of each peptide bond Dictionary<int, string> rowDic = new Dictionary<int, string>(); //intensityDic contains intensity information of fragment ions for each peptide bond Dictionary<int, List<double>> intensityDic = new Dictionary<int, List<double>>(); //commonList contains the common intensities List<double> duplicateList = new List<double>(); //call the method List<double> completeIntensityList = new List<double>(); for (int k = 1; k < len; k++) { List<double> intensityList = new List<double>(); string bion = pepSequence.Substring(0, k); string yion = pepSequence.Substring(k, len - k); int NR = Package.parseAAResidues(bion, 'R'); int NK = Package.parseAAResidues(bion, 'K'); int NH = Package.parseAAResidues(bion, 'H'); int NL = k; int CR = Package.parseAAResidues(yion, 'R'); int CK = Package.parseAAResidues(yion, 'K'); int CH = Package.parseAAResidues(yion, 'H'); int CL = len - k; int pepBond = k; int NBasicAA = NR + NK + NH; int CBasicAA = CR + CK + CH; string AA = NR + "," + NK + "," + NH + "," + NL + "," + CR + "," + CK + "," + CH + "," + CL; double[] bCharge = new double[z + 1]; double[] yCharge = new double[z + 1]; //double[] bIntensity = new double[z + 1]; //double[] yIntensity = new double[z + 1]; //add variable for "real" charges if (model == 0) //naive model { int[] bFragmentCharge = new int[z + 1]; int[] yFragmentCharge = new int[z + 1]; //return the b ion charge 1 Intensity, if matched for (int i = 1; i < z; i++) { bCharge[i] = fragmentation.b(k, i); yCharge[i] = fragmentation.y(len - k, i); //change for ORBI-ORBI purposes. Peak bmatched = Package.findClose(peakList, bCharge[i], bCharge[i] * 30 * Math.Pow(10, -6)); Peak ymatched = Package.findClose(peakList, yCharge[i], yCharge[i] * 30 * Math.Pow(10, -6)); if (bmatched != null) { //bIntensity[i] = bmatched.rankOrIntensity; int fragmentCharge = bmatched.fragmentCharge; if (fragmentCharge == i) bFragmentCharge[i] = 3; else bFragmentCharge[i] = 2; //intensityList.Add(bmatched.rankOrIntensity); //completeIntensityList.Add(bmatched.rankOrIntensity); } else bFragmentCharge[i] = 1; //else bIntensity[i] = 0; if (ymatched != null) { //yIntensity[i] = ymatched.rankOrIntensity; //yFragmentCharge[i] = ymatched.fragmentCharge; int fragmentCharge = ymatched.fragmentCharge; if (fragmentCharge == i) yFragmentCharge[i] = 3; else yFragmentCharge[i] = 2; //intensityList.Add(ymatched.rankOrIntensity); //completeIntensityList.Add(ymatched.rankOrIntensity); } else yFragmentCharge[i] = 1; //else yIntensity[i] = 0; } string finalString = idOrIndex + "," + pepSequence + "," + pepBond + "," + bFragmentCharge[1] + "," + bFragmentCharge[2] + "," + yFragmentCharge[1] + "," + yFragmentCharge[2]; file.WriteLine(finalString); } else if (model == 1) //my binary logistic regression basophile model { int b1=0, b2=0, y1=0, y2 = 0; double y1_logit = 0.1098112 * NR + 0.2085831 * NK + 0.1512109 * NH + 0.0460839 * NL - 0.3872417 * CR - 0.3684911 * CK - 0.1634741 * CH - 0.1693931 * CL + 1.2632997; double y2_logit =-0.6345364 * NR - 0.3365917 * NK - 0.4577882 * NH - 0.1492703 * NL + 0.7738133 * CR + 0.6036758 * CK + 0.5942542 * CH + 0.0701467 * CL + 0.0806280; double b1_logit = 0.0801432 * NR - 0.1088081 * NK - 0.1338220 * NH - 0.1413059 * NL - 0.3157957 * CR - 0.2708274 * CK - 0.3703136 * CH + 0.0157418 * CL + 1.2124699; double b2_logit = 0.8606449 * NR + 0.2763119 * NK + 0.4969152 * NH + 0.0685712 * NL - 1.3346995 * CR - 1.0977316 * CK - 1.0973677 * CH - 0.2028884 * CL + 1.9355980; if (b1_logit > -0.5) { double mz_b1 = fragmentation.b(k, 1); Peak matched = Package.findClose(peakList, mz_b1, mz_b1 * 30 * Math.Pow(10, -6)); if (matched != null) { if (matched.fragmentCharge == 1) b1 = 3; else b1 = 2; } else b1 = 1; } else b1 = 0; if (b2_logit > 0) { double mz_b2 = fragmentation.b(k, 2); Peak matched = Package.findClose(peakList, mz_b2, mz_b2 * 30 * Math.Pow(10, -6)); if (matched != null) { if (matched.fragmentCharge == 2) b2 = 3; else b2 = 2; } else b2 = 1; } else b2 = 0; if (y1_logit > -0.5) { double mz_y1 = fragmentation.y(len - k, 1); Peak matched = Package.findClose(peakList, mz_y1, mz_y1 * 30 * Math.Pow(10, -6)); if (matched != null) { if (matched.fragmentCharge == 1) y1 = 3; else y1 = 2; } else y1 = 1; } else y1 = 0; if (y2_logit > -0.5) { double mz_y2 = fragmentation.y(len - k, 2); Peak matched = Package.findClose(peakList, mz_y2, mz_y2 * 30 * Math.Pow(10, -6)); if (matched != null) { if (matched.fragmentCharge == 2) y2 = 3; else y2 = 2; } else y2 = 1; } else y2 = 0; string finalString = idOrIndex + "," + pepSequence + "," + pepBond + "," + b1 + "," + b2 + "," + y1 + "," + y2; file.WriteLine(finalString); } else if (model == 2) //Surendra's ordinal model { int b1 = 0, b2 = 0, y1 = 0, y2 = 0; double logit = NR * 0.9862 + NH * 0.8772 + NK * 0.7064 + NL * 0.4133 - CR * 1.1688 - CH * 0.3948 - CK * 0.6710 - CL * 0.4859; //charge Label = "1", generate b+,y++ if (logit < -2.2502) { double mz_b1 = fragmentation.b(k, 1); Peak b1matched = Package.findClose(peakList, mz_b1, mz_b1 * 30 * Math.Pow(10, -6)); if (b1matched != null) { if (b1matched.fragmentCharge == 1) b1 = 3; //matched, charge agree else b1 = 2; //matched, charge does not agree } else b1 = 1; //unmatched, but predicted. double mz_y2 = fragmentation.y(len - k, 2); Peak y2matched = Package.findClose(peakList, mz_y2, mz_y2 * 30 * Math.Pow(10, -6)); if (y2matched != null) { if (y2matched.fragmentCharge == 2) y2 = 3; //matched, charge agree else y2 = 2; //matched, charge does not agree } else y2 = 1; //unmatched, but predicted. } //ambiLabel = "2", generate b+, y+, b++, y++ else if (logit < 0.7872) { double mz_b1 = fragmentation.b(k, 1); Peak b1matched = Package.findClose(peakList, mz_b1, mz_b1 * 30 * Math.Pow(10, -6)); if (b1matched != null) { if (b1matched.fragmentCharge == 1) b1 = 3; //matched, charge agree else b1 = 2; //matched, charge does not agree } else b1 = 1; //unmatched, but predicted. double mz_y1 = fragmentation.y(len - k, 1); Peak y1matched = Package.findClose(peakList, mz_y1, mz_y1 * 30 * Math.Pow(10, -6)); if (y1matched != null) { if (y1matched.fragmentCharge == 1) y1 = 3; //matched, charge agree else y1 = 2; //matched, charge does not agree } else y1 = 1; //unmatched, but predicted. double mz_b2 = fragmentation.b(k, 2); Peak b2matched = Package.findClose(peakList, mz_b2, mz_b2 * 30 * Math.Pow(10, -6)); if (b2matched != null) { if (b2matched.fragmentCharge == 2) b2 = 3; //matched, charge agree else b2 = 2; //matched, charge does not agree } else b2 = 1; //unmatched, but predicted. double mz_y2 = fragmentation.y(len - k, 2); Peak y2matched = Package.findClose(peakList, mz_y2, mz_y2 * 30 * Math.Pow(10, -6)); if (y2matched != null) { if (y2matched.fragmentCharge == 2) y2 = 3; //matched, charge agree else y2 = 2; //matched, charge does not agree } else y2 = 1; //unmatched, but predicted. } //ambiLabel = "3", generate b++,y+ else { double mz_b2 = fragmentation.b(k, 2); Peak b2matched = Package.findClose(peakList, mz_b2, mz_b2 * 30 * Math.Pow(10, -6)); if (b2matched != null) { if (b2matched.fragmentCharge == 2) b2 = 3; //matched, charge agree else b2 = 2; //matched, charge does not agree } else b2 = 1; //unmatched, but predicted. double mz_y1 = fragmentation.y(len - k, 1); Peak y1matched = Package.findClose(peakList, mz_y1, mz_y1 * 30 * Math.Pow(10, -6)); if (y1matched != null) { if (y1matched.fragmentCharge == 1) y1 = 3; //matched, charge agree else y1 = 2; //matched, charge does not agree } else y1 = 1; //unmatched, but predicted. } string finalString = idOrIndex + "," + pepSequence + "," + pepBond + "," + b1 + "," + b2 + "," + y1 + "," + y2; file.WriteLine(finalString); } //intensityDic.Add(pepBond, intensityList); //rowDic.Add(pepBond, finalString); }//end for each peptide bond }//end if z==3 }//end foreach peptide }//end using }