Exemple #1
0
        public void TestCNFParsing()
        {
            // File	SampleSet	SampleId	Operator	Type	Weight	Error	Units	Height	Duration, s	Dead time	Build up type	Irradiation begin date	Irradiation end date	Description	Read successfuly	Error message
            // 1006379 RU - 33 - 19 - 88 - j   j - 01        SLI - 2   0.2053  0   gram    20  900 0.21    IRRAD   19.03.2020 9:50 19.03.2020 9:53 Vergel_K.N.Journal_18 True

            var spectra = new Spectra(@"D:\Spectra\2020\03\kji\1006379");

            Assert.AreEqual("1006379", spectra.SpectrumData.File);
            Assert.AreEqual("RU-33-19-88-j", spectra.SpectrumData.Id);
            Assert.AreEqual("j-01", spectra.SpectrumData.Title);
            Assert.IsTrue(string.IsNullOrEmpty(spectra.SpectrumData.CollectorName));
            Assert.AreEqual("SLI-2", spectra.SpectrumData.Type);
            Assert.AreEqual(0.2053, spectra.SpectrumData.Quantity, 2);
            Assert.AreEqual(0, spectra.SpectrumData.Uncertainty, 2);
            Assert.AreEqual("gram", spectra.SpectrumData.Units);
            Assert.AreEqual(20, spectra.SpectrumData.Geometry, 2);
            Assert.AreEqual(900, spectra.SpectrumData.Duration, 2);
            Assert.AreEqual(0.21, (double)spectra.SpectrumData.DeadTime, 2);
            Assert.AreEqual("IRRAD", spectra.SpectrumData.BuildUpType);
            //Assert.AreEqual(DateTime.Parse("19.03.2020 9:50"), spectra.SpectrumData.IrrBeginDate, TimeSpan.FromMinutes(1));
            //Assert.AreEqual(DateTime.Parse("19.03.2020 9:53"), spectra.SpectrumData.IrrEndDate, TimeSpan.FromMinutes(1));
            //Assert.AreEqual(DateTime.Parse("19.03.2020 9:58"), spectra.SpectrumData.AcqStartDate, TimeSpan.FromMinutes(1));
            Assert.AreEqual("Vergel_K.N.Journal_18", spectra.SpectrumData.Description);
            Assert.IsTrue(spectra.ReadSuccess);
            Assert.IsTrue(string.IsNullOrEmpty(spectra.ErrorMessage));
        }
Exemple #2
0
        public void Run(SparseMatrix A, int m, bool symmetric)
        {
            var solver = new Spectra(A, symmetric)
            {
                Tolerance           = 1e-6,
                ComputeEigenVectors = true,
                ArnoldiCount        = m * 3
            };

            var timer = Stopwatch.StartNew();

            var result = solver.SolveStandard(m, 0.0);

            //var result = solver.SolveStandard(m, Spectrum.SmallestMagnitude);

            //var result = solver.SolveStandard(m, 8.0);
            //var result = solver.SolveStandard(m, Spectrum.LargestMagnitude);

            timer.Stop();

            Display.Time(timer.ElapsedTicks);

            result.EnsureSuccess();

            if (Helper.CheckResiduals(A, result, symmetric, false))
            {
                Display.Ok("OK");
            }
            else
            {
                Display.Warning("residual error too large");
            }
        }
Exemple #3
0
        public InfoContainer(bool common, Spectra spec)
        {
            table = new Dictionary <string, string>();

            String msLevel = "MS";

            if (spec.getMSLevel() == 2)
            {
                msLevel = "MS2";
            }

            if (common)
            {
                table.Add(GlobalVar.MSLevelHeader, msLevel);
                table.Add(GlobalVar.PrecursorChargeHeader, spec.getPrecursorCharge().ToString());
                table.Add(GlobalVar.PrecursorMZHeader, spec.getPrecursorMz().ToString());
                table.Add(GlobalVar.ScanNumHeader, spec.getScanNum().ToString());
                table.Add(GlobalVar.ScanTimeHeader, spec.getStartTime().ToString());
            }
            else
            {
                table.Add("specificInfo1", "aa");
                table.Add("specificInfo2", "pp");
            }

            Names = table.Keys;
        }
Exemple #4
0
        protected void processMS1(Spectra spec)
        {
            log.Debug("MS1 scan, unused");

            performanceEvaluator.countMS1();
            includedSpectra.Add(spec.getScanNum());
        }
Exemple #5
0
        public void PreviewSpectra(Spectra spectra)
        {
            btnMeasure.Enabled        = true;
            picSpectra.Visible        = true;
            lblSelectStarNote.Visible = false;

            int   xOffset    = spectra.ZeroOrderPixelNo - 10;
            float xCoeff     = picSpectra.Width * 1.0f / spectra.Points.Count;
            float colorCoeff = 255.0f / spectra.MaxSpectraValue;

            using (Graphics g = Graphics.FromImage(picSpectra.Image))
            {
                foreach (SpectraPoint point in spectra.Points)
                {
                    byte  clr = (byte)(Math.Min(255, Math.Max(0, Math.Round(point.RawValue * colorCoeff))));
                    float x   = xCoeff * (point.PixelNo - xOffset);
                    if (x >= 0)
                    {
                        g.DrawLine(m_GreyPens[clr], x, 0, x, picSpectra.Width);
                    }
                }

                g.Save();
            }

            picSpectra.Invalidate();
        }
