Exemple #1
0
        public void TestDoubleAverage()
        {
            List <TopDownHit> tdhList = new List <TopDownHit>();

            for (int i = 0; i < 10; i++)
            {
                TopDownHit t = new TopDownHit();
                t.score = (10 + Convert.ToDouble(i));
                t.ms2_retention_time = 50;
                t.accession          = "accession";
                t.sequence           = "sequence";
                t.pscore             = (double)1 / (i + 1);
                t.ptm_list           = new List <Ptm>();
                t.tdResultType       = TopDownResultType.TightAbsoluteMass;
                tdhList.Add(t);
            }

            tdhList[9].ms2_retention_time = 52;

            Sweet.lollipop.top_down_hits       = tdhList;
            Sweet.lollipop.topdown_proteoforms = Sweet.lollipop.aggregate_td_hits(Sweet.lollipop.top_down_hits, Sweet.lollipop.min_score_td, Sweet.lollipop.biomarker, Sweet.lollipop.tight_abs_mass);

            int count = Sweet.lollipop.topdown_proteoforms.Count();

            Assert.AreEqual(1, count);                                                        //all topdown hits should aggregate to a single proteoform
            Assert.AreEqual(19, Sweet.lollipop.topdown_proteoforms[0].topdown_hits[0].score); //higher scoring topdown hit should be root.
            Assert.AreEqual(10, Sweet.lollipop.topdown_proteoforms[0].topdown_hits.Count());  //higher scoring topdown hit should be root.
            Assert.IsTrue(Sweet.lollipop.topdown_proteoforms[0].agg_rt < 52);
        }
Exemple #2
0
 public LabeledMs1DataPoint(double mz, double retentionTime, double logTotalIonCurrent, double logInjectionTime, double massError, TopDownHit identification)
 {
     this.mz                 = mz;
     this.retentionTime      = retentionTime;
     this.logTotalIonCurrent = logTotalIonCurrent;
     this.logInjectionTime   = logInjectionTime;
     this.massError          = massError;
     this.identification     = identification;
     Inputs = new double[] { mz, retentionTime };
 }
