/// <summary> /// Saves the database to a new directory with only the standards and peptides 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 override 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 irtDbMinimal = IrtDb.CreateIrtDb(fs.SafeName); // Calculate the minimal set of peptides needed for this document var dbPeptides = _database.GetPeptides().ToList(); var persistPeptides = dbPeptides.Where(pep => pep.Standard).Select(NewPeptide).ToList(); var dictPeptides = dbPeptides.Where(pep => !pep.Standard).ToDictionary(pep => pep.ModifiedTarget); foreach (var nodePep in document.Molecules) { var modifiedSeq = document.Settings.GetSourceTarget(nodePep); DbIrtPeptide dbPeptide; if (dictPeptides.TryGetValue(modifiedSeq, out dbPeptide)) { persistPeptides.Add(NewPeptide(dbPeptide)); // Only add once dictPeptides.Remove(modifiedSeq); } } irtDbMinimal.AddPeptides(null, persistPeptides); fs.Commit(); } return(persistPath); }
public bool Equals(IrtDb other) { if (ReferenceEquals(null, other)) { return(false); } if (ReferenceEquals(this, other)) { return(true); } return(Equals(other._path, _path) && other._modifiedTime.Equals(_modifiedTime)); }
public override RetentionScoreCalculatorSpec Initialize(IProgressMonitor loadMonitor) { if (_database != null) { return(this); } var database = IrtDb.GetIrtDb(DatabasePath, loadMonitor); // Check for the case where an exception was handled by the progress monitor if (database == null) { return(null); } return(ChangeDatabase(database)); }
public RCalcIrt ChangeDatabase(IrtDb database) { return(ChangeProp(ImClone(this), im => im._database = database)); }
public bool Equals(IrtDb other) { if (ReferenceEquals(null, other)) return false; if (ReferenceEquals(this, other)) return true; return Equals(other._path, _path) && other._modifiedTime.Equals(_modifiedTime); }
public RCalcIrt ChangeDatabase(IrtDb database) { return ChangeProp(ImClone(this), im => im._database = database); }