コード例 #1
0
ファイル: frmMainESI.cs プロジェクト: chpaul/MultiGlycan
        private void btnMergeTest_Click(object sender, EventArgs e)
        {
            GenerateImages.GenQuantImg(@"E:\!MultiGlycanbatch\1\1_Quant.csv", enumGlycanLabelingMethod.MultiplexPermethylated, @"E:\!MultiGlycanbatch\1");
            //StreamReader sr = new StreamReader(@"D:\Dropbox\for_Yunli_Hu\b1_19_1_07142012-121002 1349_FullList.csv");
            //string tmp = sr.ReadLine();
            //List<ClusteredPeak> clu = new List<ClusteredPeak>();
            //do
            //{
            //    tmp = sr.ReadLine();
            //    string[] tmpArray = tmp.Split(',');
            //    ClusteredPeak tnpCluPeak = new ClusteredPeak(Convert.ToInt32(tmpArray[1]));
            //    tnpCluPeak.StartTime = Convert.ToDouble(tmpArray[0]);
            //    tnpCluPeak.EndTime = Convert.ToDouble(tmpArray[0]);

            //    tnpCluPeak.EndScan = Convert.ToInt32(tmpArray[1]);
            //    tnpCluPeak.Intensity = Convert.ToSingle(tmpArray[2]);
            //    tnpCluPeak.GlycanComposition = new COL.GlycoLib.GlycanCompound(
            //                                                                    Convert.ToInt32(tmpArray[8]),
            //                                                                    Convert.ToInt32(tmpArray[9]),
            //                                                                    Convert.ToInt32(tmpArray[10]),
            //                                                                    Convert.ToInt32(tmpArray[11]));
            //    tnpCluPeak.Charge = Convert.ToInt32(Math.Ceiling(  Convert.ToSingle(tmpArray[12]) / Convert.ToSingle(tmpArray[3])));

            //    clu.Add(tnpCluPeak);
            //} while (!sr.EndOfStream);
            //sr.Close();
            ////MultiNGlycanESI.MergeCluster(clu, 8.0);
        }
コード例 #2
0
        private void bgWorkerGenerateImages_DoWork(object sender, DoWorkEventArgs e)
        {
            foreach (string resultFile in ResultFiles)
            {
                currentFile = resultFile;
                if (resultFile.Contains("_FullList.csv"))
                {
                    currentFile = resultFile.Remove(resultFile.IndexOf("_FullList.csv")) + ".csv";
                }
                bgWorkerGenerateImages.ReportProgress(0);
                string FullListFile = currentFile.Replace(".csv", "_FullList.csv");
                string QuantFile    = currentFile.Replace(".csv", "_Quant.csv");

                //Get individual image
                if (isIndividualImg && File.Exists(FullListFile))
                {
                    GenerateImages.GenGlycanLcImg(
                        FullListFile,
                        ExportFilePath + "\\" + Path.GetFileNameWithoutExtension(currentFile),
                        out lstImgErrors);
                }
                //Get Quant Image
                if (isQuantImg && File.Exists(QuantFile))
                {
                    GenerateImages.GenQuantImg(
                        QuantFile,
                        LabelingMethod,
                        ExportFilePath + "\\" + Path.GetFileNameWithoutExtension(currentFile));
                }
                CompletedCount = CompletedCount + 1;
                bgWorkerGenerateImages.ReportProgress(0);
            }
        }
