Beispiel #1
0
        public static binStack[] genIndex(DataView _quiXMLv,
                                          string rawPath,
                                          int scansbyframe,
                                          BinStackOptions options)
        {
            int numMatches = _quiXMLv.Count;
            int numFrames  = countFrames(_quiXMLv, scansbyframe);

            int numRawFiles;
            //LookupCollection RawFilesColl = countRawFiles(fileXml, out numRawFiles);
            LookupCollection RawFilesColl = countRawFiles(_quiXMLv, out numRawFiles);

            //create index
            binStack[] stackIndex = new binStack[numRawFiles];

            //fill rawfilenames in the index
            ArrayList rawFilesKeys   = (ArrayList)RawFilesColl.Keys;
            ArrayList rawFilesValues = (ArrayList)RawFilesColl.Values;

            for (int i = 0; i < numRawFiles; i++)
            {
                stackIndex[i]             = new binStack((int)rawFilesValues[i]);
                stackIndex[i].rawFileName = rawFilesKeys[i].ToString();
            }

            fillScans(stackIndex, _quiXMLv, options);

            //share out the spectra amongst the frames
            int currFrame       = 1;
            int currScanofFrame = 1;

            for (int i = 0; i < numRawFiles; i++)
            {
                for (int j = 0; j <= stackIndex[i].scan.GetUpperBound(0); j++)
                {
                    stackIndex[i].scan[j].frame = currFrame;
                    currScanofFrame++;
                    if (currScanofFrame > scansbyframe)
                    {
                        currFrame++;
                        currScanofFrame = 1;
                    }
                }
            }


            //WARNING: very dangerous change, but necessary to maintain old binstacks: in currFrame
            //         we swap the values of scanNumber by spectrumIndex (once we have obtained the desired
            //         spectrum, we use the unique index (spectrumIndex).



            return(stackIndex);
        }
Beispiel #2
0
        private static void fillScans(binStack[] stackIndex,
                                      DataView dv,
                                      BinStackOptions options)
        {
            double protonMass = 1.007276466812;  // source: http://physics.nist.gov/cgi-bin/cuu/Value?mpu

            //associate the dataset to a dataview
            string filter = "";

            scanIndexStrt newScan       = new scanIndexStrt();
            int           spectrumIndex = 0;

            for (int i = 0; i <= stackIndex.GetUpperBound(0); i++)
            {
                filter       = "RAWFileName = '" + stackIndex[i].rawFileName.Trim() + "'";
                dv.RowFilter = filter;

                for (int j = 0; j < dv.Count; j++)
                {
                    int firstScan = int.Parse(dv[j]["FirstScan"].ToString());
                    newScan.scanNumbers[0] = firstScan;
                    newScan.FirstScan      = firstScan;
                    newScan.spectrumIndex  = spectrumIndex;
                    dv[j]["spectrumIndex"] = spectrumIndex;

                    if (!(options.averagingMethod == averagingMethod.mostIntense ||
                          options.averagingMethod == averagingMethod.none))
                    {
                        newScan.peakStart = int.Parse(dv[j]["PeakStart"].ToString());
                        newScan.peakEnd   = int.Parse(dv[j]["PeakEnd"].ToString());
                    }

                    spectrumIndex++;

                    if (options.useParentalMass)
                    {
                        try
                        {
                            int charge = int.Parse(dv[j]["Charge"].ToString());
                            newScan.parentMass = double.Parse(dv[j]["PrecursorMass"].ToString());
                            newScan.parentMass = (newScan.parentMass + (charge - 1) * protonMass) / charge;
                        }
                        catch { }
                    }

                    stackIndex[i].insert(newScan);
                }
            }
        }
