private void SetFeature(UMCLight feature) { if (feature == null) { return; } var info = SingletonDataProviders.GetDatasetInformation(feature.GroupId); if (info != null) { SelectedFeatureName = info.DatasetName; } var model = new XicViewModel(new List <UMCLight> { feature }, "XIC"); model.PointClicked += model_PointClicked; XicModel = model; UpdateCharges(feature); }
public MsSpectraViewModel(MSSpectra spectrum) { Peptides = new ObservableCollection <PeptideViewModel>(); spectrum.Peptides.ForEach(x => Peptides.Add(new PeptideViewModel(x))); var info = SingletonDataProviders.GetDatasetInformation(spectrum.GroupId); if (info != null) { Dataset = new DatasetInformationViewModel(info); } Spectrum = spectrum; SelectedSpectrumPlotModel = new MsMsSpectraViewModel(spectrum, ""); if (spectrum.ParentFeature != null) { var msFeature = spectrum.ParentFeature; var umc = msFeature.GetParentFeature(); if (umc != null) { var newList = new List <UMCLight> { umc }; var xic = new XicViewModel(newList, "xic") { Model = { IsLegendVisible = false, TitleFontSize = 0 } }; SelectedSpectrumXic = xic; } } }
/// <summary> /// Initializes a new instance of the <see cref="DataSetViewModel"/> class. /// </summary> /// <param name="dialogService">A dialog service for opening dialogs from the view model</param> public DataSetViewModel(IMainDialogService dialogService) { this.dialogService = dialogService; ReadyToClose = false; IdFileOpen = false; SelectedPrSm = new PrSm(); ScanViewModel = new ScanViewModel(dialogService, new List <PrSm>()); CreateSequenceViewModel = new CreateSequenceViewModel(dialogService) { SelectedDataSetViewModel = this }; CreateSequenceViewModel.CreateAndAddPrSmCommand.Subscribe( _ => ScanViewModel.Data.Add(CreateSequenceViewModel.SelectedPrSm)); // Remove filter by raw file name from ScanViewModel filters ScanViewModel.Filters.Remove(ScanViewModel.Filters.FirstOrDefault(f => f.Name == "Raw File Name")); // When a PrSm is selected from the ScanViewModel, update the SelectedPrSm for this data set ScanViewModel.WhenAnyValue(x => x.SelectedPrSm).Where(prsm => prsm != null).Subscribe(x => SelectedPrSm = x); // When the scan number in the selected prsm changes, the selected scan in the xic plots should update this.WhenAnyValue(x => x.SelectedPrSm) .Where(_ => SelectedPrSm != null && SpectrumViewModel != null && XicViewModel != null) .Subscribe(prsm => { SpectrumViewModel.UpdateSpectra(prsm.Scan, SelectedPrSm.PrecursorMz); XicViewModel.SetSelectedScan(prsm.Scan); XicViewModel.ZoomToScan(prsm.Scan); }); var prsmObservable = this.WhenAnyValue(x => x.SelectedPrSm).Where(prsm => prsm != null); prsmObservable .Select(prsm => prsm.GetFragmentationSequence()).Where(fragSeq => fragSeq != null) .Subscribe(fragSeq => { SpectrumViewModel.FragmentationSequence = fragSeq; XicViewModel.FragmentationSequence = fragSeq; }); // When the prsm changes, update the Scan View Model. prsmObservable.Subscribe(prsm => ScanViewModel.SelectedPrSm = prsm); // When the prsm updates, update the prsm in the sequence creator prsmObservable.Subscribe(prsm => CreateSequenceViewModel.SelectedPrSm = prsm); // When the prsm updates, update the feature map prsmObservable.Where(_ => FeatureMapViewModel != null).Subscribe(prsm => FeatureMapViewModel.FeatureMapViewModel.SelectedPrSm = prsm); // When prsm updates, subscribe to scan updates prsmObservable.Subscribe(prsm => { prsm.WhenAnyValue(x => x.Scan, x => x.PrecursorMz) .Where(x => x.Item1 > 0 && x.Item2 > 0 && SpectrumViewModel != null) .Subscribe(x => SpectrumViewModel.UpdateSpectra(x.Item1, x.Item2)); prsm.WhenAnyValue(x => x.Scan).Where(scan => scan > 0 && XicViewModel != null) .Subscribe(scan => XicViewModel.SetSelectedScan(scan)); }); // When a new prsm is created by CreateSequenceViewModel, update SelectedPrSm CreateSequenceViewModel.WhenAnyValue(x => x.SelectedPrSm).Subscribe(prsm => SelectedPrSm = prsm); // When IDs are filtered in the ScanViewModel, update feature map with new IDs ScanViewModel.WhenAnyValue(x => x.FilteredData).Where(_ => FeatureMapViewModel != null).Subscribe(data => FeatureMapViewModel.UpdateIds(data)); // Toggle instrument data when ShowInstrumentData setting is changed. IcParameters.Instance.WhenAnyValue(x => x.ShowInstrumentData).Select(async x => await ScanViewModel.ToggleShowInstrumentDataAsync(x, (PbfLcMsRun)LcMs)).Subscribe(); // When product ion tolerance or ion correlation threshold change, update scorer factory IcParameters.Instance.WhenAnyValue(x => x.ProductIonTolerancePpm, x => x.IonCorrelationThreshold) .Subscribe( x => { var scorer = new ScorerFactory(x.Item1, Constants.MinCharge, Constants.MaxCharge, x.Item2); CreateSequenceViewModel.ScorerFactory = scorer; ScanViewModel.ScorerFactory = scorer; }); // When an ID file has been opened, turn on the unidentified scan filter this.WhenAnyValue(x => x.IdFileOpen) .Where(idFileOpen => idFileOpen) .Select(_ => ScanViewModel.Filters.FirstOrDefault(f => f.Name == "Hide Unidentified Scans")) .Where(f => f != null) .Subscribe(f => f.Selected = true); // Start MsPf Search Command StartMsPfSearchCommand = ReactiveCommand.Create(StartMsPfSearchImplementation); // Close command verifies that the user wants to close the dataset, then sets ReadyToClose to true if they are CloseCommand = ReactiveCommand.Create(() => { ReadyToClose = dialogService.ConfirmationBox( string.Format("Are you sure you would like to close {0}?", Title), string.Empty); }); }