예제 #1
0
        private TemporaryDirectory ShareSkydFile(ZipFileShare zip, TemporaryDirectory tempDir)
        {
            string pathCache = ChromatogramCache.FinalPathForName(DocumentPath, null);

            if (!File.Exists(pathCache))
            {
                return(tempDir);
            }
            if (ShareType.SkylineVersion != null && Document.Settings.HasResults)
            {
                var measuredResults = Document.Settings.MeasuredResults;
                if (measuredResults.CacheVersion.HasValue &&
                    !measuredResults.CacheVersion.Equals(ShareType.SkylineVersion.CacheFormatVersion))
                {
                    String cacheFileName = Path.GetFileName(pathCache);
                    if (cacheFileName != null)
                    {
                        if (tempDir == null)
                        {
                            tempDir = new TemporaryDirectory();
                        }
                        String newCachePath = Path.Combine(tempDir.DirPath, cacheFileName);
                        MinimizeToFile(newCachePath, CacheFormat.FromVersion(ShareType.SkylineVersion.CacheFormatVersion));
                        zip.AddFile(newCachePath);
                        return(tempDir);
                    }
                }
            }
            zip.AddFile(pathCache);
            return(tempDir);
        }
예제 #2
0
        private TemporaryDirectory ShareDataAndView(ZipFileShare zip, TemporaryDirectory tempDir)
        {
            tempDir = ShareSkydFile(zip, tempDir);
            string viewPath = SkylineWindow.GetViewFile(DocumentPath);

            if (File.Exists(viewPath))
            {
                zip.AddFile(viewPath);
            }
            return(tempDir);
        }
예제 #3
0
 private void IncludeRedundantBlib(LibrarySpec librarySpec, ZipFileShare zip, string blibPath)
 {
     if (librarySpec is BiblioSpecLiteSpec)
     {
         var redundantBlibPath = BiblioSpecLiteSpec.GetRedundantName(blibPath);
         if (File.Exists(redundantBlibPath))
         {
             zip.AddFile(redundantBlibPath);
         }
     }
 }
예제 #4
0
 private void SafeAuditLog(ZipFileShare zip, string docPath)
 {
     if (ShouldShareAuditLog(Document, ShareType))
     {
         var path = SrmDocument.GetAuditLogPath(docPath);
         if (File.Exists(path))
         {
             zip.AddFile(path);
         }
     }
 }
예제 #5
0
        private void ShareComplete(ZipFileShare zip)
        {
            TemporaryDirectory tempDir = null;

            try
            {
                // If complete sharing, just zip up existing files
                var pepSettings        = Document.Settings.PeptideSettings;
                var transitionSettings = Document.Settings.TransitionSettings;
                if (Document.Settings.HasBackgroundProteome)
                {
                    zip.AddFile(pepSettings.BackgroundProteome.BackgroundProteomeSpec.DatabasePath);
                }
                if (Document.Settings.HasRTCalcPersisted)
                {
                    zip.AddFile(pepSettings.Prediction.RetentionTime.Calculator.PersistencePath);
                }
                if (Document.Settings.HasOptimizationLibraryPersisted)
                {
                    zip.AddFile(transitionSettings.Prediction.OptimizedLibrary.PersistencePath);
                }
                if (Document.Settings.HasIonMobilityLibraryPersisted)
                {
                    zip.AddFile(pepSettings.Prediction.IonMobilityPredictor.IonMobilityLibrary.PersistencePath);
                }
                var libfiles = new HashSet <string>();
                foreach (var librarySpec in pepSettings.Libraries.LibrarySpecs)
                {
                    if (libfiles.Add(librarySpec.FilePath))
                    // Sometimes the same .blib file is referred to by different library specs
                    {
                        zip.AddFile(librarySpec.FilePath);

                        if (Document.Settings.TransitionSettings.FullScan.IsEnabledMs)
                        {
                            // If there is a .redundant.blib file that corresponds
                            // to a .blib file, add that as well
                            IncludeRedundantBlib(librarySpec, zip, librarySpec.FilePath);
                        }
                    }
                }

                // ReSharper disable ExpressionIsAlwaysNull
                tempDir = ShareDataAndView(zip, tempDir);
                // ReSharper restore ExpressionIsAlwaysNull
                if (null == ShareType.SkylineVersion)
                {
                    zip.AddFile(DocumentPath); // CONSIDER(bpratt) there's no check to see if this is a current representation of the document - a dirty check would be good
                }
                else
                {
                    tempDir = ShareDocument(zip, tempDir);
                }
                Save(zip);
            }
            finally
            {
                DeleteTempDir(tempDir);
            }
        }
