public void DisplayProtein(MyProtein p)
        {
            myProtein = p;

            ListBoxFiles.Items.Clear();
            List <String> fileNames = (from pep in p.PeptideResults
                                       from scan in pep.MyScans
                                       select scan.FileName).Distinct().ToList();

            fileNames.Sort();

            CheckBox chk = new CheckBox();

            chk.IsChecked = true;
            chk.Content   = "AllFiles";
            ListBoxFiles.Items.Add(chk);

            foreach (string fileName in fileNames)
            {
                CheckBox chk2 = new CheckBox();
                chk2.Content = fileName;
                ListBoxFiles.Items.Add(chk2);
            }

            Plot();
        }
        public void FireUpInterface(List <MyProtein> theProteinsInGroup, MyProtein p)
        {
            sequenceViewer1.DisplayProtein(p);
            MyProteinGroup = theProteinsInGroup;
            ThisProtein    = p;


            string        Locus         = p.Locus;
            string        FastaSequence = p.Sequence;
            List <string> Peptides      = p.PeptideResults.Select(a => a.PeptideSequence).ToList();

            globalProteinCoverage1.Plot(Locus, FastaSequence, Peptides);
        }
Example #3
0
        public ProtQuant(MyProtein theProtein, List <PepQuant> theQuants)
        {
            int successPos = 0;
            int successNeg = 0;

            Protein      = theProtein;
            ThePepQuants = theQuants;

            List <double> globalFold        = new List <double>();
            List <double> correctedTTests   = new List <double>();
            List <double> uncorrectedTTests = new List <double>();
            List <double> w = new List <double>();

            foreach (PepQuant pq in theQuants)
            {
                if (pq.AVGLogFold > 0)
                {
                    successPos++;
                }
                else
                {
                    successNeg++;
                }
                globalFold.Add(pq.AVGLogFold);
                correctedTTests.Add(pq.CorrectedTTest);
                uncorrectedTTests.Add(pq.TTest);
                w.Add(1);
            }

            double bin = 0;

            if (successPos > successNeg)
            {
                bin = alglib.binomialcdistribution(successPos - 1, theQuants.Count, 0.5);
            }
            else if (successNeg > successPos)
            {
                bin = alglib.binomialcdistribution(successNeg - 1, theQuants.Count, 0.5);
            }
            else
            {
                bin = 0.5;
            }

            Binomial            = bin;
            GlobalFold          = globalFold.Average();
            Stauffers           = PatternTools.pTools.StouffersMethod(correctedTTests);
            UncorrectedStauffer = PatternTools.pTools.StouffersMethod(uncorrectedTTests);
        }
Example #4
0
        private void dataGridProteins_SelectedCellsChanged(object sender, SelectedCellsChangedEventArgs e)
        {
            try
            {
                MyProtein p = (MyProtein)dataGridProteins.SelectedItem;
                MyProtein r = ResultViewerResultPackage.MyProteins.MyProteinList.Find(a => a.Locus.Equals(p.Locus));

                List <SQTScan> toDisplay = PatternTools.ObjectCopier.Clone(r.Scans);

                dataGridPeptides.ItemsSource = toDisplay;
            }
            catch (Exception e4)
            {
                Console.WriteLine("Couldn't plot protein : " + e4.Message);
            }
        }
Example #5
0
        private void buttonGo_Click(object sender, EventArgs e)
        {
            saveFileDialog1.Filter = "Fasta Files | *.fasta";
            if (saveFileDialog1.ShowDialog() != System.Windows.Forms.DialogResult.Cancel)
            {
                //Extract IDs
                string[] lines = Regex.Split(richTextBoxFastaIDs.Text, "\n");

                List <FastaItem> fastaItems = new List <FastaItem>(lines.Length);

                foreach (string line in lines)
                {
                    string[] cols  = Regex.Split(line, "\t");
                    int      index = MyRP.MyProteins.MyProteinList.FindIndex(a => a.Locus.Equals(cols[0]));

                    if (index == -1)
                    {
                        Console.WriteLine("Locus " + cols[0] + "not found in the results");
                        continue;
                    }

                    MyProtein prot = MyRP.MyProteins.MyProteinList[index];


                    FastaItem fi = new FastaItem();
                    fi.Description        = prot.Description;
                    fi.Sequence           = prot.Sequence;
                    fi.SequenceIdentifier = prot.Locus;

                    fastaItems.Add(fi);
                }

                //And now save the fasta sequences

                StreamWriter sw = new StreamWriter(saveFileDialog1.FileName);
                foreach (FastaItem fi in fastaItems)
                {
                    sw.WriteLine(">" + fi.SequenceIdentifier + " " + fi.Description);
                    sw.WriteLine(fi.Sequence);
                }
                sw.Close();

                MessageBox.Show("Fasta sequences saved");
                this.Close();
            }
        }
Example #6
0
        public ProtQuant(MyProtein myProtein, double p)
        {
            Protein = myProtein;
            P       = p;

            //Calculate the fold change
            List <double> class1 = new List <double>();
            List <double> class2 = new List <double>();

            foreach (SQTScan sqt in myProtein.Scans)
            {
                class1.Add(sqt.Quantitation[0].GetRange(0, 3).Average());
                class2.Add(sqt.Quantitation[0].GetRange(3, 3).Average());
            }

            Fold = class1.Average() / class2.Average();
        }
Example #7
0
        //Show sequence coverage
        private void dataGridProteins_MouseDoubleClick(object sender, MouseButtonEventArgs e)
        {
            try
            {
                MyProtein p = (MyProtein)dataGridProteins.SelectedItem;
                MyProtein r = searchableProteinList.Find(a => a.Locus.Equals(p.Locus));

                List <MyProtein> proteinsInGroups = ResultViewerResultPackage.MyProteins.MyProteinList.FindAll(a => a.GroupNo == p.GroupNo);

                SequenceExplorer svf = new SequenceExplorer();
                svf.FireUpInterface(proteinsInGroups, p);
                svf.Show();
            }
            catch (Exception e7)
            {
                Console.WriteLine("Unable to plot protein sequence; reason: " + e7.Message);
            }
        }
Example #8
0
        public void GenerateGraph(List <MyProtein> myProteins, MyProtein mainProtein)
        {
            g = new Graph("Protein Group");

            foreach (MyProtein p in myProteins)
            {
                g.AddNode(p.Locus);
            }

            Node n = g.FindNode(mainProtein.Locus);

            n.Attr.Fontcolor = Microsoft.Glee.Drawing.Color.Red;

            List <GraphLink> theLinks = new List <GraphLink>();

            foreach (MyProtein p in myProteins)
            {
                List <MyProtein> linkedProteins = myProteins.FindAll(a => a.DistinctPeptides.Intersect(p.DistinctPeptides).ToList().Count > 0);
                linkedProteins.Remove(p);

                foreach (MyProtein mp in linkedProteins)
                {
                    if (!theLinks.Exists(a => a.To.Equals(p.Locus) && a.From.Equals(mp.Locus)))
                    {
                        theLinks.Add(new GraphLink(mp.Locus, p.Locus));
                        Edge e = new Edge(p.Locus, "", mp.Locus);
                        e.Attr.ArrowHeadAtTarget = ArrowStyle.None;

                        if (mp.Locus.Equals(mainProtein.Locus) || p.Locus.Equals(mainProtein.Locus))
                        {
                            e.Attr.Color = Microsoft.Glee.Drawing.Color.Red;
                        }
                        g.Edges.Add(e);
                    }
                    else
                    {
                    }
                }
            }
            gViewer.Graph = g;
        }