Beispiel #1
0
        /// <summary>
        /// Fills this instance data members with the information read from <paramref name="wiffFile"/>.
        /// </summary>
        /// <param name="wiffFile">A <see cref="FMANWiffFileClass"/> instance. The data source.</param>
        private void Initialize(FMANWiffFileClass wiffFile)
        {
            //get the number of cycles
            cycles = wiffFile.GetActualNumberOfCycles(sample.Index, index);

            // get the period object
            Period period = (Period)wiffFile.GetPeriodObject(sample.Index, index);

            // get the cycle time
            cycleTime = period.CycleTime;

            // get number of experiments
            int nrExperiments = wiffFile.GetNumberOfExperiments(sample.Index, index);

            // loop through the experiments; the index of the experiments is zero based!!
            for (int actExperiment = 0; actExperiment < nrExperiments; actExperiment++)
            {
                WiffExperiment experiment = WiffExperimentFactory.CreateWiffExperiment(wiffFile, this, actExperiment);
                experiments.Add(experiment);
            }
        }
Beispiel #2
0
        /// <summary>
        /// Fills this instance data members with the information read from <paramref name="wiffFile"/>.
        /// </summary>
        /// <param name="wiffFile">A <see cref="Batch"/> instance. The data source.</param>
        private void Initialize(Batch wiffFile)
        {
            Sample sample = wiffFile.GetSample(this.index);

            // retrieve this sample's name
            this.name = sample.Details.SampleName;

            // get the position information for the selected sample the position data exists
            // in a seperate file ( one per sample ) and is read from that file 'manually'
            AppContext.ProgressStart("reading path file");
            try
            {
                // 1) Set the various WiffSample Parameters
                string pathFile = this.wiffFileContent.FileName + " (" + (this.index + 1).ToString(CultureInfo.InvariantCulture) + ").path";

                // Make sure the path file exists
                if (!File.Exists(pathFile))
                {
                    MessageBox.Show(pathFile + " is missing", "Missing File");
                    return;
                }

                var positionStream = new FileStream(@pathFile, FileMode.Open, FileAccess.Read);

                // calculate the count of position entries (12 bytes per position entry)
                this.positionDataLength = positionStream.Length / 12;

                this.x1 = 1e10;
                this.x2 = 0.0;
                this.y1 = 1e10;
                this.y2 = 0.0;

                // the array to hold the position information
                this.positionData = new uint[this.positionDataLength, 3];
                var positionReader = new BinaryReader(positionStream);
                for (long posindex = 0; posindex < this.positionDataLength; posindex++)
                {
                    this.positionData[posindex, 0] = positionReader.ReadUInt32();
                    this.positionData[posindex, 1] = positionReader.ReadUInt32();
                    this.positionData[posindex, 2] = positionReader.ReadUInt32();

                    // hundred progress ticks
                    if (Equals(posindex % (this.positionDataLength / 100.0), 0.0))
                    {
                        AppContext.ProgressSetValue(100.0 * posindex / this.positionDataLength);
                    }

                    if (this.positionData[posindex, 1] < this.x1)
                    {
                        this.x1 = this.positionData[posindex, 1];
                    }

                    if (this.positionData[posindex, 1] > this.x2)
                    {
                        this.x2 = this.positionData[posindex, 1];
                    }

                    if (this.positionData[posindex, 2] < this.y1)
                    {
                        this.y1 = this.positionData[posindex, 2];
                    }

                    if (this.positionData[posindex, 2] > this.y2)
                    {
                        this.y2 = this.positionData[posindex, 2];
                    }
                }

                positionReader.Close();
                positionStream.Close();

                this.x1 /= 1000;
                this.x2 /= 1000;
                this.y1 /= 1000;
                this.y2 /= 1000;

                this.width  = this.x2 - this.x1;
                this.height = this.y2 - this.y1;
            }
            finally
            {
                AppContext.ProgressClear();
            }

            // 2) Get the size of the scan file  set scanfilesize
            string scanpathFile = this.wiffFileContent.FileName + ".scan";
            var    fileinfo     = new FileInfo(scanpathFile);

            this.scanfilesize = fileinfo.Length;

            MassSpectrometerSample massSpecSample = sample.MassSpectrometerSample;
            int numberOfExperiments = massSpecSample.ExperimentCount;

            // 3) Get number of experiments and create WiffExperiments for each
            // loop through the experiments; the index of the experiments is zero based!!
            for (int actExperiment = 0; actExperiment < numberOfExperiments; actExperiment++)
            {
                MSExperiment msexperiment = massSpecSample.GetMSExperiment(actExperiment);

                WiffExperiment experiment = WiffExperimentFactory.CreateWiffExperiment(msexperiment, this);

                this.experiments.Add(experiment);
            }
        }