Exemple #3
0
        public void TestSimpleAggregation()
        {
            List <TopDownHit> tdhList = new List <TopDownHit>();

            for (int i = 0; i < 2; i++)
            {
                TopDownHit t = new TopDownHit();
                t.score = (10 + Convert.ToDouble(i));
                t.ms2_retention_time = 50d;
                t.ptm_list           = new List <Ptm>();
                t.pfr_accession      = "12345";
                t.sequence           = "SEQUENCE";
                t.tdResultType       = TopDownResultType.TightAbsoluteMass;
                tdhList.Add(t);
                t.pscore = 1 / (i + 1);
            }
            Sweet.lollipop.clear_td();
            Sweet.lollipop.top_down_hits       = tdhList;
            Sweet.lollipop.topdown_proteoforms = Sweet.lollipop.aggregate_td_hits(Sweet.lollipop.top_down_hits, Sweet.lollipop.min_score_td, Sweet.lollipop.biomarker, Sweet.lollipop.tight_abs_mass);

            int count = Sweet.lollipop.topdown_proteoforms.Count();

            Assert.AreEqual(1, count);                                                        //both topdown hits should aggregate to a single proteoform
            Assert.AreEqual(11, Sweet.lollipop.topdown_proteoforms[0].topdown_hits[0].score); //higher scoring topdown hit should be root.
            Assert.AreEqual(2, Sweet.lollipop.topdown_proteoforms[0].topdown_hits.Count());   //higher scoring topdown hit should be root.

            //Test no aggregation outside retention time range
            tdhList[1].ms2_retention_time     += Convert.ToDouble(Sweet.lollipop.td_retention_time_tolerance + 1);
            Sweet.lollipop.top_down_hits       = tdhList;
            Sweet.lollipop.topdown_proteoforms = Sweet.lollipop.aggregate_td_hits(Sweet.lollipop.top_down_hits, Sweet.lollipop.min_score_td, Sweet.lollipop.biomarker, Sweet.lollipop.tight_abs_mass);
            Assert.AreEqual(2, Sweet.lollipop.topdown_proteoforms.Count());

            //Test no aggregation different pfr
            tdhList[1].ms2_retention_time      = tdhList[0].ms2_retention_time;
            tdhList[1].pfr_accession           = "12346";
            Sweet.lollipop.top_down_hits       = tdhList;
            Sweet.lollipop.topdown_proteoforms = Sweet.lollipop.aggregate_td_hits(Sweet.lollipop.top_down_hits, Sweet.lollipop.min_score_td, Sweet.lollipop.biomarker, Sweet.lollipop.tight_abs_mass);
            Assert.AreEqual(2, Sweet.lollipop.topdown_proteoforms.Count()); //both topdown hits should aggregate to a single proteoform

            //if hit score below threshold, don't aggregate
            tdhList[1].pfr_accession           = "12345";
            tdhList[1].score                   = 1;
            Sweet.lollipop.min_score_td        = 3;
            Sweet.lollipop.top_down_hits       = tdhList;
            Sweet.lollipop.topdown_proteoforms = Sweet.lollipop.aggregate_td_hits(Sweet.lollipop.top_down_hits, Sweet.lollipop.min_score_td, Sweet.lollipop.biomarker, Sweet.lollipop.tight_abs_mass);
            Assert.AreEqual(1, Sweet.lollipop.topdown_proteoforms.Count());
            Assert.AreEqual(1, Sweet.lollipop.topdown_proteoforms[0].topdown_hits.Count());
        }
        public void get_topdown_hit_sequence()
        {
            Sweet.lollipop = new Lollipop();
            Sweet.lollipop.carbamidomethylation = false;
            Sweet.lollipop.enter_input_files(new string[] { Path.Combine(TestContext.CurrentContext.TestDirectory, "uniprot_yeast_test_12entries.xml") }, Lollipop.acceptable_extensions[2], Lollipop.file_types[2], Sweet.lollipop.input_files, false);
            Sweet.lollipop.enter_input_files(new string[] { Path.Combine(TestContext.CurrentContext.TestDirectory, "ptmlist.txt") }, Lollipop.acceptable_extensions[2], Lollipop.file_types[2], Sweet.lollipop.input_files, false);
            Sweet.lollipop.theoretical_database.get_theoretical_proteoforms(TestContext.CurrentContext.TestDirectory);

            //make theo database so have ptm's and sequences...
            TopDownHit hit = new TopDownHit();

            hit.sequence = "ASDACSDASD";
            hit.ptm_list = new List <Ptm>();
            Modification mod = Sweet.lollipop.theoretical_database.uniprotModifications.Values.SelectMany(m => m).Where(m => m.DatabaseReference != null && m.DatabaseReference.ContainsKey("RESID")).Where(m => m.DatabaseReference["RESID"].Contains("AA0502")).FirstOrDefault();

            hit.ptm_list.Add(new Ptm(hit.sequence.Length, mod));
            Modification mod2 = Sweet.lollipop.theoretical_database.uniprotModifications.Values.SelectMany(m => m).Where(m => m.DatabaseReference != null && m.DatabaseReference.ContainsKey("RESID")).Where(m => m.DatabaseReference["RESID"].Contains("AA0170")).FirstOrDefault();

            hit.ptm_list.Add(new Ptm(3, mod2));
            Modification mod3 = Sweet.lollipop.theoretical_database.uniprotModifications.Values.SelectMany(m => m).Where(m => m.DatabaseReference != null && m.DatabaseReference.ContainsKey("RESID")).Where(m => m.DatabaseReference["RESID"].Contains("AA0433")).FirstOrDefault();

            hit.ptm_list.Add(new Ptm(1, mod3));


            string sequencewithchemicalformula = hit.GetChemicalFormula().Formula;

            Assert.AreEqual("C46H77N12O28PS", sequencewithchemicalformula);

            //should add carbamidomethylation to C...
            Sweet.lollipop.carbamidomethylation = true;
            sequencewithchemicalformula         = hit.GetChemicalFormula().Formula;
            Assert.AreEqual("C46H77N12O28PS", sequencewithchemicalformula);

            //should return null if N term formula wrong or doesn't match mass
            Modification badNtermMod = new Modification("badNtermMod", _locationRestriction: "N-terminal.", _chemicalFormula: null, _monoisotopicMass: -1000);

            hit          = new TopDownHit();
            hit.sequence = "ASDACSDASD";
            hit.ptm_list = new List <Ptm>()
            {
                new Ptm(1, badNtermMod)
            };
            Assert.IsNull(hit.GetChemicalFormula());
        }
