protected int CompareTo(MsDataFilePath other)
        {
            // Culture specific sorting desirable in file paths
// ReSharper disable StringCompareToIsCultureSpecific
            int result = FilePath.CompareTo(other.FilePath);

            if (result != 0)
            {
                return(result);
            }
            result = SampleName.CompareTo(other.SampleName);
            if (result != 0)
            {
                return(result);
            }
            result = SampleIndex.CompareTo(other.SampleIndex);
            if (result != 0)
            {
                return(result);
            }
            result = CentroidMs1.CompareTo(other.CentroidMs1);
            if (result != 0)
            {
                return(result);
            }
            result = CentroidMs2.CompareTo(other.CentroidMs2);
            if (result != 0)
            {
                return(result);
            }
            return(LockMassParameters.CompareTo(other.LockMassParameters));
// ReSharper restore StringCompareToIsCultureSpecific
        }
Exemple #2
0
        public static MsDataFileUri Parse(string url)
        {
            if (url.StartsWith(UnifiUrl.UrlPrefix))
            {
                return(new UnifiUrl(url));
            }

            return(MsDataFilePath.ParseUri(url));
        }
 protected MsDataFilePath(MsDataFilePath msDataFilePath)
 {
     FilePath           = msDataFilePath.FilePath;
     SampleName         = msDataFilePath.SampleName;
     SampleIndex        = msDataFilePath.SampleIndex;
     LockMassParameters = msDataFilePath.LockMassParameters;
     CentroidMs1        = msDataFilePath.CentroidMs1;
     CentroidMs2        = msDataFilePath.CentroidMs2;
 }
 protected bool Equals(MsDataFilePath other)
 {
     return(string.Equals(FilePath, other.FilePath) &&
            string.Equals(SampleName, other.SampleName) &&
            SampleIndex == other.SampleIndex &&
            CentroidMs1 == other.CentroidMs1 &&
            CentroidMs2 == other.CentroidMs2 &&
            LockMassParameters.Equals(other.LockMassParameters));
 }
Exemple #5
0
 protected MsDataFilePath(MsDataFilePath msDataFilePath)
 {
     FilePath           = msDataFilePath.FilePath;
     SampleName         = msDataFilePath.SampleName;
     SampleIndex        = msDataFilePath.SampleIndex;
     LockMassParameters = msDataFilePath.LockMassParameters;
     LegacyCentroidMs1  = msDataFilePath.LegacyCentroidMs1;
     LegacyCentroidMs2  = msDataFilePath.LegacyCentroidMs2;
     LegacyCombineIonMobilitySpectra = msDataFilePath.LegacyCombineIonMobilitySpectra;
 }
Exemple #6
0
 protected bool Equals(MsDataFilePath other)
 {
     return(string.Equals(FilePath, other.FilePath) &&
            string.Equals(SampleName, other.SampleName) &&
            SampleIndex == other.SampleIndex &&
            LegacyCentroidMs1 == other.LegacyCentroidMs1 &&
            LegacyCentroidMs2 == other.LegacyCentroidMs2 &&
            LegacyCombineIonMobilitySpectra == other.LegacyCombineIonMobilitySpectra &&
            LockMassParameters.Equals(other.LockMassParameters));
 }
Exemple #7
0
        public static MsDataFileUri GetExistingDataFilePath(string cachePath, MsDataFileUri msDataFileUri)
        {
            MsDataFilePath msDataFilePath = msDataFileUri as MsDataFilePath;

            if (null == msDataFilePath)
            {
                return(msDataFileUri);
            }
            string dataFilePathPartIgnore;

            return(GetExistingDataFilePath(cachePath, msDataFilePath, out dataFilePathPartIgnore));
        }
Exemple #8
0
        public ChorusResponseChromDataProvider(SrmDocument document, ChromFileInfo chromFileInfo, IProgressStatus progressStatus, int startPercent,
                                               int endPercent, ILoadMonitor loader) : base(chromFileInfo, progressStatus, startPercent, endPercent, loader)
        {
            ChromatogramCache.RawData rawData;
            MsDataFilePath            msDataFilePath = (MsDataFilePath)chromFileInfo.FilePath;
            IPooledStream             stream         = loader.StreamManager.CreatePooledStream(msDataFilePath.FilePath, false);

            ChromatogramCache.LoadStructs(stream.Stream, out rawData);
            var chromCacheFile = rawData.ChromCacheFiles[0];

            rawData.ChromCacheFiles = new[]
            {
                new ChromCachedFile(chromFileInfo.FilePath, chromCacheFile.Flags, chromCacheFile.FileWriteTime,
                                    chromCacheFile.RunStartTime, chromCacheFile.MaxRetentionTime, chromCacheFile.MaxIntensity,
                                    chromCacheFile.InstrumentInfoList),
            };
            var cache = new ChromatogramCache("cachePath", rawData, stream); // Not L10N

            _cachedChromatogramDataProvider = new CachedChromatogramDataProvider(cache, document,
                                                                                 chromFileInfo.FilePath, chromFileInfo, null, progressStatus, startPercent, endPercent, loader);
        }
Exemple #9
0
        /// <summary>
        /// Gets a full MSDataFile path to an existing file.  If the original path is not found to
        /// exist, the folder containing the chromatogram cache is tried with the filename part.
        /// </summary>
        /// <param name="cachePath">The path to the cache file</param>
        /// <param name="dataFilePath">A full MSDataFile path, potentially including a sample part</param>
        /// <param name="dataFilePathPart">A file path only to an existing file</param>
        /// <returns>A full MSDataFile path, potentially including a sample part, to an existing file, or null if no file is found</returns>
        public static MsDataFilePath GetExistingDataFilePath(string cachePath, MsDataFilePath dataFilePath, out string dataFilePathPart)
        {
            // Check file (directory for Waters) existence, because ProteoWizard can hang on this
            if (File.Exists(dataFilePath.FilePath) || Directory.Exists(dataFilePath.FilePath))
            {
                dataFilePathPart = dataFilePath.FilePath;
                return(dataFilePath);
            }

            string dataFileName = Path.GetFileName(dataFilePath.FilePath);

            // ReSharper disable once ConditionIsAlwaysTrueOrFalse
            if (null != dataFileName)
            {
                // Check the most common case where the file is in the same directory
                // where the cache is being written.
                // Also, for tests, check Program.ExtraRawFileSearchFolder
                foreach (string folder in new[] {
                    Path.GetDirectoryName(cachePath),
                    Program.ExtraRawFileSearchFolder
                })
                {
                    if (null == folder)
                    {
                        continue;
                    }
                    var pathToCheck = Path.Combine(folder, dataFileName);
                    if (File.Exists(pathToCheck) || Directory.Exists(pathToCheck))
                    {
                        dataFilePathPart = pathToCheck;
                        return(dataFilePath.SetFilePath(pathToCheck));
                    }
                }
            }
            dataFilePathPart = dataFilePath.FilePath;
            return(null);
        }
Exemple #10
0
 protected bool Equals(MsDataFilePath other)
 {
     return string.Equals(FilePath, other.FilePath) &&
         string.Equals(SampleName, other.SampleName) &&
         SampleIndex == other.SampleIndex &&
         CentroidMs1 == other.CentroidMs1 &&
         CentroidMs2 == other.CentroidMs2 &&
         LockMassParameters.Equals(other.LockMassParameters);
 }
