コード例 #1
0
ファイル: ToolOptionsUI.cs プロジェクト: laeubisoft/pwiz
            public override PrositHelpers.PrositRequest Predict()
            {
                ActionUtil.RunAsync(() =>
                {
                    try
                    {
                        var labelType = Precursor.LabelType;
                        var ms        = IntensityModel.PredictSingle(Client, Settings,
                                                                     new PrositIntensityModel.PeptidePrecursorNCE(Peptide, Precursor, labelType, NCE), _tokenSource.Token);

                        var iRTMap = RTModel.PredictSingle(Client,
                                                           Settings,
                                                           Peptide, _tokenSource.Token);

                        var spectrumInfo = new SpectrumInfoProsit(ms, Precursor, labelType, NCE);
                        var irt          = iRTMap[Peptide];
                        Spectrum         = new SpectrumDisplayInfo(
                            spectrumInfo, Precursor, irt);
                    }
                    catch (Exception ex)
                    {
                        Exception = ex;

                        // Ignore, UpdateUI is already working on a new request,
                        // so don't even update UI
                        if (ex.InnerException is RpcException rpcEx && rpcEx.StatusCode == StatusCode.Cancelled)
                        {
                            return;
                        }
                    }

                    // Bad timing could cause the ping to finish right when we cancel as the form closes
                    // causing a UI update to be called after the form was destroyed
                    if (!_tokenSource.IsCancellationRequested)
                    {
                        _updateCallback.Invoke();
                    }
                });

                return(this);
            }
コード例 #2
0
            public virtual PrositRequest Predict()
            {
                ActionUtil.RunAsync(() =>
                {
                    try
                    {
                        var labelType = LabelType ?? Precursor.LabelType;
                        var skyIn     = new PrositIntensityModel.PeptidePrecursorNCE(Peptide,
                                                                                     Precursor, labelType, NCE);
                        var massSpectrum = IntensityModel.PredictSingle(Client,
                                                                        Settings, skyIn,
                                                                        _tokenSource.Token);
                        var iRT = RTModel.PredictSingle(Client,
                                                        Settings,
                                                        Peptide, _tokenSource.Token);
                        Spectrum = new SpectrumDisplayInfo(
                            new SpectrumInfoProsit(massSpectrum, Precursor, labelType, NCE),
                            // ReSharper disable once AssignNullToNotNullAttribute
                            Precursor,
                            iRT[Peptide]);
                    }
                    catch (PrositException ex)
                    {
                        Exception = ex;

                        // Ignore, UpdateUI is already working on a new request,
                        // so don't even update UI
                        if (ex.InnerException is RpcException rpcEx && rpcEx.StatusCode == StatusCode.Cancelled)
                        {
                            return;
                        }
                    }

                    _updateCallback.Invoke();
                });
                return(this);
            }