Skip to content

Commit 4661c8a

Browse files
committed
Merged in master
2 parents 866d6d2 + 113d196 commit 4661c8a

File tree

73 files changed

+590
-272
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

73 files changed

+590
-272
lines changed

MetaMorpheus/CMD/Program.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
using System.IO;
1010
using System.Linq;
1111
using System.Text.RegularExpressions;
12+
using EngineLayer.DatabaseLoading;
1213
using Omics.Modifications;
1314
using TaskLayer;
1415

MetaMorpheus/EngineLayer/DatabaseLoading/DatabaseLoadingEngine.cs

Lines changed: 342 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#nullable enable
2+
namespace EngineLayer.DatabaseLoading;
3+
4+
public class DbForTask
5+
{
6+
public DbForTask(string filePath, bool isContaminant, string? decoyIdentifier = null)
7+
{
8+
FilePath = filePath;
9+
IsContaminant = isContaminant;
10+
FileName = System.IO.Path.GetFileName(filePath);
11+
IsSpectralLibrary = GlobalVariables.GetFileExtension(filePath).ToLowerInvariant() == ".msp";
12+
DecoyIdentifier = decoyIdentifier ?? GlobalVariables.DecoyIdentifier;
13+
}
14+
15+
public bool IsSpectralLibrary { get; }
16+
public string FilePath { get; }
17+
public bool IsContaminant { get; }
18+
public string FileName { get; }
19+
public string DecoyIdentifier { get; }
20+
public int? BioPolymerCount { get; internal set; } = null;
21+
public int? TargetCount { get; internal set; } = null;
22+
public int? DecoyCount { get; internal set; } = null;
23+
}