Exemple #6
0
        //Called by DataProcessor, entry point to Alex's program
        public bool evaluate(Spectra spec)
        {
            currentTime = spec.getStartTime();
            updateExclusionList(spec);
            if (spec.getMSLevel() == 1)
            {
                log.Debug("Evaluating ms1 scan");
                processMS1(spec);
            }
            else if (spec.getMSLevel() == 2)
            {
                log.Debug("evaluating ms2 scan");
                if (spec.getIndex() % GlobalVar.ScansPerOutput == 0)
                {
#if SIMULATION
                    double progressPercent = spec.getIndex() / GlobalVar.ExperimentTotalScans * 100;
                    log.Info("Progress: {0:F2}% Processing ID: {1}\t ScanNum: {2} \t Excluded: {3}", progressPercent, spec.getIndex(), spec.getScanNum(),
                             excludedSpectra.Count);
#else
                    log.Info("Progress: {0}\t{1} excluded------------------------", spec.getIndex(), excludedSpectra.Count);
                    log.Info("ExclusionListSize: {0}\tRTOffset: {1}", exclusionList.getExclusionList().Count, RetentionTime.getRetentionTimeOffset());
#endif
                }

                return(processMS2(spec));
            }
            else
            {
                log.Debug("unrecognized msScan");
            }
            return(true);
        }
Exemple #7
0
        //parses the IMsScan into a spectra object so IMSscan object can be released to free memory
        public static void ParseIMsScan(IMsScan arrivedScan)
        {
            scanIDCounter++;


#if IGNORE
            if (Interlocked.Read(ref taskCounter) >= 25)
            {
                ignore = true;
            }
            else if (Interlocked.Read(ref taskCounter) < 10)
            {
                ignore = false;
            }

            if (ignore)
            {
                String scanNum = "";
                arrivedScan.CommonInformation.TryGetValue(GlobalVar.ScanNumHeader, out scanNum);
                spectraNotAdded.Add(new double[] { Double.Parse(scanNum), getCurrentMiliTime(), -1 });
                Console.WriteLine("ignoring scan " + scanNum);
                return;
            }
#endif
            Interlocked.Increment(ref taskCounter);
            //Spectra spectra = IMsScanParser.Parse(arrivedScan, scanIDCounter, getCurrentMiliTime());//Parses the IMsScan into a Spectra object
            Spectra spectra = IMsScanParser.Parse(arrivedScan, scanIDCounter, getCurrentMiliTime());

            parsedSpectra.Enqueue(spectra);
        }
Exemple #8
0
        public static Spectra Parse(IMsScan imsScan, int ID, double arrivalTime)
        {
            //As opposed to "StartTime" contained in the IMsScan information, arrival time uses the computer's own clock in milisecond rather than using the Mass spec's clock
            String temp;
            int    msLevel         = TryGetValue(imsScan, GlobalVar.MSLevelHeader, out temp) ? parseMSLevel(temp) : -1;
            int    scanNum         = TryGetValue(imsScan, GlobalVar.ScanNumHeader, out temp) ? int.Parse(temp) : ID;
            double startTime       = TryGetValue(imsScan, GlobalVar.ScanTimeHeader, out temp) ? double.Parse(temp) : -1;
            int    precursorCharge = TryGetValue(imsScan, GlobalVar.PrecursorChargeHeader, out temp) ? int.Parse(temp) : -1;
            double precursorMZ     = TryGetValue(imsScan, GlobalVar.PrecursorMZHeader, out temp) ? double.Parse(temp) : -1;
            int    centroidCount   = (int)imsScan.CentroidCount;

            double[] peakIntensity = new double[centroidCount];
            double[] peakMZ        = new double[centroidCount];

            int counter = 0;

            foreach (ICentroid2 cent in imsScan.Centroids)
            {
                peakIntensity[counter] = cent.Intensity;
                peakMZ[counter]        = cent.Mz;
                counter++;
            }
            Spectra spec = new Spectra(ID, scanNum, msLevel, centroidCount, peakMZ, peakIntensity, startTime, precursorMZ, precursorCharge, arrivalTime);

            return(spec);
        }
