示例#1
0
 static void Main(string[] args)
 {
     MSFileReader_XRawfile rawMSfile = new MSFileReader_XRawfile();
     rawMSfile.Open("L:\\Davi\\_QE\\BSAs\\20150512_BSA_The-PEG-envelope.raw");
     rawMSfile.SetCurrentController(0, 1); /* Controller type 0 means mass spec device; Controller 1 means first MS device */
     int nms = 0; /* ref int usrd with GetNumSpectra */
     int pbMSData=0;
     int pnLastSpectrum=0;
     rawMSfile.GetNumSpectra(ref nms);
     rawMSfile.IsThereMSData(ref pbMSData);
     rawMSfile.GetLastSpectrumNumber(ref pnLastSpectrum);
     Debug.WriteLine("Total Spectra: " + nms);
     Debug.WriteLine("MSdata: " + pbMSData);
     Debug.WriteLine("Last MSdata: " + pnLastSpectrum);
     double pkWidCentroid = 0.0;
     object mzList = null;
     object pkFlg = null;
     int arrLen = 0;
     for (int i = 1; i < 10; i++){
         rawMSfile.GetMassListFromScanNum(i, null, 1, 0, 0, 0, ref pkWidCentroid, ref mzList, ref pkFlg, ref arrLen);
         double[,] mslist = (double[,])mzList;
         //for (int j = 0; j < 2; j++){
             Debug.WriteLine("MSdata: " + mslist[0,i] + "MSdata: " + mslist[1,i] + "Scan:" + i);
         //}
     }
 }
示例#2
0
        public void ReadMS(int Scan)
        {
            int    ArraySize = 0;
            Object MassList = null, EmptyRef = null;
            double temp = 0.0;

            try {
                if (StickMode && Scan > 0)
                {
                    (RawFile as IXRawfile2).GetLabelData(ref MassList, ref EmptyRef, ref Scan);
                    ArraySize             = (MassList as Array).GetLength(1);
                    RawSpectra[Scan].Data = new MZData[ArraySize];
                    for (int k = 0; k < ArraySize; k++)
                    {
                        RawSpectra[Scan].Data[k].Mass      = (double)(MassList as Array).GetValue(0, k);
                        RawSpectra[Scan].Data[k].Intensity = (double)(MassList as Array).GetValue(1, k);
                    }
                    return;
                }
                else
                {
                    RawFile.GetMassListFromScanNum(ref Scan, null,
                                                   0, //type
                                                   0, //value
                                                   0, //peaks
                                                   0, //centeroid
                                                   ref temp,
                                                   ref MassList,
                                                   ref EmptyRef,
                                                   ref ArraySize);
                }
            }
            catch {
                Exception e = new Exception(string.Format("Scan #{0} cannot be loaded, probably RAW file is corrupted!", Scan));
                throw e;
            }

            //RawSpectra[Scan].Data = new MZData[ArraySize];

            for (int j = 0; j < ArraySize; j++)
            {
                Buf[j].Mass      = (double)(MassList as Array).GetValue(0, j);
                Buf[j].Intensity = (double)(MassList as Array).GetValue(1, j);
            }

            MassList = null;
            GC.Collect(2);

            //if (Settings.Default.Centroids){
            //    RawSpectra[Scan].Data = PeakDetect(Buf);
            //}else{
            //    RawSpectra[Scan].Data = Centroid(Buf, ArraySize);
            //}
            int isCentroided = 0;

            RawFile.IsCentroidScanForScanNum(Scan, ref isCentroided);

            RawSpectra[Scan].Data = Centroid(Buf, ArraySize, isCentroided != 0);
        }
示例#3
0
        public Form2(double[] Values, string flname)
        {
            InitializeComponent();
            //this.SetStyle(ControlStyles.SupportsTransparentBackColor, true);
            foreach (var item in Values)
            {
                Console.Write(item.ToString() + " ");
            }
            Console.WriteLine();
            this.Text = flname;
            TextBox t = new TextBox();

            t.Text     = "Spot Number: " + (Values[0]).ToString();
            t.Location = new Point(15, 15);
            this.Controls.Add(t);
            chart1.Series["MassSpectrum"].ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Line;
            t.BringToFront();
            int[,] sample = new int[2, 10];

            MSFileReader_XRawfile rawfile = new MSFileReader_XRawfile();

            rawfile.Open(flname);
            rawfile.SetCurrentController(0, 1);
            int ScanNumber = Convert.ToInt32(Values[0]);

            double Centroid_Peak_Width = 0.0;
            object Mass_List           = null;
            object Peak_Flags          = null;
            int    Array_Size          = 0;

            rawfile.GetMassListFromScanNum(ref ScanNumber, null, 1, 0, 0, 0, ref Centroid_Peak_Width, ref Mass_List, ref Peak_Flags, ref Array_Size);
            double[,] ms_list = (double[, ])Mass_List;
            //Random rdn = new Random();
            //chart1.Series.Add("Series2");
            double[] found = new double[(Values.Length - 2) / 2];
            //int start = 2;
            for (int i = 0; i < ms_list.Length / 2; i++)
            {
                /*for(int j = start; j < Values.Length; j = j + 2)
                 * {
                 *  if ((ms_list[0,i] > Values[j]-0.005) && (ms_list[0, i] < Values[j] + 0.005))
                 *  {
                 *      found[(j - 2) / 2] = ms_list[0, i];
                 *      start = j + 2;
                 *  }
                 * }*/
                DataPoint dp2 = new DataPoint(ms_list[0, i], ms_list[1, i]);
                chart1.Series["MassSpectrum"].Points.Add(dp2);
                //  (rdn.Next(0, 10), rdn.Next(0, 10));
            }
            for (int j = 2; j < Values.Length; j = j + 2)
            {
                //chart1.Series["MassSpectrum"].Points.FindByValue(found[j], "X").IsValueShownAsLabel = true; // = "("+Values[2*j+2]+", "+Values[2*j+3]+")";
                DataPoint dtp = chart1.Series["MassSpectrum"].Points.Aggregate((x, y) => Math.Abs(x.XValue - Values[j]) < Math.Abs(y.XValue - Values[j]) ? x : y);
                //DataPoint dtp = chart1.Series["MassSpectrum"].Points.FindByValue(found[j], "X");
                double temp = new double();
                temp      = Math.Round(dtp.XValue, 2);
                dtp.Label = temp.ToString();               //"(" + Values[2 * j + 2] + ", " + Values[2 * j + 3] + ")";
            }
            //chart1.Series["Series2"].Enabled = false;
            //chart1.Series["Series2"].IsValueShownAsLabel = true;

            chart1.Series["MassSpectrum"].Color = Color.Blue;
        }