Exemple #5
0
        //TOPDOWN pROTEOFORM
        public static TopDownProteoform TopDownProteoform(string accession, double modified_mass, double retention_time)
        {
            TopDownHit h = new TopDownHit();

            h.reported_mass      = modified_mass;
            h.theoretical_mass   = modified_mass;
            h.ms2_retention_time = retention_time;
            h.sequence           = "MSSSSSSSSSS";
            h.begin = 10;
            h.end   = 20;
            TopDownProteoform td = new TopDownProteoform(accession, new List <TopDownHit>()
            {
                h
            });

            (td as ExperimentalProteoform).topdown_id = true;
            td.accepted = true;
            return(td);
        }
Exemple #6
0
        public void TestCopyTopDown()
        {
            TopDownHit hit = new TopDownHit();

            hit.name               = "name";
            hit.uniprot_id         = "id";
            hit.sequence           = "sequence";
            hit.begin              = 0;
            hit.end                = 20;
            hit.theoretical_mass   = 1000;
            hit.reported_mass      = 1000;
            hit.ms2_retention_time = 10;
            hit.pfr_accession      = "PFR";
            TopDownProteoform td1 = new TopDownProteoform("accession", new List <TopDownHit>()
            {
                hit
            });
            TopDownProteoform td2 = new TopDownProteoform(td1);

            Assert.AreNotEqual(td1, td2);
            Assert.AreEqual(td1.root, td2.root);
            Assert.AreEqual(td1.name, td2.name);
            Assert.AreEqual(td1.ptm_set.ptm_combination.Count, td2.ptm_set.ptm_combination.Count);
            Assert.AreEqual(td1.uniprot_id, td2.uniprot_id);
            Assert.AreEqual(td1.sequence, td2.sequence);
            Assert.AreEqual(td1.begin, td2.begin);
            Assert.AreEqual(td1.end, td2.end);
            Assert.AreEqual(td1.theoretical_mass, td2.theoretical_mass);
            Assert.AreEqual(td1.topdown_hits, td2.topdown_hits);
            Assert.AreEqual(td1.modified_mass, td2.modified_mass);
            Assert.AreEqual(td1.matching_experimental, td2.matching_experimental);
            Assert.AreEqual(td1.accession, td2.accession);
            Assert.AreEqual(td1.agg_rt, td2.agg_rt);
            Assert.AreEqual(td1.lysine_count, td2.lysine_count);
            Assert.AreEqual(td1.topdown_id, td2.topdown_id);
            Assert.AreEqual(td1.agg_mass, td2.agg_mass);
            Assert.AreEqual(td1.is_target, td2.is_target);
        }
Exemple #7
0
 public DisplayTopDownHit(TopDownHit h)
     : base(h)
 {
     this.h = h;
 }
