Example #1
0
 public DisplayUnlocalizedModification(UnlocalizedModification m)
     : base(m)
 {
     this.m = m;
 }
Example #2
0
        private void btn_compare_with_td_Click(object sender, EventArgs e)
        {
            MessageBox.Show("Please select a top-down results file.");
            OpenFileDialog openFileDialog = new OpenFileDialog();

            openFileDialog.Title       = "Top-Down Results";
            openFileDialog.Filter      = "Excel Files (*.xlsx) | *.xlsx";
            openFileDialog.Multiselect = false;
            DialogResult dr = openFileDialog.ShowDialog();

            if (dr == DialogResult.OK)
            {
                MessageBox.Show("Save comparison results file.");
                SaveFileDialog saveFileDialog = new SaveFileDialog();
                saveFileDialog.Title  = "Top-Down Comparison Results";
                saveFileDialog.Filter = "Text Files (*.tsv) | *.tsv";
                DialogResult sdr = saveFileDialog.ShowDialog();
                if (sdr == DialogResult.OK)
                {
                    InputFile                     file           = new InputFile(openFileDialog.FileName, Purpose.TopDown);
                    TopDownReader                 reader         = new TopDownReader();
                    List <TopDownHit>             hits           = reader.ReadTDFile(file);
                    List <TopDownProteoform>      td_proteoforms = Sweet.lollipop.aggregate_td_hits(hits, 0, true, true);
                    List <ExperimentalProteoform> experimentals  = Sweet.lollipop.target_proteoform_community.experimental_proteoforms.Where(p => p.linked_proteoform_references != null && (Sweet.lollipop.count_adducts_as_identifications || !p.adduct) && !p.topdown_id).ToList();
                    experimentals = Sweet.lollipop.add_topdown_proteoforms(experimentals, td_proteoforms);
                    using (var writer = new System.IO.StreamWriter(saveFileDialog.FileName))
                    {
                        writer.WriteLine("Experimental Accession\tExperimental Mass\tExperimental Retention Time\tTheoretical Accession\tTheoretical Description\tTheoretical Begin\tTheoretical End\tTheoretical PTM Description\tTop-Down Accession\tTop-Down Begin\tTop-Down End\tTop-Down PTM Description\tTop-Down Observed Mass\tTop-Down Retention Time\tTop Top-Down C-Score");
                        foreach (ExperimentalProteoform ep in experimentals)
                        {
                            if (ep.topdown_id)
                            {
                                TopDownProteoform tdp = ep as TopDownProteoform;
                                if (tdp.matching_experimental != null)
                                {
                                    ExperimentalProteoform exp = tdp.matching_experimental;
                                    string exp_ptm             = exp.ptm_set.ptm_combination.Count == 0 ? "Unmodified" : string.Join(", ", exp.ptm_set.ptm_combination.Select(ptm => UnlocalizedModification.LookUpId(ptm.modification)).OrderBy(p => p));
                                    string td_ptm = tdp.topdown_ptm_set.ptm_combination.Count == 0 ? "Unmodified" : string.Join(", ", tdp.topdown_ptm_set.ptm_combination.Select(ptm => UnlocalizedModification.LookUpId(ptm.modification)).OrderBy(p => p));
                                    writer.WriteLine(exp.accession + "\t" + exp.agg_mass + "\t" + exp.agg_rt + "\t" + exp.linked_proteoform_references.First().accession.Split('_')[0] + "\t" + (exp.linked_proteoform_references.First() as TheoreticalProteoform).description + "\t" + exp.begin + "\t" + exp.end + "\t" + exp_ptm
                                                     + "\t" + tdp.accession.Split('_')[0] + "\t" + tdp.topdown_begin + "\t" + tdp.topdown_end + "\t" + td_ptm + "\t" + tdp.modified_mass + "\t" + tdp.agg_rt + "\t" + tdp.topdown_hits.Max(h => h.score));
                                }
                            }
                            else
                            {
                                string exp_ptm          = ep.ptm_set.ptm_combination.Count == 0 ? "Unmodified" : string.Join(", ", ep.ptm_set.ptm_combination.Select(ptm => UnlocalizedModification.LookUpId(ptm.modification)).OrderBy(p => p));
                                TheoreticalProteoform t = ep.linked_proteoform_references.First() as TheoreticalProteoform;
                                writer.WriteLine(ep.accession + "\t" + ep.agg_mass + "\t" + ep.agg_rt + "\t" + t.accession.Split('_')[0] + "\t" + t.description + "\t" + t.begin + "\t" + t.end + "\t" + exp_ptm
                                                 + "\t" + "N\\A" + "\t" + "N\\A" + "\t" + "N\\A" + "\t" + "N\\A" + "\t" + "N\\A" + "\t" + "N\\A" + "\t" + "N\\A");
                            }
                        }
                    }
                    MessageBox.Show("Successfully saved top-down comparison results.");
                }
                else
                {
                    return;
                }
            }
            else
            {
                return;
            }
        }