Exemple #1
0
        private void TestTopDownSearch(string specFilePath, string dbFilePath, string outputDir, AminoAcidSet aaSet,
                                       int minSequenceLength, int maxSequenceLength,
                                       int minPrecursorIonCharge, int maxPrecursorIonCharge,
                                       int minProductIonCharge, int maxProductIonCharge,
                                       double minSequenceMass, double maxSequenceMass,
                                       DatabaseSearchMode tda, InternalCleavageType searchMode)
        {
            var methodName = MethodBase.GetCurrentMethod().Name;

            Utils.ShowStarting(methodName);

            // Search parameters
            const int maxNumNTermCleavages     = 1; // 30
            const int maxNumCTermCleavages     = 0;
            const int precursorIonTolerancePpm = 10;
            const int productIonTolerancePpm   = 10;

            var topDownOptions = new MsPfParameters(
                specFilePath,
                dbFilePath,
                outputDir,
                aaSet, "")
            {
                MinSequenceLength        = minSequenceLength,
                MaxSequenceLength        = maxSequenceLength,
                MaxNumNTermCleavages     = maxNumNTermCleavages,
                MaxNumCTermCleavages     = maxNumCTermCleavages,
                MinPrecursorIonCharge    = minPrecursorIonCharge,
                MaxPrecursorIonCharge    = maxPrecursorIonCharge,
                MinProductIonCharge      = minProductIonCharge,
                MaxProductIonCharge      = maxProductIonCharge,
                MinSequenceMass          = minSequenceMass,
                MaxSequenceMass          = maxSequenceMass,
                PrecursorIonTolerancePpm = precursorIonTolerancePpm,
                ProductIonTolerancePpm   = productIonTolerancePpm,
                TargetDecoySearchMode    = tda,
                InternalCleavageMode     = searchMode,
            };

            var topDownLauncher = new IcTopDownLauncher(topDownOptions);

            //topDownLauncher.ForceParallel = true;
            //topDownLauncher.MaxNumThreads = -1;

            topDownLauncher.RunSearch(0.7);
            //topDownLauncher.RunIntactProteinSearch();
        }
Exemple #2
0
        public void TestTopDownSearch(string specFilePath, string dbFilePath, string outputDir, AminoAcidSet aaSet,
                                      int minSequenceLength, int maxSequenceLength,
                                      int minPrecursorIonCharge, int maxPrecursorIonCharge,
                                      int minProductIonCharge, int maxProductIonCharge,
                                      double minSequenceMass, double maxSequenceMass,
                                      bool?tda, int searchMode)
        {
            var methodName = MethodBase.GetCurrentMethod().Name;

            TestUtils.ShowStarting(methodName);

            // Search parameters
            const int maxNumNTermCleavages     = 1; // 30
            const int maxNumCTermCleavages     = 0;
            const int precursorIonTolerancePpm = 10;
            const int productIonTolerancePpm   = 10;

            var topDownLauncher = new IcTopDownLauncher(
                specFilePath,
                dbFilePath,
                outputDir,
                aaSet, "")
            {
                MinSequenceLength          = minSequenceLength,
                MaxSequenceLength          = maxSequenceLength,
                MaxNumNTermCleavages       = maxNumNTermCleavages,
                MaxNumCTermCleavages       = maxNumCTermCleavages,
                MinPrecursorIonCharge      = minPrecursorIonCharge,
                MaxPrecursorIonCharge      = maxPrecursorIonCharge,
                MinProductIonCharge        = minProductIonCharge,
                MaxProductIonCharge        = maxProductIonCharge,
                MinSequenceMass            = minSequenceMass,
                MaxSequenceMass            = maxSequenceMass,
                PrecursorIonTolerancePpm   = precursorIonTolerancePpm,
                ProductIonTolerancePpm     = productIonTolerancePpm,
                RunTargetDecoyAnalysisBool = tda,
                SearchModeInt = searchMode,
            };

            //topDownLauncher.ForceParallel = true;
            //topDownLauncher.MaxNumThreads = -1;

            topDownLauncher.RunSearch(0.7);
            //topDownLauncher.RunIntactProteinSearch();
        }