Exemple #9
0
        public static Spectra Parse(IMsScan imsScan, int ID)
        {
            //TODO to boost performance, hard code which table/container to search in "TryGetValue" instead of determining on runtime
            String temp;
            int    msLevel         = TryGetValue(imsScan, GlobalVar.MSLevelHeader, out temp) ? parseMSLevel(temp) : -1;
            int    scanNum         = TryGetValue(imsScan, GlobalVar.ScanNumHeader, out temp) ? int.Parse(temp) : ID;
            double startTime       = TryGetValue(imsScan, GlobalVar.ScanTimeHeader, out temp) ? double.Parse(temp) : -1;
            int    precursorCharge = TryGetValue(imsScan, GlobalVar.PrecursorChargeHeader, out temp) ? int.Parse(temp) : -1;
            double precursorMZ     = TryGetValue(imsScan, GlobalVar.PrecursorMZHeader, out temp) ? double.Parse(temp) : -1;
            int    centroidCount   = (int)imsScan.CentroidCount;

            double[] peakIntensity = new double[centroidCount];
            double[] peakMZ        = new double[centroidCount];

            int counter = 0;

            foreach (ICentroid2 cent in imsScan.Centroids)
            {
                peakIntensity[counter] = cent.Intensity;
                peakMZ[counter]        = cent.Mz;
                counter++;
            }
            Spectra spec = new Spectra(ID, scanNum, msLevel, centroidCount, peakMZ, peakIntensity, startTime, precursorMZ, precursorCharge);

            return(spec);
        }
Exemple #10
0
        protected bool processMS2(Spectra spec)
        {
            performanceEvaluator.countMS2();
            log.Debug(spec);
            IDs id = performDatabaseSearch(spec);

            Boolean isExcluded = false;

            if (id != null)
            {
                Peptide pep = getPeptideFromIdentification(id);
                isExcluded = exclusionList.containsPeptide(pep);
            }
            if (isExcluded)
            {
#if SIMULATION
                //log.Debug("Mass " + spectraMass + " is on the exclusion list. Scan " + spec.getScanNum() + " excluded.");
                evaluateExclusion(id);
                WriterClass.LogScanTime("Excluded", (int)spec.getIndex());
#endif
                performanceEvaluator.countExcludedSpectra();
                excludedSpectra.Add(spec.getScanNum());
                return(false);
            }
            else
            {
                performanceEvaluator.countAnalyzedSpectra();
                //log.Debug("Mass " + spectraMass + " was not on the exclusion list. Scan " + spec.getScanNum() + " analyzed.");
                evaluateIdentification(id);
                includedSpectra.Add(spec.getScanNum());
                // calibrate peptide if the observed retention time doesn't match the predicted
                //WriterClass.LogScanTime("Processed", (int)spec.getIndex());
                return(true);
            }
        }
Exemple #11
0
	private void LoadRelations(
		SortedList<string,string> SortedAccession, SortedList<string,Peptide> SortedPeptides) {
		
		if( m_mzid.Data.DataCollection.AnalysisData.SpectrumIdentificationList.Length != 1 )
			throw new ApplicationException( "Multiple spectrum identification lists not supported" );

		SortedList<string,PeptideEvidenceType> SortedEvidences = new SortedList<string, PeptideEvidenceType>();
		foreach( PeptideEvidenceType evidence in m_mzid.Data.SequenceCollection.PeptideEvidence )
			SortedEvidences.Add( evidence.id, evidence );

		int SpectrumID = 1;
		int PsmID = 1;
		double score;
		string type;
		Peptide.ConfidenceType confidence;
		foreach( SpectrumIdentificationResultType idres in
			m_mzid.Data.DataCollection.AnalysisData.SpectrumIdentificationList[0].SpectrumIdentificationResult ) {
			Spectrum spectrum = new Spectrum();
			spectrum.ID = SpectrumID++;
			spectrum.File = idres.spectraData_ref;
			spectrum.SpectrumID = idres.spectrumID;
			spectrum.Psm = new List<PSM>();
			Spectra.Add(spectrum);
			foreach( SpectrumIdentificationItemType item in idres.SpectrumIdentificationItem ) {
				//Console.Out.WriteLine(item.id);
				GetPsmScore( item, out score, out type, out confidence );
				PSM psm = new PSM();
				psm.ID = PsmID++;
				psm.Charge = item.chargeState;
				psm.Mz = item.experimentalMassToCharge;
				psm.Rank = item.rank;
				psm.Score = score;
				psm.ScoreType = type;
				psm.Confidence = confidence;
				psm.passThreshold = item.passThreshold;
				psm.Spectrum = spectrum;
				spectrum.Psm.Add(psm);
				if( item.PeptideEvidenceRef == null )
					continue;
				foreach( PeptideEvidenceRefType evref in item.PeptideEvidenceRef ) {
					//Console.Out.WriteLine(evref.peptideEvidence_ref);
					PeptideEvidenceType evidence = SortedEvidences[evref.peptideEvidence_ref];
					Peptide pep = SortedPeptides[evidence.peptide_ref];
					if( pep.Sequence == null || pep.Sequence.Length == 0 ) { // ProCon 0.9.348 bug
						//Notify( "Skiped peptide with empty sequence: " + pep.DBRef );
						continue;
					}					
					pep.Decoy = evidence.isDecoy;
					psm.Peptide = pep;
					//pep.Psm.Add(psm);
					Protein prot = m_SortedProteins[SortedAccession[evidence.dBSequence_ref]];
					if( pep.Proteins.Contains(prot) )
						continue;
					prot.Peptides.Add( pep );
					pep.Proteins.Add( prot );
				}
			}
		}
	}