예제 #6
0
        private TemporaryDirectory ShareDocument(ZipFileShare zip, TemporaryDirectory tempDir, out string tempDocPath)
        {
            if (tempDir == null)
            {
                tempDir = new TemporaryDirectory();
            }
            string fileName = Path.GetFileName(DocumentPath) ?? string.Empty;

            tempDocPath = Path.Combine(tempDir.DirPath, fileName);
            Document.SerializeToFile(tempDocPath, tempDocPath,
                                     ShareType.SkylineVersion ?? SkylineVersion.CURRENT, ProgressMonitor);
            zip.AddFile(tempDocPath);
            return(tempDir);
        }
예제 #7
0
        private void ShareMinimal(ZipFileShare zip)
        {
            TemporaryDirectory tempDir = null;

            try
            {
                var docOriginal = Document;
                if (Document.Settings.HasBackgroundProteome)
                {
                    // Remove any background proteome reference
                    Document = Document.ChangeSettings(Document.Settings.ChangePeptideSettings(
                                                           set => set.ChangeBackgroundProteome(BackgroundProteome.NONE)));
                }
                if (Document.Settings.HasRTCalcPersisted)
                {
                    // Minimize any persistable retention time calculator
                    tempDir = new TemporaryDirectory();
                    string tempDbPath = Document.Settings.PeptideSettings.Prediction.RetentionTime
                                        .Calculator.PersistMinimized(tempDir.DirPath, Document);
                    if (tempDbPath != null)
                    {
                        zip.AddFile(tempDbPath);
                    }
                }
                if (Document.Settings.HasOptimizationLibraryPersisted)
                {
                    if (tempDir == null)
                    {
                        tempDir = new TemporaryDirectory();
                    }
                    string tempDbPath = Document.Settings.TransitionSettings.Prediction.OptimizedLibrary.PersistMinimized(
                        tempDir.DirPath, Document);
                    if (tempDbPath != null)
                    {
                        zip.AddFile(tempDbPath);
                    }
                }
                if (Document.Settings.HasIonMobilityLibraryPersisted)
                {
                    // Minimize any persistable ion mobility predictor
                    if (tempDir == null)
                    {
                        tempDir = new TemporaryDirectory();
                    }
                    string tempDbPath = Document.Settings.TransitionSettings.IonMobilityFiltering.IonMobilityLibrary
                                        .PersistMinimized(tempDir.DirPath, Document, null, out _);
                    if (tempDbPath != null)
                    {
                        zip.AddFile(tempDbPath);
                    }
                }
                if (Document.Settings.HasLibraries)
                {
                    // Minimize all libraries in a temporary directory, and add them
                    if (tempDir == null)
                    {
                        tempDir = new TemporaryDirectory();
                    }
                    Document = BlibDb.MinimizeLibraries(Document, tempDir.DirPath,
                                                        Path.GetFileNameWithoutExtension(DocumentPath),
                                                        null,
                                                        ProgressMonitor);
                    if (ProgressMonitor != null && ProgressMonitor.IsCanceled)
                    {
                        return;
                    }

                    foreach (var librarySpec in Document.Settings.PeptideSettings.Libraries.LibrarySpecs)
                    {
                        var tempLibPath = Path.Combine(tempDir.DirPath, Path.GetFileName(librarySpec.FilePath) ?? string.Empty);
                        zip.AddFile(tempLibPath);

                        // If there is a .redundant.blib file that corresponds to a .blib file
                        // in the temp temporary directory, add that as well
                        IncludeRedundantBlib(librarySpec, zip, tempLibPath);
                    }
                }

                var auditLogDocPath = DocumentPath;
                tempDir = ShareDataAndView(zip, tempDir);
                if (ReferenceEquals(docOriginal, Document) && null == ShareType.SkylineVersion)
                {
                    zip.AddFile(DocumentPath);
                }
                else
                {
                    tempDir = ShareDocument(zip, tempDir, out auditLogDocPath);
                }

                SafeAuditLog(zip, auditLogDocPath);

                Save(zip);
            }
            finally
            {
                DeleteTempDir(tempDir);
            }
        }