コード例 #3
0
        private void bgWorker_Process_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
        {
            try
            {
                //  _MultiNGlycan.ExportParametersToExcel();
                if (DoLog)
                {
                    Logger.WriteLog("Start merge peaks");
                }
                lblStatus.Text = "Mergeing Peaks";
                if (_MultiNGlycan.LabelingMethod == enumGlycanLabelingMethod.MultiplexPermethylated)
                {
                    SecondPassedForMultiplexPermethylated.Processing(ref _MultiNGlycan);
                }
                //if (_MultiNGlycan.TwoPassedID)
                //{
                //   // _MultiNGlycan.Merge2PassedCluster();
                //    _MultiNGlycan.MergeSingleScanResultToPeak();
                //}
                //else
                //{
                // _MultiNGlycan.MergeCluster();
                _MultiNGlycan.MergeSingleScanResultToPeak();
                _MultiNGlycan.SolveDuplicateAssignment();
                _MultiNGlycan.MergeSingleScanResultToPeak();
                //}


                if (DoLog)
                {
                    Logger.WriteLog("End merge peaks");
                }
                if (_MultiNGlycan.GlycanLCorderExist)
                {
                    _MultiNGlycan.ApplyLCordrer();
                }

                if (!Directory.Exists(_MultiNGlycan.ExportFilePath + "\\Pic") && (_MultiNGlycan.IndividualImgs || _MultiNGlycan.QuantificationImgs))
                {
                    Directory.CreateDirectory(_MultiNGlycan.ExportFilePath + "\\Pic");
                }


                if (_MultiNGlycan.LabelingMethod == GlycoLib.enumGlycanLabelingMethod.MultiplexPermethylated)
                {
                    _MultiNGlycan.EstimatePurity();
                    foreach (GlycoLib.enumLabelingTag tag in _MultiNGlycan.LabelingRatio.Keys)
                    {
                        if (tag == enumLabelingTag.MP_CH3 || !_MultiNGlycan.HasEstimatePurity((tag)))
                        {
                            continue;
                        }
                        _MultiNGlycan.GetPurityEstimateImage(tag, _MultiNGlycan.ExportFilePath + "\\Pic\\EstimatePurity_" + tag.ToString() + ".png");
                    }

                    //Correct Intensity;
                    //_MultiNGlycan.CorrectIntensityByIsotope();
                }
                if (DoLog)
                {
                    ;
                    Logger.WriteLog("Start export");
                }
                lblStatus.Text = "Exporting";
                _MultiNGlycan.ExportToCSV();

                //Get individual image
                if (_MultiNGlycan.IndividualImgs &&
                    File.Exists(_MultiNGlycan.ExportFilePath + "\\" + Path.GetFileName(_MultiNGlycan.ExportFilePath) +
                                "_FullList.csv"))
                {
                    //GenerateImages.GenGlycanLcImg(
                    //    _MultiNGlycan.ExportFilePath + "\\" + Path.GetFileName(_MultiNGlycan.ExportFilePath) +"_FullList.csv",
                    //    _MultiNGlycan.ExportFilePath);
                    GenerateImages.GenGlycanLcImg(_MultiNGlycan);
                }
                //Get Quant Image
                if (_MultiNGlycan.LabelingMethod != enumGlycanLabelingMethod.None && _MultiNGlycan.QuantificationImgs &&
                    File.Exists(_MultiNGlycan.ExportFilePath + "\\" + Path.GetFileName(_MultiNGlycan.ExportFilePath) +
                                "_Quant.csv"))
                {
                    GenerateImages.GenQuantImg(
                        _MultiNGlycan.ExportFilePath + "\\" + Path.GetFileName(_MultiNGlycan.ExportFilePath) + "_Quant.csv",
                        _MultiNGlycan.LabelingMethod,
                        _MultiNGlycan.ExportFilePath);
                }


                //_MultiNGlycan.ExportToExcel();
                if (DoLog)
                {
                    Logger.WriteLog("End export");
                }
                TimeSpan TDiff = DateTime.Now.Subtract(Start);
                lblStatus.Text        = "Finish in " + TDiff.TotalMinutes.ToString("0.00") + " mins";
                lblNumberOfMerge.Text = _MultiNGlycan.MergedResultList.Count.ToString();
                progressBar1.Value    = 100;
                lblPercentage.Text    = "100%";
                FlashWindow.Flash(this);
                this.Text = "Done";
                if (DoLog)
                {
                    Logger.WriteLog("End process each scan");
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
コード例 #4
0
        private void ProcessMultiGlycanAsync(string argFile)
        {
            int runningSlot = -1;

            for (int i = 0; i < 3; i++)
            {
                if (ProcessingFile[i] == "0")
                {
                    ProcessingFile[i] = argFile;
                    runningSlot       = i;
                    break;
                }
            }
            MultiGlycanESI multiGlycan = null;

            //ZedGraphControl zedGraphControl = new ZedGraphControl();
            try
            {
                //debugWriter.WriteLine("---------------------Process file:" + argFile + "------------------------");
                ProcessingStatus[runningSlot] = "Status: Reading Raw file";
                bgWorker_Process.ReportProgress(0);
                ProgressUpdate.Add(argFile, 0);
                TotalScanNum.Add(argFile, 99999);
                if (_MultiNGlycan.LabelingRatio.Count != 0)
                {
                    multiGlycan = new MultiGlycanESI(argFile, 1, 99999, _MultiNGlycan.GlycanFile, _MultiNGlycan.MassPPM, _MultiNGlycan.GlycanPPM, _MultiNGlycan.IsPermethylated, _MultiNGlycan.IsReducedReducingEnd, _MultiNGlycan.SiaType, _MultiNGlycan.LabelingRatio, _MultiNGlycan.AdductMassToLabel, _MultiNGlycan.AdductMass, _MultiNGlycan.DoLOG);
                }
                else
                {
                    multiGlycan = new MultiGlycanESI(argFile, 1, 99999, _MultiNGlycan.GlycanFile, _MultiNGlycan.MassPPM, _MultiNGlycan.GlycanPPM, _MultiNGlycan.IsPermethylated, _MultiNGlycan.IsReducedReducingEnd, _MultiNGlycan.SiaType, _MultiNGlycan.DoLOG);
                }
                //debugWriter.WriteLine("init finish");
                multiGlycan.LabelingMethod = _MultiNGlycan.LabelingMethod;
                multiGlycan.MergeDifferentChargeIntoOne = _MultiNGlycan.MergeDifferentChargeIntoOne;
                multiGlycan.ExportFilePath          = _MultiNGlycan.ExportFilePath + "\\" + Path.GetFileNameWithoutExtension(argFile);
                multiGlycan.MaxLCBackMin            = _MultiNGlycan.MaxLCBackMin;
                multiGlycan.MaxLCFrontMin           = _MultiNGlycan.MaxLCFrontMin;
                multiGlycan.IsotopePPM              = _MultiNGlycan.IsotopePPM;
                multiGlycan.MininumIsotopePeakCount = _MultiNGlycan.MininumIsotopePeakCount;
                multiGlycan.PeakSNRatio             = _MultiNGlycan.PeakSNRatio;
                multiGlycan.IsMatchMonoisotopicOnly = _MultiNGlycan.IsMatchMonoisotopicOnly;
                multiGlycan.MinAbundance            = _MultiNGlycan.MinAbundance;
                multiGlycan.MinLengthOfLC           = _MultiNGlycan.MinLengthOfLC;
                multiGlycan.IncludeMZMatch          = _MultiNGlycan.IncludeMZMatch;
                multiGlycan.IndividualImgs          = _MultiNGlycan.IndividualImgs;
                multiGlycan.QuantificationImgs      = _MultiNGlycan.QuantificationImgs;
                multiGlycan.GlycanList              = _MultiNGlycan.GlycanList;
                multiGlycan.CandidateMzList         = _MultiNGlycan.CandidateMzList;
                multiGlycan.MinPeakHeightPrecentage = _MultiNGlycan.MinPeakHeightPrecentage;
                if (_MultiNGlycan.ApplyLinearRegLC)
                {
                    multiGlycan.ApplyLinearRegLC = _MultiNGlycan.ApplyLinearRegLC;
                    multiGlycan.TotalLCTime      = _MultiNGlycan.TotalLCTime;
                    multiGlycan.LCTimeTolerance  = _MultiNGlycan.LCTimeTolerance;
                }
                TotalScanNum[argFile] = multiGlycan.RawReader.NumberOfScans;


                //ProcessingStatus[runningSlot] = "Status:  Processing";
                //Parallel.ForEach(Enumerable.Range(1, multiGlycan.RawReader.NumberOfScans),
                //    new ParallelOptions() { MaxDegreeOfParallelism = 4 }, (i) =>
                //    {
                //        //Console.WriteLine(argFile + "-" + i.ToString());
                //        ProgressUpdate[argFile] = ProgressUpdate[argFile] + 1;
                //        bgWorker_Process.ReportProgress(Convert.ToInt32(ProgressUpdate[argFile] / TotalScanNum[argFile]));
                //        if (multiGlycan.RawReader.GetMsLevel(i) == 1)
                //        {
                //            multiGlycan.ProcessSingleScan(i);
                //        }
                //    });
                // debugWriter.WriteLine("Start processing");
                for (int i = 1; i <= multiGlycan.RawReader.NumberOfScans; i++)
                {
                    ProgressUpdate[argFile] = ProgressUpdate[argFile] + 1;
                    bgWorker_Process.ReportProgress(Convert.ToInt32(ProgressUpdate[argFile] / TotalScanNum[argFile]));
                    if (multiGlycan.RawReader.GetMsLevel(i) == 1)
                    {
                        multiGlycan.ProcessSingleScan(i);
                        //         debugWriter.WriteLine("Processed scen:" + i.ToString());
                    }
                }
                //debugWriter.WriteLine("Merge");
                ProcessingStatus[runningSlot] = "Status:  Mergeing Result";
                multiGlycan.MergeSingleScanResultToPeak();
                multiGlycan.SolveDuplicateAssignment();
                multiGlycan.MergeSingleScanResultToPeak();
                //debugWriter.WriteLine("Merge completed");
                if (multiGlycan.GlycanLCorderExist)
                {
                    multiGlycan.ApplyLCordrer();
                }
                if (!Directory.Exists(multiGlycan.ExportFilePath + "\\Pic") && (multiGlycan.IndividualImgs || multiGlycan.QuantificationImgs))
                {
                    Directory.CreateDirectory(multiGlycan.ExportFilePath + "\\Pic");
                }
                if (multiGlycan.LabelingMethod == GlycoLib.enumGlycanLabelingMethod.MultiplexPermethylated)
                {
                    multiGlycan.EstimatePurity();

                    foreach (GlycoLib.enumLabelingTag tag in multiGlycan.LabelingRatio.Keys)
                    {
                        if (tag == enumLabelingTag.MP_CH3 || !multiGlycan.HasEstimatePurity((tag)))
                        {
                            continue;
                        }
                        multiGlycan.GetPurityEstimateImage(tag, multiGlycan.ExportFilePath + "\\Pic\\EstimatePurity_" + tag.ToString() + ".png");
                    }
                }
                ProcessingStatus[runningSlot] = "Status:  Waiting for Export";
                bgWorker_Process.ReportProgress(0);


                ProcessingStatus[runningSlot] = "Status:  Exporting";
                bgWorker_Process.ReportProgress(0);
                //debugWriter.WriteLine("Export to CSV");
                multiGlycan.ExportToCSV();
                ProcessingStatus[runningSlot] = "Export completed";
                //debugWriter.WriteLine("Export completed");
                ProcessingStatus[runningSlot] = "Generate Pics";
                if (multiGlycan.IndividualImgs &&
                    File.Exists(multiGlycan.ExportFilePath + "\\" + Path.GetFileNameWithoutExtension(argFile) + "_FullList.csv"))
                {
                    //GenerateImages.GenGlycanLcImg(
                    //    _MultiNGlycan.ExportFilePath + "\\" + Path.GetFileName(_MultiNGlycan.ExportFilePath) +"_FullList.csv",
                    //    _MultiNGlycan.ExportFilePath);
                    GenerateImages.GenGlycanLcImg(multiGlycan);
                }


                bgWorker_Process.ReportProgress(0);
                SucceedFileCount = SucceedFileCount + 1;
                //debugWriter.WriteLine("Finish");
                //debugWriter.Flush();
            }
            catch (Exception e)
            {
                ErrMsg = ErrMsg + (argFile + "  error.  ErrMSG:" + e.ToString() + "\n");
            }
            finally
            {
                ProcessingStatus[runningSlot] = "Status:  Ready";
                ProcessingFile[runningSlot]   = "0";
                ProcessedFileCount            = ProcessedFileCount + 1;
            }
        }