Esempio n. 1
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;

        }
Esempio n. 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();
        }