private static void fillScans(binStack[] stackIndex, string fileXml, string schemaFile, BinStackOptions options) { DataSet ds = new DataSet(); ds.ReadXmlSchema(schemaFile); ds.ReadXml(fileXml); DataView dv = new DataView(ds.Tables["peptide_match"]); scanIndexStrt newScan = new scanIndexStrt(); int spectrumIndex = 1; for (int i = 0; i <= stackIndex.GetUpperBound(0); i++) { for (int j = 0; j < dv.Count; j++) { String RAWfilename = dv[j]["RAWFileName"].ToString().Trim(); if (RAWfilename == stackIndex[i].rawFileName.Trim()) { int firstscan = int.Parse(dv[j]["FirstScan"].ToString(), CultureInfo.InvariantCulture.NumberFormat); newScan.FirstScan = firstscan; newScan.spectrumIndex = spectrumIndex; dv[j]["spectrumIndex"] = spectrumIndex; if (options.useParentalMass) { try { int charge = int.Parse(dv[j]["Charge"].ToString(), CultureInfo.InvariantCulture.NumberFormat); newScan.parentMass = (double)dv[j]["PrecursorMass"]; newScan.parentMass = (newScan.parentMass + charge) / charge; } catch { } } stackIndex[i].insert(newScan); spectrumIndex++; } } } //Save the QuiXML with the new index (spectrumIndex) DataSet dsSave = new DataSet(); dsSave = ds.Copy(); try { dsSave.WriteXml(fileXml); } catch { FileInfo f = new FileInfo(fileXml); string quiXMLfilenew = f.DirectoryName + "\\" + f.Name + "_binStackProcessed" + f.Extension; dsSave.WriteXml(quiXMLfilenew); } }
private static void fillScans(binStack[] stackIndex, string fileXml) { //Initialize necessary objets for XML reading XmlTextReader reader = new XmlTextReader(fileXml); XmlNodeType nType = reader.NodeType; XmlDocument xmldoc = new XmlDocument(); xmldoc.Load(reader); XmlNodeList xmlnodeMatch = xmldoc.GetElementsByTagName("peptide_match"); scanIndexStrt newScan = new scanIndexStrt(); for (int i = 0; i <= stackIndex.GetUpperBound(0); i++) { foreach (XmlNode node in xmlnodeMatch) { if (node["RAWFileName"].InnerText.ToString().Trim() == stackIndex[i].rawFileName.Trim()) { newScan.FirstScan = int.Parse(node["FirstScan"].InnerText.ToString(), System.Globalization.CultureInfo.InvariantCulture); stackIndex[i].insert(newScan); } } } }
/// <summary> /// insert a new element in the chemical composition /// </summary> /// <param name="newComp">(Comb.compStrt)Element + Number of atoms</param> public void insert(scanIndexStrt newScan) { // if insert won't overflow list if (theSize < scan.Length) { // increment start and set element scan[start = (start + 1) % scan.Length] = newScan; // increment list size (we've added an element) theSize++; } }
/// <summary> /// peek at an element in the list /// </summary> /// <param name="offset">(int)array index to point</param> /// <returns>(Comb.compStrt)Element + Number of atoms</returns> public scanIndexStrt peek(int offset) { scanIndexStrt ret = new scanIndexStrt(); // is someone trying to peek beyond our size? if (offset >= theSize) { return(ret); } // get object we're peeking at (do not remove it) return(scan[(end + offset + 1) % scan.Length]); }
private static void fillScans(binStack[] stackIndex, DataView dv, BinStackOptions options) { double protonMass = 1.007276466812; // source: http://physics.nist.gov/cgi-bin/cuu/Value?mpu //associate the dataset to a dataview string filter = ""; scanIndexStrt newScan = new scanIndexStrt(); int spectrumIndex = 0; for (int i = 0; i <= stackIndex.GetUpperBound(0); i++) { filter = "RAWFileName = '" + stackIndex[i].rawFileName.Trim() + "'"; dv.RowFilter = filter; for (int j = 0; j < dv.Count; j++) { int firstScan = int.Parse(dv[j]["FirstScan"].ToString()); newScan.scanNumbers[0] = firstScan; newScan.FirstScan = firstScan; newScan.spectrumIndex = spectrumIndex; dv[j]["spectrumIndex"] = spectrumIndex; if (!(options.averagingMethod == averagingMethod.mostIntense || options.averagingMethod == averagingMethod.none)) { newScan.peakStart = int.Parse(dv[j]["PeakStart"].ToString()); newScan.peakEnd = int.Parse(dv[j]["PeakEnd"].ToString()); } spectrumIndex++; if (options.useParentalMass) { try { int charge = int.Parse(dv[j]["Charge"].ToString()); newScan.parentMass = double.Parse(dv[j]["PrecursorMass"].ToString()); newScan.parentMass = (newScan.parentMass + (charge - 1) * protonMass) / charge; } catch { } } stackIndex[i].insert(newScan); } } }
/// <summary> /// insert a new element in the chemical composition /// </summary> /// <param name="newComp">(Comb.compStrt)Element + Number of atoms</param> public void insert(scanIndexStrt newScan) { // if insert won't overflow list if (theSize < scan.Length) { // increment start and set element start = (start + 1) % scan.Length; scan[start].frame = newScan.frame; scan[start].parentMass = newScan.parentMass; scan[start].scanNumbers = (int[])newScan.scanNumbers.Clone(); scan[start].FirstScan = newScan.FirstScan; scan[start].spectrumIndex = newScan.spectrumIndex; scan[start].peakStart = newScan.peakStart; scan[start].peakEnd = newScan.peakEnd; // increment list size (we've added an element) theSize++; } }