示例#1
0
文件: RCalcIrt.cs 项目: rfellers/pwiz
        /// <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);
        }
示例#2
0
 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));
 }
示例#3
0
        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));
        }
示例#4
0
 public RCalcIrt ChangeDatabase(IrtDb database)
 {
     return(ChangeProp(ImClone(this), im => im._database = database));
 }
示例#5
0
 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);
 }
示例#6
0
 public RCalcIrt ChangeDatabase(IrtDb database)
 {
     return ChangeProp(ImClone(this), im => im._database = database);
 }