Skip to content

Commit 73af77a

Browse files
authored
Skyline: Improve code for finding Thermo method export DLLs (#3352)
Skyline: Improve code for finding Thermo method export DLLs - Thermo reported this code as failing on an Ascend at Thermo - This code was written after a full review of 7 machines in the MacCoss lab and the Ascend at Thermo to do a more complete job of finding the necessary DLLs - More recent machines have added Thermo.TNG.MethodXMLInterface2.dll to support Adaptive RT so it needs to be copied if it is found - Added a fairly thorough unit test for this more complicated new code to make sure it works as expected and stays working - added tests of DLL overwrite based on DLL last modified dates - improved support for cases seen in the MacCoss lab - but also turn off DLL copying, since Thermo feels this should not be necessary and the variety of DLLs we are seeing is not their intention. - easier to test DLL combinations when this code is turned off - fixes to Thermo method export - made it possible to have just "Thermo" as a method type where Skyline auto-detects the instrument form the registry - fixed command-line --exp-method-instrument to work with "Thermo" - expanded testing to include command-line - improved error messages for failure to find Thermo installation - added error message testing in the ExportMethodDlg
1 parent 815f4ad commit 73af77a

28 files changed

+1920
-246
lines changed

pwiz_tools/Skyline/CommandArgs.cs

+7-5
Original file line numberDiff line numberDiff line change
@@ -2036,9 +2036,9 @@ public bool RunningBatchCommands
20362036

20372037
// Export isolation / transition list
20382038
public static readonly Argument ARG_EXP_ISOLATION_LIST_INSTRUMENT = new DocArgument(@"exp-isolationlist-instrument",
2039-
ExportInstrumentType.ISOLATION_LIST_TYPES, (c, p) => c.ParseExpIsolationListInstrumentType(p)) {WrapValue = true};
2039+
ExportInstrumentType.ISOLATION_LIST_TYPES, (c, p) => c.ParseExpIsolationListInstrumentType(p)) { WrapValue = true, HasValueChecking = true };
20402040
public static readonly Argument ARG_EXP_TRANSITION_LIST_INSTRUMENT = new DocArgument(@"exp-translist-instrument",
2041-
ExportInstrumentType.TRANSITION_LIST_TYPES, (c, p) => c.ParseExpTransitionListInstrumentType(p)) {WrapValue = true};
2041+
ExportInstrumentType.TRANSITION_LIST_TYPES, (c, p) => c.ParseExpTransitionListInstrumentType(p)) { WrapValue = true, HasValueChecking = true };
20422042
private static readonly ArgumentGroup GROUP_LISTS = new ArgumentGroup(() => CommandArgUsage.CommandArgs_GROUP_LISTS_Exporting_isolation_transition_lists, false,
20432043
ARG_EXP_ISOLATION_LIST_INSTRUMENT, ARG_EXP_TRANSITION_LIST_INSTRUMENT) {LeftColumnWidth = 34};
20442044