Beispiel #3
0
        private void createBinStackBtn_Click(object sender, EventArgs e)
        {
            options = new BinStackOptions();

            if (quiXMLtxt.Text.Trim() == "")
            {
                MessageBox.Show("No QuiXML selected", "Error");
                return;
            }
            if (schemaTxt.Text.Trim() == "")
            {
                MessageBox.Show("No QuiXML schema selected", "Error");
                return;
            }

            if (specFolderTxt.Text.Trim() == "")
            {
                MessageBox.Show("No spectra folder selected", "Error");
                return;
            }
            //if (specTypeBox.Text.Trim() == "")
            //{
            //    MessageBox.Show("No spectrum type selected", "Error");
            //    return;
            //}

            //if (posBox.Text == "")
            //{
            //    MessageBox.Show("No spectrum position selected", "Error");
            //    return;
            //}

            if (parentalMassChb.Checked && parentalMassTxt.Text == "")
            {
                MessageBox.Show("No parental mass selected", "Error");
                return;
            }


            options.mode = adquisitionMode.position;

            //foreach (spectrumPositions sp in specPositionsChoose)
            //{
            //    if (posBox.Text == sp.ToString())
            //    {
            //        options.spectrumPos = sp;
            //        break;
            //    }
            //}
            options.spectrumPos = spectrumPositions.same;


            //foreach (spectrumTypes spt in spectrumTypesChoose)
            //{
            //    if (specTypeBox.Text == spt.ToString())
            //    {
            //        options.spectrumType = spt;
            //        break;
            //    }
            //}
            options.spectrumType = spectrumTypes.ZoomScan;



            if (parentalMassChb.Checked)
            {
                options.useParentalMass = true;

                foreach (massUnits mu in massUnitsChoose)
                {
                    if (massUnitsCmb.Text == mu.ToString())
                    {
                        options.parentalMassUnits = mu;
                        break;
                    }
                }
                try
                {
                    options.parentalMass = float.Parse(parentalMassTxt.Text.Trim(), CultureInfo.InvariantCulture.NumberFormat);
                }
                catch
                {
                    MessageBox.Show("Parental mass is not valid (not a number)", "Error");
                    return;
                }
            }

            int  scannumber    = 0;
            bool tryScanNumber = int.TryParse(scanNumberResTxt.Text, out scannumber);

            if (!tryScanNumber)
            {
                MessageBox.Show("Scan number is not an integer!", "Error");
                return;
            }

            options.individualRow = false;

            options.split_chars = (char[])split_chars.Clone();
            options.scanField   = scanField;


            genStack(specFolderTxt.Text.Trim(), options);
        }
