public static Dictionary <string, List <Quant> > Quant(XICGet5 xic, SQTLight theScn, double theoreticalMH, SignalGenerator isotopicSignal, int scnNo, XQuantClusteringParameters myParams) { Dictionary <string, List <Quant> > theResults = new Dictionary <string, List <Quants.Quant> >(); //We will obtain the isotopic signal and obtain the XIC according to the most intense isotope List <double> isoSignal = isotopicSignal.GetSignal(5, theoreticalMH, 0); int maximumSignalIsotope = isoSignal.IndexOf(isoSignal.Max()); foreach (int z in myParams.AcceptableChargeStates) { double pMass = ((double)z - 1.0) * 1.007276466; double iMass = (maximumSignalIsotope * 1.00335); double mz = (theoreticalMH + pMass + iMass) / (double)z; double[,] ic = xic.GetXIC3(Math.Round(mz, 4), myParams.ClusteringPPM, scnNo); if (ic != null) { Quant q = new Quants.Quant(ic, theScn.ScanNumber, z, Math.Round(mz, 4)); if (theResults.ContainsKey(theScn.PeptideSequenceCleaned)) { theResults[theScn.PeptideSequenceCleaned].Add(q); } else { theResults.Add(theScn.PeptideSequenceCleaned, new List <Quants.Quant>() { q }); } } } return(theResults); }
/// <summary> /// We recomend runing this after retaining optimal signal. This will revisit other MS1s to try and find a XIC to reuce the undersampling problem /// </summary> public void FillInTheGaps(List <string> peptideWithCharges) { //We need to know the acceptable comaprisons. List <int> groups = MyAssociationItems.Select(a => a.Assosication).Distinct().ToList(); foreach (int group in groups) { //Get the stuff from this group List <AssociationItem> items = MyAssociationItems.FindAll(a => a.Assosication == group); List <string> seproFiles = items.Select(a => a.Directory + "\\" + a.Directory + ".sepr").ToList(); //Now get all peptides from the group List <QuantPackage2> relevantQuantPackages = (from qpackg in myQuantPkgs where items.Exists(a => qpackg.FullDirPath.Contains(a.Directory) && a.FileName.Equals(qpackg.FileName)) select qpackg).ToList(); //Load all MS1s to RAM List <XICGet5> myGetters = new List <XICGet5>(items.Count); foreach (AssociationItem ai in items) { //Find out the full directory string dtmp = @"\" + ai.Directory; List <string> seprof = (from s in SEProFiles from d in s.MyFilesFullPath where d.Contains(dtmp + "\\") select d).ToList(); foreach (string s in seprof) { FileInfo f = new FileInfo(s); //We need to find out if we are dealing with .ms2, .RAW or .mzML string theExtension = GetExtension(f); string fileName = f.Directory.FullName + @"\" + Regex.Replace(ai.FileName, ".sqt", theExtension); myGetters.Add(new XICGet5(fileName)); } } peptideWithCharges.Sort(); foreach (string peptideWithZ in peptideWithCharges) { string[] cols = Regex.Split(peptideWithZ, "::"); string peptide = cols[0]; int z = int.Parse(cols[1]); //Find out which one has the greatest XIC List <QuantPackage2> qpSearch = relevantQuantPackages.FindAll(a => a.MyQuants.ContainsKey(peptide)); List <Quant> refQuants = (from qpckg in qpSearch from quant in qpckg.MyQuants[peptide] where quant.Z == z && quant.QuantArea > 0 select quant).OrderByDescending(a => a.QuantArea).ToList(); if (refQuants.Count == 0) { continue; } List <IonLight> MyIonsLight = refQuants[0].GetIonsLight(); List <string> fileNames = (from qpckg in qpSearch from quant in qpckg.MyQuants[peptide] where quant.Z == z && quant.QuantArea > 0 select qpckg.FullDirPath + @"\" + qpckg.FileName).Distinct().ToList(); //Find out the tolerance i.e., the XIC above +- the tolerance double lowerBound = MyIonsLight.Min(a => a.RetentionTime) - (double)ChromeAssociationTolerance; double upperBound = MyIonsLight.Max(a => a.RetentionTime) + (double)ChromeAssociationTolerance; //Extract the XICs of this peptide in the not found ones and add them //Find the missing getters List <string> fileGetters = myGetters.Select(a => a.MyFile.FullName).ToList(); List <string> fileQuants = new List <string>(); string theExtension = null; foreach (string fName in fileNames) { theExtension = GetExtension(new FileInfo(fName)); fileQuants.Add(Regex.Replace(fName, ".sqt", theExtension)); } List <string> missing = fileGetters.FindAll(a => !fileQuants.Contains(a)).ToList(); List <XICGet5> gettersToUse = myGetters.FindAll(a => missing.Contains(a.MyFile.FullName)); foreach (XICGet5 xg in gettersToUse) { //The problem is it is getting the reference mass of onw charge when it is supposed to be the other double mz = refQuants[0].PrecursorMZ; double ppmTol = MyClusterParams.ClusteringPPM; double minCurrent = MyClusterParams.MinMaxSignal; double minGapForItemsInCluster = MyClusterParams.MinTimeGapFromItemsInCluster; //Find out a good scan number double maxInt = MyIonsLight.Max(a => a.Intensity); IonLight maxIntIon = MyIonsLight.Find(a => a.Intensity == maxInt); double Ctolerance = (double)ChromeAssociationTolerance; double[,] cluster = xg.GetXIC3(mz, ppmTol, maxIntIon.RetentionTime); if (cluster != null) { string tmpf = xg.MyFile.Name; tmpf = Regex.Replace(tmpf, theExtension, ".sqt"); tmpf = Regex.Replace(tmpf, theExtension, ".sqt"); QuantPackage2 qp = myQuantPkgs.Find(a => a.FullDirPath.Equals(xg.MyFile.Directory.FullName) && a.FileName.Equals(tmpf)); Quant q = new Quants.Quant(cluster, -1, z, mz); if (qp.MyQuants.ContainsKey(peptide)) { qp.MyQuants[peptide].Add(q); } else { qp.MyQuants.Add(peptide, new List <Quant>() { q }); } } } Console.WriteLine(peptide); } } }