Exemplo n.º 1
0
        public void TestUmcFeatures(string path)
        {
            var reader = new MSFeatureLightFileReader {
                Delimeter = ","
            };
            var newMsFeatures = reader.ReadFile(path);
            var finder        = new UMCFeatureFinder();
            var options       = new LCMSFeatureFindingOptions
            {
                AveMassWeight               = .01f,
                ConstraintAveMass           = 6,
                ConstraintMonoMass          = 6,
                FitWeight                   = .1f,
                IsIsotopicFitFilterInverted = false,
                IsotopicFitFilter           = .15,
                IsotopicIntensityFilter     = 0,
                LogAbundanceWeight          = .1f,
                MaxDistance                 = .1,
                MinUMCLength                = 3,
                MonoMassWeight              = .01f,
                NETWeight                   = .1f,
                ScanWeight                  = .01f,
                UMCAbundanceReportingType   = AbundanceReportingType.Max,
                UseIsotopicFitFilter        = true,
                UseIsotopicIntensityFilter  = false,
                UseNET = true
            };
            var start = DateTime.Now;
            var umcs  = finder.FindFeatures(newMsFeatures.ToList(), options, null);
            var end   = DateTime.Now;

            Console.WriteLine(end.Subtract(start).TotalSeconds);
            Assert.Greater(umcs.Count, 0);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Finds LCMS Features using the PNNL Omics linkage clustering algorithms.
        /// </summary>
        public List <UMCLight> FindFeatures(List <MSFeatureLight> rawMsFeatures,
                                            LCMSFeatureFindingOptions options,
                                            ISpectraProvider provider)
        {
            const ClusterCentroidRepresentation centroidType = ClusterCentroidRepresentation.Mean;
            List <UMCLight> features = null;

            m_options = options;

            m_minScan = int.MaxValue;
            m_maxScan = int.MinValue;
            foreach (var feature in rawMsFeatures)
            {
                m_minScan = Math.Min(feature.Scan, m_minScan);
                m_maxScan = Math.Max(feature.Scan, m_maxScan);
            }

            var finder = new MSFeatureSingleLinkageClustering <MSFeatureLight, UMCLight>
            {
                Parameters =
                {
                    DistanceFunction = WeightedNETDistanceFunction,
                    RangeFunction    = WithinRange,
                    Tolerances       = { Mass = options.ConstraintMonoMass, RetentionTime = 100, DriftTime = 100 }
                }
            };

            finder.Parameters.CentroidRepresentation = centroidType;
            m_maxDistance = options.MaxDistance;
            features      = finder.Cluster(rawMsFeatures);

            // Remove the short UMC's.
            features.RemoveAll(x => (x.ScanEnd - x.ScanStart + 1) < options.MinUMCLength);

            var id = 0;

            foreach (var feature in features)
            {
                feature.NET           = Convert.ToDouble(feature.Scan - m_minScan) / Convert.ToDouble(m_maxScan - m_minScan);
                feature.RetentionTime = feature.NET;
                feature.ID            = id++;
            }

            return(features);
        }