private void LoadPsms(out List <string> errors, bool haveLoadedSpectra) { errors = new List <string>(); HashSet <string> fileNamesWithoutExtension = new HashSet <string>( SpectraFilePaths.Select(p => System.IO.Path.GetFileName(p.Replace(GlobalVariables.GetFileExtension(p), string.Empty)))); List <PsmFromTsv> psmsThatDontHaveMatchingSpectraFile = new List <PsmFromTsv>(); try { foreach (var resultsFile in PsmResultFilePaths) { lock (ThreadLocker) { foreach (PsmFromTsv psm in PsmTsvReader.ReadTsv(resultsFile, out List <string> warnings)) { if (fileNamesWithoutExtension.Contains(psm.FileNameWithoutExtension) || !haveLoadedSpectra) { AllPsms.Add(psm); } else { psmsThatDontHaveMatchingSpectraFile.Add(psm); } if (PsmsGroupedByFile.TryGetValue(psm.FileNameWithoutExtension, out var psmsForThisFile)) { psmsForThisFile.Add(psm); } else { PsmsGroupedByFile.Add(psm.FileNameWithoutExtension, new ObservableCollection <PsmFromTsv> { psm }); } } } } } catch (Exception e) { errors.Add("Error reading PSM file:\n" + e.Message); } if (psmsThatDontHaveMatchingSpectraFile.Any()) { foreach (var file in psmsThatDontHaveMatchingSpectraFile.GroupBy(p => p.FileNameWithoutExtension)) { errors.Add(file.Count() + " PSMs from " + file.Key + " were not loaded because this spectra file was not found"); } } FilterPsms(); }
public void CleanUpResources() { lock (ThreadLocker) { AllPsms.Clear(); FilteredListOfPsms.Clear(); PsmResultFilePaths.Clear(); SpectraFilePaths.Clear(); SpectralLibraryPaths.Clear(); foreach (var connection in MsDataFiles) { connection.Value.CloseDynamicConnection(); } MsDataFiles.Clear(); if (SpectralLibrary != null) { SpectralLibrary.CloseConnections(); } } }