Exemple #3
0
        public static int Main(string[] args)
        {
            var errorCode = 0;

#if (!DEBUG)
            try
#endif
            {
                var handle = Process.GetCurrentProcess().MainWindowHandle;
                SetConsoleMode(handle, EnableExtendedFlags);

                var entryAsmName = System.Reflection.Assembly.GetEntryAssembly().GetName().Name;
                var parser       = new CommandLineParser <TopDownInputParameters>(entryAsmName, Version);
                parser.UsageExamples.Add(string.Format("Perform a target+decoy search with default parameters and a mods file:\n{0}.exe -s testfile.raw -d sampleProteins.fasta -mod mods.txt -tda 1", entryAsmName));
                // TODO: add more examples, maybe a link to GitHub?
                var results = parser.ParseArgs(args);
                if (!results.Success)
                {
                    // Wait for 1.5 seconds
                    System.Threading.Thread.Sleep(1500);
                    return(-3);
                }

                if (!results.ParsedResults.Validate())
                {
                    parser.PrintHelp();

                    // Wait for 1.5 seconds
                    System.Threading.Thread.Sleep(1500);

                    return(-3);
                }
                var parameters = results.ParsedResults;

                Console.WriteLine(Name + " " + Version);
                parameters.Display();

                parameters.MaxNumNTermCleavages = 1; // max number of N-term cleavages
                parameters.MaxNumCTermCleavages = 0; // max number of C-term cleavages

                foreach (var specFilePath in parameters.SpecFilePaths)
                {
                    // Update the spec file path in the parameters for each search
                    parameters.SpecFilePath = specFilePath;
                    parameters.Write();

                    var topDownLauncher = new IcTopDownLauncher(parameters);

                    var success = topDownLauncher.RunSearch();

                    if (success)
                    {
                        continue;
                    }

                    // topDownLauncher returned false (not successful)

                    // NOTE: The DMS Analysis Manager looks for this text; do not change it
                    var errorMsg = "Error processing " + Path.GetFileName(specFilePath) + ": ";

                    if (string.IsNullOrWhiteSpace(topDownLauncher.ErrorMessage))
                    {
                        errorMsg += "unknown error";
                    }
                    else
                    {
                        errorMsg += topDownLauncher.ErrorMessage;
                    }

                    Console.WriteLine(errorMsg);

                    if (errorCode == 0)
                    {
                        // This is the first error encountered; update the error code
                        // (though we will continue processing the next file if there is one)
                        errorCode = -Math.Abs(errorMsg.GetHashCode());
                        if (errorCode == 0)
                        {
                            return(-1);
                        }
                        else
                        {
                            return(errorCode);
                        }
                    }
                }
            }
#if (!DEBUG)
            catch (Exception ex)
            {
                // NOTE: The DMS Analysis Manager looks for this text; do not change it
                Console.WriteLine("Exception while processing: " + ex.Message);
                Console.WriteLine(ex.StackTrace);
                errorCode = -Math.Abs(ex.Message.GetHashCode());

                System.Threading.Thread.Sleep(1500);

                if (errorCode == 0)
                {
                    return(-1);
                }
                else
                {
                    return(errorCode);
                }
            }
#endif

            return(errorCode);
        }
