public PeptideTreeViewModel(Peptide peptide, TreeItemViewModel parent) { m_parent = parent; m_peptide = peptide; var information = SingletonDataProviders.GetDatasetInformation(m_peptide.GroupId); if (information != null) { Name = information.DatasetName; } else { Name = string.Format("Dataset {0}", m_peptide.GroupId); } AddStatistic("Id", m_peptide.Id); AddStatistic("Dataset Id", m_peptide.GroupId); AddStatistic("Precursor m/z", m_peptide.Spectrum.PrecursorMz); if (m_peptide.Spectrum.ParentFeature != null) { AddStatistic("Charge", m_peptide.Spectrum.ParentFeature.ChargeState); } else { AddStatistic("Charge", m_peptide.Spectrum.PrecursorChargeState); } AddString("Sequence", peptide.Sequence); AddStatistic("Score", peptide.Score); AddStatistic("Scan", peptide.Scan); }
public void ClearModificationsBySites() { var peptide = new Peptide("AC[Fe]DEFGHIKLMNP[Fe]QRSTV[Fe]WY"); peptide.ClearModifications(ModificationSites.C | ModificationSites.V); Assert.AreEqual("ACDEFGHIKLMNP[Fe]QRSTVWY", peptide.ToString()); }
public void EmptyPeptideFormulaIsH2O() { Peptide pepA = new Peptide(); ChemicalFormula h2O = new ChemicalFormula("H2O"); ChemicalFormula formulaB; pepA.TryGetChemicalFormula(out formulaB); Assert.AreEqual(h2O, formulaB); }
public DatabaseSearchSequence(Peptide peptide, int featureId) { Sequence = peptide.Sequence; Scan = peptide.Scan; Score = peptide.Score; GroupId = peptide.GroupId; UmcFeatureId = featureId; Id = peptide.Id; }
public static PSM parse_psm(int id, string line) { string[] strs = line.Split('\t'); string[] strs2 = strs[0].Split('.'); int charge = int.Parse(strs2[3]); string modsites = ""; List <int> index = new List <int>(); List <Peptide> peptide = new List <Peptide>(); List <double> score = new List <double>(); string sq = strs[5]; string mod_str = strs[10]; string[] tag_flag_strs = strs[14].Split('|'); string[] sq_strs = sq.Split(new char[] { '-' }, StringSplitOptions.RemoveEmptyEntries); for (int i = 0; i < sq_strs.Length; ++i) { string[] tmp_strs = sq_strs[i].Split(new char[] { '(', ')' }, StringSplitOptions.RemoveEmptyEntries); Peptide p = new Peptide(tmp_strs[0]); p.Tag_Flag = int.Parse(tag_flag_strs[2 * i]); peptide.Add(p); index.Add(int.Parse(tmp_strs[1])); score.Add(double.Parse(strs[9])); } if (mod_str != "" && mod_str != "nomod") { string[] strs3 = mod_str.Split(new char[] { ',', ';' }, StringSplitOptions.RemoveEmptyEntries); for (int i = 0; i < strs3.Length; i += 2) { int mod_index = int.Parse(strs3[i]); string mod_name = strs3[i + 1]; if (mod_index <= peptide[0].Sq.Length + 1) //第一条肽段的修饰 { peptide[0].Mods.Add(new Modification(mod_index, ((double[])Config_Help.modStr_hash[mod_name])[0], mod_name, (List <double>)Config_Help.modStrLoss_hash[mod_name], 0)); } else //第二条肽段的修饰 { mod_index -= (peptide[0].Sq.Length + 3); peptide[1].Mods.Add(new Modification(mod_index, ((double[])Config_Help.modStr_hash[mod_name])[0], mod_name, (List <double>)Config_Help.modStrLoss_hash[mod_name], 0)); } } } for (int i = 0; i < peptide[0].Mods.Count; ++i) { modsites += peptide[0].Mods[i].Index + "," + peptide[0].Mods[i].Mod_name + "#" + 0 + ";"; } for (int i = 0; i < peptide[1].Mods.Count; ++i) { modsites += (peptide[1].Mods[i].Index + peptide[0].Sq.Length) + "," + peptide[1].Mods[i].Mod_name + "#" + 0 + ";"; } return(new PSM(id, strs[0], charge, double.Parse(strs[2]), sq, modsites, double.Parse(strs[7]), double.Parse(strs[8]), peptide.Count, peptide, index, score, strs[14], (strs[15] == "target"))); }
private void Initial() { this.Psm_detail.Peptide_index = new List <int> [Spec.Peaks.Count]; for (int i = 0; i < this.Psm_detail.Peptide_index.Length; ++i) { this.Psm_detail.Peptide_index[i] = new List <int>(); } this.Psm_detail.BOry = new int[Spec.Peaks.Count]; this.Psm_detail.Mass_error = new List <double> [Spec.Peaks.Count]; this.Psm_detail.By_num = new List <string> [Spec.Peaks.Count]; for (int i = 0; i < Spec.Peaks.Count; ++i) { this.Psm_detail.Mass_error[i] = new List <double>(); this.Psm_detail.By_num[i] = new List <string>(); } this.Psm_detail.B_flag_mix = new List <List <int> >(); this.Psm_detail.C_flag_mix = new List <List <int> >(); this.Psm_detail.Y_flag_mix = new List <List <int> >(); this.Psm_detail.Z_flag_mix = new List <List <int> >(); for (int i = 0; i < 2; ++i) { this.Psm_detail.B_flag_mix.Add(new List <int>()); this.Psm_detail.C_flag_mix.Add(new List <int>()); this.Psm_detail.Y_flag_mix.Add(new List <int>()); this.Psm_detail.Z_flag_mix.Add(new List <int>()); Peptide p = this.Pep1; switch (i) { case 0: p = this.Pep1; break; case 1: p = this.Pep2; break; } for (int j = 0; j < p.Sq.Length + 1; ++j) { this.Psm_detail.B_flag_mix[i].Add(0); this.Psm_detail.C_flag_mix[i].Add(0); this.Psm_detail.Y_flag_mix[i].Add(0); this.Psm_detail.Z_flag_mix[i].Add(0); } } this.Psm_detail.N_all_matches = new List <PSM_Match>(); this.Psm_detail.C_all_matches = new List <PSM_Match>(); for (int i = 0; i < N_Match_Flag.Length; ++i) { Psm_detail.N_all_matches.Add(new PSM_Match(this.Peptide_Number)); } for (int i = 0; i < C_Match_Flag.Length; ++i) { Psm_detail.C_all_matches.Add(new PSM_Match(this.Peptide_Number)); } }
public override int GetHashCode() { unchecked { var hashCode = (Peptide != null ? Peptide.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (Protein != null ? Protein.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (LabelType != null ? LabelType.GetHashCode() : 0); hashCode = (hashCode * 397) ^ MsLevel.GetHashCode(); return(hashCode); } }
public void PeptideEquality() { Peptide pepA = new Peptide("DEREK"); Peptide pepB = new Peptide("DEREK"); Assert.AreEqual(pepA, pepB); Peptide pepC = new Peptide("DEREKK"); Assert.AreNotEqual(pepA, pepC); }
// Add a single peptide to the exclusion list and sort public void addPeptide(Peptide pep) { // Prevents adding peptides already on the list if (!containsPeptide(exclusionList, pep)) { int position = BinarySearchUtil.findPositionToAdd(exclusionList, pep, BinarySearchUtil.SortingScheme.MASS); exclusionList.Insert(position, pep); //exclusionList.Add(pep); //SortListByMass(); } }
public double CalcMass(string sequence, string[] fixedModifications) { Peptide peptide = new Peptide(sequence); peptide.ApplyFixedModifications(Tables.ToModifications(fixedModifications)); double result = peptide.MonoIsotopicMass; result += labelModifications.GetDeltaMass(); result += trueModifications.GetDeltaMass(); return(result); }
/* * Pre-requisite: the peptide p was selected to be excluded from analysis, and * thus its mass is on the exclusion list Purpose: check if the sequence of * peptide p is truly on the exclusion list or not. If the sequence is not on * the exclusion list, then the peptide was incorrectly excluded. This is * because the mass is on the current exclusion list */ public void evaluateExclusion(ExclusionList exclusionList, Peptide p) { log.Debug("Evaluating peptide mass exclusion..."); // // // sanity check for the pre-requisite // if (!exclusionList.isExcluded(p.getMass())) { // // log.Warn( // // "ERROR: Theoretical peptide mass was found on the exclusion list, but was // // excluded... the spectra mass does not match the mass of the theoretical // // database."); // numWarnings_EvaluateExclusion++; // // return; // } #if WRITE_RT_TIME WriteRetention(String.Format("EX\t{0}\t{1}", exclusionList.getCurrentTime(), p.getRetentionTime().getRetentionTimeStart())); #endif if (containsPeptideSequence(exclusionList.getExclusionList(), p)) { if (isOnCurrentExclusionList(exclusionList, p)) { log.Debug("Peptide sequence was found on the exclusion list! This is what we want."); incrementValue(Header.EvaluateExclusion_FoundOnCurrentExclusionList); } else if (isOnFutureExclusionList(exclusionList, p)) { log.Debug("Peptide sequence was found on the future exclusion list."); incrementValue(Header.EvaluateExclusion_FoundOnFutureExclusionList); } else if (isOnPastExclusionList(exclusionList, p)) { log.Debug("Peptide sequence was found on the past exclusion list."); incrementValue(Header.EvaluateExclusion_FoundOnPastExclusionList); } else if (isOnPastObservedExclusionList(exclusionList, p)) { log.Debug("Peptide sequence was found on the past observed exclusion list."); // this means that this peptide sequence was excluded, but not anymore incrementValue(Header.EvaluateExclusion_FoundOnPastObservedExclusionList); } else if (isOnCurrentObservedExclusionList(exclusionList, p)) { log.Debug("Peptide sequence was found on the observed exclusion list! This is what we want."); incrementValue(Header.EvaluateExclusion_FoundOnCurrentObservedExclusionList); } } else { log.Debug("Peptide sequence was not found on any of the lists! It was wrongly excluded!"); // TODO figure out why this is happening......... // Solved: if a peptide not on the ex list has a similar mass within ppm tolorence of a peptide that's supposed to be excluded, this will happen incrementValue(Header.EvaluateExclusion_NotFoundOnExclusionList); } incrementValue(Header.TotalNumEvaluateExclusion); }
public void observedPeptide(Peptide pep, double time, double rt_window) { // set a new RT RetentionTime newRT = new RetentionTime(time + rt_window, rt_window, rt_window, false); // excludes it for 2*rt_window time pep.setRetentionTime(newRT); //addPeptide(pep); //personally i dont think this line is necessary, since the peptide would have already be added in //MachineLearningGuidedExclusion EvaluateIdentification() //Note that in the last line when re-setting the retention time of the peptide, isPredicted will be set to false }
public static IEnumerable<Dna> FindPatterns(Dna input, Peptide peptide) { var dnaComp = input.Complimentary(); var forward = match(input, peptide); var backWard = match(dnaComp, peptide); var resultMatches = forward.Concat(backWard.Select(d=>d.Complimentary())); return resultMatches; }
public QPeptide(MascotParser mp, int Index) { MascotSpectra ms = mp.Spectra[Index]; string buf; MascotMZ = ms.mz; MascotRT = ms.RT; MascotScan = ms.ScanNumber; IPIs = new List <string>(); Charge = ms.Charge; if (ms.Peptides.Count > 0) { Peptide Pep = ms.Peptides[0]; for (int j = 0; j < Pep.ProteinNames.Length; j++) { buf = Pep.ProteinNames[j]; if (buf[0] == '\"') { buf = buf.Substring(1); } if (buf[buf.Length - 1] == '\"') { buf = buf.Substring(0, buf.Length - 1); } IPIs.Add(buf); } MascotScore = Pep.Score; Sequence = Pep.Sequence; //модификации ModMass = 0.0; if (Pep.NModIndex != 0) { ModMass += mp.VaryMods[Pep.NModIndex].Mass; ModDesk += mp.VaryMods[Pep.NModIndex].Name + " on N-Terminus; "; } for (int k = 0; k < Pep.ModIndex.GetLength(0); k++) { if (Pep.ModIndex[k] != 0) { ModMass += mp.VaryMods[Pep.ModIndex[k]].Mass; ModDesk += mp.VaryMods[Pep.ModIndex[k]].Name + " on position " + k.ToString() + "; "; } } if (Pep.CModIndex != 0) { ModMass += mp.VaryMods[Pep.CModIndex].Mass; ModDesk += mp.VaryMods[Pep.CModIndex].Name + " on C-Terminus; "; } } Matches = null; AlreadySearched = false; }
private List <Protein> GetProteinsFromSkyline() { var result = new List <Protein>(); IReport reportTrackINTargets = _toolClient.GetReport("BLR TrackIN Targets"); var ProteinsQ = from reportRow in reportTrackINTargets.Cells where string.IsNullOrEmpty(reportRow[0]) != true group reportRow by reportRow[0] into ProteintGroup select new { Protein = ProteintGroup.Key, Peptides = from reportRow in ProteintGroup group reportRow by reportRow[1] into PeptideGroup select new { Peptide = PeptideGroup.Key, Precursors = from reportRow in PeptideGroup group reportRow by new { Isotope = reportRow[2], Precursor = reportRow[3] } into PrecursorGroup select new { Isotope = PrecursorGroup.Key.Isotope, PrecursorMZ = PrecursorGroup.Key.Precursor, ProductMZ = from reportRow in PrecursorGroup select reportRow[4] } } }; foreach (var prot in ProteinsQ) { Protein protein = new Protein(); protein.Name = prot.Protein; foreach (var pept in prot.Peptides) { Peptide peptide = new Peptide(); peptide.Name = pept.Peptide; foreach (var prec in pept.Precursors) { Precursor precursor = new Precursor(); precursor.IsotopeLabelType = prec.Isotope; precursor.PrecursorMZ = Convert.ToDouble(prec.PrecursorMZ); foreach (var prod in prec.ProductMZ) { precursor.Products.Add(Convert.ToDouble(prod)); } peptide.Precursors.Add(precursor); } protein.Peptides.Add(peptide); } result.Add(protein); } return(result); }
public IEnumerable <Peptide> Read(string path) { var peptides = new List <Peptide>(); var lines = File.ReadAllLines(path).ToList(); var precursorMap = new Dictionary <string, List <List <string> > >(); foreach (var line in lines) { var lineData = line.Split(',').ToList(); if (lineData.Count < 6) { continue; } if (!lineData[5].StartsWith("y")) { if (!lineData[5].StartsWith("b")) { continue; } } if (!precursorMap.ContainsKey(lineData[0])) { precursorMap.Add(lineData[0], new List <List <string> >()); } precursorMap[lineData[0]].Add(lineData); } foreach (var key in precursorMap.Keys) { var data = precursorMap[key]; var peptide = new Peptide(); peptide = new Peptide(); peptide.Sequence = data[0][3]; var spectrum = new MSSpectra(); spectrum.PrecursorMz = Convert.ToDouble(key); foreach (var line in data) { var fragment = Convert.ToDouble(line[1]); var point = new XYData(fragment, 100); spectrum.Peaks.Add(point); } spectrum.Peptides = new List <Peptide>(); spectrum.Peptides.Add(peptide); peptide.Spectrum = spectrum; peptides.Add(peptide); } return(peptides); }
/// <summary> /// This function takes a spectrum and a peptide and computes the /// sequest style cross-correlation. /// </summary> /// <param name="peaks">Unprocessed experimental spectrum </param> /// <param name="peptide">Peptide sequence for correlation</param> /// <param name="precursorMH">Mass of the peptide precursor</param> /// <returns>An XCorr</returns> public static double computeXCorr(List <Peak> peaks, Peptide peptide, double precursorMH) { // Prepare the spectrum for XCorr double[] processedSpectrum = processSpectrumForXCorr(ref peaks, precursorMH); // Generate the theoretical spectrum for the candidate. Map <double, int> frags = new Map <double, int>(); Map <double, char> fragTypes = new Map <double, char>(); calculateSequenceIons(peptide, 2, ref frags, ref fragTypes); double[] peptideTheoreticalSpectrum = getTheoreticalSpectrumForXCorr(frags, fragTypes, processedSpectrum.Length); // Compute and return the XCorr return(crossCorrelation(processedSpectrum, peptideTheoreticalSpectrum)); }
private void DisplayPeptide(string sequence) { try { Peptide peptide = new Peptide(sequence); peptideMassTB.Text = peptide.MonoisotopicMass.ToString(); peptideMZTB.Text = peptide.ToMz(1).ToString(); } catch (Exception) { peptideMZTB.Text = peptideMassTB.Text = "Not a valid Sequence"; } }
public override PeptideSpectralMatch Search(IMassSpectrum massSpectrum, Peptide peptide, FragmentTypes fragmentTypes, Tolerance productMassTolerance) { double[] eMasses = massSpectrum.MassSpectrum.GetMasses(); double[] eIntenisties = massSpectrum.MassSpectrum.GetIntensities(); double tic = massSpectrum.MassSpectrum.GetTotalIonCurrent(); PeptideSpectralMatch psm = new PeptideSpectralMatch(DefaultPsmScoreType) {Peptide = peptide}; double[] tMasses = peptide.Fragment(fragmentTypes).Select(frag => Mass.MzFromMass(frag.MonoisotopicMass, 1)).OrderBy(val => val).ToArray(); double score = Search(eMasses, eIntenisties, tMasses, productMassTolerance, tic); psm.Score = score; return psm; }
private List <Tuple <string, string, string> > GetPossibleRatios() { IReport reportPeptideRatios = _toolClient.GetReport("BLR Peptide Ratios"); var PeptideList = reportPeptideRatios.Cells.Where(p => p[3] != null).Select(p => p[3]).Distinct(); var PossibleRatios = from peptideN in PeptideList from peptideD in PeptideList where peptideN != peptideD select Tuple.Create(Peptide.GetPeptideShortName(peptideN), Peptide.GetPeptideShortName(peptideD), String.Format("{0}/{1}", Peptide.GetPeptideShortName(peptideN), Peptide.GetPeptideShortName(peptideD))); return(PossibleRatios.ToList()); }
public void GetSequenceCoverageFraction() { Peptide pepA = new Peptide("DERLEK"); Peptide pepAa = new Peptide("ER"); Peptide pepAb = new Peptide("RL"); List <Peptide> myList = new List <Peptide> { pepAa, pepAb }; Assert.AreEqual(0.5, pepA.GetSequenceCoverageFraction(myList)); }
public void PeptideParitalCloneInternalWithCTerminusModification() { Peptide pepA = new Peptide("DEREK"); pepA.SetModification(new OldSchoolChemicalFormulaModification(ChemicalFormula.ParseFormula("H2O")), Terminus.C); Peptide pepB = new Peptide(pepA, 2, 3); Peptide pepC = new Peptide("REK"); pepC.SetModification(new OldSchoolChemicalFormulaModification(ChemicalFormula.ParseFormula("H2O")), Terminus.C); Assert.AreEqual(pepC, pepB); }
public void TestLeucineSequence() { Assert.AreEqual("ACDEFGHLKLMNPQRSTVWY", _mockPeptideEveryAminoAcid.GetSequenceWithModifications(true)); Assert.AreEqual(20, _mockPeptideEveryAminoAcid.ResidueCount()); Assert.AreEqual(7, _mockTrypticPeptide.ResidueCount('S')); Assert.AreEqual(7, _mockTrypticPeptide.ResidueCount(Residue.GetResidue('S'))); Assert.AreEqual(2, _mockTrypticPeptide.ResidueCount(Residue.GetResidue('S'), 2, 3)); Assert.AreEqual(3, _mockTrypticPeptide.ResidueCount('S', 2, 4)); Peptide peptide = new Peptide("III-[C2H3NO]"); Assert.AreEqual("LLL-[C2H3NO]", peptide.GetSequenceWithModifications(true)); }
public PeptideViewModel(Peptide peptide) { m_peptide = peptide; var info = SingletonDataProviders.GetDatasetInformation(peptide.GroupId); if (info != null) { m_dataset = new DatasetInformationViewModel(info); } MatchedProteins = new ObservableCollection<ProteinViewModel>(); LoadProteinData(peptide); }
/// <summary> /// Determines if a peptide passes the cutoff /// </summary> public static bool PassesCutoff(Peptide peptide, double score, double fdr) { if (peptide == null) { return(false); } if (peptide.Fdr > fdr) { return(false); } return(!(peptide.Score > score)); }
public TurnoverCalculator GetTurnoverCalculator(string peptideSequence) { peptideSequence = Peptide.TrimSequence(peptideSequence); TurnoverCalculator turnoverCalculator; if (_turnoverCalculators.TryGetValue(peptideSequence, out turnoverCalculator)) { return(turnoverCalculator); } turnoverCalculator = new TurnoverCalculator(Workspace, peptideSequence); _turnoverCalculators.Add(peptideSequence, turnoverCalculator); return(turnoverCalculator); }
public void PeptideHashing() { Peptide pep1 = new Peptide("DEREK"); Peptide pep2 = new Peptide("DEREKN"); Peptide pep3 = new Peptide("DEREKM"); Peptide pep4 = new Peptide("DEREKM"); HashSet <Peptide> uu = new HashSet <Peptide> { pep1, pep2, pep3, pep4 }; uu.Add(new Peptide("DEREKN")); Assert.AreEqual(3, uu.Count); }
private void BuildPeptideRatiosGraph() { IReport reportPeptideRatios = _toolClient.GetReport("BLR Peptide Ratios"); var graph = this.graphPeptideRatios; var graphPane = this.graphPeptideRatios.GraphPane; graphPane.CurveList.Clear(); Color[] graphColors = new Color[] { Color.Red, Color.Blue, Color.Green, Color.Gray }; Queue <Color> queColors = new Queue <Color>(graphColors); var PeptideList = reportPeptideRatios.Cells.Where(p => p[3] != null).Select(p => p[3]).Distinct(); var PossibleRatios = from peptideN in PeptideList.Select(p => Peptide.GetPeptideShortName(p)) from peptideD in PeptideList.Select(p => Peptide.GetPeptideShortName(p)) where peptideN != peptideD && _peptideIntStdConcentrations.ContainsKey(peptideN) && _peptideIntStdConcentrations.ContainsKey(peptideD) select new { Nominator = peptideN, Denominator = peptideD, RatioName = String.Format("{0}/{1}", peptideN, peptideD), CorCoef = _peptideIntStdConcentrations[peptideN] / _peptideIntStdConcentrations[peptideD] }; var SelectedRatios = from mnuItem in mnuRatioSelection.DropDownItems.Cast <ToolStripMenuItem>() where mnuItem.Checked select mnuItem.Text; var GrouppedByPeptide = from reportRow in reportPeptideRatios.Cells group reportRow by Peptide.GetPeptideShortName(reportRow[3]) into GrouppedRows select new { Peptide = GrouppedRows.Key, Rows = GrouppedRows }; foreach (var ratioVariant in PossibleRatios) { var Nominators = GrouppedByPeptide.Where(p => p.Peptide == ratioVariant.Nominator).Single().Rows.Where(r => r[4] != null).Select(r => r); var Denominators = GrouppedByPeptide.Where(p => p.Peptide == ratioVariant.Denominator).Single().Rows.Where(r => r[4] != null).Select(r => r); var Ratios = Nominators.Join(Denominators, n => n[0], d => d[0], (n, d) => new { FileName = n[0], PeptideRatio = ConvertUtil.doubleTryParse(n[4]) / ConvertUtil.doubleTryParse(d[4]) * ratioVariant.CorCoef }); if (SelectedRatios.Contains(ratioVariant.RatioName)) { graphPane.AddBar(ratioVariant.RatioName, null, Ratios.Select(r => r.PeptideRatio).ToArray(), queColors.Dequeue()); graphPane.XAxis.Scale.TextLabels = Ratios.Select(f => AnalysisResults.GetMSRunShorten(f.FileName, "0, 5")).ToArray(); } } graphPane.XAxis.MajorTic.IsBetweenLabels = true; graphPane.XAxis.Type = ZedGraph.AxisType.Text; graph.AxisChange(); graph.Refresh(); }
public MsMsTreeViewModel(MSSpectra feature, TreeItemViewModel parent) { m_feature = feature; m_parent = parent; var information = SingletonDataProviders.GetDatasetInformation(m_feature.GroupId); AddStatistic("Id", m_feature.Id); AddStatistic("Dataset Id", m_feature.GroupId); AddStatistic("Precursor m/z", m_feature.PrecursorMz); if (feature.ParentFeature != null) { AddStatistic("Charge", m_feature.ParentFeature.ChargeState); } else { AddStatistic("Charge", m_feature.PrecursorChargeState); } AddStatistic("Scan", m_feature.Scan); Peptides = new ObservableCollection <Peptide>(); Peptide maxPeptide = null; foreach (var p in m_feature.Peptides) { Peptides.Add(p); if (maxPeptide == null) { maxPeptide = p; } else if (p.Score < maxPeptide.Score) { maxPeptide = p; } } if (maxPeptide != null) { Name = maxPeptide.Sequence; AddStatistic("Score", maxPeptide.Score); AddStatistic("Scan", maxPeptide.Scan); } else { Name = string.Format("Unknown - Scan: {0} m/z: {1:.00} ", m_feature.Scan, m_feature.PrecursorMz); } }
public override int GetHashCode() { unchecked { var hashCode = (Client != null ? Client.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (IntensityModel != null ? IntensityModel.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (RTModel != null ? RTModel.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (Settings != null ? Settings.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (Precursor != null ? Precursor.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (Peptide != null ? Peptide.GetHashCode() : 0); hashCode = (hashCode * 397) ^ NCE; return(hashCode); } }
public static UMCLight GetParentUmc(this Peptide peptide) { if (peptide == null) { return(null); } if (peptide.Spectrum == null) { return(null); } return(peptide.Spectrum.GetParentUmc()); }
public static void TestPyrrolysine() { Peptide mom = new Peptide("MOM"); double momMass = mom.MonoisotopicMass; Assert.That(517.23926172577, Is.EqualTo(momMass).Within(0.001)); Peptide mm = new Peptide("MM"); double mmMass = mm.MonoisotopicMass; double deltaMass = momMass - mmMass; Assert.That(237.1477268648, Is.EqualTo(deltaMass).Within(0.001)); }
public PlotModel display_TwoMS2(PSM psm1, PSM psm2) { Spectra spec1 = null, spec2 = null; Peptide pep1 = null, pep2 = null; MainW.parse_PSM(psm1, ref spec1, ref pep1); MainW.parse_PSM(psm2, ref spec2, ref pep2); PlotModel model = new PlotModel(); LinearAxis x_axis = new LinearAxis(); x_axis.Position = AxisPosition.Bottom; x_axis.Maximum = (spec1.Peaks.Last().Mass > spec2.Peaks.Last().Mass ? spec1.Peaks.Last().Mass : spec2.Peaks.Last().Mass) + 50; x_axis.Minimum = (spec1.Peaks[0].Mass < spec2.Peaks[0].Mass ? spec1.Peaks[0].Mass : spec2.Peaks[0].Mass) - 50; x_axis.AbsoluteMaximum = x_axis.Maximum; x_axis.AbsoluteMinimum = x_axis.Minimum; x_axis.PositionAtZeroCrossing = true; x_axis.TickStyle = TickStyle.Crossing; x_axis.IsAxisVisible = false; model.Axes.Add(x_axis); LinearAxis y_axis = new LinearAxis(); y_axis.Minimum = -100; y_axis.Maximum = 100; y_axis.IsPanEnabled = false; y_axis.IsZoomEnabled = false; y_axis.Title = psm2.Title + "-" + psm1.Title; model.Axes.Add(y_axis); LineSeries ls = new LineSeries(); ls.Color = OxyColors.Black; ls.LineStyle = LineStyle.Solid; ls.Points.Add(new DataPoint(x_axis.Minimum, 0)); ls.Points.Add(new DataPoint(x_axis.Maximum, 0)); model.Series.Add(ls); MainW.psm_help.Switch_PSM_Help(spec1, pep1); MainW.psm_help.Pep.Tag_Flag = int.Parse(psm1.Pep_flag); MainW.psm_help.Match_BY(); update_peaks(spec1, ref model); MainW.psm_help.Switch_PSM_Help(spec2, pep2); MainW.psm_help.Pep.Tag_Flag = int.Parse(psm2.Pep_flag); MainW.psm_help.Match_BY(); for (int i = 0; i < spec2.Peaks.Count; ++i) { spec2.Peaks[i].Intensity = -spec2.Peaks[i].Intensity; } update_peaks(spec2, ref model); return(model); }
public void PairwiseCompairison_calcMWStatsBaselineCase_Pass(Peptide pep, List <Intensity> baseline, string g1, string g2, int minNumStoichiometries, double mwStat, double mwPVal, double g1Med, double g2Med, double g1Min, double g2Min, double g1Max, double g2Max) { PairwiseCompairison PairwiseCompairisonTest = new PairwiseCompairison(pep, baseline, g1, g2, minNumStoichiometries); Assert.That(mwStat, Is.EqualTo(PairwiseCompairisonTest.MWStat).Within(0.001)); Assert.That(mwPVal, Is.EqualTo(PairwiseCompairisonTest.MWPVal).Within(0.01)); Assert.That(g1Med, Is.EqualTo(PairwiseCompairisonTest.PeptideStoichiometriesGroupOneMedian).Within(0.001)); Assert.That(g2Med, Is.EqualTo(PairwiseCompairisonTest.PeptideStoichiometriesGroupTwoMedian).Within(0.001)); Assert.That(g1Min, Is.EqualTo(PairwiseCompairisonTest.PeptideStoichiometriesGroupOneMin).Within(0.001)); Assert.That(g2Min, Is.EqualTo(PairwiseCompairisonTest.PeptideStoichiometriesGroupTwoMin).Within(0.001)); Assert.That(g1Max, Is.EqualTo(PairwiseCompairisonTest.PeptideStoichiometriesGroupOneMax).Within(0.001)); Assert.That(g2Max, Is.EqualTo(PairwiseCompairisonTest.PeptideStoichiometriesGroupTwoMax).Within(0.001)); }
protected void evaluateExclusion(IDs id) { // check if the peptide is identified or not if (id == null) { performanceEvaluator.countMS2UnidentifiedExcluded(); return; } Peptide pep = getPeptideFromIdentification(id); // Peptide pep = getPeptideFromSpectra(spec); performanceEvaluator.evaluateExclusion(exclusionList, pep); }
private XmlReader HandleMassOnlyDeclarations(ref Peptide peptide) { for (var retry = 0; retry < 4; retry++) // Looking for a common mass and set of adducts that all agree { var adjustParentMass = retry < 2; // Do/don't try adjusting the neutral mass as if it had proton gain or loss built in var assumeProtonated = retry % 2 == 0; // Do/don't try [M+H] vs [M+] foreach (var detail in _precursorRawDetails.OrderBy(d => d._declaredHeavy ? 1 : 0, SortOrder.Ascending)) // Look at lights first { var parentMassAdjustment = adjustParentMass ? Adduct.NonProteomicProtonatedFromCharge(detail._declaredCharge).ApplyToMass(TypedMass.ZERO_MONO_MASSH) : TypedMass.ZERO_MONO_MASSH; var parentMonoisotopicMass = ProposedMolecule.MonoisotopicMass - parentMassAdjustment; if (_precursorRawDetails.TrueForAll(d => { var adduct = assumeProtonated ? Adduct.NonProteomicProtonatedFromCharge(d._declaredCharge) : Adduct.FromChargeNoMass(d._declaredCharge); if (d._declaredHeavy) { var unexplainedMass = adduct.MassFromMz(d._declaredMz, MassType.Monoisotopic) - parentMonoisotopicMass; adduct = adduct.ChangeIsotopeLabels(unexplainedMass, _mzDecimalPlaces); } d._proposedAdduct = adduct; return(Math.Abs(d._declaredMz - d._proposedAdduct.MzFromNeutralMass(parentMonoisotopicMass)) <= MzToler); })) { var parentAverageMass = ProposedMolecule.AverageMass - parentMassAdjustment; ProposedMolecule = new CustomMolecule(parentMonoisotopicMass, parentAverageMass, peptide.CustomMolecule.Name); return(UpdatePeptideAndInsertAdductsInXML(ref peptide, _precursorRawDetails.Select(d => d._proposedAdduct))); } } } // Unexplained masses can be expressed as mass labels if (_precursorRawDetails.TrueForAll(d => { var adduct = Adduct.FromChargeNoMass(d._declaredCharge); var unexplainedMass = adduct.MassFromMz(d._declaredMz, MassType.Monoisotopic) - ProposedMolecule.MonoisotopicMass; d._proposedAdduct = adduct.ChangeIsotopeLabels(unexplainedMass, _mzDecimalPlaces); return(Math.Abs(d._declaredMz - d._proposedAdduct.MzFromNeutralMass(ProposedMolecule.MonoisotopicMass)) <= MzToler); })) { return(UpdatePeptideAndInsertAdductsInXML(ref peptide, _precursorRawDetails.Select(d => d._proposedAdduct))); } // Should never arrive here Assume.Fail("Unable to to deduce adducts and common molecule for " + peptide); // Not L10N return(UpdatePeptideAndInsertAdductsInXML(ref peptide, _precursorRawDetails.Select(d => d._nominalAdduct))); }
private static string SerializeAtoms(Peptide peptide) { var output = ""; var atomIdx = 1; var chainId = 'A'; var aminoAcids = peptide.AminoAcids; for (int residueIdx = 0; residueIdx < aminoAcids.Count; residueIdx++) { var aminoAcid = aminoAcids[residueIdx]; PdbAminoAcidAtomNamer.AssignNames(aminoAcid); var aminoAcidVertices = aminoAcid.VertexIds .Select(vId => aminoAcid.Molecule.MoleculeStructure.GetVertexFromId(vId)); var residueName = aminoAcid.Name.ToThreeLetterCode(); var sequenceNumber = aminoAcid.SequenceNumber; foreach (var vertex in aminoAcidVertices) { var atom = aminoAcid.Molecule.GetAtom(vertex.Id); if (atom.Element == ElementName.Hydrogen) { continue; } if (atom.Position == null) { continue; } var atomName = atom.AminoAcidAtomName ?? atom.Element.ToElementSymbol().ToString(); var x = (1e10 * atom.Position.X).ToString("F3"); var y = (1e10 * atom.Position.Y).ToString("F3"); var z = (1e10 * atom.Position.Z).ToString("F3"); var occupancy = 1.0.ToString("F2"); var temperatureFactor = 0.0.ToString("F2"); var elementSymbol = atom.Element.ToElementSymbol(); var charge = ""; if (atomIdx > 1) { output += Environment.NewLine; } output += $"ATOM {atomIdx,5} {atomName,4} {residueName,3} {chainId}{sequenceNumber,4} " + $"{x,8}{y,8}{z,8}{occupancy,6}{temperatureFactor,6} " + $"{elementSymbol,2}{charge,2}"; atomIdx++; } } output += Environment.NewLine; output += $"TER {atomIdx,5} {aminoAcids.Last().Name.ToThreeLetterCode()} {chainId}{aminoAcids.Count-1,4}".PadRight(80); return(output); }
private static IEnumerable<Dna> match(Dna input, Peptide peptide) { var resultMatches = new List<Dna>(); var rna1 = input.Translate(); for (uint offset = 0; offset < 3; offset++) { var pep = rna1.Transcribe(offset, true); var matches = DnaPattern.FindAllMatches(pep, peptide); foreach (uint match in matches) { var of = match * 3 + offset; var transDna = input.Substring(of, 3 * peptide.Length); resultMatches.Add(transDna); } } return resultMatches; }
public override IEnumerable<PeptideSpectralMatch> ReadNextPsm() { Protein prot; MSDataFile dataFile; foreach (OmssaPeptideSpectralMatch omssaPSM in _reader.GetRecords<OmssaPeptideSpectralMatch>()) { Peptide peptide = new Peptide(omssaPSM.Sequence.ToUpper()); SetFixedMods(peptide); SetDynamicMods(peptide, omssaPSM.Modifications); peptide.StartResidue = omssaPSM.StartResidue; peptide.EndResidue = omssaPSM.StopResidue; if (_proteins.TryGetValue(omssaPSM.Defline, out prot)) { peptide.Parent = prot; } PeptideSpectralMatch psm = new PeptideSpectralMatch(); if (_extraColumns.Count > 0) { foreach(string name in _extraColumns) { psm.AddExtraData(name, _reader.GetField<string>(name)); } } psm.Peptide = peptide; psm.Score = omssaPSM.EValue; psm.Charge = omssaPSM.Charge; psm.ScoreType = PeptideSpectralMatchScoreType.EValue; psm.IsDecoy = omssaPSM.Defline.StartsWith("DECOY"); psm.SpectrumNumber = omssaPSM.SpectrumNumber; psm.FileName = omssaPSM.FileName; string[] filenameparts = psm.FileName.Split('.'); if (_dataFiles.TryGetValue(filenameparts[0], out dataFile)) { if (!dataFile.IsOpen) dataFile.Open(); psm.Spectrum = dataFile[psm.SpectrumNumber] as MsnDataScan; } yield return psm; } }
protected override void WriteTransition(TextWriter writer, XmlFastaSequence sequence, XmlPeptide peptide, XmlTransition transition) { char separator = TextUtil.GetCsvSeparator(_cultureInfo); writer.Write(transition.PrecursorMz.ToString(_cultureInfo)); writer.Write(separator); writer.Write(transition.ProductMz.ToString(_cultureInfo)); writer.Write(separator); if (MethodType == ExportMethodType.Standard) writer.Write(Math.Round(DwellTime, 2).ToString(_cultureInfo)); else { if (!peptide.PredictedRetentionTime.HasValue) throw new InvalidOperationException(Resources.XmlThermoMassListExporter_WriteTransition_Attempt_to_write_scheduling_parameters_failed); writer.Write(peptide.PredictedRetentionTime.Value.ToString(_cultureInfo)); } writer.Write(separator); // Write special ID for ABI software var fastaSequence = new FastaSequence(sequence.Name, sequence.Description, null, peptide.Sequence); var newPeptide = new Peptide(fastaSequence, peptide.Sequence, 0, peptide.Sequence.Length, peptide.MissedCleavages); var nodePep = new PeptideDocNode(newPeptide); string modifiedPepSequence = AbiMassListExporter.GetSequenceWithModsString(nodePep, _document.Settings); // Not L10N; string extPeptideId = string.Format("{0}.{1}.{2}.{3}", // Not L10N sequence.Name, modifiedPepSequence, GetTransitionName(transition), "light"); // Not L10N : file format writer.WriteDsvField(extPeptideId, separator); writer.Write(separator); writer.Write(Math.Round(transition.DeclusteringPotential ?? 0, 1).ToString(_cultureInfo)); writer.Write(separator); writer.Write(Math.Round(transition.CollisionEnergy, 1).ToString(_cultureInfo)); writer.WriteLine(); }
private bool Accept(SrmSettings settings, Peptide peptide, ExplicitMods mods, IList<int> precursorCharges, PeptideFilterType filterType, out bool allowVariableMods) { // Assume variable modifications are not allowed until proven otherwise allowVariableMods = false; // Only filter user specified peptides based on the heuristic // filter when explicitly requested. bool useFilter = filterType == PeptideFilterType.full; if (filterType == PeptideFilterType.fasta) useFilter = peptide.Begin.HasValue; var libraries = PeptideSettings.Libraries; if (!libraries.HasLibraries || libraries.Pick == PeptidePick.filter) { if (!useFilter) { allowVariableMods = true; return true; } return PeptideSettings.Filter.Accept(settings, peptide, mods, out allowVariableMods); } // Check if the peptide is in the library for one of the // acceptable precursor charges. bool inLibrary = false; // If the libraries are not fully loaded, then act like nothing // could be found in the libraries. This will be corrected when // the libraries are loaded. if (libraries.IsLoaded && // Only check the library, if this is a custom ion or a peptide that already has // a variable modification, or the library contains some form of the peptide. // This is a performance improvement over checking every variable modification // of a peptide when it is not even in the library. (peptide.IsCustomIon || (mods != null && mods.IsVariableStaticMods) || LibrariesContainAny(peptide.Sequence))) { // Only allow variable modifications, if the peptide has no modifications // or already checking variable modifications, and there is reason to check // the library. Failing to do this check profiled as a performance bottleneck. allowVariableMods = mods == null || mods.IsVariableStaticMods; inLibrary = LibrariesContainMeasurablePeptide(peptide, precursorCharges, mods); } switch (libraries.Pick) { case PeptidePick.library: return inLibrary; case PeptidePick.both: return inLibrary && (!useFilter || PeptideSettings.Filter.Accept(settings, peptide, mods, out allowVariableMods)); default: return inLibrary || (!useFilter || PeptideSettings.Filter.Accept(settings, peptide, mods, out allowVariableMods)); } }
private IEnumerable<UMCLight> RetrieveFeatures(int datasetId, FeatureDataAccessProviders providers) { var features = providers.FeatureCache.FindByDatasetId(datasetId); var spectra = providers.MSnFeatureCache.FindByDatasetId(datasetId); if (spectra == null) throw new ArgumentNullException(@"There were no MS/MS spectra in the database"); var sequences = providers.DatabaseSequenceCache.FindAll(); var sequenceMaps = providers.SequenceMsnMapCache.FindByDatasetId(datasetId); var spectraMaps = providers.MSFeatureToMSnFeatureCache.FindByDatasetId(datasetId); var msFeatures = providers.MSFeatureCache.FindByDatasetId(datasetId); // Make a one pass through each enumerable list, // then use the maps to join the data together var dictFeatures = new Dictionary<int, UMCLight>(); var dictSpectra = new Dictionary<int, MSSpectra>(); var dictPeptide = new Dictionary<int, Peptide>(); var dictMsFeatures = new Dictionary<int, MSFeatureLight>(); foreach (var sequence in sequences) { if (sequence.GroupId != datasetId) continue; var peptide = new Peptide { Sequence = sequence.Sequence, Id = sequence.Id, }; dictPeptide.Add(peptide.Id, peptide); } msFeatures.ForEach(x => dictMsFeatures.Add(x.Id, x)); features.ForEach(x => dictFeatures.Add(x.Id, x)); spectra.ForEach(x => dictSpectra.Add(x.Id, x)); var count = 0; // Map the MSMS foreach (var map in sequenceMaps) { MSSpectra spectrum; Peptide peptide; var workedSpectra = dictSpectra.TryGetValue(map.MsnFeatureId, out spectrum); var workedPeptide = dictPeptide.TryGetValue(map.SequenceId, out peptide); if (workedSpectra && workedPeptide) { spectrum.Peptides.Add(peptide); peptide.Spectrum = spectrum; count++; } } Console.WriteLine("Mapped {0} peptides to spectra", count); count = 0; // Map the spectra.... foreach (var map in spectraMaps) { UMCLight feature; MSSpectra spectrum; MSFeatureLight msFeature; var workedFeatures = dictFeatures.TryGetValue(map.LCMSFeatureID, out feature); var workedSpectra = dictSpectra.TryGetValue(map.MSMSFeatureID, out spectrum); var workedMsFeature = dictMsFeatures.TryGetValue(map.MSFeatureID, out msFeature); if (!workedFeatures || !workedSpectra || !workedMsFeature) continue; var metaData = new ScanSummary { MsLevel = 2, PrecursorMz = spectrum.PrecursorMz, Scan = spectrum.Scan }; spectrum.ScanMetaData = metaData; msFeature.MSnSpectra.Add(spectrum); spectrum.ParentFeature = msFeature; feature.AddChildFeature(msFeature); msFeature.Umc = feature; count++; } Console.WriteLine("Mapped {0} spectra to parent Features", count); return features; }
public abstract PeptideSpectralMatch Search(IMassSpectrum massSpectrum, Peptide peptide, FragmentTypes fragmentTypes, Tolerance productMassTolerance);
public virtual PeptideSpectralMatch Search(IMassSpectrum massSpectrum, Peptide peptide) { return Search(massSpectrum, peptide, DefaultFragmentType, ProductMassTolerance); }
private bool LibrariesContainMeasurablePeptide(Peptide peptide, IsotopeLabelType labelType, IEnumerable<int> precursorCharges, ExplicitMods mods) { string sequenceMod = GetModifiedSequence(peptide.Sequence, labelType, mods); foreach (int charge in precursorCharges) { if (LibrariesContain(sequenceMod, charge)) { // Make sure the peptide for the found spectrum is measurable on // the current instrument. double precursorMass = GetPrecursorMass(labelType, peptide.Sequence, mods); if (IsMeasurable(precursorMass, charge)) return true; } } return false; }
public int CompareSpectra(Peptide p, MSSpectra s) { var matchingPeaks = 0; foreach (var point in p.Spectrum.Peaks) { var px = point.X; for (var i = 0; i < s.Peaks.Count - 1; i++) { var iPoint = s.Peaks[i]; var jPoint = s.Peaks[i + 1]; if (px < jPoint.X && px >= iPoint.X) { if (iPoint.Y > 0) { matchingPeaks++; break; } } } } return matchingPeaks; }
public void SetUp() { _mockPeptideEveryAminoAcid = new Peptide("ACDEFGHIKLMNPQRSTVWY"); }
public bool Accept(SrmSettings settings, Peptide peptide, ExplicitMods explicitMods, out bool allowVariableMods) { return Accept(settings, peptide, explicitMods, TransitionSettings.Filter.PrecursorCharges, PeptideFilterType.fasta, out allowVariableMods); }
/// <summary> /// Returns true if a peptide sequence would yield any usable <see cref="PeptideDocNode"/> /// elements with the current filter settings, taking into account variable modifications. /// </summary> public bool Accept(string peptideSequence, int missedCleavages) { var peptide = new Peptide(null, peptideSequence, null, null, missedCleavages); var enumDocNodes = peptide.CreateDocNodes(this, this); return enumDocNodes.GetEnumerator().MoveNext(); }
/// <summary> /// This version of Accept is used to select transition groups after the peptide /// itself has already been screened. For this reason, it only applies library /// filtering. /// </summary> public bool Accept(SrmSettings settings, Peptide peptide, ExplicitMods mods, int charge) { bool allowVariableMods; return Accept(settings, peptide, mods, new[] { charge }, PeptideFilterType.library, out allowVariableMods); }
private TransitionGroupDocNode GetMoleculeTransitionGroup(SrmDocument document, DataGridViewRow row, Peptide pep, bool requireProductInfo) { var moleculeInfo = ReadPrecursorOrProductColumns(document, row, true); // Re-read the precursor columns if (!document.Settings.TransitionSettings.IsMeasurablePrecursor(moleculeInfo.Mz)) { ShowTransitionError(new PasteError { Column = INDEX_MOLECULE_MZ, Line = row.Index, Message = string.Format(Resources.PasteDlg_GetMoleculeTransitionGroup_The_precursor_m_z__0__is_not_measureable_with_your_current_instrument_settings_, moleculeInfo.Mz) }); return null; } var customIon = moleculeInfo.ToCustomIon(); var isotopeLabelType = moleculeInfo.IsotopeLabelType ?? IsotopeLabelType.light; var group = new TransitionGroup(pep, customIon, moleculeInfo.Charge, isotopeLabelType); try { var tran = GetMoleculeTransition(document, row, pep, group, requireProductInfo); if (tran == null) return null; return new TransitionGroupDocNode(group, document.Annotations, document.Settings, null, null, moleculeInfo.ExplicitTransitionGroupValues, null, new[] {tran}, true); } catch (InvalidDataException e) { ShowTransitionError(new PasteError { Column = INDEX_PRODUCT_MZ, // Don't actually know that mz was the issue, but at least it's the right row, and in the product columns Line = row.Index, Message = e.Message }); return null; } }
public PeptideDocNode CreateDocNodeFromSettings(string seq, Peptide peptide, SrmSettingsDiff diff, out TransitionGroupDocNode nodeGroupMatched) { seq = Transition.StripChargeIndicators(seq, TransitionGroup.MIN_PRECURSOR_CHARGE, TransitionGroup.MAX_PRECURSOR_CHARGE); if (peptide == null) { string seqUnmod = FastaSequence.StripModifications(seq); try { peptide = new Peptide(null, seqUnmod, null, null, Settings.PeptideSettings.Enzyme.CountCleavagePoints(seqUnmod)); } catch (InvalidDataException) { nodeGroupMatched = null; return null; } } // Use the number of modifications as the maximum, if it is less than the current // settings to keep from over enumerating, which can be slow. var filter = new MaxModFilter(Math.Min(seq.Count(c => c == '[' || c == '('), Settings.PeptideSettings.Modifications.MaxVariableMods)); foreach (var nodePep in peptide.CreateDocNodes(Settings, filter)) { var nodePepMod = CreateDocNodeFromSettings(seq, nodePep, diff, out nodeGroupMatched); if (nodePepMod != null) return nodePepMod; } nodeGroupMatched = null; return null; }
private TransitionDocNode GetMoleculeTransition(SrmDocument document, DataGridViewRow row, Peptide pep, TransitionGroup group, bool requireProductInfo) { var massType = document.Settings.TransitionSettings.Prediction.FragmentMassType; var molecule = ReadPrecursorOrProductColumns(document, row, !requireProductInfo); // Re-read the product columns, or copy precursor if (requireProductInfo && molecule == null) { return null; } var ion = molecule.ToCustomIon(); var ionType = (!requireProductInfo || // We inspected the input list and found only precursor info ((ion.MonoisotopicMass.Equals(pep.CustomIon.MonoisotopicMass) && ion.AverageMass.Equals(pep.CustomIon.AverageMass)))) // Same mass, must be a precursor transition ? IonType.precursor : IonType.custom; double mass = ion.GetMass(massType); var transition = new Transition(group, molecule.Charge, null, ion, ionType); var annotations = document.Annotations; if (!string.IsNullOrEmpty(molecule.Note)) { var note = document.Annotations.Note; note = string.IsNullOrEmpty(note) ? molecule.Note : (note + "\r\n" + molecule.Note); // Not L10N annotations = new Annotations(note, document.Annotations.ListAnnotations(), 0); } return new TransitionDocNode(transition, annotations, null, mass, null, null, null); }
//################################################################### /// <summary> /// The class constructor /// </summary> /// <param name="config">The configuration object</param> public IonCalculator(Hashtable config) { this.neutralgain = new List<string>(); this.neutralloss = new List<string>(); this.weighttype = config.ContainsKey("weighttype") ? config["weighttype"].ToString() : this.weighttype; this.customtemplate = config.ContainsKey("customtemplate") ? config["customtemplate"].ToString() : this.customtemplate; if (config.ContainsKey("peptide") && config["peptide"] is Peptide) { this.peptide = (Peptide)config["peptide"]; } if (config.ContainsKey("maxcharge") && config["maxcharge"] is int) { this.maxcharge = (int)config["maxcharge"]; } if (config.ContainsKey("neutralloss") && config["neutralloss"] is List<string>) { this.neutralloss = (List<string>)config["neutralloss"]; } if (config.ContainsKey("neutralgain") && config["neutralgain"] is List<string>) { this.neutralgain = (List<string>)config["neutralgain"]; } if (config.ContainsKey("customonly") && config["customonly"] is bool) { this.customonly = (bool)config["customonly"]; } this._tempArray1 = new List<Ms2Ion>(); this._tempArray2 = new ArrayList(); }
public PeptideDocNode GetModifiedNode(LibKey key, string seqUnmod, SrmSettings settings, SrmSettingsDiff diff) { if (string.IsNullOrEmpty(seqUnmod)) return null; var peptide = new Peptide(null, seqUnmod, null, null, settings.PeptideSettings.Enzyme.CountCleavagePoints(seqUnmod)); // First try and create the match from the settings created to match the library explorer. Settings = HasMatches ? settings.ChangePeptideModifications(mods => MatcherPepMods) : settings; TransitionGroupDocNode nodeGroup; var nodePep = CreateDocNodeFromSettings(key.Sequence, peptide, diff, out nodeGroup); if (nodePep != null) { if (diff == null) { nodePep = (PeptideDocNode)nodePep.ChangeAutoManageChildren(false); } else { // Keep only the matching transition group, so that modifications // will be highlighted differently for light and heavy forms. // Only performed when getting peptides for display in the explorer. nodePep = (PeptideDocNode)nodePep.ChangeChildrenChecked( new DocNode[] { nodeGroup }); } return nodePep; } else if (Matches == null) return null; bool hasHeavy; // Create explicit mods from the found matches. nodePep = CreateDocNodeFromMatches(new PeptideDocNode(peptide), EnumerateSequenceInfos(key.Key, true), false, out hasHeavy); if (nodePep == null) return null; // Call change settings with the matched modification settings to enumerate the children. nodePep = nodePep.ChangeSettings(settings.ChangePeptideModifications(mods => !HasMatches ? settings.PeptideSettings.Modifications : MatcherPepMods), diff ?? SrmSettingsDiff.ALL); if (nodePep.Children.Count == 0) return null; // Select the correct child, only for use with the library explorer. if (diff != null && nodePep.Children.Count > 1) { nodePep = (PeptideDocNode) nodePep.ChangeChildrenChecked(new List<DocNode> { nodePep.Children[hasHeavy ? 1 : 0] }); } if (diff == null) { nodePep = (PeptideDocNode)nodePep.ChangeAutoManageChildren(false); } return nodePep; }
private void LoadProteinData(Peptide peptide) { MatchedProteins.Clear(); peptide.ProteinList.ForEach(x => MatchedProteins.Add(new ProteinViewModel(x))); }
public bool Accept(SrmSettings settings, Peptide peptide, ExplicitMods explicitMods, out bool allowVariableMods) { return PeptideFilter.UNFILTERED.Accept(settings, peptide, explicitMods, out allowVariableMods); }
public bool LibrariesContainMeasurablePeptide(Peptide peptide, IList<int> precursorCharges, ExplicitMods mods) { if (LibrariesContainMeasurablePeptide(peptide, IsotopeLabelType.light, precursorCharges, mods)) return true; // If light version not found, try heavy foreach (var labelType in GetHeavyLabelTypes(mods)) { if (LibrariesContainMeasurablePeptide(peptide, labelType, precursorCharges, mods)) return true; } return false; }
private PeptideDocNode GetMoleculePeptide(SrmDocument document, DataGridViewRow row, PeptideGroup group, bool requireProductInfo) { DocNodeCustomIon ion; MoleculeInfo moleculeInfo; try { moleculeInfo = ReadPrecursorOrProductColumns(document, row, true); // Re-read the precursor columns if (moleculeInfo == null) return null; // Some failure, but exception was already handled ion = new DocNodeCustomIon(moleculeInfo.Formula, moleculeInfo.MonoMass, moleculeInfo.AverageMass, Convert.ToString(row.Cells[INDEX_MOLECULE_NAME].Value)); // Short name } catch (ArgumentException e) { ShowTransitionError(new PasteError { Column = INDEX_MOLECULE_FORMULA, Line = row.Index, Message = e.Message }); return null; } try { var pep = new Peptide(ion); var tranGroup = GetMoleculeTransitionGroup(document, row, pep, requireProductInfo); if (tranGroup == null) return null; return new PeptideDocNode(pep, document.Settings, null, null, moleculeInfo.ExplicitRetentionTime, new[] { tranGroup }, true); } catch (InvalidOperationException e) { ShowTransitionError(new PasteError { Column = INDEX_MOLECULE_FORMULA, Line = row.Index, Message = e.Message }); return null; } }