コード例 #1
0
ファイル: RunTest.cs プロジェクト: PNNL-Comp-Mass-Spec/PIXIE
        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);
        }
コード例 #2
0
ファイル: RunTest.cs プロジェクト: PNNL-Comp-Mass-Spec/PIXIE
        public static void SerializerDeserializerTest()
        {
            IList<CrossSectionWorkflowResult> results = new List<CrossSectionWorkflowResult>();

            // create fake result 1
            IdentifiedIsomerInfo holyGrail1 = new IdentifiedIsomerInfo(10, 250, 6, 10, 22, 4, null, 5, AnalysisStatus.Positive, new PeakScores(1,2,3), new MolecularTarget("C2H34", IonizationMethod.APCI, "Carbon"), 1, 2);
            PeakScores averageFeatureScores1 = new PeakScores(3, 4, 5);

            IImsTarget target1 = new MolecularTarget("C2H5OH", IonizationMethod.Deprotonated, "Ginger ale");
            IImsTarget target2 = new MolecularTarget("C2H5OH", IonizationMethod.Sodiumated, "Volka");

            CrossSectionWorkflowResult result1 = new CrossSectionWorkflowResult(
                "France", 
                target1,
                AnalysisStatus.Positive,
                null,averageFeatureScores1,
                4,
                "",
                "");

            results.Add(result1);

            // Serialize fake result struct
            IFormatter formatter = new BinaryFormatter();
            using (Stream stream = new FileStream("serialized_result.bin", FileMode.Create, FileAccess.Write, FileShare.None))
            {
                formatter.Serialize(stream, results);
            }

            IList<CrossSectionWorkflowResult> newResults;

            // deserialize fake result struct
            using (Stream stream = new FileStream("serialized_result.bin", FileMode.Open, FileAccess.Read, FileShare.Read))
            {
                newResults = (IList<CrossSectionWorkflowResult>)formatter.Deserialize(stream);
            }

            CrossSectionWorkflowResult result2 = newResults.First();

            // Compare it
            var result = newResults.First();
            Assert.AreEqual(result.AnalysisStatus, result1.AnalysisStatus);
            Assert.AreEqual(result.DatasetName, result2.DatasetName);
            Assert.AreEqual(result.AverageObservedPeakStatistics.IntensityScore, result2.AverageObservedPeakStatistics.IntensityScore);
        }
コード例 #3
0
 public static bool FilterOnRelativeIntensity(IdentifiedIsomerInfo feature, double highestIntensities)
 {
     return true;
 }
コード例 #4
0
 public static bool FilterOnPpmError(IdentifiedIsomerInfo feature, double ppmTolerance)
 {
     return (Math.Abs(feature.MzInPpm) < ppmTolerance);
 }
コード例 #5
0
        /// <summary>
        /// The export identified isomer info.
        /// </summary>
        /// <param name="viperCompatibleMass">
        /// The viper compatible mass.
        /// </param>
        /// <param name="minFitPoints">
        /// The min fit points.
        /// </param>
        /// <param name="minR2">
        /// The min r 2.
        /// </param>
        /// <param name="target"></param>
        /// <returns>
        /// The <see cref="IdentifiedIsomerInfo"/>.
        /// </returns>
        public IdentifiedIsomerInfo ExportIdentifiedIsomerInfo(double viperCompatibleMass, int minFitPoints, double minR2, IImsTarget target, double bestMzInPpm)
        {
            double averageVoltageGroupStabilityScore = VoltageGroupScoring.ComputeAverageVoltageGroupStabilityScore(this.definedVoltageGroups);

            IList<ArrivalTimeSnapShot> snapshots = new List<ArrivalTimeSnapShot>();
            foreach (var observation in this.observedPeaks)
            {
                snapshots.Add(this.ExtractArrivalTimeSnapShot(observation));
            }

            IdentifiedIsomerInfo info = new IdentifiedIsomerInfo(
                this.observedPeaks.Count,
                this.AverageMzInDalton,
                this.mobilityInfo.RSquared,
                this.mobilityInfo.Mobility,
                this.mobilityInfo.CollisionCrossSectionArea,
                averageVoltageGroupStabilityScore,
                snapshots,
                viperCompatibleMass,
                this.ConcludeStatus(minFitPoints, minR2),
                this.TrackStatistics,
                target,
                this.mobilityInfo.T0,
                bestMzInPpm
                );
            return info;
        }
