コード例 #1
0
ファイル: MainSettings.cs プロジェクト: mjr129/metaboclust
        private void SaveLoad(bool save, EFlags flags)
        {
            ProgressReporter prog = ProgressReporter.GetEmpty(); // too fast to warrent dialogue

            if (flags.Has(EFlags.DoNotShowAgain))
            {
                XmlSettings.SaveLoad(save, FileId.DoNotShowAgain, ref this.DoNotShowAgain, null, prog);
            }
            if (flags.Has(EFlags.RecentSessions))
            {
                XmlSettings.SaveLoad(save, FileId.RecentSessions, ref this.RecentSessions, null, prog);
            }
            if (flags.Has(EFlags.RecentWorkspaces))
            {
                XmlSettings.SaveLoad(save, FileId.RecentWorkspaces, ref this.RecentWorkspaces, null, prog);
            }
            if (flags.Has(EFlags.General))
            {
                XmlSettings.SaveLoad(save, FileId.General, ref this.General, null, prog);
            }
            if (flags.Has(EFlags.FileLoadInfo))
            {
                XmlSettings.SaveLoad(save, FileId.FileLoadInfo, ref this.FileLoadInfo, null, prog);
            }
        }
コード例 #2
0
ファイル: ResultClusterer.cs プロジェクト: mjr129/metaboclust
        /// <summary>
        /// Determines what needs calculating.
        /// </summary>
        private void Thread_AddFilterToCalculationList([Const] Core core, [Const] ConfigurationMetric metric, [Const] IntensityMatrix vmatrix, [Const] DistanceMatrix dmatrix, [Const] EClustererStatistics statistics, [Const] Cluster[] realClusters, [Const] ObsFilter obsFilter, [MutableUnsafe] List <ForStat> needsCalculating, [MutableSafe] ProgressParallelHandler progP)
        {
            progP.SafeIncrement();

            IntensityMatrix vmatFiltered;
            DistanceMatrix  dmatFiltered;

            int[] filteredIndices;

            if (obsFilter == null)
            {
                vmatFiltered    = vmatrix;
                dmatFiltered    = dmatrix;
                filteredIndices = null;
            }
            else
            {
                filteredIndices = vmatrix.Columns.Which(z => obsFilter.Test(z.Observation)).ToArray();  // TODO: Multuple iteration
                vmatFiltered    = vmatrix.Subset(null, obsFilter, ESubsetFlags.None);
                dmatFiltered    = null;
            }

            Dictionary <Cluster, IReadOnlyList <double> > centreVectors = new Dictionary <Cluster, IReadOnlyList <double> >();

            foreach (Cluster cluster in realClusters)
            {
                /////////////////////
                // ASSIGNMENT STATS
                var centre = cluster.GetCentre(ECentreMode.Average, ECandidateMode.Assignments);
                IReadOnlyList <double> centreVector = centre.Count != 0 ? centre[0] : null;

                if (filteredIndices != null)
                {
                    centreVector = centreVector.Extract(filteredIndices);
                }

                centreVectors.Add(cluster, centreVector);
            }

            foreach (Assignment ass in Assignments)
            {
                ForStat f = new ForStat();
                f.Assignment = ass;
                f.ObsFilter  = obsFilter;

                if (filteredIndices != null)
                {
                    f.AssignmentVector = vmatFiltered.Vectors[ass.Vector.Index];
                }
                else
                {
                    f.AssignmentVector = ass.Vector;
                }

                f.ClusterVector = centreVectors[ass.Cluster];

                if (statistics.HasFlag(EClustererStatistics.SilhouetteWidth))
                {
                    if (dmatFiltered == null)
                    {
                        dmatFiltered = DistanceMatrix.Create(core, vmatrix, metric, ProgressReporter.GetEmpty());
                    }
                }

                f.DistanceMatrix = dmatFiltered;

                lock (needsCalculating)
                {
                    needsCalculating.Add(f);
                }
            }
        }