Exemple #4
0
        public static int Main(string[] args)
        {
            var errorCode = 0;

#if (!DEBUG)
            try
            {
#endif

            var handle = Process.GetCurrentProcess().MainWindowHandle;
            SetConsoleMode(handle, EnableExtendedFlags);

            if (args.Length == 0)
            {
                PrintUsageInfo();
                return(-1);
            }

            if (args.Length % 2 != 0)
            {
                PrintUsageInfo("The number of arguments must be even");
                return(-1);
            }

            // initialize parameters
            var paramDic = new Dictionary <string, string>
            {
                { "-s", null },
                { "-d", null },
                { "-o", null },
                { "-m", "1" },
                { "-mod", null },
                { "-t", "10" },
                { "-f", "10" },
                { "-tda", "0" },
                { "-minLength", "21" },
                { "-maxLength", "300" },
                { "-minCharge", "2" },
                { "-maxCharge", "60" },
                { "-minFragCharge", "1" },
                { "-maxFragCharge", "20" },
                { "-minMass", "2000.0" },
                { "-maxMass", "50000.0" },
                { "-feature", null },
                { "-threads", "0" },
                { "-tagSearch", "1" },
            };


            for (var i = 0; i < args.Length / 2; i++)
            {
                var key   = args[2 * i];
                var value = args[2 * i + 1];
                if (!paramDic.ContainsKey(key))
                {
                    PrintUsageInfo("Invalid parameter: " + key);
                    return(-2);
                }
                paramDic[key] = value;
            }

            var parameters = new TopDownInputParameters();
            var message    = parameters.Parse(paramDic);
            if (message != null)
            {
                PrintUsageInfo(message);
                return(-3);
            }

            Console.WriteLine(Name + " " + Version);
            parameters.Display();
            parameters.Write();

            foreach (var specFilePath in parameters.SpecFilePaths)
            {
                var topDownLauncher = new IcTopDownLauncher(
                    specFilePath,
                    parameters.DatabaseFilePath,
                    parameters.OutputDir,
                    parameters.AminoAcidSet,
                    parameters.FeatureFilePath)
                {
                    MinSequenceLength        = parameters.MinSequenceLength,
                    MaxSequenceLength        = parameters.MaxSequenceLength,
                    MaxNumNTermCleavages     = 1, // max number of N-term cleavages
                    MaxNumCTermCleavages     = 0, // max number of C-term cleavages
                    MinPrecursorIonCharge    = parameters.MinPrecursorIonCharge,
                    MaxPrecursorIonCharge    = parameters.MaxPrecursorIonCharge,
                    MinProductIonCharge      = parameters.MinProductIonCharge,
                    MaxProductIonCharge      = parameters.MaxProductIonCharge,
                    MinSequenceMass          = parameters.MinSequenceMass,
                    MaxSequenceMass          = parameters.MaxSequenceMass,
                    PrecursorIonTolerancePpm = parameters.PrecursorIonTolerancePpm,
                    ProductIonTolerancePpm   = parameters.ProductIonTolerancePpm,
                    //RunTargetDecoyAnalysisBool = parameters.TdaBool,
                    RunTargetDecoyAnalysis = parameters.Tda,
                    //SearchModeInt = parameters.SearchModeInt,
                    SearchMode     = parameters.SearchMode,
                    MaxNumThreads  = parameters.MaxNumThreads,
                    TagBasedSearch = parameters.TagBasedSearch
                };

                var success = topDownLauncher.RunSearch();

                if (success)
                {
                    continue;
                }

                // topDownLauncher returned false (not successful)

                // NOTE: The DMS Analysis Manager looks for this text; do not change it
                var errorMsg = "Error processing " + Path.GetFileName(specFilePath) + ": ";

                if (string.IsNullOrWhiteSpace(topDownLauncher.ErrorMessage))
                {
                    errorMsg += "unknown error";
                }
                else
                {
                    errorMsg += topDownLauncher.ErrorMessage;
                }

                Console.WriteLine(errorMsg);

                if (errorCode == 0)
                {
                    // This is the first error encountered; update the error code
                    // (though we will continue processing the next file if there is one)
                    errorCode = -Math.Abs(errorMsg.GetHashCode());
                    if (errorCode == 0)
                    {
                        return(-1);
                    }
                    else
                    {
                        return(errorCode);
                    }
                }
            }

#if (!DEBUG)
        }

        catch (Exception ex)
        {
            // NOTE: The DMS Analysis Manager looks for this text; do not change it
            Console.WriteLine("Exception while processing: " + ex.Message);
            Console.WriteLine(ex.StackTrace);
            errorCode = -Math.Abs(ex.Message.GetHashCode());

            System.Threading.Thread.Sleep(1500);

            if (errorCode == 0)
            {
                return(-1);
            }
            else
            {
                return(errorCode);
            }
        }
#endif

            return(errorCode);
        }