public PrecursorIonMobilities(PrecursorIonMobilities other) : this(other.Precursor, other.IonMobilities) { }
/// <summary> /// Saves the database to a new directory with only the ions used /// in a given document. /// </summary> /// <param name="pathDestDir">The directory to save to</param> /// <param name="document">The document for which ions are to be kept</param> /// <param name="smallMoleculeConversionMap">Used for changing charge,modifedSeq to adduct,molecule in small molecule conversion</param> /// <param name="loadedDatabase">Returns in-memory representation of the revised ion mobility table</param> /// <returns>The full path to the file saved</returns> public string PersistMinimized(string pathDestDir, SrmDocument document, IDictionary <LibKey, LibKey> smallMoleculeConversionMap, out IonMobilityDb loadedDatabase) { RequireUsable(); var fname = Path.GetFileName(FilePath); if (smallMoleculeConversionMap != null && fname != null && !fname.Contains(BiblioSpecLiteSpec.DotConvertedToSmallMolecules)) { fname = fname.Replace(IonMobilityDb.EXT, BiblioSpecLiteSpec.DotConvertedToSmallMolecules + IonMobilityDb.EXT); } fname = fname ?? string.Empty; // Keeps ReSharper from complaining about possible null string persistPath = Path.Combine(pathDestDir, fname); using (var fs = new FileSaver(persistPath)) { var libraryName = fname.Replace(IonMobilityDb.EXT, String.Empty); var ionMobilityDbMinimal = IonMobilityDb.CreateIonMobilityDb(fs.SafeName, libraryName, true); // Calculate the minimal set of peptides needed for this document var dbPrecursors = _database.DictLibrary.LibKeys; var persistIonMobilities = new List <PrecursorIonMobilities>(); var dictPrecursors = dbPrecursors.ToDictionary(p => p.LibraryKey); foreach (var pair in document.MoleculePrecursorPairs) { var test = new PrecursorIonMobilities(pair.NodePep.ModifiedTarget, pair.NodeGroup.PrecursorAdduct, 0, 0, 0, eIonMobilityUnits.none); var key = test.Precursor; if (dictPrecursors.TryGetValue(key, out var dbPrecursor)) { if (smallMoleculeConversionMap != null) { // We are in the midst of converting a document to small molecules for test purposes LibKey smallMolInfo; if (smallMoleculeConversionMap.TryGetValue(new LibKey(pair.NodePep.ModifiedSequence, pair.NodeGroup.PrecursorCharge), out smallMolInfo)) { var precursorAdduct = smallMolInfo.Adduct; var smallMoleculeAttributes = smallMolInfo.SmallMoleculeLibraryAttributes; dbPrecursor = new LibKey(smallMoleculeAttributes, precursorAdduct); } else { // Not being converted Assume.IsTrue(pair.NodeGroup.Peptide.IsDecoy); continue; } } persistIonMobilities.Add(new PrecursorIonMobilities(dbPrecursor, test.IonMobilities)); // Only add once dictPrecursors.Remove(key); } } loadedDatabase = ionMobilityDbMinimal.UpdateIonMobilities(persistIonMobilities); fs.Commit(); } return(persistPath); }