Exemple #12
0
 public override void Deactivate()
 {
     base.Deactivate();
     GetComponent <SpriteRenderer>().color = new Color(1.0f, 1.0f, 1.0f, 0.5f);
     _activeSpectra = null;
     foreach (ActivatableObjectSource source in _sources)
     {
         source.Deactivate();
     }
 }
        public static void CometSingleSearchTest()
        {
            String idx = "C:\\Coding\\2019LavalleeLab\\GitProjectRealTimeMS\\TestData\\PreComputedFiles\\uniprot_SwissProt_Human_1_11_2017_decoyConcacenated.fasta.idx";
            //String idx = "C:\\temp\\comet_2019015\\comet_source_2019015\\IDXMake\\uniprot_SwissProt_Human_1_11_2017_decoyConcacenated.fasta.idx";
            String param = "C:\\Coding\\2019LavalleeLab\\temp2\\ExampleDataSet\\2019.comet.params";

            CometSingleSearch.InitializeComet(idx, param);
            CometSingleSearch.QualityCheck();
            Program.ExitProgram(1);
            String dataRoot   = "C:\\Users\\LavalleeLab\\Documents\\JoshTemp\\MealTimeMS_APITestRun\\Data\\";
            String outputRoot = "C:\\Users\\LavalleeLab\\Documents\\JoshTemp\\MealTimeMS_APITestRun\\Output\\";
            //String mzmlPath = dataRoot+"60minMZMLShrink.csv";
            String   mzmlPath   = dataRoot + "8001.ms2.txt";
            String   dbPath     = dataRoot + "tinyDB.fasta.idx"; //
            String   outputPath = outputRoot + "output.txt";
            String   paramsPath = dataRoot + "comet.params";
            MZMLFile mzml       = Loader.parseMS2File(mzmlPath);

            //MZMLFile mzml = null;
            CometSingleSearch.InitializeComet(dbPath, paramsPath);
            var watch   = System.Diagnostics.Stopwatch.StartNew();
            int counter = 0;

            Console.WriteLine("Starting comet search");
            WriterClass.initiateWriter(outputPath);

            for (int i = 0; i < 1; i++)
            {
                if (i % 1 == 0)
                {
                    Spectra spec = mzml.getSpectraArray()[i];
                    if (spec.getMSLevel() != 2)
                    {
                        continue;
                    }
                    Console.WriteLine("scanNum {0} RT {2} Mass {2} MSLevel {3}", spec.getScanNum(), spec.getStartTime(),
                                      spec.getCalculatedPrecursorMass(), spec.getMSLevel());
                    IDs id = null;
                    if (CometSingleSearch.Search(spec, out id))
                    {
                        String outLine = String.Format("{0}\t{1}\txcorr\t{2}\tdcn\t{3}", id.getScanNum(), id.getPeptideSequence(), id.getXCorr(), id.getDeltaCN());
                        Console.WriteLine(outLine);
                        WriterClass.writeln(outLine);
                    }
                    else
                    {
                        Console.WriteLine("Spectrum cannot be matched\n");
                    }
                    counter++;
                }
            }
            watch.Stop();
            Console.WriteLine("Comet search of " + counter + " spectra took " + watch.ElapsedMilliseconds + " milliseconds");
            WriterClass.CloseWriter();
        }
        public static bool Run()
        {
            string      outputPath = @"C:\_IRIC\DATA\Test\testMhc\Stats\";
            vsCSVWriter writer     = new vsCSVWriter(outputPath + "output.csv");

            writer.AddLine("File,# MS1s,# MSMS,1 Charge,2 Charge,3 Charge,4 Charge,5 Charge,6 Charge,7 Charge,8 Charge,9 Charge,10 Charge,11 Charge,12 Charge,13 Charge,14 Charge");

            DBOptions options = MhcSample.CreateOptions(outputPath);

            string[] files = new string[] { @"N:\Thibault\-=Proteomics_Raw_Data=-\ELITE\JUL29_2013\Settepeptides_300713_10uL.raw",
                                            @"N:\Thibault\-=Proteomics_Raw_Data=-\ELITE\JUL29_2013\Settepeptides_300713_10uL_MS60_MSMS15.raw",
                                            @"N:\Thibault\-=Proteomics_Raw_Data=-\ELITE\JUL29_2013\Settepeptides_300713_10uL_MS60_MSMS30.raw",
                                            @"N:\Thibault\-=Proteomics_Raw_Data=-\ELITE\JUL29_2013\Settepeptides_300713_10uL_MS60_MSMS60.raw",
                                            @"N:\Thibault\-=Proteomics_Raw_Data=-\ELITE\JUL29_2013\Settepeptides_300713_10uL_MS120_MSMS15.raw",
                                            @"N:\Thibault\-=Proteomics_Raw_Data=-\ELITE\JUL29_2013\Settepeptides_300713_10uL_MS120_MSMS30.raw",
                                            @"N:\Thibault\-=Proteomics_Raw_Data=-\ELITE\JUL29_2013\Settepeptides_300713_10uL_MS120_MSMS60.raw" };
            foreach (string file in files)
            {
                pwiz.CLI.msdata.MSDataFile msFile = new pwiz.CLI.msdata.MSDataFile(file);
                Spectra spectra = Spectra.Load(msFile, options, file);
                spectra.Sort(ProductSpectrum.AscendingPrecursorMassComparison);

                Dictionary <Track, Precursor> DicOfComputedTracks = new Dictionary <Track, Precursor>();
                int[] charges = new int[14];
                foreach (Track track in spectra.tracks)
                {
                    if (!DicOfComputedTracks.ContainsKey(track))
                    {
                        DicOfComputedTracks.Add(track, null);
                        int charge = 0;
                        foreach (Precursor precursor in Queries.GetIsotopes(track, options, spectra.tracks, null))
                        {
                            if (precursor.Charge > 0)
                            {
                                charge = precursor.Charge;
                            }
                            if (!DicOfComputedTracks.ContainsKey(precursor.Track))
                            {
                                DicOfComputedTracks.Add(precursor.Track, precursor);
                            }
                        }
                        charges[charge]++;
                    }
                }
                string line = file + "," + spectra.MS1s.Count + "," + spectra.Count;
                for (int i = 0; i < charges.Length; i++)
                {
                    line += "," + charges[i];
                }
                writer.AddLine(line);
            }
            writer.WriteToFile();
            return(true);
        }
