Skip to content

Commit

Permalink
Eliminate those pesky warnings (#2421)
Browse files Browse the repository at this point in the history
  • Loading branch information
nbollis authored Oct 3, 2024
1 parent 6dd10e0 commit 8c8fe5f
Show file tree
Hide file tree
Showing 10 changed files with 77 additions and 49 deletions.
4 changes: 2 additions & 2 deletions MetaMorpheus/EngineLayer/PsmTsv/PsmTsvReader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public static List<PsmFromTsv> ReadTsv(string filePath, out List<string> warning
List<PsmFromTsv> psms = new List<PsmFromTsv>();
warnings = new List<string>();

StreamReader reader = null;
StreamReader reader;
try
{
reader = new StreamReader(filePath);
Expand Down Expand Up @@ -46,7 +46,7 @@ public static List<PsmFromTsv> ReadTsv(string filePath, out List<string> warning
}
catch (Exception e)
{
warnings.Add("Could not read line: " + lineCount);
warnings.Add($"Could not read line: {lineCount} with error message: {e.Message}");
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public FragmentationReanalysisViewModel(bool isProtein = true)
if (isProtein)
{
DissociationTypes = new ObservableCollection<DissociationType>(Enum.GetValues<DissociationType>()
.Where(p => p != DissociationType.AnyActivationType && Omics.Fragmentation.Peptide.DissociationTypeCollection.ProductsFromDissociationType.TryGetValue(p, out var prod) && prod.Any()));
.Where(p => p != DissociationType.AnyActivationType && Omics.Fragmentation.Peptide.DissociationTypeCollection.ProductsFromDissociationType.TryGetValue(p, out var prod) && prod.Count != 0));
PossibleProducts = new ObservableCollection<FragmentViewModel>(GetPossibleProducts(_isProtein));
SelectedDissociationType = DissociationType.HCD;
}
Expand Down Expand Up @@ -187,7 +187,7 @@ private void SetUseForFragmentsBasedUponDissociationType(DissociationType dissoc
Omics.Fragmentation.Peptide.DissociationTypeCollection.ProductsFromDissociationType[dissociationType].ToArray()
: Omics.Fragmentation.Oligo.DissociationTypeCollection.GetRnaProductTypesFromDissociationType(dissociationType).ToArray();
}
catch (Exception e)
catch (Exception)
{
_selectedDissociationType = DissociationType.HCD;
dissociationTypeProducts = isProtein ?
Expand Down
16 changes: 8 additions & 8 deletions MetaMorpheus/GuiFunctions/MetaDraw/MetaDrawSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@ public static class MetaDrawSettings
{
#region Constants

public static char[] SubScriptNumbers = {
public static readonly char[] SubScriptNumbers = {
'\u2080', '\u2081', '\u2082', '\u2083', '\u2084',
'\u2085', '\u2086', '\u2087', '\u2088', '\u2089'
};

public static char[] SuperScriptNumbers = {
public static readonly char[] SuperScriptNumbers = {
'\u2070', '\u00b9', '\u00b2', '\u00b3', '\u2074',
'\u2075', '\u2076', '\u2077', '\u2078', '\u2079'
};
Expand Down Expand Up @@ -509,7 +509,7 @@ public static void LoadSettings(MetaDrawSettingsSnapshot settings, out bool flag
throw new MetaMorpheusException("Cannot parse Product Ion Color values");
}
}
catch (Exception e)
catch (Exception)
{
Debugger.Break();
SetDefaultProductTypeColors();
Expand Down Expand Up @@ -546,7 +546,7 @@ public static void LoadSettings(MetaDrawSettingsSnapshot settings, out bool flag
throw new MetaMorpheusException("Cannot parse Beta Product Ion Color values");
}
}
catch (Exception e)
catch (Exception)
{
Debugger.Break();
SetDefaultBetaProductTypeColors();
Expand Down Expand Up @@ -582,7 +582,7 @@ public static void LoadSettings(MetaDrawSettingsSnapshot settings, out bool flag
throw new MetaMorpheusException("Cannot parse Modification Color values");
}
}
catch (Exception e)
catch (Exception)
{
Debugger.Break();
SetDefaultModificationColors();
Expand Down Expand Up @@ -618,7 +618,7 @@ public static void LoadSettings(MetaDrawSettingsSnapshot settings, out bool flag

}
}
catch (Exception e)
catch (Exception)
{
Debugger.Break();
SetDefaultCoverageTypeColors();
Expand All @@ -627,7 +627,7 @@ public static void LoadSettings(MetaDrawSettingsSnapshot settings, out bool flag

try // Spectrum Descriptors
{
if (!settings.SpectrumDescriptionValues.Any())
if (settings.SpectrumDescriptionValues.Count == 0)
throw new MetaMorpheusException("Cannot parse Spectrum Descriptor values");

var firstSplit = settings.SpectrumDescriptionValues.First().Split(',');
Expand Down Expand Up @@ -657,7 +657,7 @@ public static void LoadSettings(MetaDrawSettingsSnapshot settings, out bool flag
throw new MetaMorpheusException("Cannot parse Spectrum Descriptor values");
}
}
catch (Exception e)
catch (Exception)
{
Debugger.Break();
SetDefaultProductTypeColors();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,7 @@ public class SpectralAveragingParametersViewModel : BaseViewModel, IEquatable<Sp
{
#region Private Members

private SpectralAveragingParameters spectralAveragingParameters;
private int previousOverlap;
private string? savedPath;
private SpectralAveragingParameters _spectralAveragingParameters;

#endregion

Expand All @@ -35,79 +33,79 @@ enum PresetAveragingParameters

public SpectralAveragingParameters SpectralAveragingParameters
{
get => spectralAveragingParameters;
set { spectralAveragingParameters = value; OnPropertyChanged(nameof(SpectralAveragingParameters)); UpdateVisualRepresentation(); }
get => _spectralAveragingParameters;
set { _spectralAveragingParameters = value; OnPropertyChanged(nameof(SpectralAveragingParameters)); UpdateVisualRepresentation(); }
}

public OutlierRejectionType RejectionType
{
get => spectralAveragingParameters.OutlierRejectionType;
set { spectralAveragingParameters.OutlierRejectionType = value; OnPropertyChanged(nameof(RejectionType)); }
get => _spectralAveragingParameters.OutlierRejectionType;
set { _spectralAveragingParameters.OutlierRejectionType = value; OnPropertyChanged(nameof(RejectionType)); }
}

public SpectraWeightingType WeightingType
{
get => spectralAveragingParameters.SpectralWeightingType;
set { spectralAveragingParameters.SpectralWeightingType = value; OnPropertyChanged(nameof(WeightingType)); }
get => _spectralAveragingParameters.SpectralWeightingType;
set { _spectralAveragingParameters.SpectralWeightingType = value; OnPropertyChanged(nameof(WeightingType)); }
}

public SpectraFileAveragingType SpectraFileAveragingType
{
get => spectralAveragingParameters.SpectraFileAveragingType;
set { spectralAveragingParameters.SpectraFileAveragingType = value; OnPropertyChanged(nameof(SpectraFileAveragingType)); }
get => _spectralAveragingParameters.SpectraFileAveragingType;
set { _spectralAveragingParameters.SpectraFileAveragingType = value; OnPropertyChanged(nameof(SpectraFileAveragingType)); }
}

public bool PerformNormalization
{
get => spectralAveragingParameters.NormalizationType == NormalizationType.RelativeToTics ? true : false;
get => _spectralAveragingParameters.NormalizationType == NormalizationType.RelativeToTics ? true : false;
set
{
spectralAveragingParameters.NormalizationType = value == true ? NormalizationType.RelativeToTics : NormalizationType.NoNormalization;
_spectralAveragingParameters.NormalizationType = value ? NormalizationType.RelativeToTics : NormalizationType.NoNormalization;
OnPropertyChanged(nameof(PerformNormalization));
}
}

public double Percentile
{
get => spectralAveragingParameters.Percentile;
set { spectralAveragingParameters.Percentile = value; OnPropertyChanged(nameof(Percentile)); }
get => _spectralAveragingParameters.Percentile;
set { _spectralAveragingParameters.Percentile = value; OnPropertyChanged(nameof(Percentile)); }
}

public double MinSigmaValue
{
get => spectralAveragingParameters.MinSigmaValue;
set { spectralAveragingParameters.MinSigmaValue = value; OnPropertyChanged(nameof(MinSigmaValue)); }
get => _spectralAveragingParameters.MinSigmaValue;
set { _spectralAveragingParameters.MinSigmaValue = value; OnPropertyChanged(nameof(MinSigmaValue)); }
}

public double MaxSigmaValue
{
get => spectralAveragingParameters.MaxSigmaValue;
set { spectralAveragingParameters.MaxSigmaValue = value; OnPropertyChanged(nameof(MaxSigmaValue)); }
get => _spectralAveragingParameters.MaxSigmaValue;
set { _spectralAveragingParameters.MaxSigmaValue = value; OnPropertyChanged(nameof(MaxSigmaValue)); }
}

public double BinSize
{
get => spectralAveragingParameters.BinSize;
set { spectralAveragingParameters.BinSize = value; OnPropertyChanged(nameof(BinSize)); }
get => _spectralAveragingParameters.BinSize;
set { _spectralAveragingParameters.BinSize = value; OnPropertyChanged(nameof(BinSize)); }
}

public int NumberOfScansToAverage
{
get => spectralAveragingParameters.NumberOfScansToAverage;
get => _spectralAveragingParameters.NumberOfScansToAverage;
set
{
spectralAveragingParameters.NumberOfScansToAverage = value;
spectralAveragingParameters.ScanOverlap = value - 1;
_spectralAveragingParameters.NumberOfScansToAverage = value;
_spectralAveragingParameters.ScanOverlap = value - 1;
OnPropertyChanged(nameof(NumberOfScansToAverage));
}
}

public int MaxThreads
{
get => spectralAveragingParameters.MaxThreadsToUsePerFile;
get => _spectralAveragingParameters.MaxThreadsToUsePerFile;
set
{
spectralAveragingParameters.MaxThreadsToUsePerFile = value;
_spectralAveragingParameters.MaxThreadsToUsePerFile = value;
OnPropertyChanged(nameof(MaxThreads));
}
}
Expand All @@ -123,7 +121,7 @@ public int MaxThreads
public SpectralAveragingParametersViewModel(SpectralAveragingParameters parameters)
{
// value initialization
spectralAveragingParameters = parameters;
_spectralAveragingParameters = parameters;
RejectionTypes = (OutlierRejectionType[])Enum.GetValues(typeof(OutlierRejectionType));
WeightingTypes = new [] { SpectraWeightingType.WeightEvenly, SpectraWeightingType.TicValue};
SpectraFileAveragingTypes = new[] { SpectraFileAveragingType.AverageAll, SpectraFileAveragingType.AverageDdaScans, SpectraFileAveragingType.AverageEverynScansWithOverlap};
Expand Down Expand Up @@ -180,7 +178,7 @@ public void SetOtherParameters(object settingsNameToSet)
throw new ArgumentException("This should never be hit!");
}

spectralAveragingParameters = parameters;
_spectralAveragingParameters = parameters;
UpdateVisualRepresentation();
}

Expand Down
34 changes: 34 additions & 0 deletions MetaMorpheus/MetaMorpheus.sln.DotSettings
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
<s:Boolean x:Key="/Default/UserDictionary/Words/=Calib/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=coisolation/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=crosslinked/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=crosslinks/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=csms/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=Cterm/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=deadend/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=fasta/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=Frac/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=Glyco/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=Gsms/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=inframe/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=localizaiton/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=localizeable/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=missense/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=Mzml/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=Ngly/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=nglyco/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=Nterm/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=Ogly/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=oglyco/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=Phospho/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=prot/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=proteingroup/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=psmtsv/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=pwsm/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=Silac/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=Taskconfig/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=toml/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=Unimod/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=Uniprot/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=xlink/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=xlinker/@EntryIndexedValue">True</s:Boolean></wpf:ResourceDictionary>
5 changes: 2 additions & 3 deletions MetaMorpheus/TaskLayer/AveragingTask/SpectralAveragingTask.cs
Original file line number Diff line number Diff line change
Expand Up @@ -81,15 +81,14 @@ protected override MyTaskResults RunSpecific(string OutputFolder, List<DbForTask
}
catch (Exception e)
{
Warn($"Averaging Failure! Could not average spectra for file {originalUnaveragedFilepathWithoutExtenstion}");
Warn($"Averaging Failure! Could not average spectra for file {originalUnaveragedFilepathWithoutExtenstion} with exception {e.Message}");
}
myFileManager.DoneWithFile(originalUnaveragedFilepath);

// carry over file-specific parameters from the unaveraged file to the averaged one
var fileSpecificParams = new FileSpecificParameters();
if (fileSettingsList[spectraFileIndex] != null)
{
fileSpecificParams = fileSettingsList[spectraFileIndex].Clone();// write toml settings for the averaged file if there are file specific parameters
var fileSpecificParams = fileSettingsList[spectraFileIndex].Clone();// write toml settings for the averaged file if there are file specific parameters
var newTomlFileName = Path.Combine(OutputFolder, originalUnaveragedFilepathWithoutExtenstion + AveragingSuffix + ".toml");
Toml.WriteFile(fileSpecificParams, newTomlFileName, tomlConfig);
FinishedWritingFile(newTomlFileName, new List<string> { taskId, "Individual Spectra Files", originalUnaveragedFilepathWithoutExtenstion });
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,6 @@ protected override MyTaskResults RunSpecific(string OutputFolder, List<DbForTask

public MyTaskResults Run(string OutputFolder, List<DbForTask> dbFilenameList, List<string> currentRawFileList, string taskId, FileSpecificParameters[] fileSettingsList, List<GlycoSpectralMatch> allPsms, CommonParameters commonParameters, GlycoSearchParameters glycoSearchParameters, List<Protein> proteinList, List<Modification> variableModifications, List<Modification> fixedModifications, List<string> localizeableModificationTypes, MyTaskResults MyTaskResults)
{
List<ProteinGroup> proteinGroups = null;

if (!Parameters.GlycoSearchParameters.WriteDecoys)
{
allPsms.RemoveAll(b => b.IsDecoy);
Expand Down
1 change: 0 additions & 1 deletion MetaMorpheus/Test/SpectralRecoveryTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,6 @@ public void SpectralRecoveryTestSetup()
Path.Combine(TestContext.CurrentContext.TestDirectory, "TestData", @"SpectralRecoveryTest\K13_20ng_1min_frac1.mzML") };
databaseList = new List<DbForTask>() {new DbForTask(
Path.Combine(TestContext.CurrentContext.TestDirectory, "TestData", @"SpectralRecoveryTest\HumanFastaSlice.fasta"), false) };
outputFolder = outputFolder;

SearchTask searchTask = new SearchTask
{
Expand Down
2 changes: 1 addition & 1 deletion MetaMorpheus/Test/TestDataFile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -419,7 +419,7 @@ public TestDataFile(PeptideWithSetModifications pepWithSetMods)
Scans = ScansHere.ToArray();
}

public string FilePath
public new string FilePath
{
get
{
Expand Down
4 changes: 2 additions & 2 deletions MetaMorpheus/Test/XLTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1636,7 +1636,7 @@ internal class XLTestDataFile : MsDataFile
Scans = ScansHere.ToArray();
}

public static string FilePath
public new static string FilePath
{
get
{
Expand Down Expand Up @@ -1718,7 +1718,7 @@ internal class XLTestDataFileDiffSite : MsDataFile
Scans = ScansHere.ToArray();
}

public string FilePath
public new string FilePath
{
get
{
Expand Down

0 comments on commit 8c8fe5f

Please sign in to comment.