Exemple #11
0
        /// <summary>
        /// Gets a full MSDataFile path to an existing file.  If the original path is not found to
        /// exist, the folder containing the chromatogram cache is tried with the filename part.
        /// </summary>
        /// <param name="cachePath">The path to the cache file</param>
        /// <param name="dataFilePath">A full MSDataFile path, potentially including a sample part</param>
        /// <param name="dataFilePathPart">A file path only to an existing file</param>
        /// <returns>A full MSDataFile path, potentially including a sample part, to an existing file, or null if no file is found</returns>
        public static MsDataFilePath GetExistingDataFilePath(string cachePath, MsDataFilePath dataFilePath, out string dataFilePathPart)
        {
            // Check file (directory for Waters) existence, because ProteoWizard can hang on this
            if (File.Exists(dataFilePath.FilePath) || Directory.Exists(dataFilePath.FilePath))
            {
                dataFilePathPart = dataFilePath.FilePath;
                return dataFilePath;
            }

            string dataFileName = Path.GetFileName(dataFilePath.FilePath);
            if (null != dataFileName)
            {
                // Check the most common case where the file is in the same directory
                // where the cache is being written.
                // Also, for tests, check Program.ExtraRawFileSearchFolder
                foreach (string folder in new[] {
                    Path.GetDirectoryName(cachePath),
                    Program.ExtraRawFileSearchFolder })
                {
                    if (null == folder)
                    {
                        continue;
                    }
                    var pathToCheck = Path.Combine(folder, dataFileName);
                    if (File.Exists(pathToCheck) || Directory.Exists(pathToCheck))
                    {
                        dataFilePathPart = pathToCheck;
                        return dataFilePath.SetFilePath(pathToCheck);
                    }
                }
            }
            dataFilePathPart = dataFilePath.FilePath;
            return null;
        }
        public void ConsoleMultiReplicateImportTest()
        {
            bool useRaw = ExtensionTestContext.CanImportThermoRaw && ExtensionTestContext.CanImportWatersRaw;
            string testZipPath = useRaw
                                     ? @"TestA\ImportAllCmdLineTest.zip"
                                     : @"TestA\ImportAllCmdLineTestMzml.zip";
            string extRaw = useRaw
                                ? ".raw"
                                : ".mzML";

            var testFilesDir = new TestFilesDir(TestContext, testZipPath);

            // Contents:
            // ImportAllCmdLineTest
            //   -- REP01
            //       -- CE_Vantage_15mTorr_0001_REP1_01.raw|mzML
            //       -- CE_Vantage_15mTorr_0001_REP1_02.raw|mzML
            //   -- REP02
            //       -- CE_Vantage_15mTorr_0001_REP2_01.raw|mzML
            //       -- CE_Vantage_15mTorr_0001_REP2_02.raw|mzML
            //   -- 160109_Mix1_calcurve_070.mzML
            //   -- 160109_Mix1_calcurve_073.mzML
            //   -- 160109_Mix1_calcurve_071.raw (Waters .raw directory)
            //   -- 160109_Mix1_calcurve_074.raw (Waters .raw directory)
            //   -- bad_file.raw (Should not be imported. Only in ImportAllCmdLineTest.zip)
            //   -- bad_file_folder
            //       -- bad_file.raw (Should not be imported. Only in ImportAllCmdLineTest.zip)
            //   -- FullScan.RAW|mzML (should not be imported)
            //   -- FullScan_folder
            //       -- FullScan.RAW|mzML (should not be imported)

            var docPath = testFilesDir.GetTestPath("test.sky");
            var outPath1 = testFilesDir.GetTestPath("Imported_multiple1.sky");
            FileEx.SafeDelete(outPath1);
            var outPath2 = testFilesDir.GetTestPath("Imported_multiple2.sky");
            FileEx.SafeDelete(outPath2);
            var outPath3 = testFilesDir.GetTestPath("Imported_multiple3.sky");
            FileEx.SafeDelete(outPath3);

            var rawPath = new MsDataFilePath(testFilesDir.GetTestPath(@"REP01\CE_Vantage_15mTorr_0001_REP1_01" + extRaw));

            // Test: Cannot use --import-file and --import-all options simultaneously
            var msg = RunCommand("--in=" + docPath,
                                 "--import-file=" + rawPath.FilePath,
                                 "--import-replicate-name=Unscheduled01",
                                 "--import-all=" + testFilesDir.FullPath,
                                 "--out=" + outPath1);
            Assert.IsTrue(msg.Contains(Resources.CommandArgs_ParseArgsInternal_Error____import_file_and___import_all_options_cannot_be_used_simultaneously_), msg);
            // output file should not exist
            Assert.IsFalse(File.Exists(outPath1));

            // Test: Cannot use --import-replicate-name with --import-all
            msg = RunCommand("--in=" + docPath,
                             "--import-replicate-name=Unscheduled01",
                             "--import-all=" + testFilesDir.FullPath,
                             "--out=" + outPath1);
            Assert.IsTrue(msg.Contains(Resources.CommandArgs_ParseArgsInternal_Error____import_replicate_name_cannot_be_used_with_the___import_all_option_), msg);
            // output file should not exist
            Assert.IsFalse(File.Exists(outPath1));

            // Test: Cannot use --import-naming-pattern with --import-file
            msg = RunCommand("--in=" + docPath,
                                 "--import-file=" + rawPath.FilePath,
                                 "--import-naming-pattern=prefix_(.*)",
                                 "--out=" + outPath1);
            Assert.IsTrue(msg.Contains(Resources.CommandArgs_ParseArgsInternal_Error____import_naming_pattern_cannot_be_used_with_the___import_file_option_), msg);
            // output file should not exist
            Assert.IsFalse(File.Exists(outPath1));

            // Test: invalid regular expression (1)
            msg = RunCommand("--in=" + docPath,
                                 "--import-all=" + testFilesDir.FullPath,
                                 "--import-naming-pattern=A",
                                 "--out=" + outPath1);
            // output file should not exist
            Assert.IsFalse(File.Exists(outPath1));
            Assert.IsTrue(msg.Contains(string.Format(Resources.CommandArgs_ParseArgsInternal_Error__Regular_expression___0___does_not_have_any_groups___String, "A")), msg);

            // Test: invalid regular expression (2)
            msg = RunCommand("--in=" + docPath,
                      "--import-all=" + testFilesDir.FullPath,
                      "--import-naming-pattern=invalid",
                      "--out=" + outPath1);
            // output file should not exist
            Assert.IsTrue(!File.Exists(outPath1));
            Assert.IsTrue(msg.Contains(string.Format(Resources.CommandArgs_ParseArgsInternal_Error__Regular_expression___0___does_not_have_any_groups___String, "invalid")), msg);

            // Test: Import files in the "REP01" directory;
            // Use a naming pattern that will cause the replicate names of the two files to be the same
            msg = RunCommand("--in=" + docPath,
                             "--import-all=" + testFilesDir.GetTestPath("REP01"),
                             "--import-naming-pattern=.*_(REP[0-9]+)_(.+)",
                             "--out=" + outPath1);
            Assert.IsFalse(File.Exists(outPath1));
            Assert.IsTrue(msg.Contains(string.Format(Resources.CommandLine_ApplyNamingPattern_Error__Duplicate_replicate_name___0___after_applying_regular_expression_,"REP1")), msg);

            // Test: Import files in the "REP01" directory; Use a naming pattern
            msg = RunCommand("--in=" + docPath,
                             "--import-all=" + testFilesDir.GetTestPath("REP01"),
                             "--import-naming-pattern=.*_([0-9]+)",
                             "--out=" + outPath1);
            Assert.IsTrue(File.Exists(outPath1), msg);
            SrmDocument doc = ResultsUtil.DeserializeDocument(outPath1);
            Assert.AreEqual(2, doc.Settings.MeasuredResults.Chromatograms.Count);
            Assert.IsTrue(doc.Settings.MeasuredResults.ContainsChromatogram("01"));
            Assert.IsTrue(doc.Settings.MeasuredResults.ContainsChromatogram("02"));

            Assert.IsFalse(File.Exists(outPath2));

            // Test: Import a single file
            // Import REP01\CE_Vantage_15mTorr_0001_REP1_01.raw;
            // Use replicate name "REP01"
            msg = RunCommand("--in=" + docPath,
                       "--import-file=" + rawPath.FilePath,
                       "--import-replicate-name=REP01",
                       "--out=" + outPath2);
            Assert.IsTrue(File.Exists(outPath2), msg);
            doc = ResultsUtil.DeserializeDocument(outPath2);
            Assert.AreEqual(1, doc.Settings.MeasuredResults.Chromatograms.Count);
            int initialFileCount = 0;
            foreach (var chromatogram in doc.Settings.MeasuredResults.Chromatograms)
            {
                initialFileCount += chromatogram.MSDataFilePaths.Count();
            }

            // Import another single file.
            var rawPath2 = MsDataFileUri.Parse(testFilesDir.GetTestPath("160109_Mix1_calcurve_070.mzML"));
            msg = RunCommand("--in=" + outPath2,
                       "--import-file=" + rawPath2.GetFilePath(),
                       "--import-replicate-name=160109_Mix1_calcurve_070",
                       "--save");
            doc = ResultsUtil.DeserializeDocument(outPath2);
            Assert.AreEqual(2, doc.Settings.MeasuredResults.Chromatograms.Count, msg);
            ChromatogramSet chromatSet;
            int idx;
            doc.Settings.MeasuredResults.TryGetChromatogramSet("160109_Mix1_calcurve_070", out chromatSet, out idx);
            Assert.IsNotNull(chromatSet, msg);
            Assert.IsTrue(chromatSet.MSDataFilePaths.Contains(rawPath2));

            // Test: Import all files and sub-folders in test directory
            // The document should already contain a replicate named "REP01".
            // Only one more file should be added to the "REP01" replicate.
            // The document should also already contain replicate "160109_Mix1_calcurve_070".
            // There should be notes about ignoring the two files that are already in the document.
            msg = RunCommand("--in=" + outPath2,
                             "--import-all=" + testFilesDir.FullPath,
                             "--save");
            // ExtensionTestContext.ExtThermo raw uses different case from file on disk
            // which happens to make a good test case.
            MsDataFilePath rawPathDisk = GetThermoDiskPath(rawPath);

            // These messages are due to files that were already in the document.
            Assert.IsTrue(msg.Contains(string.Format(Resources.CommandLine_RemoveImportedFiles__0______1___Note__The_file_has_already_been_imported__Ignoring___, "REP01", rawPathDisk)), msg);
            Assert.IsTrue(msg.Contains(string.Format(Resources.CommandLine_RemoveImportedFiles__0______1___Note__The_file_has_already_been_imported__Ignoring___, "160109_Mix1_calcurve_070", rawPath2)), msg);
            //            Assert.IsTrue(msg.Contains(string.Format("160109_Mix1_calcurve_070 -> {0}",rawPath2)), msg);

            doc = ResultsUtil.DeserializeDocument(outPath2);
            Assert.IsTrue(doc.Settings.HasResults);
            Assert.AreEqual(6, doc.Settings.MeasuredResults.Chromatograms.Count,
                string.Format("Expected 6 replicates, found: {0}",
                              string.Join(", ", doc.Settings.MeasuredResults.Chromatograms.Select(chromSet => chromSet.Name).ToArray())));
            // count the number of files imported into the document
            int totalImportedFiles = 0;
            foreach (var chromatogram in doc.Settings.MeasuredResults.Chromatograms)
            {
                totalImportedFiles += chromatogram.MSDataFilePaths.Count();
            }
            // We should have imported 7 more file
            Assert.AreEqual(initialFileCount + 7, totalImportedFiles);
            // In the "REP01" replicate we should have 2 files
            ChromatogramSet chromatogramSet;
            int index;
            doc.Settings.MeasuredResults.TryGetChromatogramSet("REP01", out chromatogramSet, out index);
            Assert.IsNotNull(chromatogramSet);
            Assert.IsTrue(chromatogramSet.MSDataFilePaths.Count() == 2);
            Assert.IsTrue(chromatogramSet.MSDataFilePaths.Contains(rawPath));
            Assert.IsTrue(chromatogramSet.MSDataFilePaths.Contains(
                new MsDataFilePath(testFilesDir.GetTestPath(@"REP01\CE_Vantage_15mTorr_0001_REP1_01" +
                extRaw))));
            Assert.IsTrue(!useRaw || chromatogramSet.MSDataFilePaths.Contains(
                GetThermoDiskPath(new MsDataFilePath(testFilesDir.GetTestPath(@"REP01\CE_Vantage_15mTorr_0001_REP1_02" + extRaw)))));

            Assert.IsFalse(File.Exists(outPath3));
            // Test: Import a single file
            // Import 160109_Mix1_calcurve_074.raw;
            // Use replicate name "REP01"
            var rawPath3 = testFilesDir.GetTestPath("160109_Mix1_calcurve_074" + extRaw);
            msg = RunCommand("--in=" + docPath,
                       "--import-file=" + rawPath3,
                       "--import-replicate-name=REP01",
                       "--out=" + outPath3);
            Assert.IsTrue(File.Exists(outPath3), msg);
            doc = ResultsUtil.DeserializeDocument(outPath3);
            Assert.AreEqual(1, doc.Settings.MeasuredResults.Chromatograms.Count);
            // Now import all files and sub-folders in test directory.
            // This should return an error since the replicate "REP01" that already
            // exists in the document has an unexpected file: '160109_Mix1_calcurve_074.raw'.
            msg = RunCommand("--in=" + outPath3,
                             "--import-all=" + testFilesDir.FullPath,
                             "--save");
            Assert.IsTrue(
                msg.Contains(
                    string.Format(
                        Resources.CommandLine_CheckReplicateFiles_Error__Replicate__0__in_the_document_has_an_unexpected_file__1__,"REP01",
                        rawPath3)), msg);
        }
 private static MsDataFilePath GetThermoDiskPath(MsDataFilePath pathToRaw)
 {
     return ExtensionTestContext.CanImportThermoRaw && ExtensionTestContext.CanImportWatersRaw
         ? pathToRaw.SetFilePath(Path.ChangeExtension(pathToRaw.FilePath, "raw"))
         : pathToRaw;
 }
        private void sourcePathTextBox_KeyUp( object sender, KeyEventArgs e )
        {
            switch( e.KeyCode )
            {
                case Keys.Enter:
                    if( Directory.Exists( sourcePathTextBox.Text ) )
                        CurrentDirectory = new MsDataFilePath(sourcePathTextBox.Text);
                    else if( CurrentDirectory is MsDataFilePath && Directory.Exists( Path.Combine( ((MsDataFilePath) CurrentDirectory).FilePath, sourcePathTextBox.Text ) ) )
                        CurrentDirectory = new MsDataFilePath(Path.Combine(((MsDataFilePath)CurrentDirectory).FilePath, sourcePathTextBox.Text));
                    else if (CurrentDirectory is MsDataFilePath)
                    {
                        // check that all manually-entered paths are valid
                        string[] sourcePaths = sourcePathTextBox.Text.Split(" ".ToCharArray()); // Not L10N
                        List<string> invalidPaths = new List<string>();
                        foreach( string path in sourcePaths )
                            if( !File.Exists( path ) && !File.Exists( Path.Combine( ((MsDataFilePath)CurrentDirectory).FilePath, path ) ) )
                                invalidPaths.Add( path );

                        if( invalidPaths.Count == 0 )
                        {
                            DataSources = sourcePaths.Select(MsDataFileUri.Parse).ToArray();
                            DialogResult = DialogResult.OK;
                            Close();
                    }
                        else
                        {
                            MessageBox.Show(this, TextUtil.LineSeparate(invalidPaths),
                                Resources.OpenDataSourceDialog_sourcePathTextBox_KeyUp_Some_source_paths_are_invalid);
                        }
                    }
                    break;
                case Keys.F5:
                    _abortPopulateList = true;
                    populateListViewFromDirectory( _currentDirectory ); // refresh
                    break;
            }
        }
 private void ImportResults(string prefix, string[] paths, string optimization, bool addNew = true)
 {
     var importResultsDlg = ShowDialog<ImportResultsDlg>(SkylineWindow.ImportResults);
     RunUI(() =>
     {
         if (addNew)
         {
             importResultsDlg.RadioAddNewChecked = true;
             importResultsDlg.ReplicateName = prefix;
             importResultsDlg.OptimizationName = optimization;
         }
         var files = new MsDataFileUri[paths.Length];
         for (int i = 0; i < paths.Length; i++)
         {
             files[i] = new MsDataFilePath(GetTestPath(paths[i]));
         }
         var keyPair = new KeyValuePair<string, MsDataFileUri[]>(prefix, files);
         KeyValuePair<string, MsDataFileUri[]>[] pathHolder = addNew
             ? new[] {keyPair}
             : importResultsDlg.GetDataSourcePathsFileReplicates(files);
         importResultsDlg.NamedPathSets = pathHolder;
     });
     if (addNew)
         OkDialog(importResultsDlg, importResultsDlg.OkDialog);
     else
     {
         var keepPrefixDlg = ShowDialog<ImportResultsNameDlg>(importResultsDlg.OkDialog);
         RunUI(keepPrefixDlg.NoDialog);
         WaitForClosedForm(keepPrefixDlg);
         WaitForClosedForm(importResultsDlg);
     }
     WaitForDocumentLoaded();
 }
 private void upOneLevelButton_Click( object sender, EventArgs e )
 {
     MsDataFileUri parent = null;
     var chorusUrl = _currentDirectory as ChorusUrl;
     var dataFilePath = _currentDirectory as MsDataFilePath;
     if (chorusUrl != null)
     {
         parent = chorusUrl.GetParent();
     }
     else if (dataFilePath != null && !string.IsNullOrEmpty(dataFilePath.FilePath))
     {
         DirectoryInfo parentDirectory = Directory.GetParent(dataFilePath.FilePath);
         if (parentDirectory != null)
         {
             parent = new MsDataFilePath(parentDirectory.FullName);
         }
     }
     if (null != parent && !Equals(parent, _currentDirectory))
     {
         _previousDirectories.Push(_currentDirectory);
         CurrentDirectory = parent;
     }
 }