Exemple #15
0
 public SimCentroid(Spectra spec, int i, Random rnd)
 {
     IsExceptional  = true;
     IsReferenced   = false;
     IsMerged       = true;
     IsFragmented   = true;
     IsMonoisotopic = true;
     Charge         = rnd.Next(1, 6); //note this charge is the charge of each peak on a ms2, so this is not the precursor charge
     Profile        = null;
     Mz             = spec.getPeakMz()[i];
     Intensity      = spec.getPeakIntensity()[i];
     Resolution     = 100000;
 }
Exemple #16
0
	/// <summary>
	/// Loads data from a peptide identification file
	/// </summary>
	/// <param name="merge">
	/// A <see cref="System.Boolean"/> indicating wether merge the new file with the existing data
	/// </param>
	public void Load( string path, bool merge ) {
		if( !merge || m_Run == 0 ) {
			m_InputFiles.Clear();
			Proteins.Clear();
			Peptides.Clear();
			Spectra.Clear();
			m_gid = 1;
			m_SortedProteins = new SortedList<string, Protein>();
			m_Run = 1;
		} else
			m_Run++;
		Load( path );
		m_InputFiles.Add( Path.GetFileName(path) );
	}
Exemple #17
0
        public PlotModel display_TwoMS2(PSM psm1, PSM psm2)
        {
            Spectra spec1 = null, spec2 = null;
            Peptide pep1 = null, pep2 = null;

            MainW.parse_PSM(psm1, ref spec1, ref pep1);
            MainW.parse_PSM(psm2, ref spec2, ref pep2);

            PlotModel  model  = new PlotModel();
            LinearAxis x_axis = new LinearAxis();

            x_axis.Position               = AxisPosition.Bottom;
            x_axis.Maximum                = (spec1.Peaks.Last().Mass > spec2.Peaks.Last().Mass ? spec1.Peaks.Last().Mass : spec2.Peaks.Last().Mass) + 50;
            x_axis.Minimum                = (spec1.Peaks[0].Mass < spec2.Peaks[0].Mass ? spec1.Peaks[0].Mass : spec2.Peaks[0].Mass) - 50;
            x_axis.AbsoluteMaximum        = x_axis.Maximum;
            x_axis.AbsoluteMinimum        = x_axis.Minimum;
            x_axis.PositionAtZeroCrossing = true;
            x_axis.TickStyle              = TickStyle.Crossing;
            x_axis.IsAxisVisible          = false;
            model.Axes.Add(x_axis);
            LinearAxis y_axis = new LinearAxis();

            y_axis.Minimum       = -100;
            y_axis.Maximum       = 100;
            y_axis.IsPanEnabled  = false;
            y_axis.IsZoomEnabled = false;
            y_axis.Title         = psm2.Title + "-" + psm1.Title;
            model.Axes.Add(y_axis);
            LineSeries ls = new LineSeries();

            ls.Color     = OxyColors.Black;
            ls.LineStyle = LineStyle.Solid;
            ls.Points.Add(new DataPoint(x_axis.Minimum, 0));
            ls.Points.Add(new DataPoint(x_axis.Maximum, 0));
            model.Series.Add(ls);

            MainW.psm_help.Switch_PSM_Help(spec1, pep1);
            MainW.psm_help.Pep.Tag_Flag = int.Parse(psm1.Pep_flag);
            MainW.psm_help.Match_BY();
            update_peaks(spec1, ref model);
            MainW.psm_help.Switch_PSM_Help(spec2, pep2);
            MainW.psm_help.Pep.Tag_Flag = int.Parse(psm2.Pep_flag);
            MainW.psm_help.Match_BY();
            for (int i = 0; i < spec2.Peaks.Count; ++i)
            {
                spec2.Peaks[i].Intensity = -spec2.Peaks[i].Intensity;
            }
            update_peaks(spec2, ref model);
            return(model);
        }
