public DbOptimization GetOptimization(OptimizationType type, string seq, int charge, string fragment, int productCharge) { RequireUsable(); var key = new OptimizationKey(type, seq, charge, fragment, productCharge); double value; return((_database.DictLibrary.TryGetValue(new OptimizationKey(type, seq, charge, fragment, productCharge), out value)) ? new DbOptimization(key, value) : null); }
/// <summary> /// Saves the database to a new directory with only the optimizations used /// in a given document. /// </summary> /// <param name="pathDestDir">The directory to save to</param> /// <param name="document">The document for which peptides are to be kept</param> /// <returns>The full path to the file saved</returns> public string PersistMinimized(string pathDestDir, SrmDocument document) { RequireUsable(); string persistPath = Path.Combine(pathDestDir, Path.GetFileName(PersistencePath) ?? string.Empty); // ReSharper using (var fs = new FileSaver(persistPath)) { var optDbMinimal = OptimizationDb.CreateOptimizationDb(fs.SafeName); // Calculate the minimal set of optimizations needed for this document var persistOptimizations = new List <DbOptimization>(); var dictOptimizations = new OptimizationDictionary(_database.GetOptimizations()); var persistedKeys = new HashSet <OptimizationKey>(); foreach (PeptideGroupDocNode seq in document.MoleculeGroups) { // Skip peptide groups with no transitions if (seq.TransitionCount == 0) { continue; } foreach (PeptideDocNode peptide in seq.Children) { foreach (TransitionGroupDocNode group in peptide.Children) { var modSeq = document.Settings.GetSourceTarget(peptide); var charge = group.PrecursorAdduct; foreach (TransitionDocNode transition in group.Children) { foreach (var optType in Enum.GetValues(typeof(OptimizationType)).Cast <OptimizationType>()) { var optimizationKey = new OptimizationKey(optType, modSeq, charge, transition.FragmentIonName, transition.Transition.Adduct); foreach (var dbOptimization in dictOptimizations.EntriesMatching(optimizationKey)) { if (persistedKeys.Add(dbOptimization.Key)) { persistOptimizations.Add(dbOptimization); } break; } } } } } } optDbMinimal.UpdateOptimizations(persistOptimizations, new DbOptimization[0]); fs.Commit(); } return(persistPath); }
/// <summary> /// Saves the database to a new directory with only the optimizations used /// in a given document. /// </summary> /// <param name="pathDestDir">The directory to save to</param> /// <param name="document">The document for which peptides are to be kept</param> /// <returns>The full path to the file saved</returns> public string PersistMinimized(string pathDestDir, SrmDocument document) { RequireUsable(); string persistPath = Path.Combine(pathDestDir, Path.GetFileName(PersistencePath) ?? string.Empty); // ReSharper using (var fs = new FileSaver(persistPath)) { var optDbMinimal = OptimizationDb.CreateOptimizationDb(fs.SafeName); // Calculate the minimal set of optimizations needed for this document var persistOptimizations = new List <DbOptimization>(); var dictOptimizations = _database.GetOptimizations().ToDictionary(opt => opt.Key); foreach (PeptideGroupDocNode seq in document.MoleculeGroups) { // Skip peptide groups with no transitions if (seq.TransitionCount == 0) { continue; } foreach (PeptideDocNode peptide in seq.Children) { foreach (TransitionGroupDocNode group in peptide.Children) { string modSeq = document.Settings.GetSourceTextId(peptide); int charge = group.PrecursorCharge; foreach (TransitionDocNode transition in group.Children) { foreach (var optType in Enum.GetValues(typeof(OptimizationType)).Cast <OptimizationType>()) { var optimizationKey = new OptimizationKey(optType, modSeq, charge, transition.FragmentIonName, transition.Transition.Charge); DbOptimization dbOptimization; if (dictOptimizations.TryGetValue(optimizationKey, out dbOptimization)) { persistOptimizations.Add(new DbOptimization(dbOptimization.Key, dbOptimization.Value)); // Only add once dictOptimizations.Remove(optimizationKey); } } } } } } optDbMinimal.UpdateOptimizations(persistOptimizations, new DbOptimization[0]); fs.Commit(); } return(persistPath); }
/// <summary> /// Saves the database to a new directory with only the optimizations used /// in a given document. /// </summary> /// <param name="pathDestDir">The directory to save to</param> /// <param name="document">The document for which peptides are to be kept</param> /// <returns>The full path to the file saved</returns> public string PersistMinimized(string pathDestDir, SrmDocument document) { RequireUsable(); string persistPath = Path.Combine(pathDestDir, Path.GetFileName(PersistencePath) ?? string.Empty); // ReSharper using (var fs = new FileSaver(persistPath)) { var optDbMinimal = OptimizationDb.CreateOptimizationDb(fs.SafeName); // Calculate the minimal set of optimizations needed for this document var persistOptimizations = new List<DbOptimization>(); var dictOptimizations = _database.GetOptimizations().ToDictionary(opt => opt.Key); foreach (PeptideGroupDocNode seq in document.MoleculeGroups) { // Skip peptide groups with no transitions if (seq.TransitionCount == 0) continue; foreach (PeptideDocNode peptide in seq.Children) { foreach (TransitionGroupDocNode group in peptide.Children) { string modSeq = document.Settings.GetSourceTextId(peptide); int charge = group.PrecursorCharge; foreach (TransitionDocNode transition in group.Children) { foreach (var optType in Enum.GetValues(typeof(OptimizationType)).Cast<OptimizationType>()) { var optimizationKey = new OptimizationKey(optType, modSeq, charge, transition.FragmentIonName, transition.Transition.Charge); DbOptimization dbOptimization; if (dictOptimizations.TryGetValue(optimizationKey, out dbOptimization)) { persistOptimizations.Add(new DbOptimization(dbOptimization.Key, dbOptimization.Value)); // Only add once dictOptimizations.Remove(optimizationKey); } } } } } } optDbMinimal.UpdateOptimizations(persistOptimizations, new DbOptimization[0]); fs.Commit(); } return persistPath; }
public DbOptimization GetOptimization(OptimizationType type, string seq, int charge, string fragment, int productCharge) { RequireUsable(); var key = new OptimizationKey(type, seq, charge, fragment, productCharge); double value; return (_database.DictLibrary.TryGetValue(new OptimizationKey(type, seq, charge, fragment, productCharge), out value)) ? new DbOptimization(key, value) : null; }
public OptimizationKey(OptimizationKey other) : this(other.OptType, other.PeptideModSeq, other.PrecursorAdduct, other.FragmentIon, other.ProductAdduct) { }
public DbOptimization(OptimizationType type, Target seq, Adduct charge, string fragmentIon, Adduct productCharge, double value) { Key = new OptimizationKey(type, seq, charge, fragmentIon, productCharge); Value = value; }
public DbOptimization(OptimizationKey key, double value) : this(key.OptType, key.PeptideModSeq, key.PrecursorAdduct, key.FragmentIon, key.ProductAdduct, value) { }
protected DbOptimization() { Key = new OptimizationKey(); }
public OptimizationKey(OptimizationKey other) : this(other.OptType, other.PeptideModSeq, other.Charge, other.FragmentIon, other.ProductCharge) { }
public DbOptimization(OptimizationKey key, double value) : this(key.OptType, key.PeptideModSeq, key.Charge, key.FragmentIon, key.ProductCharge, value) { }
protected DbOptimization() { Key = new OptimizationKey(); }
public DbOptimization(OptimizationType type, string seq, int charge, string fragmentIon, int productCharge, double value) { Key = new OptimizationKey(type, seq, charge, fragmentIon, productCharge); Value = value; }
public DbOptimization(OptimizationKey key, double value) : this(key.OptType, key.PeptideModSeq, key.Charge, key.FragmentIon, key.ProductCharge, value) { }
public OptimizationKey(OptimizationKey other) : this(other.OptType, other.PeptideModSeq, other.Charge, other.FragmentIon, other.ProductCharge) { }