示例#1
0
 /// <summary>
 ///     Default constructor.
 /// </summary>
 public AlgorithmBuilder()
 {
     m_provider = new AlgorithmProvider();
 }
        public void ClusterFeatures()
        {
            
            this.algorithms = this.builder.GetAlgorithmProvider(this.options);
            var clusterer = this.algorithms.Clusterer;
            clusterer.Parameters = LcmsClusteringOptions.ConvertToOmics(this.options.LcmsClusteringOptions);
            this.featureCache = this.analysis.DataProviders.FeatureCache;

            // This just tells us whether we are using mammoth memory partitions or not.          
            var clusterCount = 0;
            var providers = this.analysis.DataProviders;

            // Here we see if we need to separate the charge...
            // IMS is said to require charge separation 
            if (!this.analysis.Options.LcmsClusteringOptions.ShouldSeparateCharge)
            {
                var features = this.featureCache.FindAll();
                var clusters = new List<UMCClusterLight>();
                clusters = clusterer.Cluster(features, clusters);
                foreach (var cluster in clusters)
                {
                    cluster.Id = clusterCount++;
                    cluster.UmcList.ForEach(x => x.ClusterId = cluster.Id);

                    // Updates the cluster with statistics
                    foreach (var feature in cluster.UmcList)
                    {
                        cluster.MsMsCount += feature.MsMsCount;
                        cluster.IdentifiedSpectraCount += feature.IdentifiedSpectraCount;
                    }
                }
                providers.ClusterCache.AddAll(clusters);
                providers.FeatureCache.UpdateAll(features);
                this.analysis.Clusters = clusters;
            }
            else
            {
                var maxChargeState = this.featureCache.FindMaxCharge();

                /*
                 * Here we cluster all charge states separately.  Probably IMS Data.
                 */
                for (var chargeState = 1; chargeState <= maxChargeState; chargeState++)
                {
                    var features = this.featureCache.FindByCharge(chargeState);
                    if (features.Count < 1)
                    {
                        break;
                    }

                    var clusters = clusterer.Cluster(features);
                    foreach (var cluster in clusters)
                    {
                        cluster.Id = clusterCount++;
                        cluster.UmcList.ForEach(x => x.ClusterId = cluster.Id);

                        // Updates the cluster with statistics
                        foreach (var feature in cluster.Features)
                        {
                            cluster.MsMsCount += feature.MsMsCount;
                            cluster.IdentifiedSpectraCount += feature.IdentifiedSpectraCount;
                        }
                    }

                    this.analysis.DataProviders.ClusterCache.AddAll(clusters);
                    this.analysis.DataProviders.FeatureCache.UpdateAll(features);
                }
                this.analysis.Clusters = this.analysis.DataProviders.ClusterCache.FindAll();
            }

            MessageBox.Show("Working Command");
        }
        private void AlignToBaseline()
        {
            if (this.SelectedBaseline != null && this.SelectedBaseline.Dataset.FeaturesFound)
            {
                //Update algorithms and providers
                this.featureCache.Providers = this.analysis.DataProviders;
                this.algorithms = this.builder.GetAlgorithmProvider(this.analysis.Options);
                this.aligner.m_algorithms = this.algorithms;

                var baselineFeatures = this.featureCache.LoadDataset(this.selectedBaseline.Dataset, this.analysis.Options.MsFilteringOptions,
                    this.analysis.Options.LcmsFindingOptions, this.analysis.Options.LcmsFilteringOptions);
                var alignmentData = new AlignmentDAOHibernate();
                alignmentData.ClearAll();

                this.SelectedBaseline.IsAligning = true;
                var selectedFiles = this.selectedDatasets.Where(file => !file.DoingWork).ToList();
                foreach (var file in selectedFiles)
                {
                    file.IsAligning = true;
                }

                foreach (var file in selectedFiles)
                {
                    ThreadSafeDispatcher.Invoke(() => this.AlignToBaselineCommand.RaiseCanExecuteChanged());
                    ThreadSafeDispatcher.Invoke(() => this.DisplayAlignmentCommand.RaiseCanExecuteChanged());
                    if (file.Dataset.IsBaseline || !file.FeaturesFound)
                    {
                        file.IsAligned = true;
                        file.IsAligning = false;
                        continue;
                    }
                    var features = this.featureCache.LoadDataset(file.Dataset, this.analysis.Options.MsFilteringOptions,
                        this.analysis.Options.LcmsFindingOptions, this.analysis.Options.LcmsFilteringOptions);
                    var alignment = this.aligner.AlignToDataset(ref features, baselineFeatures, file.Dataset, this.selectedBaseline.Dataset);
                    //Check if there is information from a previous alignment for this dataset. If so, replace it. If not, just add the new one.
                    var priorAlignment = from x in this.alignmentInformation where x.DatasetID == alignment.DatasetID select x;
                    if (priorAlignment.Any())
                    {
                        this.alignmentInformation.Remove(priorAlignment.Single());
                        this.alignmentInformation.Add(alignment);
                    }
                    else
                    {
                        this.alignmentInformation.Add(alignment);
                    }

                    this.featureCache.CacheFeatures(features);
                    file.IsAligned = true;
                    file.IsAligning = false;
                    ThreadSafeDispatcher.Invoke(() => this.AlignToBaselineCommand.RaiseCanExecuteChanged());
                    ThreadSafeDispatcher.Invoke(() => this.DisplayAlignmentCommand.RaiseCanExecuteChanged());
                }

                this.SelectedBaseline.IsAligning = false;
            }
            else
            {
                MessageBox.Show("Please select a baseline with detected features.");
            }
        }
 /// <summary>
 ///     Default constructor.
 /// </summary>
 public MultiAlignAnalysisProcessor()
 {
     m_algorithms = null;
     CreateAnalysisMethodMap();
 }
示例#5
0
 /// <summary>
 ///     Default constructor.
 /// </summary>
 public MultiAlignAnalysisProcessor()
 {
     m_algorithms = null;
     CreateAnalysisMethodMap();
 }
示例#6
0
 /// <summary>
 ///     Default constructor.
 /// </summary>
 public AlgorithmBuilder()
 {
     m_provider = new AlgorithmProvider();
 }