Exemplo n.º 1
0
        public void TestWriteReal(params string[] paths)
        {
            var fullPaths       = new List <string>();
            var fullOutputPaths = new List <string>();

            foreach (var path in paths)
            {
                fullPaths.Add(GetPath(path));
                fullOutputPaths.Add(GetOutputPath(path));
            }
            var options = new Options();

            var analysisProcessor = new AnalysisJobProcessor(options);
            var individualJobs    = fullPaths.Select(path => new AnalysisJobItem(path, LcmsIdentificationTool.MsgfPlus)).ToList();
            var bWorker           = new BackgroundWorker();

            var jobs = analysisProcessor.Process(individualJobs, bWorker);

            var databaseProcess = new MtdbProcessor(options);

            var database = databaseProcess.Process(jobs.Select(job => job.DataSet).ToList(), bWorker);

            var writer = new SqLiteTargetDatabaseWriter();

            writer.Write(database, options, GetTestSuiteDataPath(@"Output.mtdb"));
        }
Exemplo n.º 2
0
        public void BackgroundWorker_DoWork(object sender, DoWorkEventArgs e)
        {
            mAbortRequested = false;
            ITargetDatabaseWriter targetDatabaseWriter = new SqLiteTargetDatabaseWriter();

            if (DatabaseOptions.DatabaseType != DatabaseType.Access)
            {
                targetDatabaseWriter = new SqLiteTargetDatabaseWriter();
            }
            else
            {
                targetDatabaseWriter = new AccessTargetDatabaseWriter();
            }
            targetDatabaseWriter.ProgressChanged += targetDatabaseWriter_ProgressChanged;
            targetDatabaseWriter.Write(Database, DatabaseOptions, DatabaseFileName);
        }
Exemplo n.º 3
0
        public void TestWriteDatabase(string path, int numberOfTargets, int numberOfEvidences)
        {
            var reader        = new SqLiteTargetDatabaseWriter();
            var options       = new Options();
            var database      = new TargetDatabase();
            var proteinCount  = 1;
            var evidenceCount = 1;

            for (var i = 1; i <= numberOfTargets; i++)
            {
                var target = new ConsensusTarget {
                    Id = i
                };

                var protein = new ProteinInformation
                {
                    ProteinName   = "SO_Test" + proteinCount++,
                    CleavageState = clsPeptideCleavageStateCalculator.ePeptideCleavageStateConstants.Full,
                    TerminusState = clsPeptideCleavageStateCalculator.ePeptideTerminusStateConstants.ProteinNTerminus,
                };
                protein.Consensus.Add(target);

                for (var j = 1; j <= numberOfEvidences; j++)
                {
                    var evidence = new Evidence
                    {
                        AnalysisId   = j,
                        Charge       = 1,
                        Id           = evidenceCount,
                        CleanPeptide = "MIKEDEGAN" + evidenceCount,
                        Sequence     = "BIGBIRD" + evidenceCount,
                        Mz           = 405,
                        Scan         = evidenceCount++,
                        PeptideInfo  = new TargetPeptideInfo()
                    };

                    evidence.AddProtein(protein);
                    target.AddEvidence(evidence);
                }
                target.AddProtein(protein);
                target.CalculateStatistics();
                database.ConsensusTargets.Add(target);
            }
            reader.Write(database, options, GetTestSuiteDataPath(path));
        }
Exemplo n.º 4
0
        /// <summary>
        /// Create a MTDB with the given files
        /// </summary>
        /// <param name="paths">Paths to the files to process</param>
        /// <param name="dbFileName">Name of MTDB to create</param>
        /// <returns></returns>
        public static TargetDatabase CreateDB(List <string> paths, string dbFileName)
        {
            var options           = new Options();
            var analysisProcessor = new AnalysisJobProcessor(options);
            var mtdbProcessor     = new MtdbProcessor(options);
            var bWorker           = new BackgroundWorker();
            var writer            = new SqLiteTargetDatabaseWriter();

            var reader           = new SqLiteTargetDatabaseReader();
            var existingDatabase = new TargetDatabase();

            IEnumerable <LcmsDataSet> priorDataSets = new List <LcmsDataSet>();

            if (File.Exists(dbFileName))
            {
                priorDataSets    = reader.Read(dbFileName);
                existingDatabase = reader.ReadDb(dbFileName);
            }
            var priorDatasetList = priorDataSets.Select(x => x.Name).ToList();
            var listJobs         = new List <AnalysisJobItem>();

            foreach (var path in paths)
            {
                if (File.Exists(path))
                {
                    var tool    = DetermineTool(path);
                    var jobName = path.Split('\\').Last();
                    if (tool == LcmsIdentificationTool.NOT_SUPPORTED)
                    {
                        Console.WriteLine(jobName + " is not a supported LCMS format for MTDBCreator;\nExcluding this file from MTDB creation\n");
                    }
                    else if (priorDatasetList.Any(x => jobName.Contains(x)))
                    {
                        Console.WriteLine(jobName + " is part of prior analysis;\nExcluding from reading portion of MTDB creation\n");
                    }
                    else
                    {
                        var individualJob = new AnalysisJobItem(path, tool);
                        listJobs.Add(individualJob);
                    }
                }
                else
                {
                    Console.WriteLine(path + " does not exist;\nExcluding this file in MTDB creation\n");
                }
            }
            if (listJobs.Count != 0)
            {
                var processedjobs = analysisProcessor.Process(listJobs, bWorker);

                var datasetList = processedjobs.Select(job => job.DataSet).ToList();
                if (priorDataSets != null)
                {
                    datasetList.AddRange(priorDataSets);
                }
                var database = mtdbProcessor.Process(datasetList, bWorker);

                writer.Write(database, options, dbFileName);

                return(database);
            }

            return(existingDatabase);
        }