Exemple #17
0
 protected int CompareTo(MsDataFilePath other)
 {
     // Culture specific sorting desirable in file paths
     // ReSharper disable StringCompareToIsCultureSpecific
     int result = FilePath.CompareTo(other.FilePath);
     if (result != 0)
         return result;
     result = SampleName.CompareTo(other.SampleName);
     if (result != 0)
         return result;
     result = SampleIndex.CompareTo(other.SampleIndex);
     if (result != 0)
         return result;
     result = CentroidMs1.CompareTo(other.CentroidMs1);
     if (result != 0)
         return result;
     result = CentroidMs2.CompareTo(other.CentroidMs2);
     if (result != 0)
         return result;
     return LockMassParameters.CompareTo(other.LockMassParameters);
     // ReSharper restore StringCompareToIsCultureSpecific
 }
Exemple #18
0
 protected MsDataFilePath(MsDataFilePath msDataFilePath)
 {
     FilePath = msDataFilePath.FilePath;
     SampleName = msDataFilePath.SampleName;
     SampleIndex = msDataFilePath.SampleIndex;
     LockMassParameters = msDataFilePath.LockMassParameters;
     CentroidMs1 = msDataFilePath.CentroidMs1;
     CentroidMs2 = msDataFilePath.CentroidMs2;
 }
 private void myDocumentsButton_Click( object sender, EventArgs e )
 {
     CurrentDirectory = new MsDataFilePath(Environment.GetFolderPath( Environment.SpecialFolder.MyDocuments ));
 }
 private void desktopButton_Click( object sender, EventArgs e )
 {
     CurrentDirectory = new MsDataFilePath(Environment.GetFolderPath( Environment.SpecialFolder.DesktopDirectory ));
 }