Exemple #18
0
        public static void parseMZML()
        {
            String   mzmlPath = "/Users/lavalleelab/Desktop/JoshLab/Temp/60minMZML.csv";
            MZMLFile mzml     = Loader.parseMZMLCSV(mzmlPath);

            for (int i = 0; i < 7000; i++)
            {
                if (i % 500 == 0)
                {
                    Spectra spec = mzml.getSpectraArray()[i];
                    Console.WriteLine("ID {0} scanNum{1} RT{2} Mass{3} MSLevel{4}", spec.getIndex(), spec.getScanNum(), spec.getStartTime(),
                                      spec.getCalculatedPrecursorMass(), spec.getMSLevel());
                }
            }
        }
        private void setUpRandomlyExcludedMS2_NoneDDA(List <Spectra> ms2SpectraArray, int numExcluded, int numAnalyzed,
                                                      int maximumNumberOfMS2Spectra)
        {
            ms2SpectraArray       = CloneList(ms2SpectraArray);       //just removes the reference to the original variable, so any operation to the new list doesn't mess with the original list up outside of this function
            randomlyExcludedScans = new List <int>();
            Random r = new Random();

            while (ms2SpectraArray.Count > numAnalyzed)
            {
                int     pos = r.Next(ms2SpectraArray.Count);
                Spectra spectraToBeExcluded = ms2SpectraArray[pos];
                randomlyExcludedScans.Add(spectraToBeExcluded.getScanNum());
                ms2SpectraArray.RemoveAt(pos);
            }
        }
Exemple #20
0
        public static MZMLFile parseMZMLCSV(String fileName, int num)
        {
            List <Spectra> spectraArray = new List <Spectra>();

            log.Info("Parsing the mzML file.");
            log.Debug("File path: " + fileName);
            StreamReader reader = new StreamReader(fileName);

            String[] header = reader.ReadLine().Split("\t".ToCharArray());

            String line    = reader.ReadLine();
            int    counter = 0;

            while (line != null)
            {
                String[] data            = line.Split("\t".ToCharArray());
                int      index           = (int)double.Parse(data[0]);
                int      scanNum         = int.Parse(data[1]);
                int      msLevel         = int.Parse(data[2]);
                int      peakCount       = int.Parse(data[3]);
                double   startTime       = double.Parse(data[4]);
                double   precursorMz     = double.Parse(data[5]);
                double   precursorCharge = double.Parse(data[6]);



                String[] mzArr         = reader.ReadLine().Split("\t".ToCharArray());
                String[] intensityArr  = reader.ReadLine().Split("\t".ToCharArray());
                double[] peakMz        = new double[peakCount];
                double[] peakIntensity = new double[peakCount];
                for (int i = 0; i < peakCount; i++)
                {
                    peakMz[i]        = double.Parse(mzArr[i]);
                    peakIntensity[i] = double.Parse(intensityArr[i]);
                }
                Spectra spec = new Spectra(index, scanNum, msLevel, peakCount, peakMz, peakIntensity,
                                           startTime, precursorMz, precursorCharge);
                spectraArray.Add(spec);
                line = reader.ReadLine();
                counter++;
                if (counter >= num)
                {
                    break;
                }
            }
            Console.WriteLine("Finished Parsing MZML. Parsed " + counter + " spectra");
            return(new MZMLFile(fileName, spectraArray));
        }
        protected bool processMS2(Spectra spec)
        {
            performanceEvaluator.countMS2();

            log.Debug(spec);
            IDs id = performDatabaseSearch(spec);

            // check if mass is on exclusion list

            Boolean isExcluded = false;

            if (id != null)
            {
                Peptide pep = getPeptideFromIdentification(id);
                isExcluded = exclusionList.containsPeptide(pep);                  //checks if the mass should've been excluded,
                //in a real experiment, this should never equal to true
                //since the mass should not have been scanned in the first place
                //if MS exclusion table was updated correctly through API
                if (!peptideRT.Keys.Contains(pep.getSequence()))
                {
                    peptideRT.Add(pep.getSequence(), spec.getStartTime());
                }
            }



            if (isExcluded)
            {
#if SIMULATION
                //log.Debug("Mass " + spectraMass + " is on the exclusion list. Scan " + spec.getScanNum() + " excluded.");
                evaluateExclusion(id);
                WriterClass.LogScanTime("Excluded", (int)spec.getIndex());
#endif
                performanceEvaluator.countExcludedSpectra();
                excludedSpectra.Add(spec.getScanNum());
                return(false);
            }
            else
            {
                performanceEvaluator.countAnalyzedSpectra();
                //log.Debug("Mass " + spectraMass + " was not on the exclusion list. Scan " + spec.getScanNum() + " analyzed.");
                evaluateIdentification(id);
                includedSpectra.Add(spec.getScanNum());
                // calibrate peptide if the observed retention time doesn't match the predicted
                //WriterClass.LogScanTime("Processed", (int)spec.getIndex());
                return(true);
            }
        }