Beispiel #4
0
        private void genStack(string rawPath,
                              BinStackOptions options)
        {
            Application.DoEvents();
            string schemaFile = schemaTxt.Text.Trim();

            try
            {
                this.statusLabel.Text    = "Generating binaries stack... Creating index...";
                this.statusLabel.Visible = true;

                string idFileXml        = this.quiXMLtxt.Text.Trim();
                string stackIndexFolder = idFileXml.Substring(0, idFileXml.LastIndexOf(@"\")) + "\\binStack\\";
                string stackIndexFile   = stackIndexFolder + "index.idx";
                if (!Directory.Exists(stackIndexFolder))
                {
                    Directory.CreateDirectory(stackIndexFolder);
                }

                //scans by frame
                int scbyframe = 100;

                //calculate number of frames
                int inumFrames = binStack.countFrames(idFileXml, scbyframe);

                //MessageBox.Show(inumFrames.ToString());

                //generate index
                binStack[] stackIndex = binStack.genIndex(idFileXml, schemaFile, rawPath, scbyframe, options);



                //Dangerous thing: we swap the values of FirstScan and spectrumIndex at the binStack


                //generate and save frames
                for (int i = 1; i <= inumFrames; i++)
                {
                    Application.DoEvents();
                    this.statusLabel.Text = "Generating binaries stack... generating frame " + i.ToString() + "/" + inumFrames.ToString();
                    binFrame        currFrame = binStack.genFrame(stackIndex, i, scbyframe, rawPath, options);
                    string          frameFile = stackIndexFolder + currFrame.frame.ToString() + ".bfr";
                    FileStream      qFr       = new FileStream(frameFile, FileMode.Create, FileAccess.Write);
                    BinaryFormatter bFr       = new BinaryFormatter();
                    bFr.Serialize(qFr, currFrame);
                    qFr.Close();
                }


                //Save index
                //WARNING: very dangerous change, but necessary to maintain old binstacks: in currFrame
                //         we swap the values of scanNumber by spectrumIndex (once we have obtained the desired
                //         spectrum, we use the unique index (spectrumIndex).
                for (int i = stackIndex.GetLowerBound(0); i <= stackIndex.GetUpperBound(0); i++)
                {
                    for (int j = stackIndex[i].scan.GetLowerBound(0); j <= stackIndex[i].scan.GetUpperBound(0); j++)
                    {
                        int scanNumber_t = stackIndex[i].scan[j].FirstScan;
                        stackIndex[i].scan[j].FirstScan = stackIndex[i].scan[j].spectrumIndex;

                        //this is not necessary, but I want to maintain the scanNumber elsewhere...
                        stackIndex[i].scan[j].spectrumIndex = scanNumber_t;
                    }
                }

                FileStream      q = new FileStream(stackIndexFile, FileMode.Create, FileAccess.Write);
                BinaryFormatter b = new BinaryFormatter();
                b.Serialize(q, stackIndex);
                q.Close();
            }
            catch
            {
                MessageBox.Show("Unable to generate binaries stack");
                this.statusLabel.Text    = "";
                this.statusLabel.Visible = false;
                return;
            }

            this.statusLabel.Text    = "";
            this.statusLabel.Visible = false;

            MessageBox.Show("BinStack successfully created!!");
        }
Beispiel #5
0
        public static binFrame genFrame(binStack[] stackIndex, int frame, int scansbyframe, string rawPath, BinStackOptions options)
        {
            binFrame currFrame = new binFrame(scansbyframe);

            currFrame.frame = frame;

            int currScanofFrame = 0;

            for (int j = 0; j <= stackIndex.GetUpperBound(0); j++)
            {
                for (int k = 0; k <= stackIndex[j].scan.GetUpperBound(0); k++)
                {
                    if (currFrame.frame == stackIndex[j].scan[k].frame)
                    {
                        currFrame.scan[currScanofFrame].rawFileName   = stackIndex[j].rawFileName;
                        currFrame.scan[currScanofFrame].scanNumber    = stackIndex[j].scan[k].FirstScan;
                        currFrame.scan[currScanofFrame].parentMass    = stackIndex[j].scan[k].parentMass;
                        currFrame.scan[currScanofFrame].spectrumIndex = stackIndex[j].scan[k].spectrumIndex;
                        currScanofFrame++;
                    }
                }
            }

            int nRawsinFrame;
            LookupCollection rawsinFrame = RawFilesinFrame(currFrame, out nRawsinFrame);

            DA_raws[] tRawList       = new DA_raws[nRawsinFrame];
            ArrayList rawFilesKeys   = (ArrayList)rawsinFrame.Keys;
            ArrayList rawFilesValues = (ArrayList)rawsinFrame.Values;

            for (int i = 0; i < nRawsinFrame; i++)
            {
                tRawList[i] = new DA_raws((int)rawFilesValues[i]);

                tRawList[i].rawFile = rawFilesKeys[i].ToString();

                for (int j = tRawList[i].scan.GetLowerBound(0); j <= tRawList[i].scan.GetUpperBound(0); j++)
                {
                    tRawList[i].scan[j].rawFileName = rawFilesKeys[i].ToString();
                }
            }

            for (int i = 0; i <= currFrame.scan.GetUpperBound(0); i++)
            {
                for (int j = tRawList.GetLowerBound(0); j <= tRawList.GetUpperBound(0); j++)
                {
                    if (currFrame.scan[i].rawFileName != null)
                    {
                        if (currFrame.scan[i].rawFileName.Trim() == tRawList[j].rawFile.Trim())
                        {
                            for (int k = tRawList[j].scan.GetLowerBound(0); k <= tRawList[j].scan.GetUpperBound(0); k++)
                            {
                                if (tRawList[j].scan[k].scanNumber == 0)
                                {
                                    tRawList[j].scan[k].scanNumber    = currFrame.scan[i].scanNumber;
                                    tRawList[j].scan[k].parentMass    = currFrame.scan[i].parentMass;
                                    tRawList[j].scan[k].spectrumIndex = currFrame.scan[i].spectrumIndex;
                                    break;
                                }
                            }
                        }
                    }
                }
            }

            for (int i = 0; i < nRawsinFrame; i++)
            {
                int[] scansRawList = new int[tRawList[i].scan.GetLength(0)];

                double[] parentMassList;
                if (options.useParentalMass)
                {
                    parentMassList = new double[tRawList[i].scan.GetLength(0)];
                }
                else
                {
                    parentMassList = null;
                }

                for (int j = 0; j <= scansRawList.GetUpperBound(0); j++)
                {
                    scansRawList[j] = tRawList[i].scan[j].scanNumber; //These are the MSMS identified spectra
                    if (options.useParentalMass)
                    {
                        parentMassList[j] = tRawList[i].scan[j].parentMass;
                    }
                }
                int          t           = tRawList[i].size();
                string       rawFileName = tRawList[i].rawFile;
                DA_raw       daRaw1      = new DA_raw();
                Comb.mzI[][] scansRaw    = daRaw1.ReadScanRaw(rawPath, rawFileName, scansRawList, parentMassList, options);
                daRaw1 = null;

                for (int j = 0; j <= scansRawList.GetUpperBound(0); j++)
                {
                    if (scansRaw[j] != null)
                    {
                        tRawList[i].scan[j].spectrum    = (Comb.mzI[])scansRaw[j];
                        tRawList[i].scan[j].rawFileName = tRawList[i].rawFile;
                    }
                }
            }

            for (int i = currFrame.scan.GetLowerBound(0); i <= currFrame.scan.GetUpperBound(0); i++)
            {
                for (int j = tRawList.GetLowerBound(0); j <= tRawList.GetUpperBound(0); j++)
                {
                    if (currFrame.scan[i].rawFileName != null)
                    {
                        if (currFrame.scan[i].rawFileName.Trim() == tRawList[j].rawFile.Trim())
                        {
                            for (int k = tRawList[j].scan.GetLowerBound(0); k <= tRawList[j].scan.GetUpperBound(0); k++)
                            {
                                if (currFrame.scan[i].spectrumIndex == tRawList[j].scan[k].spectrumIndex)
                                {
                                    currFrame.scan[i].spectrum = tRawList[j].scan[k].spectrum;
                                    break;
                                }
                            }
                            break;
                        }
                    }
                }
            }

            //WARNING: very dangerous change, but necessary to maintain old binstacks: in currFrame
            //         we swap the values of scanNumber by spectrumIndex (once we have obtained the desired
            //         spectrum, we use the unique index (spectrumIndex).

            for (int i = currFrame.scan.GetLowerBound(0); i <= currFrame.scan.GetUpperBound(0); i++)
            {
                int scanNumber_t = currFrame.scan[i].scanNumber;
                currFrame.scan[i].scanNumber = currFrame.scan[i].spectrumIndex;

                //this is not necessary, but I want to maintain the scanNumber elsewhere...
                currFrame.scan[i].spectrumIndex = scanNumber_t;
            }


            return(currFrame);
        }
Beispiel #6
0
        private static void fillScans(binStack[] stackIndex, string fileXml, string schemaFile, BinStackOptions options)
        {
            DataSet ds = new DataSet();

            ds.ReadXmlSchema(schemaFile);
            ds.ReadXml(fileXml);

            DataView dv = new DataView(ds.Tables["peptide_match"]);

            scanIndexStrt newScan       = new scanIndexStrt();
            int           spectrumIndex = 1;

            for (int i = 0; i <= stackIndex.GetUpperBound(0); i++)
            {
                for (int j = 0; j < dv.Count; j++)
                {
                    String RAWfilename = dv[j]["RAWFileName"].ToString().Trim();
                    if (RAWfilename == stackIndex[i].rawFileName.Trim())
                    {
                        int firstscan = int.Parse(dv[j]["FirstScan"].ToString(), CultureInfo.InvariantCulture.NumberFormat);
                        newScan.FirstScan      = firstscan;
                        newScan.spectrumIndex  = spectrumIndex;
                        dv[j]["spectrumIndex"] = spectrumIndex;


                        if (options.useParentalMass)
                        {
                            try
                            {
                                int charge = int.Parse(dv[j]["Charge"].ToString(), CultureInfo.InvariantCulture.NumberFormat);

                                newScan.parentMass = (double)dv[j]["PrecursorMass"];
                                newScan.parentMass = (newScan.parentMass + charge) / charge;
                            }
                            catch { }
                        }

                        stackIndex[i].insert(newScan);

                        spectrumIndex++;
                    }
                }
            }

            //Save the QuiXML with the new index (spectrumIndex)
            DataSet dsSave = new DataSet();

            dsSave = ds.Copy();
            try
            {
                dsSave.WriteXml(fileXml);
            }
            catch
            {
                FileInfo f = new FileInfo(fileXml);

                string quiXMLfilenew = f.DirectoryName + "\\" + f.Name + "_binStackProcessed" + f.Extension;
                dsSave.WriteXml(quiXMLfilenew);
            }
        }
Beispiel #7
0
        public static binStack[] genIndex(string fileXml, string schemaFile, string rawPath, int scansbyframe, BinStackOptions options)
        {
            int numMatches = countMatches(fileXml);

            int numFrames = countFrames(fileXml, scansbyframe);

            int numRawFiles;
            LookupCollection RawFilesColl = countRawFiles(fileXml, out numRawFiles);

            //create index
            binStack[] stackIndex = new binStack[numRawFiles];

            //fill rawfilenames in the index
            ArrayList rawFilesKeys   = (ArrayList)RawFilesColl.Keys;
            ArrayList rawFilesValues = (ArrayList)RawFilesColl.Values;

            for (int i = 0; i < numRawFiles; i++)
            {
                stackIndex[i]             = new binStack((int)rawFilesValues[i]);
                stackIndex[i].rawFileName = rawFilesKeys[i].ToString();
            }
            fillScans(stackIndex, fileXml, schemaFile, options);

            //share out the spectra amongst the frames
            int currFrame       = 1;
            int currScanofFrame = 1;

            for (int i = 0; i < numRawFiles; i++)
            {
                for (int j = 0; j <= stackIndex[i].scan.GetUpperBound(0); j++)
                {
                    stackIndex[i].scan[j].frame = currFrame;
                    currScanofFrame++;
                    if (currScanofFrame > scansbyframe)
                    {
                        currFrame++;
                        currScanofFrame = 1;
                    }
                }
            }

            return(stackIndex);
        }
Beispiel #8
0
        public static binFrame genFrame(binStack[] stackIndex,
                                        int frame,
                                        int scansbyframe,
                                        string rawPath,
                                        BinStackOptions options,
                                        Label _status,
                                        ref object _parObject,
                                        int currNumFrame,
                                        int totNumFrames)
        {
            binFrame currFrame = new binFrame(scansbyframe);

            currFrame.frame = frame;

            int currScanofFrame = 0;

            for (int j = 0; j <= stackIndex.GetUpperBound(0); j++)
            {
                for (int k = 0; k <= stackIndex[j].scan.GetUpperBound(0); k++)
                {
                    if (currFrame.frame == stackIndex[j].scan[k].frame)
                    {
                        currFrame.scan[currScanofFrame].rawFileName   = stackIndex[j].rawFileName;
                        currFrame.scan[currScanofFrame].scanNumber    = stackIndex[j].scan[k].FirstScan;
                        currFrame.scan[currScanofFrame].parentMass    = stackIndex[j].scan[k].parentMass;
                        currFrame.scan[currScanofFrame].spectrumIndex = stackIndex[j].scan[k].spectrumIndex;
                        currFrame.scan[currScanofFrame].peakStart     = stackIndex[j].scan[k].peakStart;
                        currFrame.scan[currScanofFrame].peakEnd       = stackIndex[j].scan[k].peakEnd;
                        currScanofFrame++;
                    }
                }
            }

            int nRawsinFrame;
            LookupCollection rawsinFrame = RawFilesinFrame(currFrame, out nRawsinFrame);

            DA_raws[] tRawList       = new DA_raws[nRawsinFrame];
            ArrayList rawFilesKeys   = (ArrayList)rawsinFrame.Keys;
            ArrayList rawFilesValues = (ArrayList)rawsinFrame.Values;

            for (int i = 0; i < nRawsinFrame; i++)
            {
                tRawList[i]         = new DA_raws((int)rawFilesValues[i]);
                tRawList[i].rawFile = rawFilesKeys[i].ToString();

                for (int j = tRawList[i].scan.GetLowerBound(0); j <= tRawList[i].scan.GetUpperBound(0); j++)
                {
                    tRawList[i].scan[j].rawFileName = rawFilesKeys[i].ToString();
                }
            }

            for (int i = 0; i <= currFrame.scan.GetUpperBound(0); i++)
            {
                for (int j = tRawList.GetLowerBound(0); j <= tRawList.GetUpperBound(0); j++)
                {
                    if (currFrame.scan[i].rawFileName != null)
                    {
                        if (currFrame.scan[i].rawFileName.Trim() == tRawList[j].rawFile.Trim())
                        {
                            for (int k = tRawList[j].scan.GetLowerBound(0); k <= tRawList[j].scan.GetUpperBound(0); k++)
                            {
                                if (tRawList[j].scan[k].scanNumber == 0)
                                {
                                    tRawList[j].scan[k].rawFileName   = currFrame.scan[i].rawFileName;
                                    tRawList[j].scan[k].scanNumber    = currFrame.scan[i].scanNumber;
                                    tRawList[j].scan[k].parentMass    = currFrame.scan[i].parentMass;
                                    tRawList[j].scan[k].spectrumIndex = currFrame.scan[i].spectrumIndex;
                                    tRawList[j].scan[k].peakStart     = currFrame.scan[i].peakStart;
                                    tRawList[j].scan[k].peakEnd       = currFrame.scan[i].peakEnd;

                                    break;
                                }
                            }
                        }
                    }
                }
            }

            // gets spectra (added to tRawList)
            for (int i = 0; i < nRawsinFrame; i++)
            {
                int[] firstScans = new int[tRawList[i].scan.GetLength(0)];
                int[] peakStarts = new int[tRawList[i].scan.GetLength(0)];
                int[] peakEnds   = new int[tRawList[i].scan.GetLength(0)];

                double[] parentMassList;
                if (options.useParentalMass)
                {
                    parentMassList = new double[tRawList[i].scan.GetLength(0)];
                }
                else
                {
                    parentMassList = null;
                }

                for (int j = 0; j <= firstScans.GetUpperBound(0); j++)
                {
                    firstScans[j] = tRawList[i].scan[j].scanNumber; //These are the MSMS identified spectra

                    if (!(options.averagingMethod == averagingMethod.mostIntense ||
                          options.averagingMethod == averagingMethod.none))
                    {
                        peakStarts[j] = tRawList[i].scan[j].peakStart;
                        peakEnds[j]   = tRawList[i].scan[j].peakEnd;
                    }

                    if (options.useParentalMass)
                    {
                        parentMassList[j] = tRawList[i].scan[j].parentMass;
                    }
                }
                int    t           = tRawList[i].size();
                string rawFileName = tRawList[i].rawFile;
                DA_raw daRaw1      = new DA_raw();

                // reads raws, and saves spectra to scansRaw
                Comb.mzI[][] scansRaw = daRaw1.ReadScanRaw(rawPath,
                                                           rawFileName,
                                                           firstScans,
                                                           peakStarts,
                                                           peakEnds,
                                                           parentMassList,
                                                           options,
                                                           _status,
                                                           ref _parObject,
                                                           currNumFrame,
                                                           totNumFrames);


                //Comb.mzI[][] scansRaw = null;
                if (scansRaw == null)
                {
                    return(null);
                }

                daRaw1 = null;

                for (int j = 0; j <= firstScans.GetUpperBound(0); j++)
                {
                    if (scansRaw[j] != null)
                    { // transfers spectra from scansRaw to tRawList
                        tRawList[i].scan[j].spectrum    = (Comb.mzI[])scansRaw[j];
                        tRawList[i].scan[j].rawFileName = tRawList[i].rawFile;
                    }
                }
            }


            // adds spectra to currFrame
            for (int i = currFrame.scan.GetLowerBound(0); i <= currFrame.scan.GetUpperBound(0); i++)
            {
                for (int j = tRawList.GetLowerBound(0); j <= tRawList.GetUpperBound(0); j++)
                {
                    if (currFrame.scan[i].rawFileName != null)
                    {
                        if (currFrame.scan[i].rawFileName.Trim() == tRawList[j].rawFile.Trim())
                        {
                            for (int k = tRawList[j].scan.GetLowerBound(0); k <= tRawList[j].scan.GetUpperBound(0); k++)
                            {
                                if (currFrame.scan[i].spectrumIndex == tRawList[j].scan[k].spectrumIndex) //Bug corrected: currFrame.scan[i].scanNumber == tRawList[j].scan[k].scanNumber
                                {
                                    currFrame.scan[i].spectrum = tRawList[j].scan[k].spectrum;
                                    break;
                                }
                            }
                            break;
                        }
                    }
                }
            }


            //WARNING: very dangerous change, but necessary to maintain old binstacks: in currFrame
            //         we swap the values of scanNumber by spectrumIndex (once we have obtained the desired
            //         spectrum, we use the unique index (spectrumIndex).

            for (int i = currFrame.scan.GetLowerBound(0); i <= currFrame.scan.GetUpperBound(0); i++)
            {
                int scanNumber_t = currFrame.scan[i].scanNumber;
                currFrame.scan[i].scanNumber = currFrame.scan[i].spectrumIndex;

                //this is not necessary, but I want to maintain the scanNumber elsewhere...
                currFrame.scan[i].spectrumIndex = scanNumber_t;
            }

            return(currFrame);
        }