Exemple #1
0
        internal static Target FromHandle(LLVMTargetRef targetHandle)
        {
            targetHandle.ValidateNotDefault(nameof(targetHandle));
            lock ( TargetMap )
            {
                if (TargetMap.TryGetValue(targetHandle, out Target retVal))
                {
                    return(retVal);
                }

                retVal = new Target(targetHandle);
                TargetMap.Add(targetHandle, retVal);
                return(retVal);
            }
        }
Exemple #2
0
        public static List <IrtStandard> BestMatch(ICollection <SpectrumMzInfo> targets)
        {
            var potentialMatches = BestMatch(targets.Select(t => t.Key.Target)).ToList();

            var matches = new List <IrtStandard>();

            foreach (var standard in potentialMatches)
            {
                var doc = standard.GetDocument();
                if (doc == null || doc.Peptides.All(nodePep => nodePep.ExplicitModsHeavy.Count == 0))
                {
                    matches.Add(standard);
                    continue;
                }

                // Compare precursor m/zs in document (heavy label check)
                var docPeps      = new TargetMap <PeptideDocNode>(doc.Peptides.Select(pep => new KeyValuePair <Target, PeptideDocNode>(pep.ModifiedTarget, pep)));
                var matchTargets = doc.Peptides.Select(pep => pep.ModifiedTarget).ToHashSet();
                foreach (var target in targets)
                {
                    if (!docPeps.TryGetValue(target.Key.Target, out var nodePep))
                    {
                        continue;
                    }

                    var nodeTranGroup = nodePep.TransitionGroups.FirstOrDefault(precursor => precursor.PrecursorCharge == target.Key.Charge);
                    if (nodeTranGroup != null && Math.Abs(nodeTranGroup.PrecursorMz - target.PrecursorMz) < 1)
                    {
                        matchTargets.Remove(nodePep.ModifiedTarget);
                    }
                }
                if (matchTargets.Count == 0)
                {
                    matches.Add(standard);
                }
            }

            if (matches.Contains(BIOGNOSYS_10) && matches.Contains(BIOGNOSYS_11))
            {
                matches.Remove(BIOGNOSYS_10);
            }

            return(matches);
        }
Exemple #3
0
        public IEnumerable <PeptideDocNode> FindInDocument(SrmDocument document)
        {
            var standardDoc = GetDocument();
            var docPeps     = new TargetMap <Dictionary <int, SignedMz> >(standardDoc != null
                ? standardDoc.Peptides.Select(pep =>
                                              new KeyValuePair <Target, Dictionary <int, SignedMz> >(pep.ModifiedTarget,
                                                                                                     pep.TransitionGroups.ToDictionary(nodeTranGroup => nodeTranGroup.PrecursorCharge, nodeTranGroup => nodeTranGroup.PrecursorMz)))
                : Peptides.Select(pep => new KeyValuePair <Target, Dictionary <int, SignedMz> >(pep.ModifiedTarget, null)));

            // Compare precursor m/z to see if heavy labeled
            foreach (var nodePep in document.Peptides)
            {
                if (docPeps.TryGetValue(nodePep.ModifiedTarget, out var precursors) &&
                    (precursors == null || nodePep.TransitionGroups.Any(nodeTranGroup => precursors.TryGetValue(nodeTranGroup.PrecursorCharge, out var mz) && Math.Abs(mz - nodeTranGroup.PrecursorMz) < 1)))
                {
                    yield return(nodePep);
                }
            }
        }
Exemple #4
0
 public double?CirtIrt(Target target)
 {
     return(_cirtAll.TryGetValue(target, out var irt) ? irt : (double?)null);
 }
Exemple #5
0
        public void OkDialog()
        {
            var reader           = new StringReader(textPeptides.Text);
            var standardPeptides = new List <DbIrtPeptide>();
            var invalidLines     = new List <string>();

            string line;

            while ((line = reader.ReadLine()) != null)
            {
                line = line.Trim();
                // Skip blank lines
                if (string.IsNullOrEmpty(line))
                {
                    continue;
                }
                DbIrtPeptide peptide = null;
                var          target  = TargetResolver.ResolveTarget(line);
                if (target == null || !_dictSequenceToPeptide.TryGetValue(target, out peptide))  // CONSIDER(bspratt) - small molecule equivalent?
                {
                    invalidLines.Add(line);
                }
                standardPeptides.Add(peptide);
            }

            if (invalidLines.Count > 0)
            {
                string message;
                if (invalidLines.Count == 1)
                {
                    message = ModeUIAwareStringFormat(Resources.ChangeIrtPeptidesDlg_OkDialog_The_sequence__0__is_not_currently_in_the_database,
                                                      invalidLines[0]);
                    MessageBox.Show(this, message, Program.Name);
                }
                else
                {
                    message = TextUtil.LineSeparate(GetModeUIHelper().Translate(Resources.ChangeIrtPeptidesDlg_OkDialog_The_following_sequences_are_not_currently_in_the_database),
                                                    string.Empty,
                                                    TextUtil.LineSeparate(invalidLines),
                                                    string.Empty,
                                                    GetModeUIHelper().Translate(Resources.ChangeIrtPeptidesDlg_OkDialog_Standard_peptides_must_exist_in_the_database));
                    MessageBox.Show(this, message, Program.Name);
                }
                return;
            }

            ReplacementProtein = null;
            var selected = (ComboBoxProtein)comboProteins.SelectedItem;

            if (selected.IsNotNull)
            {
                var removedPeptides = selected.RemovedPeptides(TargetResolver, textPeptides.Lines).ToArray();
                if (removedPeptides.Any())
                {
                    switch (MultiButtonMsgDlg.Show(this, TextUtil.LineSeparate(
                                                       Resources.ChangeIrtPeptidesDlg_OkDialog_The_following_peptides_were_removed_,
                                                       TextUtil.LineSeparate(removedPeptides.Select(nodePep => nodePep.ModifiedSequenceDisplay)),
                                                       Resources.ChangeIrtPeptidesDlg_OkDialog_Would_you_like_to_remove_them_from_the_document_),
                                                   MultiButtonMsgDlg.BUTTON_YES, MultiButtonMsgDlg.BUTTON_NO, true))
                    {
                    case DialogResult.Yes:
                        ReplacementProtein = selected.RemovePeptides(TargetResolver, textPeptides.Lines);
                        break;

                    case DialogResult.No:
                        break;

                    case DialogResult.Cancel:
                        return;
                    }
                }
            }

            _standardPeptides = standardPeptides.ToArray();

            DialogResult = DialogResult.OK;
        }