InsertResult() public method

Insert a single result
public InsertResult ( CrossSectionWorkflowResult result ) : System.Threading.Tasks.Task
result ImsInformed.Workflows.CrossSectionExtraction.CrossSectionWorkflowResult
return System.Threading.Tasks.Task
Example #1
0
        public async static void AnalysisDBTest()
        {
            var snapshot1 = new ArrivalTimeSnapShot();
            snapshot1.DriftTubeVoltageInVolt = 1000;
            snapshot1.MeasuredArrivalTimeInMs = 22;
            snapshot1.PressureInTorr = 4;
            snapshot1.TemperatureInKelvin = 10;
            var iso1 = new IdentifiedIsomerInfo(2 ,222, 0.9, 10.5, 115, 123, new List<ArrivalTimeSnapShot>(){snapshot1}, 100, AnalysisStatus.Positive, new PeakScores(1.0, 0.8, 0.7), new MolecularTarget("C2H4O16P2", IonizationMethod.Protonated, "testamin"), 0.1, 0);
            var idens = new List<IdentifiedIsomerInfo>() {iso1};
            
            PeakScores scores = new PeakScores(0, 0.5, 1);
            CrossSectionWorkflowResult result1 = new CrossSectionWorkflowResult("ABC_Dataset_01", new MolecularTarget("C2H4O16P2", IonizationMethod.Protonated, "testamin"), AnalysisStatus.Positive, new AssociationHypothesisInfo(0.1, 0.2), scores, 0.5, OutputFileDir, "123");
            CrossSectionWorkflowResult result2 = new CrossSectionWorkflowResult("ABC_Dataset_02", new MolecularTarget("C2H4O16P2", IonizationMethod.Protonated, "testamin"), AnalysisStatus.Positive, new AssociationHypothesisInfo(0.1, 0.4), scores, 0.8, OutputFileDir, "123");
            CrossSectionWorkflowResult result3 = new CrossSectionWorkflowResult("ABC_Dataset_03", new MolecularTarget("C2H4O16P2", IonizationMethod.Deprotonated, "testamin"), AnalysisStatus.Positive, new AssociationHypothesisInfo(0.1, 0.4), idens, scores, 0.8, OutputFileDir, "123");
            CrossSectionWorkflowResult result4 = new CrossSectionWorkflowResult("ABC_Dataset_03", new MolecularTarget("C2H4O16P2", IonizationMethod.Sodiumated, "testamin"), AnalysisStatus.Positive, new AssociationHypothesisInfo(0.1, 0.4), idens, scores, 0.8, OutputFileDir, "123");
            CrossSectionWorkflowResult result5 = new CrossSectionWorkflowResult("ABC_Dataset_03", new MolecularTarget("C10H40", IonizationMethod.Protonated, "googlin"), AnalysisStatus.Positive, new AssociationHypothesisInfo(0.1, 0.4), idens, scores, 0.8, OutputFileDir, "123");
            CrossSectionWorkflowResult result6 = new CrossSectionWorkflowResult("ABC_Dataset_03", new MolecularTarget("C10H40", IonizationMethod.Protonated, "googlin"), AnalysisStatus.Negative, null, idens, scores, 0.8, OutputFileDir, "123");

            string fileName = @"output\test.sqlite";
            AnalysisLibrary lib = new AnalysisLibrary(fileName);
            await lib.CreateTables();
            await lib.InsertResult(result1);
            await lib.InsertResult(result2);
            await lib.InsertResult(result3);
            await lib.InsertResult(result4);
            await lib.InsertResult(result5);
            await lib.InsertResult(result6);
        }
        /// <summary>
        /// process result files collected and generate the CCS/mz DB.
        /// </summary>
        /// <param name="analysisDirectory">
        /// The analysis directory.
        /// </param>
        /// <exception cref="Exception">
        /// </exception>
        public void ProcessResultFiles(string analysisDirectory, AnalysisLibrary lib)
        {
            long count = 0;
            long totalTasks = this.Tasks.Count();

            foreach (ImsInformedProcess task in this.Tasks)
            {
                // Deserialize the results and dispatch them into lookup tables.
                try
                {
                    IList<CrossSectionWorkflowResult> results = task.DeserializeResultBinFile();

                    AsyncHelpers.RunSync(() => lib.InsertResult(results));
                    count++;
                    Console.WriteLine("Number of results processed: {0}/{1}", count, totalTasks);
                    Console.SetCursorPosition(0, Console.CursorTop - 1);
                    // Dispose the task as it is no longer used.
                    task.Dispose();
                }
                catch (Exception e)
                {
                    Console.WriteLine("Result processing for {0} failed", task.DataSetName);
                    Console.WriteLine("Exception: {0}", e.Message);
                    Console.WriteLine(string.Empty);
                }
            }

            this.empty = false;
        }