Exemplo n.º 1
0
        /// <summary>
        /// I wrote this when the program crashed after an hour.
        /// Intermediate results can now be saved to avoid losing data.
        /// </summary>
        private static ResultClusterer TryLoadIntermediateResult(Core core, Guid guid, int value, int repetition, ProgressReporter proggy)
        {
            string fileName = UiControls.GetTemporaryFile("." + value + "." + repetition + ".intermediate.dat", guid);

            if (!File.Exists(fileName))
            {
                return(null);
            }

            LookupByGuidSerialiser guidS = core.GetLookups();

            proggy.Enter("Loading saved results");
            ResultClusterer result;

            try
            {
                result = XmlSettings.LoadOrDefault <ResultClusterer>(new FileDescriptor(fileName, SerialisationFormat.MSerialiserFastBinary), null, guidS, proggy);
            }
            catch
            {
                proggy.Leave(); // Result will probably be NULL rather than throwing an exception
                return(null);
            }

            UiControls.Assert(!guidS.HasLookupTableChanged, "Didn't expect the GUID lookup table to change when loading data.");
            proggy.Leave();

            return(result);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Gets object GUIDs (prior to partial (de)serialisation)
        /// </summary>
        public LookupByGuidSerialiser GetLookups()
        {
            if (this._guids == null)
            {
                this._guids = new Dictionary <Guid, WeakReference>();
            }

            LookupByGuidSerialiser result = new LookupByGuidSerialiser(this._guids);

            result.Add(typeof(Peak), LookupByGuidSerialiser.ETypeBehaviour.Default);
            result.Add(typeof(Compound), LookupByGuidSerialiser.ETypeBehaviour.Default);
            result.Add(typeof(Pathway), LookupByGuidSerialiser.ETypeBehaviour.Default);
            result.Add(typeof(Adduct), LookupByGuidSerialiser.ETypeBehaviour.Default);
            result.Add(typeof(PeakFilter), LookupByGuidSerialiser.ETypeBehaviour.Default);
            result.Add(typeof(ObsFilter), LookupByGuidSerialiser.ETypeBehaviour.Default);
            result.Add(typeof(ConfigurationCorrection), LookupByGuidSerialiser.ETypeBehaviour.Default);
            result.Add(typeof(ConfigurationStatistic), LookupByGuidSerialiser.ETypeBehaviour.Default);
            //result.Add(typeof(ConfigurationClusterer), LookupByGuidSerialiser.ETypeBehaviour.Default); <-- Don't add these because they can be temporary
            result.Add(typeof(ConfigurationTrend), LookupByGuidSerialiser.ETypeBehaviour.Default);
            result.Add(typeof(GroupInfo), LookupByGuidSerialiser.ETypeBehaviour.Default);
            result.Add(typeof(ObservationInfo), LookupByGuidSerialiser.ETypeBehaviour.Default);
            result.Add(typeof(ObservationInfo), LookupByGuidSerialiser.ETypeBehaviour.Default);

            return(result);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Retrieves and sets object GUIDs (after partial serialisation)
        /// </summary>
        /// <returns>If anything has changed</returns>
        public bool SetLookups(LookupByGuidSerialiser src)
        {
            if (src.HasLookupTableChanged)
            {
                src.GetLookupTable(this._guids);
                return(true);
            }

            return(false);
        }
Exemplo n.º 4
0
        /// <summary>
        /// Loads results from file.
        /// </summary>
        public static ClusterEvaluationResults LoadResults(Core core, string fileName, ProgressReporter z)
        {
            LookupByGuidSerialiser   guidS = core.GetLookups();
            ClusterEvaluationResults set;

            set = XmlSettings.LoadOrDefault <ClusterEvaluationResults>(fileName, null, guidS, z);

            if (set != null)
            {
                if (set.CoreGuid != core.CoreGuid)
                {
                    throw new InvalidOperationException("Wrong Session - The result set selected was not created using the current session. In order to view these results you must load the relevant session.\r\n\r\nCurrent session: " + core.CoreGuid + "\r\nResults session: " + set.CoreGuid);
                }
            }

            return(set);
        }
Exemplo n.º 5
0
        /// <summary>
        /// I wrote this when the program crashed after an hour.
        /// Intermediate results can now be saved to avoid losing data.
        /// </summary>
        private static void SaveIntermediateResult(Core core, Guid guid, int value, int repetition, ResultClusterer result, ProgressReporter proggy)
        {
            string fileName = UiControls.GetTemporaryFile("." + value + "." + repetition + ".intermediate.dat", guid);

            LookupByGuidSerialiser guidS = core.GetLookups();

            proggy.Enter("Saving intermediate results");
            XmlSettings.Save <ResultClusterer>(new FileDescriptor(fileName, SerialisationFormat.MSerialiserFastBinary), result, guidS, proggy);

            if (core.SetLookups(guidS))
            {
                // UIDs have changed
                SaveSession(core, proggy);
            }

            proggy.Leave();
        }
Exemplo n.º 6
0
        /// <summary>
        /// Saves results to file
        ///
        /// Returns pointer (unless originalPointer is NULL, in which case the action is assumed to be an export and is ignored).
        /// </summary>
        private static ClusterEvaluationPointer SaveResults(Core core, string fileName, ClusterEvaluationPointer originalPointer, ClusterEvaluationResults results, ProgressReporter proggy)
        {
            LookupByGuidSerialiser guidS = core.GetLookups();

            proggy.Enter("Saving results");
            XmlSettings.Save <ClusterEvaluationResults>(fileName, results, guidS, proggy);

            if (core.SetLookups(guidS))
            {
                // UIDs have changed
                SaveSession(core, proggy);
            }

            proggy.Leave();

            if (originalPointer == null)
            {
                return(null);
            }

            return(new ClusterEvaluationPointer(fileName, originalPointer.Configuration));
        }