Ejemplo n.º 1
0
        public static List <Feature> GetAllFeaturesFromDatabase(SQLiteConnection conn)
        {
            List <Feature> returnFeatures = new List <Feature>();
            var            queryText      =
                "SELECT s.mz, s.ApexRT, s.ApexIntensity, s.ID_Number, s.SmoothFeatureString, s.RawFeatureString FROM featureTable s";
            var queryCommand = new SQLiteCommand(queryText, conn);
            var reader       = queryCommand.ExecuteReader();

            while (reader.Read())
            {
                var           apexRT       = double.Parse(reader["ApexRT"].ToString());
                var           mz           = double.Parse(reader["mz"].ToString());
                var           id           = int.Parse(reader["ID_Number"].ToString());
                var           smoothString = reader["SmoothFeatureString"].ToString();
                var           rawString    = reader["RawFeatureString"].ToString();
                List <RTPeak> smoothPeaks  = ConvertFeatureStringToPeakList(smoothString);
                List <RTPeak> rawPeaks     = ConvertFeatureStringToPeakList(rawString);
                var           feat         = new Feature();
                feat.ApexTime  = apexRT;
                feat.AverageMZ = mz;
                feat.ID_Number = id;
                foreach (var peak in rawPeaks)
                {
                    feat.AddPeak(peak);
                }
                foreach (var peak in smoothPeaks)
                {
                    feat.AddSmoothPeak(peak);
                }
                returnFeatures.Add(feat);
                //feat.ApexTime = apexRT;
                feat.AverageMZ = mz;
            }
            return(returnFeatures);
        }
Ejemplo n.º 2
0
        public static List <Feature> GetFeatures(string name, SQLiteConnection conn, double minTime, double maxTime)
        {
            var queryText    = "SELECT s.ID, s.mz, s.Name, s.ApexRT, s.ApexIntensity, s.SmoothFeatureString FROM featureTable s WHERE s.Name=@Name AND s.ApexRT<@Max AND s.ApexRT>@Min";
            var queryCommand = new SQLiteCommand(queryText, conn);

            queryCommand.Parameters.AddWithValue("@Name", name);
            queryCommand.Parameters.AddWithValue("@Min", minTime);
            queryCommand.Parameters.AddWithValue("@Max", maxTime);

            List <Feature> returnFeatures = new List <Feature>();

            var reader = queryCommand.ExecuteReader();

            while (reader.Read())
            {
                var      id            = reader["ID"].ToString();
                double   mz            = double.Parse(reader["mz"].ToString());
                var      apexRT        = double.Parse(reader["ApexRT"].ToString());
                var      apexIntensity = double.Parse(reader["ApexIntensity"].ToString());
                var      featString    = reader["SmoothFeatureString"].ToString();
                string[] parts         = featString.Split('|');
                //double mz = double.Parse(parts[0]);
                //double rt = double.Parse(parts[1]);
                string[] peaks   = parts[0].Split(';');
                var      feature = new Feature();
                // feature.AverageMZ = mz;
                feature.ApexTime = apexRT;
                foreach (var peak in peaks)
                {
                    if (!string.IsNullOrEmpty(peak))
                    {
                        string[] peakParts = peak.Split(',');
                        double   time      = double.Parse(peakParts[0]);
                        double   intensity = double.Parse(peakParts[1]);
                        var      newPeak   = new RTPeak(mz, intensity, time);
                        feature.AddSmoothPeak(newPeak);
                        if (Math.Round(newPeak.RT, 3) == Math.Round(apexRT, 3))
                        {
                            feature.totalIntensity += newPeak.Intensity;
                        }
                    }
                }
                feature.AverageMZ    = mz;
                feature.maxIntensity = apexIntensity;
                returnFeatures.Add(feature);
            }
            return(returnFeatures);
        }
Ejemplo n.º 3
0
        public IEnumerable <Feature> GetSubFeatures(Feature feature, List <int> apexIndexes)
        {
            List <Feature> returnList = new List <Feature>();

            foreach (int apexIndex in apexIndexes)
            {
                double threshold  = feature.SmoothRTPeaks[apexIndex].Intensity * 0.99;
                int    leftIndex  = GetLeftStopIndex(apexIndex, feature.SmoothRTPeaks, threshold);
                int    rightIndex = GetRightStopIndex(apexIndex, feature.SmoothRTPeaks, threshold);

                Feature newFeature = new Feature();
                newFeature.ApexTime = feature.SmoothRTPeaks[apexIndex].RT;
                for (int i = leftIndex; i <= rightIndex; i++)
                {
                    newFeature.AddSmoothPeak(feature.SmoothRTPeaks[i]);
                }
                yield return(newFeature);
            }
        }