Ejemplo n.º 1
0
        public static binFrame genFrame(binStack[] stackIndex, int frame, int scansbyframe, string rawPath, string spectrumType, string spectrumPosition)
        {
            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;
                        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;
                                    break;
                                }
                            }
                        }
                    }
                }
            }

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

                for (int j = 0; j <= scansRawList.GetUpperBound(0); j++)
                {
                    scansRawList[j] = tRawList[i].scan[j].scanNumber; //These are the MSMS identified spectra
                }
                int          t           = tRawList[i].size();
                string       rawFileName = tRawList[i].rawFile;
                DA_raw       daRaw1      = new DA_raw();
                Comb.mzI[][] scansRaw    = daRaw1.ReadScanRaw(rawPath, rawFileName, scansRawList, spectrumType, spectrumPosition);
                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].scanNumber == tRawList[j].scan[k].scanNumber)
                                {
                                    currFrame.scan[i].spectrum = tRawList[j].scan[k].spectrum;
                                    break;
                                }
                            }
                            break;
                        }
                    }
                }
            }



            return(currFrame);
        }
Ejemplo n.º 2
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);
        }
Ejemplo n.º 3
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);
        }