public void CalculateO18() { EmassProfileBuilder builder = new EmassProfileBuilder(@"../../../data/ISOTOPE.DAT"); AtomComposition light = new AtomComposition("C45H73N13O13"); var res = builder.GetProfile(light, 2, 5); Console.WriteLine("nature"); foreach (var r in res) { Console.WriteLine("{0:0.0000}\t{1:0.000000}", r.Mz, r.Intensity); } AtomComposition O181 = new AtomComposition("(O18)1C45H73N13O12"); var resH = builder.GetProfile(O181, 2, 5); Console.WriteLine("O181"); foreach (var r in resH) { Console.WriteLine("{0:0.0000}\t{1:0.000000}", r.Mz, r.Intensity); } AtomComposition O182 = new AtomComposition("(O18)2C45H73N13O11"); var resH2 = builder.GetProfile(O182, 2, 5); Console.WriteLine("O182"); foreach (var r in resH2) { Console.WriteLine("{0:0.0000}\t{1:0.000000}", r.Mz, r.Intensity); } Console.WriteLine(string.Format("O18 - O16 = {0:0.0000}", Atom.O18.MonoMass - Atom.O.MonoMass)); Console.WriteLine(string.Format("2 * (C13 - C12) = {0:0.0000}", 2 * (Atom.C13.MonoMass - Atom.C.MonoMass))); Console.WriteLine(string.Format("O18 - O181, ppm = {0:0.00}ppm", PrecursorUtils.mz2ppm(res[0].Mz, resH[0].Mz - res[2].Mz))); Console.WriteLine(string.Format("O18 - O182, ppm = {0:0.00}ppm", PrecursorUtils.mz2ppm(res[0].Mz, resH2[0].Mz - res[4].Mz))); Console.WriteLine(string.Format("O181- O182, ppm = {0:0.00}ppm", PrecursorUtils.mz2ppm(resH[0].Mz, resH2[0].Mz - resH[2].Mz))); }
public void CalculateO18_charge1() { EmassProfileBuilder builder = new EmassProfileBuilder(@"../../../data/ISOTOPE.DAT"); AtomComposition light = new AtomComposition("C45H73N13O13"); var res = builder.GetProfile(light, 1, 5); var max = res.Max(m => m.Intensity); Console.WriteLine("nature"); foreach (var r in res) { Console.WriteLine("{0:0.0000}\t{1:0.000000}", r.Mz - Atom.H.MonoMass, r.Intensity * 100 / max); } }
public void Calculate() { var calc = new EmassCalculator(@"../../../data/ISOTOPE.DAT"); EmassProfileBuilder builder = new EmassProfileBuilder(); AtomComposition light = new AtomComposition("C45H73N13O13"); var res = builder.GetProfile(light, 2, 4); Console.WriteLine("light"); foreach (var r in res) { Console.WriteLine("{0:0.0000}\t{1:0.000000}", r.Mz, r.Intensity); } AtomComposition heavy = new AtomComposition("(C13)6(N15)4C39H73N9O13"); var resH = builder.GetProfile(heavy, 2, 4); Console.WriteLine("heavy"); foreach (var r in resH) { Console.WriteLine("{0:0.0000}\t{1:0.000000}", r.Mz, r.Intensity); } }
public SilacQuantificationSummaryItem ReadFromFile(string filename) { XElement root = XElement.Load(filename); var result = new SilacQuantificationSummaryItem(root.GetChildValue("SampleIsLight", true)); result.RawFilename = root.GetChildValue("RawFilename", ""); result.SoftwareVersion = root.GetChildValue("SoftwareVersion", ""); result.PeptideSequence = root.GetChildValue("PeptideSequence"); result.Charge = root.GetChildValue("Charge", 2); result.SampleAtomComposition = root.GetChildValue("SampleAtomComposition"); result.ReferenceAtomComposition = root.GetChildValue("ReferenceAtomComposition"); result.Ratio = root.GetChildValue("Ratio", 0.0); result.RegressionCorrelation = root.GetChildValue("Correlation", 0.0); result.SampleAbundance = root.GetChildValue("SampleAbundance", 0.0); result.ReferenceAbundance = root.GetChildValue("ReferenceAbundance", 0.0); result.SampleProfile = new List <Peak>(); ReadProfile(root, "SampleProfile", result.SampleProfile); result.ReferenceProfile = new List <Peak>(); ReadProfile(root, "ReferenceProfile", result.ReferenceProfile); var observed = root.Element("ObservedEnvelopes"); result.ObservedEnvelopes = new SilacEnvelopes(); foreach (var pkl in observed.Elements()) { var peakList = new SilacPeakListPair(); int scan = Convert.ToInt32(pkl.Attribute("Scan").Value); double retentiontime = MyConvert.ToDouble(pkl.Attribute("Retentiontime").Value); peakList.Enabled = Convert.ToBoolean(pkl.Attribute("Enabled").Value); peakList.IsIdentified = Convert.ToBoolean(pkl.Attribute("Identified").Value); var extended = pkl.Attribute("ExtendedIdentification"); if (extended != null) { peakList.IsExtendedIdentification = Convert.ToBoolean(pkl.Attribute("ExtendedIdentification").Value); } else { peakList.IsExtendedIdentification = false; } peakList.LightIntensity = MyConvert.ToDouble(pkl.Attribute("LightIntensity").Value); peakList.HeavyIntensity = MyConvert.ToDouble(pkl.Attribute("HeavyIntensity").Value); peakList.Light = new PeakList <Peak>(); peakList.Light.ScanTimes.Add(new ScanTime(scan, retentiontime)); peakList.Heavy = new PeakList <Peak>(); peakList.Heavy.ScanTimes.Add(new ScanTime(scan, retentiontime)); ReadPeakList(pkl, "LightPeakList", peakList.Light); ReadPeakList(pkl, "HeavyPeakList", peakList.Heavy); result.ObservedEnvelopes.Add(peakList); } if (result.LightProfile[0].Mz == 0.0) { EmassProfileBuilder builder = new EmassProfileBuilder(); double minPercentage = 0.0001; AtomComposition acSample = new AtomComposition(result.SampleAtomComposition); result.SampleProfile = builder.GetProfile(acSample, result.Charge, minPercentage); AtomComposition acRef = new AtomComposition(result.ReferenceAtomComposition); result.ReferenceProfile = builder.GetProfile(acRef, result.Charge, minPercentage); } result.CalculateCorrelation(); return(result); }
public override IEnumerable <string> Process() { var annos = new AnnotationFormat().ReadFromFile(boundaryFile); var aas = new Aminoacids(); var pbuilder = new EmassProfileBuilder(); var chroFormat = new ChromatographProfileTextWriter(); foreach (var ann in annos) { var chroFile = Path.Combine(ann.Annotations["ChroDirectory"] as string, ann.Annotations["ChroFile"] as string) + ".tsv"; var peptide = (ann.Annotations["PeptideId"] as string).StringBefore("_"); var start = double.Parse(ann.Annotations["ChroLeft"] as string); var end = double.Parse(ann.Annotations["ChroRight"] as string); var chro = chroFormat.ReadFromFile(chroFile); var chroFiltered = chro.Profiles.Where(l => l.RetentionTime >= start && l.RetentionTime <= end).ToArray(); //all observed isotopimers, start from 1, transfer to zero-based var allIsotopics = (from f in chroFiltered from s in f select s.Isotopic - 1).Distinct().OrderBy(l => l).ToArray(); //get minimum intensity of each isotopimer var minIntensities = (from iso in allIsotopics select(from f in chroFiltered where f.Count > iso select f[iso].Intensity).Min()).ToArray(); //how many isotopic should I trust? var iso0 = (from f in chroFiltered select f.First().Intensity).ToArray(); int maxIso = 1; for (int i = 2; i < allIsotopics.Length; i++) { var isoi = (from f in chroFiltered select f.Count > i ? f[i].Intensity : minIntensities[i]).ToArray(); var corr = MathNet.Numerics.Statistics.Correlation.Pearson(iso0, isoi); if (corr < minPearsonCorrelation) { maxIso = i; break; } } var maxIsoArray = allIsotopics.Where(l => l <= maxIso).ToArray(); //get observed profile in each scan var observedIons = (from f in chroFiltered select(from iso in maxIsoArray select f.Count > iso ? f[iso].Intensity : minIntensities[iso]).ToArray()).ToArray(); var atomComposition = aas.GetPeptideAtomComposition(peptide); var hatom = (int)(Math.Round(aas.ExchangableHAtom(peptide))); for (int h2 = 0; h2 < hatom; h2++) { } var profiles = pbuilder.GetProfile(atomComposition, 1, 3); var isotopicIons = (from peak in profiles select new IsotopicIon() { Mz = peak.Mz, Intensity = peak.Intensity, }).ToArray(); } return(null); }