/// <summary> /// If your started an empty cluster you will need to initiate all new clusters /// </summary> /// <param name="thisIon"></param> public void StartCluster(IonLight thisIon) { Sequences = new List <SequenceHit>(); ReferenceMass = thisIon.MZ; MyIons = new List <IonLight>() { thisIon }; }
public IonCluster(IonLight thisIon, double refMass) { Sequences = new List <SequenceHit>(); ReferenceMass = refMass; MyScans = new List <SQTLight>(); MyIons = new List <IonLight>() { thisIon }; }
public IonCluster(IonLight thisIon) { Sequences = new List <SequenceHit>(); ReferenceMass = thisIon.MZ; MyScans = new List <SQTLight>(); MyIons = new List <IonLight>() { thisIon }; }
/// <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); } } }
/// <summary> /// /// </summary> /// <param name="referenceMass">The mass used to obtain the XIC</param> public void Plot() { tabControlTheTabs.Items.Clear(); //Generate a list of colors List <Tuple <string, double[]> > theColors = new List <Tuple <string, double[]> >(); Type brushesType = typeof(System.Windows.Media.Brushes); // Get all static properties var properties = brushesType.GetProperties(BindingFlags.Static | BindingFlags.Public); foreach (var prop in properties) { string name = prop.Name; SolidColorBrush brush = (SolidColorBrush)prop.GetValue(null, null); Color color = brush.Color; theColors.Add(new Tuple <string, double[]>(name, new double[] { color.A, color.R, color.G, color.B })); //Console.WriteLine("Brush named {0} has RGB colors of {1}{2}{2}", name, color.R, color.G, color.B); } PlotModel MyModel = new PlotModel(); MyModel.Title = "Reference m/z : " + ReferenceMass; //Find the division factor IonLight mostIntenseIon = new IonLight(0, 0, 0, 0); foreach (Tuple <int, string, List <IonLight>, List <int> > t in MyData) { double maxInt = t.Item3.Select(a => a.Intensity).Max(); IonLight i = t.Item3.Find(a => a.Intensity == maxInt); if (i.Intensity > mostIntenseIon.Intensity) { mostIntenseIon = i; } } //Calculate division factor double f1 = Math.Floor(Math.Log10(mostIntenseIon.Intensity)); double factor = Math.Pow(10, f1); Console.WriteLine("Factor = " + factor); var linearAxis1 = new LinearAxis(); linearAxis1.Title = "Intensity x 10E" + f1; MyModel.Axes.Add(linearAxis1); var linearAxis2 = new LinearAxis(); linearAxis2.Title = "Retention time"; linearAxis2.Position = AxisPosition.Bottom; MyModel.Axes.Add(linearAxis2); List <Tuple <int, string, List <IonLight>, List <int> > > plotData = MyData; if ((bool)CheckBoxAlign.IsChecked) { plotData = AlignChromatograms(MyData); } foreach (var t in plotData) { LineSeries ls = new LineSeries(); ls.Title = t.Item2; List <DataPoint> points = t.Item3.Select(a => new DataPoint(a.RetentionTime, a.Intensity / factor)).ToList(); ls.Points.AddRange(points); ls.Smooth = true; ls.MarkerSize = 6; ls.MarkerType = MarkerType.Circle; ls.ToolTip = t.Item2; ScatterSeries ss = new ScatterSeries(); foreach (int scanNo in t.Item4) { //Find the closest time from the interpolated vector int minDistance = t.Item3.Min(a => Math.Abs(a.ScanNumber - scanNo)); IonLight closestIon = t.Item3.Find(a => Math.Abs(a.ScanNumber - scanNo) == minDistance); double x = closestIon.RetentionTime; double y = closestIon.Intensity / factor; ss.Points.Add(new ScatterPoint(x, y)); } MyModel.Series.Add(ls); MyModel.Series.Add(ss); DataGrid dg = new DataGrid(); dg.Background = Brushes.AliceBlue; dg.ItemsSource = t.Item3; TabItem ti = new TabItem(); ti.Header = t.Item2; ti.Content = dg; tabControlTheTabs.Items.Add(ti); } MyPlot.Model = MyModel; }