-
Notifications
You must be signed in to change notification settings - Fork 30
modified the source code to exclude duplicated metabolite info. #703
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -30,7 +30,7 @@ public MatchResultAnnotationDeduplicator(IMatchResultEvaluator<MsScanMatchResult | |||||||||||
| } | ||||||||||||
|
|
||||||||||||
| public void Process(IEnumerable<AlignmentSpotProperty> spots) { | ||||||||||||
| var spotList = spots.Where(n => n.IsReferenceMatched(_evaluator)).OrderByDescending(spot => spot.MatchResults.Representative.LibraryID).ToList(); | ||||||||||||
| var spotList = spots.Where(n => n.IsReferenceMatched(_evaluator) && !n.Name.StartsWith("Putative")).OrderByDescending(spot => spot.MatchResults.Representative.LibraryID).ToList(); | ||||||||||||
| var currentPeakId = 0; | ||||||||||||
| var currentLibraryId = spotList[currentPeakId].MatchResults.Representative.LibraryID; | ||||||||||||
|
|
||||||||||||
|
Comment on lines
+33
to
36
|
||||||||||||
|
|
@@ -56,7 +56,7 @@ public void Process(IEnumerable<AlignmentSpotProperty> spots) { | |||||||||||
|
|
||||||||||||
| // by InChIKey | ||||||||||||
| spotList = spots | ||||||||||||
| .Where(n => n.IsReferenceMatched(_evaluator)) | ||||||||||||
| .Where(n => n.IsReferenceMatched(_evaluator) && !n.Name.StartsWith("Putative")) | ||||||||||||
| .Where(n => !string.IsNullOrEmpty(n.MatchResults?.Representative?.InChIKey) && n.MatchResults.Representative.InChIKey.Length > 1) | ||||||||||||
| .OrderByDescending(spot => spot.MatchResults.Representative.InChIKey) | ||||||||||||
|
Comment on lines
58
to
61
|
||||||||||||
| .ToList(); | ||||||||||||
|
|
@@ -83,7 +83,7 @@ public void Process(IEnumerable<AlignmentSpotProperty> spots) { | |||||||||||
|
|
||||||||||||
| // by Name | ||||||||||||
| spotList = spots | ||||||||||||
| .Where(n => n.IsReferenceMatched(_evaluator)) | ||||||||||||
| .Where(n => n.IsReferenceMatched(_evaluator) && !n.Name.StartsWith("Putative")) | ||||||||||||
| .Where(n => !n.MatchResults.Representative.Name.IsEmptyOrNull()) | ||||||||||||
| .OrderByDescending(spot => spot.MatchResults.Representative.Name) | ||||||||||||
| .ToList(); | ||||||||||||
|
|
@@ -110,8 +110,8 @@ public void Process(IEnumerable<AlignmentSpotProperty> spots) { | |||||||||||
| } | ||||||||||||
|
|
||||||||||||
| static void ChangeAnnotationToLowScore(AlignmentSpotProperty spot) { | ||||||||||||
| spot.MatchResults.Representative.IsReferenceMatched = false; | ||||||||||||
| spot.Name = "putative: " + spot.Name; | ||||||||||||
| //spot.MatchResults.Representative.IsReferenceMatched = false; | ||||||||||||
|
||||||||||||
| //spot.MatchResults.Representative.IsReferenceMatched = false; | |
| var representative = spot.MatchResults?.Representative; | |
| if (representative != null) { | |
| representative.IsReferenceMatched = false; | |
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -52,7 +52,7 @@ public AnnotatedMSDecResult[] MainProcess(IReadOnlyList<MSDecResult> ms1DecResul | |
|
|
||
| var features = new AnnotatedMSDecResult[ms1DecResults.Count]; | ||
| if (_parameter.OnlyReportTopHitInMspSearch) { | ||
| var used = new HashSet<MoleculeMsReference>(); | ||
| var used = new HashSet<MoleculeMsReference>(new MoleculeMsReferenceEqualityComparer()); | ||
| foreach (var (container, i) in containers.WithIndex().OrderByDescending(p => p.Item1.Representative.TotalScore)) { | ||
|
Comment on lines
+55
to
56
|
||
| if (container.Representative is MsScanMatchResult topHit && !topHit.IsUnknown) { | ||
| ms1DecResults[i].MspIDs.AddRange(containers[i].MatchResults.OrderByDescending(r => r.TotalScore).Select(r => r.LibraryID)); | ||
|
|
@@ -99,4 +99,43 @@ public AnnotatedMSDecResult[] MainProcess(IReadOnlyList<MSDecResult> ms1DecResul | |
| return ms1DecResults.Select(r => new AnnotatedMSDecResult(r, new MsScanMatchResultContainer())).ToArray(); | ||
| } | ||
| } | ||
|
|
||
| public class MoleculeMsReferenceEqualityComparer : IEqualityComparer<MoleculeMsReference> { | ||
| public bool Equals(MoleculeMsReference x, MoleculeMsReference y) { | ||
| if (ReferenceEquals(x, y)) return true; | ||
| if (x is null || y is null) return false; | ||
|
|
||
| if (!string.IsNullOrEmpty(x.InChIKey) && !string.IsNullOrEmpty(y.InChIKey)) { | ||
| if (x.InChIKey == y.InChIKey) return true; | ||
| } | ||
|
|
||
| if (x.ScanID != 0 && y.ScanID != 0 && x.ScanID == y.ScanID) { | ||
| return true; | ||
| } | ||
|
|
||
| if (!string.IsNullOrEmpty(x.Name) && !string.IsNullOrEmpty(y.Name)) { | ||
| if (x.Name.ToLower() == y.Name.ToLower()) return true; | ||
| } | ||
|
Comment on lines
+116
to
+118
|
||
|
|
||
| return false; | ||
| } | ||
|
Comment on lines
+104
to
+121
|
||
|
|
||
| public int GetHashCode(MoleculeMsReference obj) { | ||
| if (obj is null) return 0; | ||
|
|
||
| if (!string.IsNullOrEmpty(obj.InChIKey)) { | ||
| return obj.InChIKey.GetHashCode(); | ||
| } | ||
|
|
||
| if (obj.ScanID != 0) { | ||
| return obj.ScanID.GetHashCode(); | ||
| } | ||
|
|
||
| if (!string.IsNullOrEmpty(obj.Name)) { | ||
| return obj.Name.ToLower().GetHashCode(); | ||
| } | ||
|
|
||
| return 0; | ||
| } | ||
| } | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Test coverage: this change alters the alignment deduplication behavior (Putative prefix filtering + match flag behavior), but the existing
RefineMspDuplicateTestin LcmsAlignmentRefinerTests is currently marked[Ignore], and there don’t appear to be active tests covering MatchResultAnnotationDeduplicator. Adding/enabling a test for the updated behavior would help prevent regressions.