예제 #1
0
        /// <summary>
        /// Name:        FindExperiment
        /// Description: This function will find the experimental data (in the form of a list) that matches the given experimental code.
        /// </summary>
        /// <param name="experimentCode">
        /// Input:       The experimentCode is a code that can reference a given experiment that is in the current opened mz data file.
        /// </param>
        /// <returns>
        /// Output:      The output is a List of ActualElement, where actual elements are containers with all possible data that can be in the current file.
        /// </returns>
        public List <ActualElement> FindExperiment(int experimentCode)
        {
            //Initialize a new experimentalData list to return.
            List <ActualElement> experimentData = new List <ActualElement>();

            //update the new experimentCode to the inputed experiment code, so we can get the right Parent Ion number.
            this.m_experimentCode = experimentCode;

            if (this.m_isFileOpened)
            {
                //We need to Cache the entire file into memory (which puts it into MZList) to look at the data in the file.
                m_fileToRead.ReadAndCacheEntireFile();

                //narrow the number of Spectrums down to all the data sets that match the experimentCode.
                bool result = m_fileToRead.GetSpectrumByScanNumber(m_experimentCode, ref m_currentSpectrum);
                this.m_mZIndex = 0;

                //We will run through each data that is in memory and convert that data into
                //  an ActualElement structure and then all the element to the experimentData List.
                while (m_mZIndex < this.m_currentSpectrum.MZList.Count())
                {
                    ActualElement inputForList = new ActualElement();
                    inputForList.MZValue   = this.m_currentSpectrum.MZList[m_mZIndex];
                    inputForList.Intensity = (double)this.m_currentSpectrum.LookupIonIntensityByMZ(inputForList.MZValue, (float)0, (float)0.04);
                    experimentData.Add(inputForList);
                    ++m_mZIndex;
                }
            }
            return(experimentData);
        }
예제 #2
0
 /// <summary>
 /// The constructor of this parser will attempt to open any files that
 /// end in ".mzXML" or ".mzData".  If a null string is passed in or a
 /// a string without a ".mzXML" or ".mzData" file extension then an exception
 /// will be thrown.
 /// </summary>
 /// <param name="fileLocation">This must be a file Location to a ".mzXML" or ".mzData" file.</param>
 public MzParser(string fileLocation)
 {
     this.m_fileLocation = fileLocation;
     if (m_fileLocation != null)
     {
         if (m_fileLocation.ToLower().EndsWith(".mzXML".ToLower()) ||
             m_fileLocation.ToLower().EndsWith(".mzData".ToLower()))
         {
             m_fileToRead = new clsMzXMLFileAccessor();
             m_fileOpened = m_fileToRead.OpenFile(m_fileLocation);
         }
         else
         {
             throw new System.InvalidProgramException("Invalid File Type, must be .mzXML or .mzData");
         }
         m_fileToRead.ReadAndCacheEntireFile();
     }
     else
     {
         throw new System.InvalidOperationException("The file location passed was equal to null");
     }
 }