/// <summary>
        /// Determines with what kind of experiment we're dealing with and instatiates
        /// an object of the accurate subclass derived from the abstract baseclass
        /// <see cref="WiffExperiment"/>.
        /// </summary>
        /// <param name="wiffFile">A <see cref="FMANWiffFileClass"/> instance. The source from where to
        /// read the experiments properties and data.</param>
        /// <param name="wiffPeriod">The <see cref="WiffPeriod"/> instance this the experiment belongs to.</param>
        /// <param name="experimentIndex">The <b>zero-based</b> index of the experiment in the associated period.</param>
        /// <returns>The newly created, <see cref="WiffExperiment"/> dirived object.</returns>
        public static WiffExperiment CreateWiffExperiment(FMANWiffFileClass wiffFile, WiffPeriod wiffPeriod, int experimentIndex)
        {
            Experiment experiment = (Experiment)wiffFile.GetExperimentObject(wiffPeriod.Sample.Index, wiffPeriod.Index, experimentIndex);
            // get scan type
            short          scanType      = experiment.ScanType;
            WiffExperiment theExperiment = null;

            switch (scanType)
            {
            case 0:     // Q1 scan
            {
                theExperiment = new Q1ScanExperiment(wiffFile, wiffPeriod, experimentIndex);
            }
            break;

            case 1:     // Q1 MI scan
            case 2:     // Q3 scan
            case 3:     // Q3 MI scan
                break;

            case 4:     // MRM scan
            {
                theExperiment = new MRMScanExperiment(wiffFile, wiffPeriod, experimentIndex);
            }
            break;

            case 5:     // precursor scan
            case 6:     // product ion scan
            case 7:     // neural loss scan
                break;

            default:
            {
                // TODO -- Check if this is really, really intended...
                theExperiment = new MRMScanExperiment(wiffFile, wiffPeriod, experimentIndex);
            }
            break;
            }

            return(theExperiment);
        }
Exemple #2
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);
            }
        }
Exemple #3
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);
            }
        }