Exemple #21
0
 private void ImportFoundResultsFiles(CommandArgs commandArgs, ImportPeptideSearch import)
 {
     foreach (var resultFile in import.GetFoundResultsFiles())
     {
         var filePath = new MsDataFilePath(resultFile.Path);
         if (!_doc.Settings.HasResults || _doc.Settings.MeasuredResults.FindMatchingMSDataFile(filePath) == null)
         {
             if (!ImportResultsFile(filePath.ChangeParameters(_doc, commandArgs.LockMassParameters), resultFile.Name, null, null, null))
                 break; // Lots of work completed, still want to save
         }
     }
 }
Exemple #22
0
        private bool ParseArgsInternal(IEnumerable<string> args)
        {
            foreach (string s in args)
            {
                var pair = new NameValuePair(s);
                if (string.IsNullOrEmpty(pair.Name))
                    continue;

                if (IsNameOnly(pair, "ui")) // Not L10N
                {
                    // Handled by Program
                }
                else if (IsNameOnly(pair, "hideacg")) // Not L10N
                {
                    HideAllChromatogramsGraph = true;
                }
                else if (IsNameOnly(pair, "noacg")) // Not L10N
                {
                    NoAllChromatogramsGraph = true;
                }
                else if (IsNameValue(pair, "in")) // Not L10N
                {
                    SkylineFile = GetFullPath(pair.Value);
                    // Set requiresInCommand to be true so if SkylineFile is null or empty it still complains.
                    RequiresSkylineDocument = true;
                }
                else if (IsNameValue(pair, "dir")) // Not L10N
                {
                    if (!Directory.Exists(pair.Value))
                    {
                        _out.WriteLine(Resources.CommandArgs_ParseArgsInternal_Error__The_specified_working_directory__0__does_not_exist_, pair.Value);
                        return false;
                    }
                    Directory.SetCurrentDirectory(pair.Value);
                }
                else if (IsNameOnly(pair, "timestamp")) // Not L10N
                {
                    _out.IsTimeStamped = true;
                }

                // A command that exports all the tools to a text file in a SkylineRunner form for --batch-commands
                // Not advertised.
                // ReSharper disable NonLocalizedString
                else if (IsNameValue(pair, "tool-list-export"))
                {
                    string pathToOutputFile = pair.Value;
                    using (StreamWriter sw = new StreamWriter(pathToOutputFile))
                    {
                        foreach (var tool in Settings.Default.ToolList)
                        {
                            string command = "--tool-add=" + "\"" + tool.Title + "\"" +
                                             " --tool-command=" + "\"" + tool.Command + "\"" +
                                             " --tool-arguments=" + "\"" + tool.Arguments + "\"" +
                                             " --tool-initial-dir=" + "\"" + tool.InitialDirectory + "\"" +
                                             " --tool-conflict-resolution=skip" +
                                             " --tool-report=" + "\"" + tool.ReportTitle + "\"";

                            if (tool.OutputToImmediateWindow)
                                command += " --tool-output-to-immediate-window";

                            sw.WriteLine(command);
                        }
                    }
                }
                // ReSharper restore NonLocalizedString

                // Import a skyr file.
                else if (IsNameValue(pair, "report-add")) // Not L10N
                {
                    ImportingSkyr = true;
                    SkyrPath = pair.Value;
                }

                else if (IsNameValue(pair, "report-conflict-resolution")) // Not L10N
                {
                    string input = pair.Value.ToLowerInvariant();
                    if (input == "overwrite") // Not L10N
                    {
                        ResolveSkyrConflictsBySkipping = false;
                    }
                    if (input == "skip") // Not L10N
                    {
                        ResolveSkyrConflictsBySkipping = true;
                    }
                }

                else if (IsNameValue(pair, ARG_FULL_SCAN_PRECURSOR_RES))
                {
                    RequiresSkylineDocument = true;
                    FullScanPrecursorRes = ParseDouble(pair.Value, ARG_FULL_SCAN_PRECURSOR_RES);
                    if (!FullScanPrecursorRes.HasValue)
                        return false;
                }
                else if (IsNameValue(pair, ARG_FULL_SCAN_PRECURSOR_RES_MZ))
                {
                    RequiresSkylineDocument = true;
                    FullScanPrecursorResMz = ParseDouble(pair.Value, ARG_FULL_SCAN_PRECURSOR_RES_MZ);
                    if (!FullScanPrecursorResMz.HasValue)
                        return false;
                }
                else if (IsNameValue(pair, ARG_FULL_SCAN_PRODUCT_RES))
                {
                    RequiresSkylineDocument = true;
                    FullScanProductRes = ParseDouble(pair.Value, ARG_FULL_SCAN_PRODUCT_RES);
                    if (!FullScanProductRes.HasValue)
                        return false;
                }
                else if (IsNameValue(pair, ARG_FULL_SCAN_PRODUCT_RES_MZ))
                {
                    RequiresSkylineDocument = true;
                    FullScanProductResMz = ParseDouble(pair.Value, ARG_FULL_SCAN_PRODUCT_RES_MZ);
                    if (!FullScanProductResMz.HasValue)
                        return false;
                }
                else if (IsNameValue(pair, ARG_FULL_SCAN_RT_FILTER_TOLERANCE))
                {
                    RequiresSkylineDocument = true;
                    FullScanRetentionTimeFilterLength = ParseDouble(pair.Value, ARG_FULL_SCAN_RT_FILTER_TOLERANCE);
                    if (!FullScanRetentionTimeFilterLength.HasValue)
                        return false;
                }

                else if (IsNameValue(pair, "tool-add-zip")) // Not L10N
                {
                    InstallingToolsFromZip = true;
                    ZippedToolsPath = pair.Value;
                }
                else if (IsNameValue(pair, "tool-zip-conflict-resolution")) // Not L10N
                {
                    string input = pair.Value.ToLowerInvariant();
                    if (input == "overwrite") // Not L10N
                    {
                        ResolveZipToolConflictsBySkipping = CommandLine.ResolveZipToolConflicts.overwrite;
                    }
                    if (input == "parallel") // Not L10N
                    {
                        ResolveZipToolConflictsBySkipping = CommandLine.ResolveZipToolConflicts.in_parallel;
                    }
                }
                else if (IsNameValue(pair, "tool-zip-overwrite-annotations")) // Not L10N
                {
                    string input = pair.Value.ToLowerInvariant();
                    if (input == "true") // Not L10N
                    {
                        ResolveZipToolAnotationConflictsBySkipping = true;
                    }
                    if (input == "false") // Not L10N
                    {
                        ResolveZipToolAnotationConflictsBySkipping = false;
                    }
                }
                else if (IsNameValue(pair, "tool-program-macro")) // example --tool-program-macro=R,2.15.2  // Not L10N
                {
                    string [] spliced = pair.Value.Split(',');
                    if (spliced.Count() > 2)
                    {
                        _out.WriteLine(Resources.CommandArgs_ParseArgsInternal_Warning__Incorrect_Usage_of_the___tool_program_macro_command_);
                    }
                    else
                    {
                        string programName = spliced[0];
                        string programVersion = null;
                        if (spliced.Count() > 1)
                        {
                            // Extract the version if specified.
                            programVersion = spliced[1];
                        }
                        ZippedToolsProgramPathContainer = new ProgramPathContainer(programName, programVersion);
                    }
                }
            // ReSharper disable NonLocalizedString
                else if (IsNameValue(pair, "tool-program-path"))
                {
                    ZippedToolsProgramPathValue = pair.Value;
                }
                else if (IsNameOnly(pair, "tool-ignore-required-packages"))
                {
                    ZippedToolsPackagesHandled = true;
                }

                else if (IsNameValue(pair, "tool-add"))
                {
                    ImportingTool = true;
                    ToolName = pair.Value;
                }

                else if (IsNameValue(pair, "tool-command"))
                {
                    ImportingTool = true;
                    ToolCommand = pair.Value;
                }

                else if (IsNameValue(pair, "tool-arguments"))
                {
                    ImportingTool = true;
                    ToolArguments = pair.Value;
                }

                else if (IsNameValue(pair, "tool-initial-dir"))
                {
                    ImportingTool = true;
                    ToolInitialDirectory = pair.Value;
                }
                else if (IsNameValue(pair, "tool-report"))
                {
                    ImportingTool = true;
                    ToolReportTitle = pair.Value;
                }
                else if (IsNameOnly(pair, "tool-output-to-immediate-window"))
                {
                    ImportingTool = true;
                    ToolOutputToImmediateWindow = true;
                }

                else if (IsNameValue(pair, "tool-conflict-resolution"))
                {
                    string input = pair.Value.ToLowerInvariant();
                    if (input == "overwrite")
                    {
                        ResolveToolConflictsBySkipping = false;
                    }
                    if (input == "skip")
                    {
                        ResolveToolConflictsBySkipping = true;
                    }
                }
                else if (IsNameValue(pair, ARG_IMPORT_PEPTIDE_SEARCH_FILE))
                {
                    RequiresSkylineDocument = true;
                    SearchResultsFiles.Add(GetFullPath(pair.Value));
                    CutoffScore = CutoffScore ?? Settings.Default.LibraryResultCutOff;
                }
                else if (IsNameValue(pair, ARG_IMPORT_PEPTIDE_SEARCH_CUTOFF))
                {
                    double? cutoff;
                    try
                    {
                        cutoff = pair.ValueDouble;
                        if (cutoff < 0 || cutoff > 1)
                        {
                            cutoff = null;
                        }
                    }
                    catch
                    {
                        cutoff = null;
                    }
                    if (cutoff.HasValue)
                    {
                        CutoffScore = cutoff.Value;
                    }
                    else
                    {
                        var defaultScore = Settings.Default.LibraryResultCutOff;
                        _out.WriteLine(Resources.CommandArgs_ParseArgsInternal_Warning__The_cutoff_score__0__is_invalid__It_must_be_a_value_between_0_and_1_, pair.Value);
                        _out.WriteLine(Resources.CommandArgs_ParseArgsInternal_Defaulting_to__0__, defaultScore);
                        CutoffScore = defaultScore;
                    }
                }
                else if (IsNameOnly(pair, ARG_IMPORT_PEPTIDE_SEARCH_MODS))
                {
                    AcceptAllModifications = true;
                }
                else if (IsNameOnly(pair, ARG_IMPORT_PEPTIDE_SEARCH_AMBIGUOUS))
                {
                    IncludeAmbiguousMatches = true;
                }

                // Run each line of a text file like a SkylineRunner command
                else if (IsNameValue(pair, "batch-commands"))
                {
                    BatchCommandsPath = GetFullPath(pair.Value);
                    RunningBatchCommands = true;
                }

                else if (IsNameOnly(pair, "save"))
                {
                    Saving = true;
                    RequiresSkylineDocument = true;
                }

                else if (IsNameValue(pair, "out"))
                {
                    SaveFile = GetFullPath(pair.Value);
                    RequiresSkylineDocument = true;
                }

                else if (IsNameValue(pair, "add-library-name"))
                {
                    LibraryName = pair.Value;
                    RequiresSkylineDocument = true;
                }

                else if (IsNameValue(pair, "add-library-path"))
                {
                    LibraryPath = GetFullPath(pair.Value);
                    RequiresSkylineDocument = true;
                }

                else if (IsNameValue(pair, "import-fasta"))
                {
                    FastaPath = GetFullPath(pair.Value);
                    RequiresSkylineDocument = true;
                }

                else if (IsNameValue(pair, ARG_IMPORT_TRANSITION_LIST))
                {
                    TransitionListPath = GetFullPath(pair.Value);
                    IsTransitionListAssayLibrary = false;
                    RequiresSkylineDocument = true;
                }

                else if (IsNameValue(pair, ARG_IMPORT_ASSAY_LIBRARY))
                {
                    TransitionListPath = GetFullPath(pair.Value);
                    IsTransitionListAssayLibrary = true;
                    RequiresSkylineDocument = true;
                }

                else if (IsNameOnly(pair, ARG_IGNORE_TRANSITION_ERRORS))
                {
                    IsIgnoreTransitionErrors = true;
                }

                else if (IsNameValue(pair, ARG_IRT_STANDARDS_GROUP_NAME))
                {
                    IrtGroupName = pair.Value;
                }

                else if (IsNameValue(pair, ARG_IRT_STANDARDS_FILE))
                {
                    IrtStandardsPath = pair.Value;
                }

                else if (IsNameValue(pair, ARG_IRT_DATABASE_PATH))
                {
                    IrtDatabasePath = pair.Value;
                }

                else if (IsNameValue(pair, ARG_IRT_CALC_NAME))
                {
                    IrtCalcName = pair.Value;
                }

                else if (IsNameValue(pair, ARG_DECOYS_ADD))
                {
                    if (pair.Value == "reversed")
                        AddDecoysType = DecoyGeneration.REVERSE_SEQUENCE;
                    else if (pair.Value == "shuffled")
                        AddDecoysType = DecoyGeneration.SHUFFLE_SEQUENCE;
                    else
                    {
                        _out.WriteLine(Resources.CommandArgs_ParseArgsInternal_Error__Invalid_value___0___for__1___use__reversed__or__shuffled__, pair.Value, ARG_DECOYS_ADD);
                        return false;
                    }
                    RequiresSkylineDocument = true;
                }

                else if (IsNameValue(pair, ARG_DECOYS_ADD_COUNT))
                {
                    int count;
                    if (!int.TryParse(pair.Value, out count))
                    {
                        _out.WriteLine(Resources.CommandArgs_ParseArgsInternal_Error__The_value___0___for__1__must_be_an_integer_, pair.Value, ARG_DECOYS_ADD_COUNT);
                        return false;
                    }
                    AddDecoysCount = count;
                }

                else if (IsNameOnly(pair, ARG_DECOYS_DISCARD))
                {
                    DiscardDecoys = true;
                    RequiresSkylineDocument = true;
                }

                else if (IsNameOnly(pair, "keep-empty-proteins"))
                {
                    KeepEmptyProteins = true;
                }

                else if (IsNameValue(pair, "import-file"))
                {
                    if (pair.Value.StartsWith(ChorusUrl.ChorusUrlPrefix))
                    {
                        ReplicateFile = MsDataFileUri.Parse(pair.Value);
                    }
                    else
                    {
                        ReplicateFile = new MsDataFilePath(GetFullPath(pair.Value));
                    }
                    RequiresSkylineDocument = true;
                }

                else if (IsNameValue(pair, "import-replicate-name"))
                {
                    ReplicateName = pair.Value;
                    RequiresSkylineDocument = true;
                }

                else if (IsNameValue(pair, ARG_IMPORT_LOCKMASS_POSITIVE))
                {
                    LockmassPositive = ParseDouble(pair.Value, ARG_IMPORT_LOCKMASS_POSITIVE);
                    RequiresSkylineDocument = true;
                }

                else if (IsNameValue(pair, ARG_IMPORT_LOCKMASS_NEGATIVE))
                {
                    LockmassNegative = ParseDouble(pair.Value, ARG_IMPORT_LOCKMASS_NEGATIVE);
                    RequiresSkylineDocument = true;
                }

                else if (IsNameValue(pair, ARG_IMPORT_LOCKMASS_TOLERANCE))
                {
                    LockmassTolerance = ParseDouble(pair.Value, ARG_IMPORT_LOCKMASS_TOLERANCE);
                    RequiresSkylineDocument = true;
                }

                else if (IsNameOnly(pair, "import-append"))
                {
                    ImportAppend = true;
                    RequiresSkylineDocument = true;
                }

                else if (IsNameValue(pair, "import-all"))
                {
                    ImportSourceDirectory = GetFullPath(pair.Value);
                    RequiresSkylineDocument = true;
                }

                else if (IsNameOnly(pair, "import-no-join"))
                {
                    ImportDisableJoining = true;
                    RequiresSkylineDocument = true;
                }
                // ReSharper restore NonLocalizedString

                else if (IsNameValue(pair, "import-naming-pattern")) // Not L10N
                {
                    var importNamingPatternVal = pair.Value;
                    RequiresSkylineDocument = true;
                    if (importNamingPatternVal != null)
                    {
                        try
                        {
                            ImportNamingPattern = new Regex(importNamingPatternVal);
                        }
                        catch (Exception e)
                        {
                            _out.WriteLine(Resources.CommandArgs_ParseArgsInternal_Error__Regular_expression__0__cannot_be_parsed_, importNamingPatternVal);
                            _out.WriteLine(e.Message);
                            return false;
                        }

                        Match match = Regex.Match(importNamingPatternVal, @".*\(.+\).*"); // Not L10N
                        if (!match.Success)
                        {
                            _out.WriteLine(Resources.CommandArgs_ParseArgsInternal_Error__Regular_expression___0___does_not_have_any_groups___String,
                                importNamingPatternVal);
                            return false;
                        }
                    }
                }

                else if (IsNameValue(pair, "import-optimizing")) // Not L10N
                {
                    try
                    {
                        ImportOptimizeType = pair.Value;
                    }
                    catch (ArgumentException)
                    {
                        _out.WriteLine(
                            Resources.CommandArgs_ParseArgsInternal_Warning__Invalid_optimization_parameter___0____Use__ce____dp___or__none____Defaulting_to_none_,
                            pair.Value);
                    }
                }

                else if (IsNameValue(pair, "import-before")) // Not L10N
                {
                    var importBeforeDate = pair.Value;
                    if (importBeforeDate != null)
                    {
                        try
                        {
                            ImportBeforeDate = Convert.ToDateTime(importBeforeDate);
                        }
                        catch (Exception e)
                        {
                            _out.WriteLine(Resources.CommandArgs_ParseArgsInternal_Error__Date__0__cannot_be_parsed_, importBeforeDate);
                            _out.WriteLine(e.Message);
                            return false;
                        }
                    }
                }

                else if (IsNameValue(pair, "import-on-or-after")) // Not L10N
                {
                    var importAfterDate = pair.Value;
                    if (importAfterDate != null)
                    {
                        try
                        {
                            ImportOnOrAfterDate = Convert.ToDateTime(importAfterDate);
                        }
                        catch (Exception e)
                        {
                            _out.WriteLine(Resources.CommandArgs_ParseArgsInternal_Error__Date__0__cannot_be_parsed_, importAfterDate);
                            _out.WriteLine(e.Message);
                            return false;
                        }
                    }
                }

                else if (IsNameValue(pair, "remove-all")) // Not L10N
                {
                    RemovingResults = true;
                    RequiresSkylineDocument = true;
                    RemoveBeforeDate = null;
                }
                else if (IsNameValue(pair, "remove-before")) // Not L10N
                {
                    var removeBeforeDate = pair.Value;
                    RemovingResults = true;
                    RequiresSkylineDocument = true;
                    if (removeBeforeDate != null)
                    {
                        try
                        {
                            RemoveBeforeDate = Convert.ToDateTime(removeBeforeDate);
                        }
                        catch (Exception e)
                        {
                            _out.WriteLine(Resources.CommandArgs_ParseArgsInternal_Error__Date__0__cannot_be_parsed_, removeBeforeDate);
                            _out.WriteLine(e.Message);
                            return false;
                        }
                    }
                }
                else if (IsNameValue(pair, ARG_REINTEGRATE_MODEL_NAME))
                {
                    ReintegratModelName = pair.Value;
                }
                else if (IsNameOnly(pair, ARG_REINTEGRATE_CREATE_MODEL))
                {
                    IsCreateScoringModel = true;
                    if (!IsSecondBestModel)
                        IsDecoyModel = true;
                }
                else if (IsNameOnly(pair, ARG_REINTEGRATE_ANNOTATE_SCORING))
                {
                    IsAnnotateScoring = true;
                }
                else if (IsNameOnly(pair, ARG_REINTEGRATE_OVERWRITE_PEAKS))
                {
                    IsOverwritePeaks = true;
                }
                else if (IsNameOnly(pair, ARG_REINTEGRATE_MODEL_SECOND_BEST))
                {
                    IsSecondBestModel = true;
                    IsDecoyModel = false;
                }
                else if (IsNameOnly(pair, ARG_REINTEGRATE_MODEL_BOTH))
                {
                    IsSecondBestModel = IsDecoyModel = true;
                }
                else if (IsNameValue(pair, "report-name")) // Not L10N
                {
                    ReportName = pair.Value;
                    RequiresSkylineDocument = true;
                }

                else if (IsNameValue(pair, "report-file")) // Not L10N
                {
                    ReportFile = GetFullPath(pair.Value);
                    RequiresSkylineDocument = true;
                }

                else if (IsNameValue(pair, "report-format")) // Not L10N
                {
                    if (pair.Value.Equals("TSV", StringComparison.CurrentCultureIgnoreCase)) // Not L10N
                        ReportColumnSeparator = TextUtil.SEPARATOR_TSV;
                    else if (pair.Value.Equals("CSV", StringComparison.CurrentCultureIgnoreCase)) // Not L10N
                        ReportColumnSeparator = TextUtil.CsvSeparator;
                    else
                    {
                        _out.WriteLine(
                            Resources.CommandArgs_ParseArgsInternal_Warning__The_report_format__0__is_invalid__It_must_be_either__CSV__or__TSV__,
                            pair.Value);
                        _out.WriteLine(Resources.CommandArgs_ParseArgsInternal_Defaulting_to_CSV_);
                        ReportColumnSeparator = TextUtil.CsvSeparator;
                    }
                }

                else if (IsName(pair, "report-invariant")) // Not L10N
                {
                    IsReportInvariant = true;
                }

                else if (IsNameValue(pair, "chromatogram-file")) // Not L10N
                {
                    ChromatogramsFile = GetFullPath(pair.Value);
                    RequiresSkylineDocument = true;
                }

                else if (IsNameOnly(pair, "chromatogram-precursors")) // Not L10N
                {
                    ChromatogramsPrecursors = true;
                }

                else if (IsNameOnly(pair, "chromatogram-products")) // Not L10N
                {
                    ChromatogramsProducts = true;
                }

                else if (IsNameOnly(pair, "chromatogram-base-peaks")) // Not L10N
                {
                    ChromatogramsBasePeaks = true;
                }

                else if (IsNameOnly(pair, "chromatogram-tics")) // Not L10N
                {
                    ChromatogramsTics = true;
                }
                else if (IsNameValue(pair, "exp-translist-instrument")) // Not L10N
                {
                    try
                    {
                        TransListInstrumentType = pair.Value;
                        RequiresSkylineDocument = true;
                    }
                    catch (ArgumentException)
                    {
                        _out.WriteLine(Resources.CommandArgs_ParseArgsInternal_Warning__The_instrument_type__0__is_not_valid__Please_choose_from_,
                            pair.Value);
                        foreach (string str in ExportInstrumentType.TRANSITION_LIST_TYPES)
                        {
                            _out.WriteLine(str);
                        }
                        _out.WriteLine(Resources.CommandArgs_ParseArgsInternal_No_transition_list_will_be_exported_);
                    }
                }
                else if (IsNameValue(pair, "exp-method-instrument")) // Not L10N
                {
                    try
                    {
                        MethodInstrumentType = pair.Value;
                        RequiresSkylineDocument = true;
                    }
                    catch (ArgumentException)
                    {
                        _out.WriteLine(Resources.CommandArgs_ParseArgsInternal_Warning__The_instrument_type__0__is_not_valid__Please_choose_from_,
                            pair.Value);
                        foreach (string str in ExportInstrumentType.METHOD_TYPES)
                        {
                            _out.WriteLine(str);
                        }
                        _out.WriteLine(Resources.CommandArgs_ParseArgsInternal_No_method_will_be_exported_);
                    }
                }
                else if (IsNameValue(pair, "exp-file")) // Not L10N
                {
                    ExportPath = GetFullPath(pair.Value);
                    RequiresSkylineDocument = true;
                }
                else if (IsNameValue(pair, "exp-strategy")) // Not L10N
                {
                    ExportStrategySet = true;
                    RequiresSkylineDocument = true;

                    string strategy = pair.Value;

                    if (strategy.Equals("single", StringComparison.CurrentCultureIgnoreCase)) // Not L10N
                    {
                        //default
                    }
                    else if (strategy.Equals("protein", StringComparison.CurrentCultureIgnoreCase)) // Not L10N
                        ExportStrategy = ExportStrategy.Protein;
                    else if (strategy.Equals("buckets", StringComparison.CurrentCultureIgnoreCase)) // Not L10N
                        ExportStrategy = ExportStrategy.Buckets;
                    else
                    {
                        _out.WriteLine(Resources.CommandArgs_ParseArgsInternal_Warning__The_export_strategy__0__is_not_valid__It_must_be_one_of_the_following___string,
                            pair.Value);
                        //already set to Single
                    }
                }

                else if (IsNameValue(pair, "exp-method-type")) // Not L10N
                {
                    var type = pair.Value;
                    RequiresSkylineDocument = true;
                    if (type.Equals("scheduled", StringComparison.CurrentCultureIgnoreCase)) // Not L10N
                    {
                        ExportMethodType = ExportMethodType.Scheduled;
                    }
                    else if (type.Equals("triggered", StringComparison.CurrentCultureIgnoreCase)) // Not L10N
                    {
                        ExportMethodType = ExportMethodType.Triggered;
                    }
                    else if (type.Equals("standard", StringComparison.CurrentCultureIgnoreCase)) // Not L10N
                    {
                        //default
                    }
                    else
                    {
                        _out.WriteLine(
                            Resources.CommandArgs_ParseArgsInternal_Warning__The_method_type__0__is_invalid__It_must_be_one_of_the_following___standard____scheduled__or__triggered__,
                            pair.Value);
                        _out.WriteLine(Resources.CommandArgs_ParseArgsInternal_Defaulting_to_standard_);
                    }
                }

                else if (IsNameValue(pair, "exp-max-trans")) // Not L10N
                {
                    //This one can't be kept within bounds because the bounds depend on the instrument
                    //and the document.
                    try
                    {
                        MaxTransitionsPerInjection = pair.ValueInt;
                    }
                    catch
                    {
                        _out.WriteLine(Resources.CommandArgs_ParseArgsInternal_Warning__Invalid_max_transitions_per_injection_parameter___0___, pair.Value);
                        _out.WriteLine(Resources.CommandArgs_ParseArgsInternal_It_must_be_a_number__Defaulting_to__0__, AbstractMassListExporter.MAX_TRANS_PER_INJ_DEFAULT);
                        MaxTransitionsPerInjection = AbstractMassListExporter.MAX_TRANS_PER_INJ_DEFAULT;
                    }
                    RequiresSkylineDocument = true;
                }

                else if (IsNameValue(pair, "exp-optimizing")) // Not L10N
                {
                    try
                    {
                        ExportOptimizeType = pair.Value;
                    }
                    catch (ArgumentException)
                    {
                        _out.WriteLine(
                            Resources.CommandArgs_ParseArgsInternal_Warning__Invalid_optimization_parameter___0____Use__ce____dp___or__none__,
                            pair.Value);
                        _out.WriteLine(Resources.CommandArgs_ParseArgsInternal_Defaulting_to_none_);
                    }
                    RequiresSkylineDocument = true;
                }
                else if (IsNameValue(pair, "exp-scheduling-replicate")) // Not L10N
                {
                    SchedulingReplicate = pair.Value;
                    RequiresSkylineDocument = true;
                }
                else if (IsNameValue(pair, "exp-template")) // Not L10N
                {
                    TemplateFile = GetFullPath(pair.Value);
                    RequiresSkylineDocument = true;
                }
                else if (IsNameOnly(pair, "exp-ignore-proteins")) // Not L10N
                {
                    IgnoreProteins = true;
                    RequiresSkylineDocument = true;
                }
                else if (IsNameValue(pair, "exp-primary-count")) // Not L10N
                {
                    try
                    {
                        PrimaryTransitionCount = pair.ValueInt;
                    }
                    catch
                    {
                        _out.WriteLine(
                            Resources.CommandArgs_ParseArgsInternal_Warning__The_primary_transition_count__0__is_invalid__it_must_be_a_number_between__1__and__2__,
                            pair.Value,
                            AbstractMassListExporter.PRIMARY_COUNT_MIN, AbstractMassListExporter.PRIMARY_COUNT_MAX);
                        _out.WriteLine(Resources.CommandArgs_ParseArgsInternal_Defaulting_to__0__, AbstractMassListExporter.PRIMARY_COUNT_DEFAULT);
                    }
                    RequiresSkylineDocument = true;
                }
                else if (IsNameValue(pair, "exp-dwell-time")) // Not L10N
                {
                    try
                    {
                        DwellTime = pair.ValueInt;
                    }
                    catch
                    {
                        _out.WriteLine(
                            Resources.CommandArgs_ParseArgsInternal_Warning__The_dwell_time__0__is_invalid__it_must_be_a_number_between__1__and__2__,
                            pair.Value,
                            AbstractMassListExporter.DWELL_TIME_MIN, AbstractMassListExporter.DWELL_TIME_MAX);
                        _out.WriteLine(Resources.CommandArgs_ParseArgsInternal_Defaulting_to__0__, AbstractMassListExporter.DWELL_TIME_DEFAULT);
                    }
                    RequiresSkylineDocument = true;
                }
                else if (IsNameOnly(pair, "exp-add-energy-ramp")) // Not L10N
                {
                    AddEnergyRamp = true;
                    RequiresSkylineDocument = true;
                }
                else if (IsNameOnly(pair, "exp-use-s-lens")) // Not L10N
                {
                    UseSlens = true;
                    RequiresSkylineDocument = true;
                }
                else if (IsNameValue(pair, "exp-run-length")) // Not L10N
                {
                    try
                    {
                        RunLength = pair.ValueInt;
                    }
                    catch
                    {
                        _out.WriteLine(
                            Resources
                                .CommandArgs_ParseArgsInternal_Warning__The_run_length__0__is_invalid__It_must_be_a_number_between__1__and__2__,
                            pair.Value,
                            AbstractMassListExporter.RUN_LENGTH_MIN, AbstractMassListExporter.RUN_LENGTH_MAX);
                        _out.WriteLine(Resources.CommandArgs_ParseArgsInternal_Defaulting_to__0__,
                            AbstractMassListExporter.RUN_LENGTH_DEFAULT);
                    }
                    RequiresSkylineDocument = true;
                }
                else if (IsNameValue(pair, PANORAMA_SERVER_URI))
                {
                    PanoramaServerUri = pair.Value;
                }
                else if (IsNameValue(pair, PANORAMA_USERNAME))
                {
                    PanoramaUserName = pair.Value;
                }
                else if (IsNameValue(pair, PANORAMA_PASSWD))
                {
                    PanoramaPassword = pair.Value;
                }
                else if (IsNameValue(pair, PANORAMA_FOLDER))
                {
                    PanoramaFolder = pair.Value;
                }
                else if (IsName(pair, "share-zip")) // Not L10N
                {
                    SharingZipFile = true;
                    RequiresSkylineDocument = true;
                    if (!string.IsNullOrEmpty(pair.Value))
                    {
                        SharedFile = pair.Value;
                    }
                }
                else
                {
                    _out.WriteLine(Resources.CommandArgs_ParseArgsInternal_Error__Unexpected_argument____0_, pair.Name);
                    return false;
                }
            }

            if (Reintegrating)
                RequiresSkylineDocument = true;
            else
            {
                if (IsCreateScoringModel)
                    WarnArgRequirment(ARG_REINTEGRATE_MODEL_NAME, ARG_REINTEGRATE_CREATE_MODEL);
                if (IsAnnotateScoring)
                    WarnArgRequirment(ARG_REINTEGRATE_MODEL_NAME, ARG_REINTEGRATE_ANNOTATE_SCORING);
                if (IsOverwritePeaks)
                    WarnArgRequirment(ARG_REINTEGRATE_MODEL_NAME, ARG_REINTEGRATE_OVERWRITE_PEAKS);
            }
            if (FullScanPrecursorResMz.HasValue && !FullScanPrecursorRes.HasValue)
                WarnArgRequirment(ARG_FULL_SCAN_PRECURSOR_RES, ARG_FULL_SCAN_PRECURSOR_RES_MZ);
            if (FullScanProductResMz.HasValue && !FullScanProductRes.HasValue)
                WarnArgRequirment(ARG_FULL_SCAN_PRODUCT_RES, ARG_FULL_SCAN_PRODUCT_RES_MZ);
            if (!IsCreateScoringModel && IsSecondBestModel)
            {
                if (IsDecoyModel)
                    WarnArgRequirment(ARG_REINTEGRATE_CREATE_MODEL, ARG_REINTEGRATE_MODEL_BOTH);
                else
                    WarnArgRequirment(ARG_REINTEGRATE_CREATE_MODEL, ARG_REINTEGRATE_MODEL_SECOND_BEST);
            }
            if (!AddDecoys && AddDecoysCount.HasValue)
            {
                WarnArgRequirment(ARG_DECOYS_ADD, ARG_DECOYS_ADD_COUNT);
            }
            if (!ImportingTransitionList)
            {
                if (IsIgnoreTransitionErrors)
                    WarnArgRequirment(ARG_IMPORT_TRANSITION_LIST, ARG_IGNORE_TRANSITION_ERRORS);
            }
            if (!ImportingTransitionList || !IsTransitionListAssayLibrary)
            {
                if (!string.IsNullOrEmpty(IrtGroupName))
                    WarnArgRequirment(ARG_IMPORT_ASSAY_LIBRARY, ARG_IRT_STANDARDS_GROUP_NAME);
                if (!string.IsNullOrEmpty(IrtStandardsPath))
                    WarnArgRequirment(ARG_IMPORT_ASSAY_LIBRARY, ARG_IRT_STANDARDS_FILE);
            }
            if (!string.IsNullOrEmpty(PanoramaServerUri) || !string.IsNullOrEmpty(PanoramaFolder))
            {
                if (!PanoramaArgsComplete())
                {
                    return false;
                }

                var serverUri = PanoramaUtil.ServerNameToUri(PanoramaServerUri);
                if (serverUri == null)
                {
                    _out.WriteLine(Resources.EditServerDlg_OkDialog_The_text__0__is_not_a_valid_server_name_,
                        PanoramaServerUri);
                    return false;
                }

                var panoramaClient = new WebPanoramaClient(serverUri);
                var panoramaHelper = new PanoramaHelper(_out);
                PanoramaServer = panoramaHelper.ValidateServer(panoramaClient, PanoramaUserName, PanoramaPassword);
                if (PanoramaServer == null)
                {
                    return false;
                }

                if (!panoramaHelper.ValidateFolder(panoramaClient, PanoramaServer, PanoramaFolder))
                {
                    return false;
                }

                RequiresSkylineDocument = true;
                PublishingToPanorama = true;
            }
            if (!ImportingSearch)
            {
                if (CutoffScore.HasValue)
                    WarnArgRequirment(ARG_IMPORT_PEPTIDE_SEARCH_FILE, ARG_IMPORT_PEPTIDE_SEARCH_CUTOFF);
                if (AcceptAllModifications)
                    WarnArgRequirment(ARG_IMPORT_PEPTIDE_SEARCH_FILE, ARG_IMPORT_PEPTIDE_SEARCH_MODS);
                if (IncludeAmbiguousMatches)
                    WarnArgRequirment(ARG_IMPORT_PEPTIDE_SEARCH_FILE, ARG_IMPORT_PEPTIDE_SEARCH_AMBIGUOUS);
            }

            // If skylineFile isn't set and one of the commands that requires --in is called, complain.
            if (String.IsNullOrEmpty(SkylineFile) && RequiresSkylineDocument && !_isDocumentLoaded)
            {
                _out.WriteLine(Resources.CommandArgs_ParseArgsInternal_Error__Use___in_to_specify_a_Skyline_document_to_open_);
                return false;
            }

            if(ImportingReplicateFile && ImportingSourceDirectory)
            {
                _out.WriteLine(Resources.CommandArgs_ParseArgsInternal_Error____import_file_and___import_all_options_cannot_be_used_simultaneously_);
                return false;
            }
            if(ImportingReplicateFile && ImportNamingPattern != null)
            {
                _out.WriteLine(Resources.CommandArgs_ParseArgsInternal_Error____import_naming_pattern_cannot_be_used_with_the___import_file_option_);
                return false;
            }
            if(ImportingSourceDirectory && !string.IsNullOrEmpty(ReplicateName))
            {
                _out.WriteLine(Resources.CommandArgs_ParseArgsInternal_Error____import_replicate_name_cannot_be_used_with_the___import_all_option_);
                return false;
            }

            // Use the original file as the output file, if not told otherwise.
            if (Saving && String.IsNullOrEmpty(SaveFile))
            {
                SaveFile = SkylineFile;
            }
            return true;
        }
