예제 #1
0
        private void buttonXtract_Click(object sender, EventArgs e)
        {
            if (textBoxScanNo.Text.Length == 0)
            {
                MessageBox.Show("Please enter a valid scan number");
                return;
            }
            double theoreticalMH = double.Parse(textBoxTheoreticalMass.Text);
            int    scanNo        = int.Parse(textBoxScanNo.Text);

            SQTLight s = new SQTLight(null);

            s.PeptideSequenceCleaned = "N/A";
            XQuantClusteringParameters myParams = parameters1.GetFromScreen();

            Stopwatch stopwatch = new Stopwatch();

            stopwatch.Start();
            Dictionary <string, List <Quant> > theQuants = Core35.Quant(getter, s, theoreticalMH, isotopicSignal, scanNo, myParams);

            stopwatch.Stop();
            Console.WriteLine("Time elapsed: {0}", stopwatch.Elapsed);

            foreach (var kvp in theQuants)
            {
                foreach (Quant q in kvp.Value)
                {
                    //XICViewer viewer = new XICViewer();

                    //viewer.Plot(q.PrecursorMZ, q.GetIonsLight(), new List<int>() { q.ScanNoMS2 });
                    //viewer.ShowDialog();
                }
            }
        }
예제 #2
0
        public static Core35 DeserializeJSON(string fileName)
        {
            StreamReader sr = new StreamReader(fileName);
            Core35       c  = JsonConvert.DeserializeObject <Core35>(
                sr.ReadToEnd());

            sr.Close();

            return(c);
        }
예제 #3
0
        public static Core35 Deserialize(string fileName)
        {
            Stream          stream     = File.Open(fileName, FileMode.Open);
            BinaryFormatter bformatter = new BinaryFormatter();
            Core35          core       = (Core35)bformatter.Deserialize(stream);

            stream.Close();

            //Make sure we are loading something clean
            core.RemoveDuplicateQuants();

            return(core);
        }
        public void UpdateCoreWithLabels(Core35 theCore)
        {
            for (int y = 0; y < dataGridViewQuantPckgs.Rows.Count; y++)
            {
                string dir   = dataGridViewQuantPckgs.Rows[y].Cells[0].Value.ToString();
                int    index = theCore.myQuantPkgs.FindIndex(a => a.FullDirPath.Equals(dir));

                if (index == -1)
                {
                    throw new Exception("Error in class assignment linkage.");
                }

                int lbl = int.Parse(dataGridViewQuantPckgs.Rows[y].Cells[1].Value.ToString());
                theCore.myQuantPkgs[index].ClassLabel = lbl;

                int index2 = theCore.MyAssociationItems.FindIndex(a => a.FileName.Equals(theCore.myQuantPkgs[index].FileName) && dir.Contains(a.Directory));
                theCore.MyAssociationItems[index2].Label = lbl;
            }
        }
예제 #5
0
        public void Process()
        {
            myQuantPkgs = new List <QuantPackage2>();
            SignalGenerator isotopicSignal = new SignalGenerator();

            foreach (SEProFileInfo sfi in SEProFiles)
            {
                foreach (string file in sfi.MyFilesFullPath)
                {
                    Console.WriteLine("Processing for " + file);
                    ResultPackage rp = ResultPackage.Load(file);

                    List <string> filesInSEPro = (from sqt in rp.MyProteins.AllSQTScans
                                                  select sqt.FileName).Distinct().ToList();

                    FileInfo fi = new FileInfo(file);

                    foreach (string msFile in filesInSEPro)
                    {
                        QuantPackage2 qp = new QuantPackage2(msFile, fi.Directory.FullName, sfi.ClassLabel);

                        Console.WriteLine("\t" + msFile);
                        List <string> ms1OrRawOrmzMLFiles = fi.Directory.GetFiles("*.ms1").ToList().Concat(fi.Directory.GetFiles("*.RAW")).Concat(fi.Directory.GetFiles("*.mzML")).ToList().Select(a => a.Name).ToList();


                        int fileToRead = ms1OrRawOrmzMLFiles.FindIndex(a => RemoveExtension(a).Equals(RemoveExtension(msFile)));

                        XICGet5 xic = new XICGet5(fi.DirectoryName + "/" + ms1OrRawOrmzMLFiles[fileToRead]);

                        List <SQTScan> scansTMP = rp.MyProteins.AllSQTScans.FindAll(a => a.FileName.Equals(msFile));

                        if (MyClusterParams.OnlyUniquePeptides)
                        {
                            int removedForNotUnique = scansTMP.RemoveAll(a => a.IsUnique);
                            Console.WriteLine("Scans removed for not dealing with unique peptides: " + removedForNotUnique);
                        }

                        List <SQTLight> scans = scansTMP.Select(a => new SQTLight(a)).ToList();

                        int counter = 0;
                        for (int i = 0; i < scans.Count; i++)
                        {
                            Dictionary <string, List <Quant> > theseQuants = Core35.Quant(xic, scans[i], scans[i].TheoreticalMH, isotopicSignal, scans[i].ScanNumber, MyClusterParams);

                            foreach (var kvp in theseQuants)
                            {
                                kvp.Value.RemoveAll(a => a.MyIons.GetLength(1) < MyClusterParams.MinMS1Counts);

                                if (kvp.Value.Count > 0)
                                {
                                    if (qp.MyQuants.ContainsKey(kvp.Key))
                                    {
                                        qp.MyQuants[kvp.Key].AddRange(kvp.Value);
                                    }
                                    else
                                    {
                                        qp.MyQuants.Add(kvp.Key, kvp.Value);
                                    }
                                }
                            }

                            counter++;
                            Console.Write("\rScans Processed: " + counter + "/" + scans.Count);
                        }

                        //Store them
                        myQuantPkgs.Add(qp);
                        Console.WriteLine("\nTotal quants stored so far = " + myQuantPkgs.Sum(a => a.MyQuants.Count));
                        Console.WriteLine("Total files analyzed so far = " + myQuantPkgs.Count);

                        Console.WriteLine("Done procesing :" + msFile);
                        System.GC.Collect();
                        System.GC.WaitForPendingFinalizers();
                        System.GC.Collect();
                    }
                }
            }


            GenerateAssociationItems();
        }