public IEnumerable<UMCLight> TestUmcFeatures(string path)
        {
            var reader = new MsFeatureLightFileReader {Delimeter = ","};
            var newMsFeatures = reader.ReadFile(path);

            var finder = new UmcTreeFeatureFinder
            {
                MaximumNet = .005,
                MaximumScan = 50
            };
            var tolerances = new FeatureTolerances
            {
                Mass = 8,
                Net = .005
            };
            var options = new LcmsFeatureFindingOptions(tolerances);
            var features = finder.FindFeatures(newMsFeatures.ToList(), options, null);

            // Work on total feature count here.
            Assert.Greater(features.Count, 0);

            return features;
        }
        public void TestUmcFeaturesMultipleCharges(string path, string rawPath, int maxScanDiff)
        {
            var reader = new MsFeatureLightFileReader {Delimeter = ","};
            var newMsFeatures = reader.ReadFile(path);
            var finder = new UmcTreeFeatureFinder();
            var featureTolerances = new FeatureTolerances
            {
                Mass = 12,
                Net = .05
            };
            var options = new LcmsFeatureFindingOptions(featureTolerances)
            {
                MaximumNetRange = .002,
                MaximumScanRange = 50
            };

            var provider = RawLoaderFactory.CreateFileReader(rawPath);
            provider.AddDataFile(rawPath, 0);

            var start = DateTime.Now;
            IEnumerable<UMCLight> features = finder.FindFeatures(newMsFeatures.ToList(), options, provider);
            var end = DateTime.Now;
            Console.WriteLine(@"Test Took: " + end.Subtract(start).TotalSeconds);

            if (features == null)
                throw new NullReferenceException("The feature list came back empty.  This is a problem.");

            var dirPath = Path.GetDirectoryName(path);
            if (dirPath != null)
                using (
                    var writer =
                        File.CreateText(Path.Combine(dirPath, Path.GetFileName(path).Replace("_isos.csv", "_xics.csv")))
                    )
                {
                    foreach (var feature in features)
                    {
                        writer.WriteLine();
                        writer.WriteLine("Feature {0}", feature.Id);
                        var chargeMap = feature.CreateChargeMap();

                        if (chargeMap.Keys.Count < 2)
                            continue;

                        foreach (var charge in chargeMap.Keys)
                        {
                            writer.WriteLine();
                            foreach (var msFeature in chargeMap[charge])
                            {
                                var count = msFeature.MSnSpectra.Count;
                                writer.WriteLine("{0},{1},{2},{3},{4}", charge, msFeature.Mz, msFeature.Scan,
                                    msFeature.Abundance, count);
                            }
                        }

                        var charges = chargeMap.Keys.ToList();

                        for (var i = 0; i < charges.Count; i++)
                        {
                            for (var j = i; j < charges.Count; j++)
                            {
                                var x = chargeMap[charges[i]];
                                var y = chargeMap[charges[j]];

                                var diff = x.MinScan() - y.MinScan();
                                if (diff > maxScanDiff)
                                {
                                    throw new Exception(
                                        "There is a problem with the feature finder across charge states");
                                }
                            }
                        }
                    }
                }

            // Work on total feature count here.
            Assert.Greater(features.Count(), 0);
        }
        public void TestUmcFeatures(string relativePath, string relativeRawPath)
        {
            // Get absolute paths
            var path = GetPath(relativePath);
            var rawPath = GetPath(relativeRawPath);

            var reader = new MsFeatureLightFileReader { Delimiter = ',' };
            var newMsFeatures = reader.ReadFile(path);
            var finder = new UmcTreeFeatureFinder();
            var featureTolerances = new FeatureTolerances
            {
                Mass = 12,
                Net = .04
            };
            var options = new LcmsFeatureFindingOptions(featureTolerances)
            {
                MaximumNetRange = .003,
                MaximumScanRange = 50
            };

            var provider = RawLoaderFactory.CreateFileReader(rawPath);
            provider.AddDataFile(rawPath, 0);

            var start = DateTime.Now;
            IEnumerable<UMCLight> features = finder.FindFeatures(newMsFeatures.ToList(), options, provider);
            var end = DateTime.Now;
            Console.WriteLine(@"Test Took: " + end.Subtract(start).TotalSeconds);

            if (features == null)
                throw new NullReferenceException("The feature list came back empty.  This is a problem.");

            var dirPath = Path.GetDirectoryName(path);
            if (dirPath != null)
                using (
                    var writer =
                        File.CreateText(Path.Combine(dirPath, Path.GetFileName(path).Replace("_isos.csv", "_xics.csv")))
                    )
                {
                    foreach (var feature in features)
                    {
                        writer.WriteLine();
                        writer.WriteLine("Feature {0}", feature.Id);
                        var chargeMap = feature.CreateChargeMap();
                        foreach (var charge in chargeMap.Keys)
                        {
                            writer.WriteLine();
                            foreach (var msFeature in chargeMap[charge])
                            {
                                var count = msFeature.MSnSpectra.Count;
                                writer.WriteLine("{0},{1},{2},{3},{4}", charge, msFeature.Mz, msFeature.Scan,
                                    msFeature.Abundance, count);
                            }
                        }
                    }
                }

            // Work on total feature count here.
            Assert.Greater(features.Count(), 0);
        }