Exemple #8
0
        public void TestRelateTD()
        {
            Sweet.lollipop = new Lollipop();
            Sweet.lollipop.neucode_labeled                = false;
            Sweet.lollipop.maximum_missed_monos           = 1;
            Sweet.lollipop.agg_minBiorepsWithObservations = 0;
            InputFile f = new InputFile("path", Purpose.Identification);

            Sweet.lollipop.input_files.Add(f);
            // Two proteoforms; lysine count equal; mass difference < 250 -- return 1
            Component c1 = new Component();

            c1.weighted_monoisotopic_mass = 1000.0;
            c1.rt_apex       = 45;
            c1.accepted      = true;
            c1.id            = 1.ToString();
            c1.intensity_sum = 1e6;
            c1.input_file    = f;
            c1.charge_states = new List <ChargeState>()
            {
                new ChargeState(1, c1.intensity_sum, c1.weighted_monoisotopic_mass)
            };
            Component c2 = new Component();

            c2.weighted_monoisotopic_mass = 1000.0;
            c2.rt_apex       = 85;
            c2.accepted      = true;
            c2.input_file    = f;
            c2.intensity_sum = 1e6;
            c2.charge_states = new List <ChargeState>()
            {
                new ChargeState(1, c2.intensity_sum, c2.weighted_monoisotopic_mass)
            };
            c2.id = 2.ToString();
            Component c3 = new Component();

            c3.weighted_monoisotopic_mass = 1131.04;
            c3.rt_apex       = 45;
            c3.accepted      = true;
            c3.input_file    = f;
            c3.intensity_sum = 1e6;
            c3.charge_states = new List <ChargeState>()
            {
                new ChargeState(1, c3.intensity_sum, c3.weighted_monoisotopic_mass)
            };
            c3.id = 3.ToString();
            Component c4 = new Component();

            c4.weighted_monoisotopic_mass = 2000.00;
            c4.rt_apex       = 45;
            c4.accepted      = true;
            c4.input_file    = new InputFile("path", Purpose.Identification);
            c4.intensity_sum = 1e6;
            c4.charge_states = new List <ChargeState>()
            {
                new ChargeState(1, c4.intensity_sum, c4.weighted_monoisotopic_mass)
            };
            c4.id = 4.ToString();
            Component c5 = new Component();

            c5.weighted_monoisotopic_mass = 1001.0;
            c5.rt_apex       = 45;
            c5.accepted      = true;
            c5.input_file    = f;
            c5.intensity_sum = 1e6;
            c5.charge_states = new List <ChargeState>()
            {
                new ChargeState(1, c5.intensity_sum, c5.weighted_monoisotopic_mass)
            };
            c5.id = 2.ToString();
            List <IAggregatable> components = new List <IAggregatable>()
            {
                c1, c2, c3, c4, c5
            };

            Sweet.lollipop.raw_experimental_components = components.OfType <Component>().ToList();

            TopDownProteoform td1 = ConstructorsForTesting.TopDownProteoform("ACCESSION_1", 1000.0, 45);
            TopDownProteoform td2 = ConstructorsForTesting.TopDownProteoform("ACCESSION_2", 1001.0, 85);
            TopDownProteoform td3 = ConstructorsForTesting.TopDownProteoform("ACCESSION_3", 1131.04, 45);

            TheoreticalProteoform t1 = ConstructorsForTesting.make_a_theoretical("ACCESSION", 1000.0, 1);

            //need to make theoretical accession database
            TestProteoformCommunityRelate.prepare_for_et(new List <double>()
            {
                0
            });
            Sweet.lollipop.target_proteoform_community.community_number   = -100;
            Sweet.lollipop.theoretical_database.theoreticals_by_accession = new Dictionary <int, Dictionary <string, List <TheoreticalProteoform> > >();
            Sweet.lollipop.theoretical_database.theoreticals_by_accession.Add(-100, new Dictionary <string, List <TheoreticalProteoform> >());
            Sweet.lollipop.theoretical_database.theoreticals_by_accession[-100].Add(t1.accession, new List <TheoreticalProteoform>()
            {
                t1
            });

            //need to make decon error top "deconvolution error"
            ModificationMotif motif;

            ModificationMotif.TryGetMotif("S", out motif);
            Modification m = new Modification("id", _modificationType: "modtype", _target: motif, _locationRestriction: "Anywhere.", _monoisotopicMass: 1);

            Sweet.lollipop.theoretical_database.all_mods_with_mass.Add(m);
            PtmSet set = new PtmSet(new List <Ptm> {
                new Ptm(-1, m)
            });

            Sweet.lollipop.theoretical_database.all_possible_ptmsets.Add(set);
            Sweet.lollipop.modification_ranks.Add(-1.0023, 2);
            Sweet.lollipop.theoretical_database.possible_ptmset_dictionary.Add(-1.0, new List <PtmSet>()
            {
                set
            });

            //need missing error
            Modification m2 = new Modification("id", _modificationType: "modtype", _target: motif, _locationRestriction: "Anywhere.", _monoisotopicMass: 1);

            Sweet.lollipop.theoretical_database.all_mods_with_mass.Add(m2);
            PtmSet set2 = new PtmSet(new List <Ptm> {
                new Ptm(-1, m2)
            });

            Sweet.lollipop.theoretical_database.all_possible_ptmsets.Add(set2);
            Sweet.lollipop.modification_ranks.Add(-87.03, 2);
            Sweet.lollipop.theoretical_database.possible_ptmset_dictionary.Add(-87.0, new List <PtmSet>()
            {
                set2
            });

            Sweet.lollipop.target_proteoform_community.theoretical_proteoforms = new List <TheoreticalProteoform>()
            {
                t1
            }.ToArray();
            Sweet.lollipop.topdown_proteoforms = new List <TopDownProteoform> {
                td1, td2, td3
            };
            Sweet.lollipop.add_td_proteoforms = true;
            Sweet.lollipop.aggregate_proteoforms(Sweet.lollipop.validate_proteoforms, Sweet.lollipop.raw_neucode_pairs, Sweet.lollipop.raw_experimental_components, Sweet.lollipop.raw_quantification_components, 0);
            List <ProteoformRelation> relations = Sweet.lollipop.target_proteoform_community.relate(Sweet.lollipop.target_proteoform_community.experimental_proteoforms, Sweet.lollipop.target_proteoform_community.theoretical_proteoforms, ProteoformComparison.ExperimentalTheoretical, true, Environment.CurrentDirectory, true);
            List <DeltaMassPeak>      peaks     = Sweet.lollipop.target_proteoform_community.accept_deltaMass_peaks(relations, new Dictionary <string, List <ProteoformRelation> >());

            //should have 4 experimental proteoforms -- 3 topdown, 1 not topdown experimental
            Assert.AreEqual(3, Sweet.lollipop.target_proteoform_community.experimental_proteoforms.Count(e => e.topdown_id));
            Assert.AreEqual(4, Sweet.lollipop.target_proteoform_community.experimental_proteoforms.Count());
            Assert.AreEqual(1, relations.Count);
            Assert.AreEqual(1, relations.Count(r => r.RelationType == ProteoformComparison.ExperimentalTheoretical && (r.connected_proteoforms[0] as ExperimentalProteoform).topdown_id));
            Assert.AreEqual(1, td1.relationships.Count(r => r.RelationType == ProteoformComparison.ExperimentalTheoretical && (r.connected_proteoforms[0] as ExperimentalProteoform).topdown_id));
            Assert.AreEqual(0, td2.relationships.Count());
            Assert.AreEqual(0, td3.relationships.Count());

            //accession 3 has higher score... gets td
            Sweet.lollipop.clear_td();
            td3 = ConstructorsForTesting.TopDownProteoform("ACCESSION_3", 1000.0, 45);
            TopDownHit h3 = new TopDownHit();

            h3.score         = 100;
            td3.topdown_hits = new List <TopDownHit>()
            {
                h3
            };
            TopDownHit h4 = new TopDownHit();

            h4.score = 1;
            TopDownProteoform td4 = ConstructorsForTesting.TopDownProteoform("ACCESSION_4", 1001.0, 45);

            td4.topdown_hits = new List <TopDownHit>()
            {
                h4
            };
            Sweet.lollipop.topdown_proteoforms = new List <TopDownProteoform> {
                td4, td3
            };
            Sweet.lollipop.topdown_proteoforms.OrderBy(p => p.modified_mass);
            Sweet.lollipop.aggregate_proteoforms(Sweet.lollipop.validate_proteoforms, Sweet.lollipop.raw_neucode_pairs, Sweet.lollipop.raw_experimental_components, Sweet.lollipop.raw_quantification_components, 0);
            Assert.AreEqual(0, Math.Round(td3.modified_mass - td3.matching_experimental.modified_mass, 0));
            Assert.IsNull(td4.matching_experimental);
        }