MetaMorpheus/EngineLayer/GlobalVariables.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ namespace EngineLayer
2222
{
2323
public static class GlobalVariables
2424
{
25+
public static string DecoyIdentifier { get; set; } = "DECOY";
2526
// for now, these are only used for error-checking in the command-line version.
2627
// compressed versions of the protein databases (e.g., .xml.gz) are also supported
2728
public static List<string> AcceptedDatabaseFormats { get; private set; }

MetaMorpheus/EngineLayer/MetaMorpheusEngine.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
using System.Collections.Generic;
77
using System.Diagnostics;
88
using System.Linq;
9+
using System.Threading.Tasks;
910
using Transcriptomics.Digestion;
1011

1112
namespace EngineLayer
@@ -290,6 +291,8 @@ public MetaMorpheusEngineResults Run()
290291
return myResults;
291292
}
292293

294+
public Task<MetaMorpheusEngineResults> RunAsync() => Task.Run(Run);
295+
293296
/// <summary>
294297
/// Changes the name of the analytes from "peptide" to "proteoform" or "oligo" if the protease is set to top-down
295298
/// </summary>

MetaMorpheus/EngineLayer/ProteinScoringAndFdr/ProteinScoringAndFdrEngine.cs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ public class ProteinScoringAndFdrEngine : MetaMorpheusEngine
1212
private readonly bool TreatModPeptidesAsDifferentPeptides;
1313
private readonly bool MergeIndistinguishableProteinGroups;
1414
private readonly List<ProteinGroup> ProteinGroups;
15+
private readonly HashSet<string> _decoyIdentifiers;
1516

1617
public ProteinScoringAndFdrEngine(List<ProteinGroup> proteinGroups, List<SpectralMatch> newPsms, bool noOneHitWonders, bool treatModPeptidesAsDifferentPeptides, bool mergeIndistinguishableProteinGroups, CommonParameters commonParameters, List<(string fileName, CommonParameters fileSpecificParameters)> fileSpecificParameters, List<string> nestedIds) : base(commonParameters, fileSpecificParameters, nestedIds)
1718
{
@@ -20,6 +21,7 @@ public ProteinScoringAndFdrEngine(List<ProteinGroup> proteinGroups, List<Spectra
2021
NoOneHitWonders = noOneHitWonders;
2122
TreatModPeptidesAsDifferentPeptides = treatModPeptidesAsDifferentPeptides;
2223
MergeIndistinguishableProteinGroups = mergeIndistinguishableProteinGroups;
24+
_decoyIdentifiers = proteinGroups.SelectMany(p => p.Proteins.Where(b => b.IsDecoy).Select(b => b.Accession.Split('_')[0])).ToHashSet();
2325
}
2426

2527
protected override MetaMorpheusEngineResults RunSpecific()
@@ -31,9 +33,12 @@ protected override MetaMorpheusEngineResults RunSpecific()
3133
return myAnalysisResults;
3234
}
3335

34-
private static string StripDecoyIdentifier(string proteinGroupName) //we're keeping only the better scoring protein group for each target/decoy pair. to do that we need to strip decoy from the name temporarily. this is the "top-picked" method
36+
private static string StripDecoyIdentifier(string proteinGroupName, HashSet<string> decoyIdentifiers) //we're keeping only the better scoring protein group for each target/decoy pair. to do that we need to strip decoy from the name temporarily. this is the "top-picked" method
3537
{
36-
return proteinGroupName.Contains("DECOY_") ? proteinGroupName.Replace("DECOY_", "") : proteinGroupName;
38+
foreach (var ident in decoyIdentifiers.Where(proteinGroupName.Contains))
39+
return proteinGroupName.Replace($"{ident}_", "");
40+
41+
return proteinGroupName;
3742
}
3843

3944
private void ScoreProteinGroups(List<ProteinGroup> proteinGroups, IEnumerable<SpectralMatch> psmList)
@@ -142,7 +147,7 @@ private List<ProteinGroup> DoProteinFdr(List<ProteinGroup> proteinGroups)
142147
{
143148
foreach (var protein in pg.Proteins)
144149
{
145-
string stippedAccession = StripDecoyIdentifier(protein.Accession); //remove "DECOY_" from the accession
150+
string stippedAccession = StripDecoyIdentifier(protein.Accession, _decoyIdentifiers); //remove "DECOY_" from the accession
146151

147152
if (accessionToProteinGroup.TryGetValue(stippedAccession, out List<ProteinGroup> groups))
148153
{

MetaMorpheus/GUI/ForDisplayingInDataGrids/ProteinDbForDataGrid.cs

Lines changed: 31 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
11
using System.IO;
2+
using EngineLayer;
3+
using EngineLayer.DatabaseLoading;
4+
using GuiFunctions;
25
using TaskLayer;
36

47
namespace MetaMorpheusGUI
58
{
6-
public class ProteinDbForDataGrid
9+
public class ProteinDbForDataGrid : BaseViewModel
710
{
811
#region Public Constructors
912

@@ -27,17 +30,41 @@ public ProteinDbForDataGrid(DbForTask uu)
2730
Contaminant = uu.IsContaminant;
2831
FilePath = uu.FilePath;
2932
FileName = uu.FileName;
33+
DecoyIdentifier = uu.DecoyIdentifier;
3034
}
3135

3236
#endregion Public Constructors
3337

3438
#region Public Properties
3539

36-
public bool Use { get; set; }
37-
public bool Contaminant { get; set; }
40+
private bool _use;
41+
private bool _isContaminant;
42+
private bool _inProgress;
43+
private string _decoyIdentifier = GlobalVariables.DecoyIdentifier;
44+
45+
public bool Use
46+
{
47+
get => _use;
48+
set { _use = value; OnPropertyChanged(nameof(Use)); }
49+
}
50+
public bool Contaminant
51+
{
52+
get => _isContaminant;
53+
set { _isContaminant = value; OnPropertyChanged(nameof(Contaminant)); }
54+
}
3855
public string FileName { get; private set; }
3956
public string FilePath { get; private set; }
40-
public bool InProgress { get; private set; }
57+
public bool InProgress
58+
{
59+
get => _inProgress;
60+
private set { _inProgress = value; OnPropertyChanged(nameof(InProgress)); }
61+
}
62+
63+
public string DecoyIdentifier
64+
{
65+
get => _decoyIdentifier;
66+
set { _decoyIdentifier = value; OnPropertyChanged(nameof(DecoyIdentifier)); }
67+
}
4168

4269
#endregion Public Properties
4370

MetaMorpheus/GUI/MainWindow.xaml

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -550,10 +550,11 @@
550550
<Style TargetType="{x:Type DataGridCell}" BasedOn="{StaticResource DataGridCellStyle}" />
551551
</DataGrid.CellStyle>
552552
<DataGrid.Columns>
553-
<DataGridTextColumn Header="File" Binding="{Binding FileName, Mode=OneWay}" Width="250" />
554-
<DataGridTextColumn Header="File Path" Binding="{Binding FilePath, Mode=OneWay}" Width="200" />
555-
<DataGridTextColumn Header="Contaminant?" Binding="{Binding Contaminant, Mode=OneWay}" Width="250" />
556-
<DataGridCheckBoxColumn Header="Use?" Binding="{Binding Use, Mode=TwoWay}"/>
553+
<DataGridTextColumn Header="File" Binding="{Binding FileName, Mode=OneWay}" Width="366" />
554+
<DataGridTextColumn Header="File Path" Binding="{Binding FilePath, Mode=OneWay}" Width="160" />
555+
<DataGridCheckBoxColumn Header="Contaminant?" Binding="{Binding Contaminant, Mode=TwoWay}" MinWidth="90" />
556+
<DataGridCheckBoxColumn Header="Use?" Binding="{Binding Use, Mode=TwoWay}" MinWidth="80"/>
557+
<DataGridTextColumn Header="Decoy Identifier" Binding="{Binding DecoyIdentifier, Mode=TwoWay}" Width="160"/>
557558
</DataGrid.Columns>
558559
</DataGrid>
559560
</Grid>
@@ -698,8 +699,9 @@
698699
</DataGrid.CellStyle>
699700
<DataGrid.Columns>
700701
<DataGridTextColumn Header="File" Binding="{Binding FileName, Mode=OneWay}" Width="230" />
701-
<DataGridTextColumn Header="Contaminant?" Binding="{Binding Contaminant, Mode=OneWay}" Width="170" />
702-
<DataGridCheckBoxColumn Header="Use?" Binding="{Binding Use, Mode=TwoWay}"/>
702+
<DataGridCheckBoxColumn Header="Use?" Binding="{Binding Use, Mode=TwoWay}" MinWidth="40"/>
703+
<DataGridCheckBoxColumn Header="Contaminant?" Binding="{Binding Contaminant, Mode=TwoWay}" MinWidth="90"/>
704+
<DataGridTextColumn Header="Decoy Identifier" Binding="{Binding DecoyIdentifier, Mode=TwoWay}" Width="160" />
703705
</DataGrid.Columns>
704706
</DataGrid>
705707
<Button Name="MiniAddProteinDbButton" Grid.Row="0" Width="20" Height="20" HorizontalAlignment="Right" VerticalAlignment="Bottom" Margin="0,0,1,1" Content="+"

MetaMorpheus/GUI/MainWindow.xaml.cs

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
using System.Text.RegularExpressions;
2323
using Readers.InternalResults;
2424
using System.Diagnostics;
25+
using EngineLayer.DatabaseLoading;
2526

2627
namespace MetaMorpheusGUI
2728
{
@@ -665,7 +666,8 @@ private void DatabaseOrSpectraFile_DoubleClick(object sender, MouseButtonEventAr
665666
}
666667

667668
// user is probably just checking or unchecking a checkbox, don't open the file
668-
if (sender is DataGridCell cell && cell.Column is DataGridCheckBoxColumn)
669+
// User is double clicking the decoy ident column.
670+
if (sender is DataGridCell { Column: DataGridCheckBoxColumn } || sender is DataGridCell { Column: DataGridTextColumn, TabIndex: >= 3})
669671
{
670672
return;
671673
}
@@ -986,7 +988,7 @@ private void RunAllTasks_Click(object sender, RoutedEventArgs e)
986988
// everything is ready to run
987989
EverythingRunnerEngine a = new EverythingRunnerEngine(InProgressTasks.Select(b => (b.DisplayName, b.Task)).ToList(),
988990
SpectraFiles.Where(b => b.Use).Select(b => b.FilePath).ToList(),
989-
ProteinDatabases.Where(b => b.Use).Select(b => new DbForTask(b.FilePath, b.Contaminant)).ToList(),
991+
ProteinDatabases.Where(b => b.Use).Select(b => new DbForTask(b.FilePath, b.Contaminant, b.DecoyIdentifier)).ToList(),
990992
outputFolder);
991993

992994
var t = new Task(a.Run);
@@ -1088,31 +1090,34 @@ private void BoxWithList_PreviewKeyDown(object sender, KeyEventArgs e)
10881090
{
10891091
if (!RunTasksButton.IsEnabled) return;
10901092

1093+
bool IsDatabaseOrSpectra(KeyEventArgs args) => args.OriginalSource is DataGrid;
1094+
bool IsTask(KeyEventArgs args) => args.OriginalSource is TreeViewItem;
1095+
10911096
switch (e.Key)
10921097
{
10931098
// delete selected task/db/spectra
1094-
case Key.Delete:
1095-
case Key.Back:
1099+
case Key.Delete when IsDatabaseOrSpectra(e) || IsTask(e):
1100+
case Key.Back when IsDatabaseOrSpectra(e) || IsTask(e):
10961101
Delete_Click(sender, e);
10971102
e.Handled = true;
10981103
break;
10991104

11001105
// move task down
1101-
case Key.Add:
1102-
case Key.OemPlus:
1106+
case Key.Add when IsTask(e):
1107+
case Key.OemPlus when IsTask(e):
11031108
MoveSelectedTask_Click(sender, e, false);
11041109
e.Handled = true;
11051110
break;
11061111

11071112
// move task up
1108-
case Key.Subtract:
1109-
case Key.OemMinus:
1113+
case Key.Subtract when IsTask(e):
1114+
case Key.OemMinus when IsTask(e):
11101115
MoveSelectedTask_Click(sender, e, true);
11111116
e.Handled = true;
11121117
break;
11131118

11141119
// copy selected task
1115-
case Key.C when (Keyboard.Modifiers & ModifierKeys.Control) == ModifierKeys.Control:
1120+
case Key.C when IsTask(e) && (Keyboard.Modifiers & ModifierKeys.Control) == ModifierKeys.Control:
11161121
if (sender is TreeView { SelectedItem: PreRunTask preRunTask })
11171122
{
11181123
_clipboard = preRunTask.metaMorpheusTask;
@@ -1122,7 +1127,7 @@ private void BoxWithList_PreviewKeyDown(object sender, KeyEventArgs e)
11221127
break;
11231128

11241129
// paste selected task
1125-
case Key.V when (Keyboard.Modifiers & ModifierKeys.Control) == ModifierKeys.Control:
1130+
case Key.V when IsTask(e) && (Keyboard.Modifiers & ModifierKeys.Control) == ModifierKeys.Control:
11261131
if (sender is TreeView && _clipboard != null)
11271132
{
11281133
PreRunTasks.Add(new PreRunTask(_clipboard));
@@ -1132,7 +1137,7 @@ private void BoxWithList_PreviewKeyDown(object sender, KeyEventArgs e)
11321137
break;
11331138

11341139
// Duplicate Selected Task
1135-
case Key.D when (Keyboard.Modifiers & ModifierKeys.Control) == ModifierKeys.Control:
1140+
case Key.D when IsTask(e) && (Keyboard.Modifiers & ModifierKeys.Control) == ModifierKeys.Control:
11361141
if (sender is TreeView { SelectedItem: PreRunTask task })
11371142
{
11381143
PreRunTasks.Add(task);

MetaMorpheus/GUI/Util/GuiGlobalParams.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ public class GuiGlobalParams
1616
// User can set a custom proteome directory. Be sure to use double slashes in the path, otherwise it will not be read in properly.
1717
[TomlMember(Key = "UserSpecifiedProteomeDir")]
1818
public string ProteomeDirectory { get; internal set; }
19+
public string DecoyIdentifier { get; internal set; } = "DECOY";
1920

2021
//Ask about protease-specific parameter recommendations
2122
public bool AskAboutTopDownParams { get; internal set; } = true;

0 commit comments

Comments
 (0)