LoginSignup
0
0

More than 5 years have passed since last update.

ThermoMSの.rawファイルをC#でこじ開ける方法

Posted at

ThermoMSの.rawファイルをC#でこじ開ける方法

日本語での解説が無かったので備忘録的に使用

Bioinformatics for Proteomic Mass Spectrometry 生物資訊於蛋白質體的質譜資料分析
を参考に

参照を追加にXrawfi2_x64.dllを追加。
やり方は参照ページのが詳しい。

ファイルをフォームにD&Dで名前取得するようにあらかじめ指定しておいてから使っていた。

        private void textBox1_DragDrop(object sender, DragEventArgs e)
        {
            MSFileReader_XRawfile rawfile = new MSFileReader_XRawfile();

            string[] fileName = (string[])e.Data.GetData(DataFormats.FileDrop, false);

            rawfile.Open(fileName[0]);
            rawfile.SetCurrentController(0, 1);

            int totalscannum = 0;
            double lowmass = 0;
            double highmass = 0;
            double massresolution = 0;

            string MSname = null;
            string MSmodel = null;


            rawfile.GetNumSpectra(ref totalscannum);
            rawfile.GetLowMass(ref lowmass);
            rawfile.GetHighMass(ref highmass);
            rawfile.GetMassResolution(ref massresolution);

            rawfile.GetInstModel(ref MSname);
            rawfile.GetInstName(ref MSmodel);

            double ProfilePeakWidth = 0.0;
            object MassList = null;
            object PeakFlags = null;
            int ArraySize = 0;
            int ArraySize2 = 0;

            object MassList2 = null;

            Series mz = new Series();
            Series mz2 = new Series();
            Series chart = new Series();



            rawfile.GetMassListFromScanNum(1, null, 1, 0, 0, 0, ref ProfilePeakWidth,
            ref MassList, ref PeakFlags, ref ArraySize);

            double[,] mslist = (double[,])MassList;
            int prescan = mslist.GetLength(0);

            double[, ,] array3d = new double[totalscannum, 2, mslist.GetLength(1)];

            for (int d1 = 1; d1 < totalscannum; d1++)
            {
                for (int d2 = 1; d2 < mslist.GetLength(1); d2++)
                {
                    long d3 = d2 - 1;

                    rawfile.GetMassListFromScanNum(d1, null, 1, 0, 0, 0, ref ProfilePeakWidth,
                    ref MassList2, ref PeakFlags, ref ArraySize2);

                    double[,] mslist2 = (double[,])MassList2;

                    array3d[d1, 0, d2] = mslist2[0, d3];
                    array3d[d1, 1, d2] = mslist2[1, d3];

                }
            }

        }

確かこんな感じで動いたはず。
ものすごく無駄が多い配列の初期化をしているけど、いずれよくなったらなあと。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0