Exemplo n.º 1
0
        public void Display()
        {
            Console.WriteLine("MaxThreads: " + MaxNumThreads);

            foreach (var specFilePath in SpecFilePaths)
            {
                Console.WriteLine("SpectrumFilePath: " + specFilePath);
            }

            Console.WriteLine("DatabaseFilePath: " + DatabaseFilePath);
            Console.WriteLine("FeatureFilePath:  {0}", FeatureFilePath ?? "N/A");
            Console.WriteLine("OutputDir:        " + OutputDir);
            Console.WriteLine("InternalCleavageMode: " + InternalCleavageMode);
            Console.WriteLine("Tag-based search: " + TagBasedSearch);
            Console.WriteLine("Tda: " + (TargetDecoySearchMode == DatabaseSearchMode.Both ? "Target+Decoy" : TargetDecoySearchMode.ToString()));
            Console.WriteLine("PrecursorIonTolerancePpm: " + PrecursorIonTolerancePpm);
            Console.WriteLine("ProductIonTolerancePpm: " + ProductIonTolerancePpm);
            Console.WriteLine("MinSequenceLength: " + MinSequenceLength);
            Console.WriteLine("MaxSequenceLength: " + MaxSequenceLength);
            Console.WriteLine("MinPrecursorIonCharge: " + MinPrecursorIonCharge);
            Console.WriteLine("MaxPrecursorIonCharge: " + MaxPrecursorIonCharge);
            Console.WriteLine("MinProductIonCharge: " + MinProductIonCharge);
            Console.WriteLine("MaxProductIonCharge: " + MaxProductIonCharge);
            Console.WriteLine("MinSequenceMass: " + MinSequenceMass);
            Console.WriteLine("MaxSequenceMass: " + MaxSequenceMass);
            Console.WriteLine("MaxDynamicModificationsPerSequence: " + MaxDynamicModificationsPerSequence);
            Console.WriteLine("Modifications: ");

            foreach (var searchMod in Modifications)
            {
                Console.WriteLine(searchMod);
            }

            if (!string.IsNullOrWhiteSpace(FeatureFilePath))
            {
                Console.WriteLine("Getting MS1 features from " + FeatureFilePath);
            }

            if (ScanNumbers != null && ScanNumbers.Any())
            {
                Console.WriteLine("Processing specific MS2 scans:");
                Console.WriteLine(string.Join(", ", ScanNumbers));
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Method responsible for parsing RAW File.
        /// </summary>
        /// <param name="fileName"></param>
        /// <returns></returns>
        public List <MSUltraLight> ParseFile(String rawFile, short fileIndex = -1, int MsnLevel = 2, List <int> ScanNumbers = null, bool toPrint_console = true)
        {
            if (!File.Exists(rawFile))
            {
                throw new Exception("ParserUltraLightRAW error:: Unable to find the file " + rawFile);
            }

            MSFileReaderLib.IXRawfile2 raw = (MSFileReaderLib.IXRawfile2) new MSFileReader_XRawfile();
            raw.Open(rawFile);
            raw.SetCurrentController(0, 1);

            Dictionary <int, double[, ]> ms1s = null;

            if (GET_PRECURSOR_MZ_AND_INTENSITY_FROM_MS1)
            {
                ms1s = new Dictionary <int, double[, ]>();
            }

            int first_scan_number = -1;

            raw.GetFirstSpectrumNumber(ref first_scan_number);
            int last_scan_number = -1;

            raw.GetLastSpectrumNumber(ref last_scan_number);

            object progress_lock     = new object();
            int    spectra_processed = 0;
            int    old_progress      = 0;

            MSUltraLight[] myTMSArray = new MSUltraLight[last_scan_number + 2];

            //We will only retrieve certain scan numbers
            if (ScanNumbers == null)
            {
                ScanNumbers = new List <int>();
                for (int scan_number = first_scan_number; scan_number <= last_scan_number + 1; scan_number++)
                {
                    ScanNumbers.Add(scan_number);
                }
            }

            ScanNumbers.Sort();


            foreach (int scan_number in ScanNumbers)
            {
                spectra_processed++;
                string scan_filter = null;
                raw.GetFilterForScanNum(scan_number, ref scan_filter);

                if (String.IsNullOrEmpty(scan_filter))
                {
                    Console.WriteLine("Scan " + scan_number + " is null");
                    continue;
                }

                if (MsnLevel == 1)
                {
                    if (!isMS1.IsMatch(scan_filter))
                    {
                        if (!isMS1_1.IsMatch(scan_filter))
                        {
                            continue;
                        }
                    }
                }
                else if (MsnLevel == 2)
                {
                    if (!isMS2.IsMatch(scan_filter))
                    {
                        continue;
                    }
                }
                else if (MsnLevel == 3)
                {
                    if (!isMS3.IsMatch(scan_filter))
                    {
                        continue;
                    }
                }


                string spectrum_id = "controllerType=0 controllerNumber=1 scan=" + scan_number.ToString();

                double retention_time = double.NaN;
                raw.RTFromScanNum(scan_number, ref retention_time);

                double precursor_mz;
                double precursor_intensity;
                int    precursor_scanNumber;


                double ionInjectionTime;
                int    charge;

                if (MsnLevel > 1)
                {
                    GetPrecursor(ms1s, raw, scan_number, scan_filter, first_scan_number, out precursor_mz, out precursor_intensity, out precursor_scanNumber);
                    DeterminePrecursorParams(raw, scan_number, out charge, out ionInjectionTime);
                }
                else
                {
                    charge              = -1;
                    precursor_mz        = -1;
                    precursor_intensity = -1;
                }

                double[,] label_data = GetFragmentationData(raw, scan_number, scan_filter);

                List <Tuple <float, float> > peaks = new List <Tuple <float, float> >(label_data.GetLength(1));
                for (int peak_index = label_data.GetLowerBound(1); peak_index <= label_data.GetUpperBound(1); peak_index++)
                {
                    // Calculate index in list of ions object
                    int index = peak_index - label_data.GetLowerBound(1);

                    // Get fragment ion m/z and intensity from RAW file
                    float mz        = (float)label_data[(int)RawLabelDataColumn.MZ, peak_index];
                    float intensity = (float)label_data[(int)RawLabelDataColumn.Intensity, peak_index];

                    // Create new ion object
                    peaks.Add(new Tuple <float, float>(mz, intensity));
                }

                if (peaks.Count > 0)
                {
                    MSUltraLight ms = new MSUltraLight((float)retention_time,
                                                       scan_number,
                                                       peaks,
                                                       new List <Tuple <float, short> >()
                    {
                        new Tuple <float, short>((float)precursor_mz, (short)charge)
                    },
                                                       (float)precursor_intensity,
                                                       1,          //Instrument type
                                                       (short)MsnLevel,
                                                       fileIndex);

                    myTMSArray[scan_number] = ms;
                }

                lock (progress_lock)
                {
                    int new_progress = (int)((double)spectra_processed / (last_scan_number - first_scan_number + 1) * 100);
                    if (new_progress > old_progress)
                    {
                        old_progress = new_progress;
                        if (toPrint_console)
                        {
                            int currentLineCursor = Console.CursorTop;
                            Console.SetCursorPosition(0, Console.CursorTop);
                            Console.Write(" Reading RAW File: " + old_progress + "%");
                            Console.SetCursorPosition(0, currentLineCursor);
                        }
                        else
                        {
                            Console.Write(" Reading RAW File: " + old_progress + "%");
                        }
                    }
                }
            }

            Console.Write(" Reading RAW File: 100%");
            return(myTMSArray.Where(a => a != null).ToList());
        }