public void testFindRawNeuCodePairsMethod() { //reading in test excel file, process raw components before testing neucode pairs. SaveState.lollipop.correctionFactors = null; SaveState.lollipop.raw_experimental_components.Clear(); Func <InputFile, IEnumerable <Component> > componentReader = c => new ComponentReader().read_components_from_xlsx(c, SaveState.lollipop.correctionFactors); InputFile noisy = new InputFile(Path.Combine(TestContext.CurrentContext.TestDirectory, "noisy.xlsx"), Labeling.NeuCode, Purpose.Identification); SaveState.lollipop.input_files.Add(noisy); string inFileId = noisy.UniqueId.ToString(); SaveState.lollipop.neucode_labeled = true; SaveState.lollipop.process_raw_components(SaveState.lollipop.input_files, SaveState.lollipop.raw_experimental_components, Purpose.Identification); Assert.AreEqual(223, SaveState.lollipop.raw_experimental_components.Count); //Check the validity of one component read from the Excel file Component c1 = SaveState.lollipop.raw_experimental_components[0]; Component c2 = SaveState.lollipop.raw_experimental_components[6]; // this one doesn't have the same number of charge states, which makes for a good example List <int> c1_charges = c1.charge_states.Select(charge_state => charge_state.charge_count).ToList(); List <int> c2_charges = c2.charge_states.Select(charge_states => charge_states.charge_count).ToList(); List <int> overlapping_charge_states = c1_charges.Intersect(c2_charges).ToList(); Assert.AreEqual(9, c1.charge_states.Count); Assert.AreEqual(8, overlapping_charge_states.Count); Assert.AreEqual(SaveState.lollipop.input_files.Where(f => f.filename == "noisy").FirstOrDefault().UniqueId + "_1", c1.id); //this line behaving strangely. Assert.AreEqual(Math.Round(8982.7258, 4), Math.Round(c1.reported_monoisotopic_mass, 4)); Assert.AreEqual(Math.Round(32361626.3, 1), Math.Round(c1.intensity_sum, 1)); c1.calculate_sum_intensity_olcs(overlapping_charge_states); Assert.AreEqual(Math.Round(32135853.39, 2), Math.Round(c1.intensity_sum_olcs, 2)); Assert.AreEqual(9, c1.num_charge_states); Assert.AreEqual(Math.Round(2127.5113, 4), Math.Round(c1.delta_mass, 4)); Assert.AreEqual(Math.Round(54.97795307, 8), Math.Round(c1.relative_abundance, 8)); Assert.AreEqual(Math.Round(1.141297566, 8), Math.Round(c1.fract_abundance, 8)); Assert.AreEqual("413-415", c1.scan_range); Assert.AreEqual("56.250-56.510", c1.rt_range); Assert.AreEqual(Math.Round(56.3809775, 7), Math.Round(c1.rt_apex, 7)); //testing intensity ratio NeuCodePair neucode_pair = SaveState.lollipop.raw_neucode_pairs.Where(i => i.neuCodeHeavy.id == inFileId + "_5" && i.neuCodeLight.id == inFileId + "_1").First(); Assert.AreEqual(2.0595679693624596, neucode_pair.intensity_ratio); //testing K-count Assert.AreEqual(7, neucode_pair.lysine_count); //testing that only overlapping charge states go into intensity ratio neucode_pair = SaveState.lollipop.raw_neucode_pairs.Where(i => i.neuCodeHeavy.id == inFileId + "_122" && i.neuCodeLight.id == inFileId + "_57").First(); Assert.AreEqual(1.7231604062234347, neucode_pair.intensity_ratio); }
public void testFindRawNeuCodePairsMethod() { //reading in test excel file, process raw components before testing neucode pairs. Sweet.lollipop = new Lollipop(); Func <InputFile, IEnumerable <Component> > componentReader = c => new ComponentReader().read_components_from_xlsx(c, true); InputFile noisy = new InputFile(Path.Combine(TestContext.CurrentContext.TestDirectory, "noisy.xlsx"), Labeling.NeuCode, Purpose.Identification); Sweet.lollipop.input_files.Add(noisy); string inFileId = noisy.UniqueId.ToString(); Sweet.lollipop.neucode_labeled = true; Sweet.lollipop.process_raw_components(Sweet.lollipop.input_files, Sweet.lollipop.raw_experimental_components, Purpose.Identification, true); Assert.AreEqual(223, Sweet.lollipop.raw_experimental_components.Count); //Check the validity of one component read from the Excel file Component c1 = Sweet.lollipop.raw_experimental_components[0]; Component c2 = Sweet.lollipop.raw_experimental_components[6]; // this one doesn't have the same number of charge states, which makes for a good example List <int> c1_charges = c1.charge_states.Select(charge_state => charge_state.charge_count).ToList(); List <int> c2_charges = c2.charge_states.Select(charge_states => charge_states.charge_count).ToList(); HashSet <int> overlapping_charge_states = new HashSet <int>(c1_charges.Intersect(c2_charges)); Assert.AreEqual(9, c1.charge_states.Count); Assert.AreEqual(8, overlapping_charge_states.Count); Assert.AreEqual(Sweet.lollipop.input_files.Where(f => f.filename == "noisy").FirstOrDefault().UniqueId + "_1", c1.id); //this line behaving strangely. Assert.AreEqual(Math.Round(8982.7258, 4), Math.Round(c1.reported_monoisotopic_mass, 4)); Assert.AreEqual(Math.Round(2868299.6, 1), Math.Round(c1.intensity_sum, 1)); //charge state normalized Assert.AreEqual(Math.Round(2836046.31, 2), Math.Round(NeuCodePair.calculate_sum_intensity_olcs(c1.charge_states, overlapping_charge_states), 2)); Assert.AreEqual(9, c1.charge_states.Count); Assert.AreEqual("413-415", c1.min_scan + "-" + c1.max_scan); Assert.AreEqual("56.25-56.51", c1.min_rt + "-" + c1.max_rt); Assert.AreEqual(Math.Round(56.3809775, 7), Math.Round(c1.rt_apex, 7)); Assert.AreEqual(8981.69, Math.Round(c1.charge_states.OrderBy(s => s.charge_count).First().reported_mass, 2)); //testing intensity ratio NeuCodePair neucode_pair = Sweet.lollipop.raw_neucode_pairs.Where(i => i.neuCodeHeavy.id == inFileId + "_5" && i.neuCodeLight.id == inFileId + "_1").First(); Assert.AreEqual(2.0695212171812423d, neucode_pair.intensity_ratio); //intensities are charge state normalized //testing K-count Assert.AreEqual(7, neucode_pair.lysine_count); //testing that only overlapping charge states go into intensity ratio neucode_pair = Sweet.lollipop.raw_neucode_pairs.Where(i => i.neuCodeHeavy.id == inFileId + "_122" && i.neuCodeLight.id == inFileId + "_57").First(); Assert.AreEqual(1.7301034510740836, neucode_pair.intensity_ratio); }
// The calculations for unlabeled and neucode components are the same, currently public static List <IAggregatable> generate_neucode_components(double starter_mass) { List <IAggregatable> components = new List <IAggregatable>(); InputFile inFile = new InputFile("somepath", Labeling.NeuCode, Purpose.Identification); for (int i = 0; i < 2; i++) { Component light = new Component(); Component heavy = new Component(); light.input_file = inFile; heavy.input_file = inFile; light.id = 1.ToString(); heavy.id = 2.ToString(); light.weighted_monoisotopic_mass = starter_mass; heavy.weighted_monoisotopic_mass = starter_mass + starter_lysine_count * Lollipop.NEUCODE_LYSINE_MASS_SHIFT; light.intensity_sum = starter_intensity; //using the special intensity sum for overlapping charge states in a neucode pair heavy.intensity_sum = starter_intensity / 2; //using the special intensity sum for overlapping charge states in a neucode pair light.rt_apex = starter_rt; heavy.rt_apex = starter_rt; light.accepted = true; heavy.accepted = true; ChargeState light_charge_state = new ChargeState(1, light.intensity_sum, light.weighted_monoisotopic_mass + 1.00727645D); ChargeState heavy_charge_state = new ChargeState(1, heavy.intensity_sum, heavy.weighted_monoisotopic_mass + 1.00727645D); light.charge_states = new List <ChargeState> { light_charge_state }; heavy.charge_states = new List <ChargeState> { heavy_charge_state }; double mass_difference = heavy.weighted_monoisotopic_mass - light.weighted_monoisotopic_mass; NeuCodePair n = new NeuCodePair(light, light.intensity_sum, heavy, heavy.intensity_sum, mass_difference, new HashSet <int>() { 1 }, true); n.lysine_count = starter_lysine_count; components.Add(n); } return(components); }
// The calculations for unlabeled and neucode components are the same, currently public static List <Component> generate_neucode_components(double starter_mass) { List <Component> components = new List <Component>(); InputFile inFile = new ProteoformSuiteInternal.InputFile("somepath", Labeling.NeuCode, Purpose.Identification); for (int i = 0; i < 2; i++) { Component light = new Component(); Component heavy = new Component(); light.input_file = inFile; heavy.input_file = inFile; light.id = 1.ToString(); heavy.id = 2.ToString(); light.weighted_monoisotopic_mass = starter_mass; heavy.weighted_monoisotopic_mass = starter_mass + starter_lysine_count * Lollipop.NEUCODE_LYSINE_MASS_SHIFT; light.intensity_sum_olcs = starter_intensity; //using the special intensity sum for overlapping charge states in a neucode pair heavy.intensity_sum_olcs = starter_intensity / 2; //using the special intensity sum for overlapping charge states in a neucode pair light.rt_apex = starter_rt; heavy.rt_apex = starter_rt; light.accepted = true; heavy.accepted = true; ChargeState light_charge_state = new ChargeState(1, light.intensity_sum_olcs, light.weighted_monoisotopic_mass, 1.00727645D); ChargeState heavy_charge_state = new ChargeState(1, heavy.intensity_sum_olcs, heavy.weighted_monoisotopic_mass, 1.00727645D); light.charge_states = new List <ChargeState> { light_charge_state }; heavy.charge_states = new List <ChargeState> { heavy_charge_state }; NeuCodePair n = new NeuCodePair(light, heavy); n.lysine_count = starter_lysine_count; n.calculate_properties(); components.Add(n); } return(components); }
public DisplayNeuCodePair(NeuCodePair c) : base(c) { this.c = c; }