Exemple #22
0
 void OnTriggerEnter2D(Collider2D collider)
 {
     if (collider.GetComponent <Spectra>())
     {
         if (_activeSpectra == null)
         {
             _activeSpectra = collider.GetComponent <Spectra>();
             if (opticColors.Contains(_activeSpectra.SpectraColor))
             {
                 Activate();
             }
             else
             {
                 _activeSpectra = null;
             }
         }
     }
 }
Exemple #23
0
        private void SetBestAngle(float bestAngle)
        {
            SelectedStarBestAngle = bestAngle;

            m_OperationState = SpectroscopyState.StarConfirmed;

            var reader = new SpectraReader(m_VideoController.GetCurrentAstroImage(false), bestAngle, PixelValueCoefficient);

            Spectra spectra = reader.ReadSpectra(
                (float)SelectedStar.XDouble,
                (float)SelectedStar.YDouble,
                MeasurementAreaWing,
                BackgroundAreaWing,
                BackgroundAreaGap,
                PixelCombineMethod.Average);

            m_ControlPanel.PreviewSpectra(spectra);
        }
Exemple #24
0
        /// <summary>
        /// Example program that illustrates how to solve a real nonsymmetric standard eigenvalue
        /// problem in regular mode.
        /// </summary>
        /// <remarks>
        /// MODULE LNSymReg.cc
        ///
        /// In this example we try to solve A*x = x*lambda in regular mode, where A is derived from
        /// the standard central difference discretization of the 2-dimensional convection-diffusion
        /// operator
        ///                    (Laplacian u) + rho*(du/dx)
        /// on a unit square with zero Dirichlet boundary conditions.
        /// </remarks>
        static void LNSymReg()
        {
            int nx = 10;

            // Creating a 100x100 matrix.
            var A = Generate.BlockTridMatrix(nx);

            // Defining what we need: the four eigenvectors of A with largest magnitude.
            var prob = new Spectra(A)
            {
                ComputeEigenVectors = true
            };

            // Finding eigenvalues and eigenvectors.
            var result = prob.SolveStandard(4, Spectrum.LargestMagnitude);

            // Printing solution.
            Solution.General(A, (SpectraResult)result, false);
        }
Exemple #25
0
        /// <summary>
        /// Example program that illustrates how to solve a real nonsymmetric standard eigenvalue
        /// problem in shift and invert mode.
        /// </summary>
        /// <remarks>
        /// MODULE LNSymShf.cc
        ///
        /// In this example we try to solve A*x = x*lambda in shift and invert mode, where A is
        /// derived from 2-D Brusselator Wave Model. The shift is a real number.
        ///
        /// The SuperLU package is called to solve some linear systems involving (A-sigma*I).
        /// </remarks>
        static void LNSymShf()
        {
            int n = 200; // Dimension of the problem.

            // Creating a 200x200 matrix.
            var A = Generate.BrusselatorMatrix(1.0, 0.004, 0.008, 2.0, 5.45, n);

            // Defining what we need: the four eigenvectors of BWM nearest to 0.0.
            var prob = new Spectra(A)
            {
                ComputeEigenVectors = true, ArnoldiCount = 30
            };

            // Finding eigenvalues and eigenvectors.
            var result = prob.SolveStandard(4, 0.0, Spectrum.LargestMagnitude);

            // Printing solution.
            Solution.General(A, (SpectraResult)result, true);
        }
Exemple #26
0
        /// <summary>
        /// Example program that illustrates how to solve a real symmetric standard eigenvalue
        /// problem in shift and invert mode.
        /// </summary>
        /// <remarks>
        /// MODULE LSymShf.cc
        ///
        /// In this example we try to solve A*x = x*lambda in shift and invert mode, where A is
        /// derived from the central difference discretization of the one-dimensional Laplacian
        /// on [0, 1] with zero Dirichlet boundary conditions.
        ///
        /// The SuperLU package is called to solve some linear systems involving (A-sigma*I).
        /// This is needed to implement the shift and invert strategy.
        /// </remarks>
        static void LSymShf()
        {
            int n = 100; // Dimension of the problem.

            // Creating a 100x100 matrix.
            var A = Symmetrize(Generate.SymmetricMatrixB(n));

            // Defining what we need: the four eigenvectors of A nearest to 1.0.
            var prob = new Spectra(A, true)
            {
                ComputeEigenVectors = true
            };

            // Finding eigenvalues and eigenvectors.
            var result = prob.SolveStandard(4, 1.0);

            // Printing solution.
            Solution.Symmetric(A, (SpectraResult)result, true);
        }