コード例 #6
0
 private async Task<long> InsertIdentifications(SQLiteCommand cmd, IdentifiedIsomerInfo result, long analysisID)
 {
         cmd.CommandText = "INSERT INTO identifications (detection_analysis , measured_mz_in_dalton, ppm_error, viper_compatible_mz, r2 , analysis_status, intensity_score , peak_shape_score , isotopic_score , collision_cross_section, mobility, t0, relative_ppm) VALUES      (@detection_analysis , @measured_mz_in_dalton, @ppm_error, @viper_compatible_mz, @r2, @analysis_status, @intensity_score, @peak_shape_score, @isotopic_score, @collision_cross_section, @mobility, @t0, @relative_ppm)";
         cmd.Parameters.AddWithValue("@detection_analysis", analysisID);
         cmd.Parameters.AddWithValue("@measured_mz_in_dalton", result.MzInDalton);
         cmd.Parameters.AddWithValue("@ppm_error", result.MzInPpm);
         cmd.Parameters.AddWithValue("@viper_compatible_mz", result.ViperCompatibleMass);
         cmd.Parameters.AddWithValue("@r2", result.RSquared);
         cmd.Parameters.AddWithValue("@analysis_status", result.AnalysisStatus.ToString());
         cmd.Parameters.AddWithValue("@intensity_score", result.PeakScores.IntensityScore);
         cmd.Parameters.AddWithValue("@peak_shape_score", result.PeakScores.PeakShapeScore);
         cmd.Parameters.AddWithValue("@isotopic_score", result.PeakScores.IsotopicScore);
         cmd.Parameters.AddWithValue("@collision_cross_section", result.CrossSectionalArea);
         cmd.Parameters.AddWithValue("@mobility", result.Mobility);
         cmd.Parameters.AddWithValue("@t0", result.T0);
         cmd.Parameters.AddWithValue("@relative_ppm", result.RelativeMzInPpm);
         await Task.Run(() => cmd.ExecuteNonQuery());
         return await this.LastID(cmd);
 }
コード例 #7
0
        /// <summary>
        /// The fuse isomer result.
        /// </summary>
        /// <param name="A">
        /// The a.
        /// </param>
        /// <param name="B">
        /// The b.
        /// </param>
        /// <param name="weightA">
        /// The weight a.
        /// </param>
        /// <param name="weightB">
        /// The weight b.
        /// </param>
        /// <returns>
        /// The <see cref="IdentifiedIsomerInfo"/>.
        /// </returns>
        private static IdentifiedIsomerInfo FuseIsomerResult(IdentifiedIsomerInfo A, IdentifiedIsomerInfo B, double weightA, double weightB)
        {
            double sum = weightA + weightB;
            weightB /= sum;
            weightA /= sum;

            IEnumerable<ArrivalTimeSnapShot> arivalTimeSnapShots = A.ArrivalTimeSnapShots.Concat(B.ArrivalTimeSnapShots);

            int numberOfFeaturePointsUsed = A.NumberOfFeaturePointsUsed + B.NumberOfFeaturePointsUsed;

            IdentifiedIsomerInfo newIsomer = new IdentifiedIsomerInfo(
                numberOfFeaturePointsUsed,
                (A.MzInDalton + B.MzInDalton) / 2,
                A.RSquared * weightA + B.RSquared * weightB,
                A.Mobility * weightA + B.Mobility * weightB,
                A.CrossSectionalArea * weightA + B.CrossSectionalArea * weightB,
                A.AverageVoltageGroupStabilityScore * weightA + B.AverageVoltageGroupStabilityScore * weightB,
                arivalTimeSnapShots,
                A.ViperCompatibleMass  + B.ViperCompatibleMass,
                A.AnalysisStatus,
                null,
                null, A.T0 * weightA + B.T0 * weightB,
                A.RelativeMzInPpm * weightA + B.RelativeMzInPpm * weightB);

            return newIsomer;
        }
コード例 #8
0
        /// <summary>
        /// The check conflict.
        /// </summary>
        /// <param name="A">
        /// The a.
        /// </param>
        /// <param name="B">
        /// The b.
        /// </param>
        /// <returns>
        /// The <see cref="bool"/>.
        /// </returns>
        private static bool CheckConflict(IdentifiedIsomerInfo A, IdentifiedIsomerInfo B)
        {
            if (Math.Abs(A.CrossSectionalArea - B.CrossSectionalArea) > CollisionCrossSectionTolerance)
            {
                return true;
            }

            return false;
        }