Пример #1
0
        /// <summary>
        /// Base-Constructor. Performs the initalizations common to all experiments.
        /// </summary>
        /// <param name="wiffFile">A <see cref="FMANWiffFileClass"/> instance. The source from where to
        /// read the periods properties and data.</param>
        /// <param name="wiffPeriod">The <see cref="WiffPeriod"/> instance this experiment belongs to.</param>
        /// <param name="experimentIndex">The <b>zero-based</b> index of this experiment in the associated period.</param>
        public WiffExperiment(FMANWiffFileClass wiffFile, WiffPeriod wiffPeriod, int experimentIndex)
        {
            if (wiffFile == null)
            {
                throw new ArgumentNullException("wiffFile");
            }

            if (wiffPeriod == null)
            {
                throw new ArgumentNullException("wiffPeriod");
            }

            this.wiffPeriod = wiffPeriod;
            this.index      = experimentIndex;

            Initialize(wiffFile);
        }
Пример #2
0
 /// <summary>
 /// Constructor. Creates and initializes a Q1ScanExperiment instance.
 /// </summary>
 /// <param name="wiffFile">A <see cref="FMANWiffFileClass"/> instance. The source from where to
 /// read the periods properties and data.</param>
 /// <param name="wiffPeriod">The <see cref="WiffPeriod"/> instance this experiment belongs to.</param>
 /// <param name="experimentIndex">The <b>zero-based</b> index of this experiment in the associated period.</param>
 public Q1ScanExperiment(FMANWiffFileClass wiffFile, WiffPeriod wiffPeriod, int experimentIndex)
     : base(wiffFile, wiffPeriod, experimentIndex)
 {
 }
Пример #3
0
        // Private Methods (1) 

        /// <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)
        {
            // retrieve this sample's name
            name = wiffFile.GetSampleName(index);

            // 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
            {
                string     pathFile       = wiffFileContent.FileName + " (" + index.ToString() + ").path";
                FileStream positionStream = new FileStream(@pathFile, FileMode.Open, FileAccess.Read);

                // calculate the count of position entries
                positionDataLength = positionStream.Length / 12; // 12 Byte per position entry

                // the array to hold the position information
                positionData = new uint[positionDataLength, 3];
                BinaryReader positionReader = new BinaryReader(positionStream);
                for (long i = 0; i < positionDataLength; i++)
                {
                    positionData[i, 0] = positionReader.ReadUInt32();
                    positionData[i, 1] = positionReader.ReadUInt32();
                    positionData[i, 2] = positionReader.ReadUInt32();
                    if ((i % (positionDataLength / 100.0)) == 0) // hundred progress ticks
                    {
                        AppContext.ProgressSetValue(100.0 * i / positionDataLength);
                    }
                }

                positionReader.Close();
                positionStream.Close();
            }
            finally
            {
                AppContext.ProgressClear();
            }

#if (false)
            string csvPosFile = wiffFileContent.FileName + " (" + index.ToString() + ").path" + ".csv";
            using (FileStream csvPosStream = new FileStream(@csvPosFile, FileMode.Create, FileAccess.Write))
            {
                using (StreamWriter sw = new StreamWriter(csvPosStream))
                {
                    for (long i = 0; i < positionDataLength; i++)
                    {
                        sw.Write(positionData[i, 0]);
                        sw.Write(',');
                        sw.Write(positionData[i, 1]);
                        sw.Write(',');
                        sw.Write(positionData[i, 2]);
                        sw.WriteLine();
                    }
                }
            }
#endif


            // get user data of the selected sample
            string userData = wiffFile.GetUserData(index);

            if (!string.IsNullOrEmpty(userData))
            {
                //width in mm
                x2    = float.Parse(userData.Split(',')[2]);
                x1    = float.Parse(userData.Split(',')[0]);
                width = x2 - x1;

                //height in mm
                y2     = float.Parse(userData.Split(',')[3]);
                y1     = float.Parse(userData.Split(',')[1]);
                height = y2 - y1;
            }


            // get the number of periods
            int nrPeriods = wiffFile.GetActualNumberOfPeriods(index);

            // loop through the periods; the index of the periods is zero based!!
            for (int actPeriod = 0; actPeriod < nrPeriods; actPeriod++)
            {
                WiffPeriod period = new WiffPeriod(wiffFile, this, actPeriod);
                periods.Add(period);
            }
        }
        /// <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);
        }