Exemple #27
0
        /// <summary>
        /// Example program that illustrates how to solve a real symmetric standard eigenvalue
        /// problem in regular mode.
        /// </summary>
        /// <remarks>
        /// MODULE LSymReg.cc
        ///
        /// In this example we try to solve A*x = x*lambda in regular  mode, where A is derived
        /// from the standard central difference  discretization of the 2-dimensional Laplacian
        /// on the unit square with zero Dirichlet boundary conditions.
        /// </remarks>
        static void LSymReg()
        {
            int nx = 10;

            // Creating a 100x100 matrix.
            var A = Symmetrize(Generate.SymmetricMatrixA(nx));

            // Defining what we need: the four eigenvectors of A with smallest magnitude.
            var prob = new Spectra(A, true)
            {
                ComputeEigenVectors = true
            };

            // Finding eigenvalues and eigenvectors.
            var result = prob.SolveStandard(2, Spectrum.SmallestMagnitude);

            // Printing solution.
            Solution.Symmetric(A, (SpectraResult)result, false);
        }
Exemple #28
0
        /// <summary>
        /// Example program that illustrates how to solve a real symmetric generalized eigenvalue
        /// problem in regular mode.
        /// </summary>
        /// <remarks>
        /// MODULE LSymGReg.cc
        ///
        /// In this example we try to solve A*x = B*x*lambda in regular mode, where A and B are obtained
        /// from the finite element discretization of the 1-dimensional discrete Laplacian
        ///                               d^2u / dx^2
        /// on the interval [0,1] with zero Dirichlet boundary conditions using piecewise linear elements.
        ///
        /// The SuperLU package is called to solve some linear systems involving B.
        /// </remarks>
        static void LSymGReg()
        {
            int n = 100; // Dimension of the problem.

            // Creating matrices A and B.
            var A = Symmetrize(Generate.SymmetricMatrixC(n));
            var B = Symmetrize(Generate.SymmetricMatrixD(n));

            // Defining what we need: the four eigenvectors with largest magnitude.
            var prob = new Spectra(A, B, true)
            {
                ComputeEigenVectors = true
            };

            // Finding eigenvalues and eigenvectors.
            var result = prob.SolveGeneralized(4, Spectrum.LargestMagnitude);

            // Printing solution.
            Solution.Symmetric(A, B, (SpectraResult)result, ShiftMode.None);
        }
Exemple #29
0
        protected IDs performDatabaseSearch(Spectra spec)
        {
            IDs id = null;

            if (CometSingleSearch.Search(spec, out id))
            {
                log.Debug("MS2 scan was identified.");
                log.Debug(id);
                performanceEvaluator.countMS2Identified();
                PSMTSVReaderWriter.WritePSM(id);
            }
            else
            {
                // scan cannot be matched to a peptide
                log.Debug("MS2 scan {0} was not identified by a comet search", spec.getScanNum());
                performanceEvaluator.countMS2Unidentified();
            }

            return(id);
        }
Exemple #30
0
        /// <summary>
        /// Example program that illustrates how to solve a real symmetric generalized eigenvalue
        /// problem in Cayley mode.
        /// </summary>
        /// <remarks>
        /// MODULE LSymGCay.cc
        ///
        /// In this example we try to solve A*x = B*x*lambda in Cayley mode, where A and B are obtained
        /// from the finite element discretization of the 1-dimensional discrete Laplacian
        ///                               d^2u / dx^2
        ///  on the interval [0,1] with zero Dirichlet boundary conditions using piecewise linear elements.
        ///
        /// The SuperLU package is called to solve some linear systems involving (A-sigma*B).
        /// </remarks>
        static void LSymGCay()
        {
            int n = 100; // Dimension of the problem.

            // Creating matrices A and B.
            var A = Symmetrize(Generate.SymmetricMatrixC(n));
            var B = Symmetrize(Generate.SymmetricMatrixD(n));

            // Defining what we need: the four eigenvectors nearest to 150.0.
            var prob = new Spectra(A, B, true)
            {
                ComputeEigenVectors = true
            };

            // Finding eigenvalues and eigenvectors.
            var result = prob.SolveGeneralized(4, 150.0, ShiftMode.Cayley);

            // Printing solution.
            Solution.Symmetric(A, B, (SpectraResult)result, ShiftMode.Cayley);
        }
        public override bool CompleteFirstPass()
        {
            // Ignore this notification, if there is no retention time predictor
            if (_retentionTimePredictor == null)
                return false;

            ExtractionComplete();
            var dataFile = _spectra.Detach();

            // Start the second pass
            _filter = new SpectrumFilter(_document, FileInfo.FilePath, _filter, _retentionTimePredictor);
            _spectra = null;
            _isSrm = false;

            InitSpectrumReader(dataFile);
            InitChromatogramExtraction();
            return true;
        }
        private void InitSpectrumReader(MsDataFileImpl dataFile)
        {
            // Create the spectra object responsible for delivering spectra for extraction
            _spectra = new Spectra(_document, _filter, _allChromData, dataFile);

            // Determine what type of demultiplexer, if any, to use based on settings in the
            // IsolationScheme menu
            _demultiplexer = _spectra.CreateDemultiplexer();

            if (_demultiplexer == null)
            {
                _spectra.RunAsync();
            }
        }