@@ -2122,7 +2122,7 @@ private void WriteInstrumentValueError(NameValuePair pair, string[] listInstrume
21222122

21232123
// Export method
21242124
public static readonly Argument ARG_EXP_METHOD_INSTRUMENT = new DocArgument(@"exp-method-instrument",
2125-
ExportInstrumentType.METHOD_TYPES, (c, p) => c.ParseExpMethodInstrumentType(p)) { WrapValue = true };
2125+
ExportInstrumentType.METHOD_TYPES, (c, p) => c.ParseExpMethodInstrumentType(p)) { WrapValue = true, HasValueChecking = true };
21262126
public static readonly Argument ARG_EXP_TEMPLATE = new DocArgument(@"exp-template", PATH_TO_FILE,
21272127
(c, p) => c.TemplateFile = p.ValueFullPath);
21282128
private static readonly ArgumentGroup GROUP_METHOD = new ArgumentGroup(() => CommandArgUsage.CommandArgs_GROUP_METHOD_Exporting_native_instrument_methods, false,
@@ -2134,7 +2134,8 @@ public string MethodInstrumentType
21342134
get { return _methodInstrumentType; }
21352135
set
21362136
{
2137-
if (ExportInstrumentType.METHOD_TYPES.Any(inst => inst.Equals(value)))
2137+
if (ExportInstrumentType.METHOD_TYPES.Any(inst => inst.Equals(value)) ||
2138+
ExportInstrumentType.ThermoInstallationType(value) != null) // Allow Thermo instrument names for which we know the installation type
21382139
{
21392140
_methodInstrumentType = value;
21402141
}
@@ -2708,6 +2709,7 @@ public string[] Values
27082709
public bool WrapValue { get; set; }
27092710
public bool OptionalValue { get; set; }
27102711
public bool InternalUse { get; set; }
2712+
public bool HasValueChecking { get; set; } // Set to avoid default checking against values listed for documentation
27112713

27122714
public string ArgumentText
27132715
{
@@ -3078,7 +3080,7 @@ public bool IsMatch(Argument arg)
30783080
else
30793081
{
30803082
var val = Value;
3081-
if (arg.Values != null && !arg.Values.Any(v => v.Equals(val, StringComparison.CurrentCultureIgnoreCase)))
3083+
if (arg.Values != null && !arg.HasValueChecking && !arg.Values.Any(v => v.Equals(val, StringComparison.CurrentCultureIgnoreCase)))
30823084
throw new ValueInvalidException(arg, Value, arg.Values);
30833085
}
30843086
}

pwiz_tools/Skyline/CommandLine.cs

+36
Original file line numberDiff line numberDiff line change
@@ -3991,6 +3991,42 @@ private bool ExportInstrumentFile(ExportFileType type, CommandArgs args)
39913991

39923992
if (Equals(type, ExportFileType.Method))
39933993
{
3994+
// If the instrument type is either just Thermo or a Thermo instrument type that
3995+
// support the TNG XML method API
3996+
string thermoInstallationType = ExportInstrumentType.ThermoInstallationType(args.MethodInstrumentType);
3997+
if (thermoInstallationType != null || Equals(args.MethodInstrumentType, ExportInstrumentType.THERMO))
3998+
{
3999+
var dllFinder = new ThermoDllFinder();
4000+
var thermoSoftwareInfo = dllFinder.GetSoftwareInfo(); // CONSIDER: This behaves differently for tests on a computer with Thermo software installed
4001+
if (thermoSoftwareInfo.InstrumentType == null)
4002+
{
4003+
_out.WriteLine(TextUtil.SpaceSeparate(Resources.CommandStatusWriter_WriteLine_Error_,
4004+
ModelResources.ThermoMassListExporter_EnsureLibraries_Failed_to_find_a_valid_Thermo_instrument_installation_));
4005+
_out.WriteLine(thermoSoftwareInfo.FailureReason);
4006+
return false;
4007+
}
4008+
// If not generally exporting a Thermo method, and the instrument type
4009+
// specified does not match the installed type, then error.
4010+
else if (Equals(args.MethodInstrumentType, ExportInstrumentType.THERMO))
4011+
{
4012+
var instrumentType = ExportInstrumentType.ThermoTypeFromInstallationType(thermoSoftwareInfo.InstrumentType);
4013+
if (instrumentType == null)
4014+
{
4015+
_out.WriteLine(TextUtil.SpaceSeparate(Resources.CommandStatusWriter_WriteLine_Error_,
4016+
string.Format(ModelResources.ThermoMassListExporter_EnsureLibraries_Unknown_Thermo_instrument_type___0___installed_, thermoSoftwareInfo.InstrumentType)));
4017+
return false;
4018+
}
4019+
4020+
args.MethodInstrumentType = instrumentType;
4021+
}
4022+
else if (!Equals(thermoSoftwareInfo.InstrumentType, thermoInstallationType))
4023+
{
4024+
_out.WriteLine(ModelResources.CommandLine_ExportInstrumentFile_Error__The_specified_instrument_type___0___does_not_match_the_installed_software___1___,
4025+
args.MethodInstrumentType, thermoSoftwareInfo.InstrumentType);
4026+
_out.WriteLine(ModelResources.CommandLine_ExportInstrumentFile_Use_the_instrument_type__Thermo__to_export_a_method_with_the_installed_software_);
4027+
return false;
4028+
}
4029+
}
39944030
if (string.IsNullOrEmpty(args.TemplateFile))
39954031
{
39964032
_out.WriteLine(Resources.CommandLine_ExportInstrumentFile_Error__A_template_file_is_required_to_export_a_method_);

pwiz_tools/Skyline/Executables/BuildMethod/BuildThermoMethod/Program.cs

+22-35
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ private static string GetErrorText(Exception x)
6363
// Thermo libraries can sometimes throw exceptions with multi-line errors
6464
// Any lines that do not get ERROR: prepended will not get reported
6565
var sb = new StringBuilder();
66-
var reader = new StringReader(x.Message);
66+
var reader = new StringReader(x.ToString());
6767
string line;
6868
while ((line = reader.ReadLine()) != null)
6969
sb.AppendLine("ERROR: " + line);
@@ -77,14 +77,7 @@ static void Usage()
7777
" Takes template Thermo method file and a Skyline generated Thermo\n" +
7878
" scheduled transition list as inputs, to generate a method file\n" +
7979
" as output.\n" +
80-
" -f Fusion method [default]\n" +
81-
" -e Endura method\n" +
82-
" -q Quantiva method\n" +
83-
" -a Altis method\n" +
84-
" -p Exploris method\n" +
85-
" -l Fusion Lumos method\n" +
86-
" -c Eclipse method\n" +
87-
" -t Stellar method\n" +
80+
" -t <inst type> as in registry [default TSQAltis]\n" +
8881
" -o <output file> New method is written to the specified output file\n" +
8982
" -x Export method XML to <basename>.xml file\n" +
9083
" -s Transition list is read from stdin.\n" +
@@ -343,14 +336,25 @@ internal sealed class BuildThermoMethod
343336
{
344337
private const string ThermoMethodExt = ".meth";
345338
private const string InstrumentFusion = "OrbitrapFusion";
346-
private const string InstrumentExploris = "OrbitrapExploris480";
347339
private const string InstrumentFusionLumos = "OrbitrapFusionLumos";
348340
private const string InstrumentEclipse = "OrbitrapEclipse";
341+
private const string InstrumentAscend = "OrbitrapAscend";
342+
private const string InstrumentAstral = "OrbitrapAstral";
343+
private const string InstrumentExploris = "OrbitrapExploris480";
349344
private const string InstrumentEndura = "TSQEndura";
350345
private const string InstrumentQuantiva = "TSQQuantiva";
351346
private const string InstrumentAltis = "TSQAltis";
352347
private const string InstrumentStellar = "Stellar";
353348

349+
private static readonly string[] KnownInstruments =
350+
{
351+
InstrumentFusion, InstrumentFusionLumos, InstrumentEclipse, InstrumentAscend, // tribrids
352+
InstrumentAstral, // tofs
353+
InstrumentExploris, // exactives
354+
InstrumentEndura, InstrumentQuantiva, InstrumentAltis, // tsqs
355+
InstrumentStellar, // qits
356+
};
357+
354358
private string InstrumentType { get; set; }
355359
private string InstrumentVersion { get; set; }
356360
private string TemplateMethod { get; set; }
@@ -359,7 +363,7 @@ internal sealed class BuildThermoMethod
359363

360364
public BuildThermoMethod()
361365
{
362-
InstrumentType = InstrumentQuantiva;
366+
InstrumentType = InstrumentAltis;
363367
InstrumentVersion = null;
364368
TemplateMethod = null;
365369
MethodTrans = new List<MethodTransitions>();
@@ -377,29 +381,12 @@ public void ParseCommandArgs(string[] args)
377381
string arg = args[i++];
378382
switch (arg[1])
379383
{
380-
case 'f':
381-
InstrumentType = InstrumentFusion;
382-
break;
383-
case 'e':
384-
InstrumentType = InstrumentEndura;
385-
break;
386-
case 'q':
387-
InstrumentType = InstrumentQuantiva;
388-
break;
389-
case 'a':
390-
InstrumentType = InstrumentAltis;
391-
break;
392-
case 'p':
393-
InstrumentType = InstrumentExploris;
394-
break;
395-
case 'l':
396-
InstrumentType = InstrumentFusionLumos;
397-
break;
398-
case 'c':
399-
InstrumentType = InstrumentEclipse;
400-
break;
401384
case 't':
402-
InstrumentType = InstrumentStellar;
385+
if (i >= args.Length)
386+
throw new UsageException();
387+
InstrumentType = args[i++];
388+
if (!KnownInstruments.Contains(InstrumentType))
389+
throw new UsageException(string.Format("Unknown instrument type {0}", InstrumentType));
403390
break;
404391
case 'o':
405392
if (i >= args.Length)
@@ -423,7 +410,7 @@ public void ParseCommandArgs(string[] args)
423410
InstrumentVersion = MethodXMLFactory.GetLatestInstalledVersion(InstrumentType);
424411

425412
if (multiFile && !string.IsNullOrEmpty(outputMethod))
426-
Usage("Multi-file and specific output are not compatibile.");
413+
Usage("Multi-file and specific output are not compatible.");
427414

428415
int argcLeft = args.Length - i;
429416
if (argcLeft < 1 || (!readStdin && argcLeft < 2))
@@ -572,11 +559,11 @@ public void Build()
572559
case InstrumentFusion:
573560
mx.ApplyMethodModificationsFromXML(GetFusionModificationXml(InstrumentType, listItems, outMeth));
574561
break;
562+
case InstrumentAstral:
575563
case InstrumentExploris:
576564
mx.ApplyMethodModificationsFromXML(GetExplorisXml(InstrumentType, listItems, outMeth));
577565
break;
578566
case InstrumentEclipse:
579-
// case InstrumentFusion:
580567
case InstrumentFusionLumos:
581568
mx.ApplyMethodModificationsFromXML(GetCalciumXml(InstrumentType, listItems, outMeth));
582569
break;

0 commit comments

Comments
 (0)