Skip to content

Commit

Permalink
ptm loss bug fix
Browse files Browse the repository at this point in the history
  • Loading branch information
unknown committed Oct 18, 2017
1 parent d2fc670 commit 4988525
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 2 deletions.
2 changes: 1 addition & 1 deletion ProteoformSuiteInternal/Proteoform.cs
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ public List<ExperimentalProteoform> identify_connected_experimentals(List<PtmSet
bool within_loss_tolerance = deltaM >= -set.mass - mass_tolerance && deltaM <= -set.mass + mass_tolerance;
List<ModificationWithMass> these_mods = this.ptm_set.ptm_combination.Select(ptm => ptm.modification).ToList();
List<ModificationWithMass> those_mods = set.ptm_combination.Select(ptm => ptm.modification).ToList(); // all must be in the current set to remove them
bool can_be_removed = those_mods.All(m => these_mods.Contains(m));
bool can_be_removed = those_mods.All(m1 => these_mods.Count(m2 => m2.id == m1.id) >= those_mods.Count(m2 => m2.id == m1.id)); //# of each mod in current set must be greater than or equal to # in set to remove.
bool better_than_current_best_loss = best_loss == null || Math.Abs(deltaM - (-set.mass)) < Math.Abs(deltaM - (-best_loss.mass));
if (can_be_removed && within_loss_tolerance && better_than_current_best_loss)
{
Expand Down
39 changes: 38 additions & 1 deletion Test/TestProteoformIdentification.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,20 +50,57 @@ public void loss_of_ptm_set()
{
new Ptm(0, new ModificationWithMass("acetyl", new Tuple<string, string>("", ""), motif, TerminusLocalization.Any, 42.01, new Dictionary<string, IList<string>>(), new List<double>(), new List<double>(), "Mod")),
});
PtmSet set4 = new PtmSet(new List<Ptm>
{
new Ptm(0, new ModificationWithMass("acetyl", new Tuple<string, string>("", ""), motif, TerminusLocalization.Any, 42.01, new Dictionary<string, IList<string>>(), new List<double>(), new List<double>(), "Mod")),
new Ptm(0, new ModificationWithMass("acetyl", new Tuple<string, string>("", ""), motif, TerminusLocalization.Any, 42.01, new Dictionary<string, IList<string>>(), new List<double>(), new List<double>(), "Mod")),
new Ptm(0, new ModificationWithMass("acetyl", new Tuple<string, string>("", ""), motif, TerminusLocalization.Any, 42.01, new Dictionary<string, IList<string>>(), new List<double>(), new List<double>(), "Mod")),
new Ptm(0, new ModificationWithMass("acetyl", new Tuple<string, string>("", ""), motif, TerminusLocalization.Any, 42.01, new Dictionary<string, IList<string>>(), new List<double>(), new List<double>(), "Mod")),
});

e.ptm_set = set;
Sweet.lollipop.theoretical_database.possible_ptmset_dictionary = new Dictionary<double, List<PtmSet>>
{
{ Math.Round(set.mass, 1), new List<PtmSet> { set } },
{ Math.Round(set2.mass, 1), new List<PtmSet> { set2 } },
{ Math.Round(set3.mass, 1), new List<PtmSet> { set3 } },
{ Math.Round(set4.mass, 1), new List<PtmSet> { set4 } },
};

ExperimentalProteoform e2 = ConstructorsForTesting.ExperimentalProteoform("", 10042.01, 0, true);
ConstructorsForTesting.make_relation(e, e2, ProteoformComparison.ExperimentalExperimental, 126.03);
e.relationships.First().Accepted = true;
e.relationships.First().peak = new DeltaMassPeak(e.relationships.First(), new HashSet<ProteoformRelation> { e.relationships.First() });
e.identify_connected_experimentals(new List<PtmSet> { set }, new List<ModificationWithMass> { set.ptm_combination.First().modification });
Assert.IsNotNull(e2.linked_proteoform_references);
Assert.AreEqual(0, e2.ptm_set.mass);

e.relationships.Clear();
e2 = ConstructorsForTesting.ExperimentalProteoform("", 10042.01, 0, true);
ConstructorsForTesting.make_relation(e, e2, ProteoformComparison.ExperimentalExperimental, 84.02);
e.relationships.First().Accepted = true;
e.relationships.First().peak = new DeltaMassPeak(e.relationships.First(), new HashSet<ProteoformRelation> { e.relationships.First() });
e.identify_connected_experimentals(new List<PtmSet> { set, set2, set3 }, new List<ModificationWithMass> { set.ptm_combination.First().modification });
e.identify_connected_experimentals(new List<PtmSet> { set2 }, new List<ModificationWithMass> { set2.ptm_combination.First().modification });
Assert.IsNotNull(e2.linked_proteoform_references);
Assert.AreEqual(42.01, e2.ptm_set.mass);

e.relationships.Clear();
e2 = ConstructorsForTesting.ExperimentalProteoform("", 10042.01, 0, true);
ConstructorsForTesting.make_relation(e, e2, ProteoformComparison.ExperimentalExperimental, 42.01);
e.relationships.First().Accepted = true;
e.relationships.First().peak = new DeltaMassPeak(e.relationships.First(), new HashSet<ProteoformRelation> { e.relationships.First() });
e.identify_connected_experimentals(new List<PtmSet> { set3 }, new List<ModificationWithMass> { set3.ptm_combination.First().modification });
Assert.IsNotNull(e2.linked_proteoform_references);
Assert.AreEqual(84.02, e2.ptm_set.mass);

//can't remove more acetylations than in e's ptmset
e.relationships.Clear();
e2 = ConstructorsForTesting.ExperimentalProteoform("", 10042.01, 0, true);
ConstructorsForTesting.make_relation(e, e2, ProteoformComparison.ExperimentalExperimental, 168.04);
e.relationships.First().Accepted = true;
e.relationships.First().peak = new DeltaMassPeak(e.relationships.First(), new HashSet<ProteoformRelation> { e.relationships.First() });
e.identify_connected_experimentals(new List<PtmSet> { set4 }, new List<ModificationWithMass> { set4.ptm_combination.First().modification });
Assert.IsNull(e2.linked_proteoform_references);
}

[Test]
Expand Down

0 comments on commit 4988525

Please sign in to comment.