Exemple #23
0
        public static bool IsChorusResponse(MsDataFileUri msDataFileUri)
        {
            MsDataFilePath msDataFilePath = msDataFileUri as MsDataFilePath;

            return(null != msDataFilePath && msDataFilePath.GetExtension() == DataSourceUtil.EXT_CHORUSRESPONSE);
        }
        public void InitializeSpectrumSourceFiles(SrmDocument document)
        {
            if (DocLib == null)
                return;

            var measuredResults = document.Settings.MeasuredResults;
            foreach (var dataFile in DocLib.LibraryDetails.DataFiles)
            {
                var msDataFilePath = new MsDataFilePath(dataFile);
                SpectrumSourceFiles[dataFile] = new FoundResultsFilePossibilities(msDataFilePath.GetFileNameWithoutExtension());

                // If a matching file is already in the document, then don't include
                // this library spectrum source in the set of files to find.
                if (measuredResults != null && measuredResults.FindMatchingMSDataFile(MsDataFileUri.Parse(dataFile)) != null)
                    continue;

                if (File.Exists(dataFile) && DataSourceUtil.IsDataSource(dataFile))
                {
                    // We've found the dataFile in the exact location
                    // specified in the document library, so just add it
                    // to the "FOUND" list.
                    SpectrumSourceFiles[dataFile].ExactMatch = msDataFilePath.ToString();
                }
            }
            DocLib.ReadStream.CloseStream();
        }