Skip to content

Commit 6c86caa

Browse files
committed
make-template: fix type error
1 parent e4d42b8 commit 6c86caa

File tree

3 files changed

+242
-2
lines changed

3 files changed

+242
-2
lines changed

cwltool/main.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -330,10 +330,10 @@ def generate_input_template(tool: Process) -> CWLObjectType:
330330
"""Generate an example input object for the given CWL process."""
331331
template = ruamel.yaml.comments.CommentedMap()
332332
for inp in cast(
333-
list[MutableMapping[str, str]],
333+
list[CWLObjectType],
334334
realize_input_schema(tool.tool["inputs"], tool.schemaDefs),
335335
):
336-
name = shortname(inp["id"])
336+
name = shortname(cast(str, inp["id"]))
337337
value, comment = generate_example_input(inp["type"], inp.get("default", None))
338338
template.insert(0, name, value, comment)
339339
return template

tests/CometAdapter.cwl

+228
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,228 @@
1+
# Copyright (c) 2002-present, The OpenMS Team -- EKU Tuebingen, ETH Zurich, and FU Berlin
2+
# SPDX-License-Identifier: Apache-2.0
3+
label: CometAdapter
4+
doc: Annotates MS/MS spectra using Comet.
5+
inputs:
6+
in:
7+
doc: Input file
8+
type: File
9+
out:
10+
doc: Output file
11+
type: string
12+
database:
13+
doc: FASTA file
14+
type: File
15+
comet_executable:
16+
doc: The Comet executable. Provide a full or relative path, or make sure it can be found in your PATH environment.
17+
type: File
18+
pin_out:
19+
doc: Output file - for Percolator input
20+
type: string?
21+
default_params_file:
22+
doc: Default Comet params file. All parameters of this take precedence. A template file can be generated using 'comet.exe -p'
23+
type: File?
24+
precursor_mass_tolerance:
25+
doc: "Precursor monoisotopic mass tolerance (Comet parameter: peptide_mass_tolerance). See also precursor_error_units to set the unit."
26+
type: double?
27+
precursor_error_units:
28+
doc: "Unit of precursor monoisotopic mass tolerance for parameter precursor_mass_tolerance (Comet parameter: peptide_mass_units)"
29+
type: string?
30+
isotope_error:
31+
doc: This parameter controls whether the peptide_mass_tolerance takes into account possible isotope errors in the precursor mass measurement. Use -8/-4/0/4/8 only for SILAC.
32+
type: string?
33+
fragment_mass_tolerance:
34+
doc: "This is half the bin size, which is used to segment the MS/MS spectrum. Thus, the value should be a bit higher than for other search engines, since the bin might not be centered around the peak apex (see 'fragment_bin_offset').CAUTION: Low tolerances have heavy impact on RAM usage (since Comet uses a lot of bins in this case). Consider using use_sparse_matrix and/or spectrum_batch_size."
35+
type: double?
36+
fragment_error_units:
37+
doc: Fragment monoisotopic mass error units
38+
type: string?
39+
fragment_bin_offset:
40+
doc: "Offset of fragment bins. Recommended by Comet: low-res: 0.4, high-res: 0.0"
41+
type: double?
42+
instrument:
43+
doc: "Comets theoretical_fragment_ions parameter: theoretical fragment ion peak representation, high-res: sum of intensities plus flanking bins, ion trap (low-res) ms/ms: sum of intensities of central M bin only"
44+
type: string?
45+
use_A_ions:
46+
doc: use A ions for PSM
47+
type: boolean?
48+
use_B_ions:
49+
doc: use B ions for PSM
50+
type: boolean?
51+
use_C_ions:
52+
doc: use C ions for PSM
53+
type: boolean?
54+
use_X_ions:
55+
doc: use X ions for PSM
56+
type: boolean?
57+
use_Y_ions:
58+
doc: use Y ions for PSM
59+
type: boolean?
60+
use_Z_ions:
61+
doc: use Z ions for PSM
62+
type: boolean?
63+
use_NL_ions:
64+
doc: use neutral loss (NH3, H2O) ions from b/y for PSM
65+
type: boolean?
66+
enzyme:
67+
doc: The enzyme used for peptide digestion.
68+
type: string?
69+
second_enzyme:
70+
doc: Additional enzyme used for peptide digestion.
71+
type: string?
72+
num_enzyme_termini:
73+
doc: Specify the termini where the cleavage rule has to match
74+
type: string?
75+
missed_cleavages:
76+
doc: Number of possible cleavage sites missed by the enzyme. It has no effect if enzyme is unspecific cleavage.
77+
type: long?
78+
min_peptide_length:
79+
doc: Minimum peptide length to consider.
80+
type: long?
81+
max_peptide_length:
82+
doc: Maximum peptide length to consider.
83+
type: long?
84+
num_hits:
85+
doc: Number of peptide hits (PSMs) per spectrum in output file
86+
type: long?
87+
precursor_charge:
88+
doc: "Precursor charge range to search (if spectrum is not annotated with a charge or if override_charge!=keep any known): 0:[num] == search all charges, 2:6 == from +2 to +6, 3:3 == +3"
89+
type: string?
90+
override_charge:
91+
doc: "_keep any known_: keep any precursor charge state (from input), _ignore known_: ignore known precursor charge state and use precursor_charge parameter, _ignore outside range_: ignore precursor charges outside precursor_charge range, _keep known search unknown_: keep any known precursor charge state. For unknown charge states, search as singly charged if there is no signal above the precursor m/z or use the precursor_charge range"
92+
type: string?
93+
ms_level:
94+
doc: MS level to analyze, valid are levels 2 (default) or 3
95+
type: long?
96+
activation_method:
97+
doc: If not ALL, only searches spectra of the given method
98+
type: string?
99+
digest_mass_range:
100+
doc: MH+ peptide mass range to analyze
101+
type: string?
102+
max_fragment_charge:
103+
doc: Set maximum fragment charge state to analyze as long as still lower than precursor charge - 1. (Allowed max 5)
104+
type: long?
105+
max_precursor_charge:
106+
doc: set maximum precursor charge state to analyze (allowed max 9)
107+
type: long?
108+
clip_nterm_methionine:
109+
doc: If set to true, also considers the peptide sequence w/o N-term methionine separately and applies appropriate N-term mods to it
110+
type: boolean?
111+
spectrum_batch_size:
112+
doc: max. number of spectra to search at a time; use 0 to search the entire scan range in one batch
113+
type: long?
114+
mass_offsets:
115+
doc: One or more mass offsets to search (values subtracted from deconvoluted precursor mass). Has to include 0.0 if you want the default mass to be searched.
116+
type: double[]?
117+
minimum_peaks:
118+
doc: Required minimum number of peaks in spectrum to search (default 10)
119+
type: long?
120+
minimum_intensity:
121+
doc: Minimum intensity value to read in
122+
type: double?
123+
remove_precursor_peak:
124+
doc: no = no removal, yes = remove all peaks around precursor m/z, charge_reduced = remove all charge reduced precursor peaks (for ETD/ECD). phosphate_loss = remove the HPO3 (-80) and H3PO4 (-98) precursor phosphate neutral loss peaks. See also remove_precursor_tolerance
125+
type: string?
126+
remove_precursor_tolerance:
127+
doc: one-sided tolerance for precursor removal in Thompson
128+
type: double?
129+
clear_mz_range:
130+
doc: for iTRAQ/TMT type data; will clear out all peaks in the specified m/z range, if not 0:0
131+
type: string?
132+
fixed_modifications:
133+
doc: Fixed modifications, specified using Unimod (www.unimod.org) terms, e.g. 'Carbamidomethyl (C)' or 'Oxidation (M)'
134+
type: string[]?
135+
variable_modifications:
136+
doc: Variable modifications, specified using Unimod (www.unimod.org) terms, e.g. 'Carbamidomethyl (C)' or 'Oxidation (M)'
137+
type: string[]?
138+
binary_modifications:
139+
doc: "List of modification group indices. Indices correspond to the binary modification index used by comet to group individually searched lists of variable modifications.\nNote: if set, both variable_modifications and binary_modifications need to have the same number of entries as the N-th entry corresponds to the N-th variable_modification.\n if left empty (default), all entries are internally set to 0 generating all permutations of modified and unmodified residues.\n For a detailed explanation please see the parameter description in the Comet help."
140+
type: long[]?
141+
max_variable_mods_in_peptide:
142+
doc: Set a maximum number of variable modifications per peptide
143+
type: long?
144+
require_variable_mod:
145+
doc: If true, requires at least one variable modification per peptide
146+
type: boolean?
147+
reindex:
148+
doc: Recalculate peptide to protein association using OpenMS. Annotates target-decoy information.
149+
type: string?
150+
log:
151+
doc: Name of log file (created only when specified)
152+
type: string?
153+
debug:
154+
doc: Sets the debug level
155+
type: long?
156+
threads:
157+
doc: Sets the number of threads allowed to be used by the TOPP tool
158+
type: long?
159+
no_progress:
160+
doc: Disables progress logging to command line
161+
type: boolean?
162+
force:
163+
doc: Overrides tool-specific checks
164+
type: boolean?
165+
test:
166+
doc: Enables the test mode (needed for internal use only)
167+
type: boolean?
168+
PeptideIndexing__decoy_string:
169+
doc: String that was appended (or prefixed - see 'decoy_string_position' flag below) to the accessions in the protein database to indicate decoy proteins. If empty (default), it's determined automatically (checking for common terms, both as prefix and suffix).
170+
type: string?
171+
PeptideIndexing__decoy_string_position:
172+
doc: Is the 'decoy_string' prepended (prefix) or appended (suffix) to the protein accession? (ignored if decoy_string is empty)
173+
type: string?
174+
PeptideIndexing__missing_decoy_action:
175+
doc: "Action to take if NO peptide was assigned to a decoy protein (which indicates wrong database or decoy string): 'error' (exit with error, no output), 'warn' (exit with success, warning message), 'silent' (no action is taken, not even a warning)"
176+
type: string?
177+
PeptideIndexing__write_protein_sequence:
178+
doc: If set, the protein sequences are stored as well.
179+
type: boolean?
180+
PeptideIndexing__write_protein_description:
181+
doc: If set, the protein description is stored as well.
182+
type: boolean?
183+
PeptideIndexing__keep_unreferenced_proteins:
184+
doc: If set, protein hits which are not referenced by any peptide are kept.
185+
type: boolean?
186+
PeptideIndexing__unmatched_action:
187+
doc: "If peptide sequences cannot be matched to any protein: 1) raise an error; 2) warn (unmatched PepHits will miss target/decoy annotation with downstream problems); 3) remove the hit."
188+
type: string?
189+
PeptideIndexing__aaa_max:
190+
doc: Maximal number of ambiguous amino acids (AAAs) allowed when matching to a protein database with AAAs. AAAs are 'B', 'J', 'Z' and 'X'.
191+
type: long?
192+
PeptideIndexing__mismatches_max:
193+
doc: Maximal number of mismatched (mm) amino acids allowed when matching to a protein database. The required runtime is exponential in the number of mm's; apply with care. MM's are allowed in addition to AAA's.
194+
type: long?
195+
PeptideIndexing__IL_equivalent:
196+
doc: Treat the isobaric amino acids isoleucine ('I') and leucine ('L') as equivalent (indistinguishable). Also occurrences of 'J' will be treated as 'I' thus avoiding ambiguous matching.
197+
type: boolean?
198+
PeptideIndexing__allow_nterm_protein_cleavage:
199+
doc: Allow the protein N-terminus amino acid to clip.
200+
type: string?
201+
PeptideIndexing__enzyme__name:
202+
doc: "Enzyme which determines valid cleavage sites - e.g. trypsin cleaves after lysine (K) or arginine (R), but not before proline (P). Default: deduce from input"
203+
type: string?
204+
PeptideIndexing__enzyme__specificity:
205+
doc: "Specificity of the enzyme. Default: deduce from input.\n 'full': both internal cleavage sites must match.\n 'semi': one of two internal cleavage sites must match.\n 'none': allow all peptide hits no matter their context (enzyme is irrelevant)."
206+
type: string?
207+
outputs:
208+
out:
209+
type: File
210+
outputBinding:
211+
glob: $(inputs.out)
212+
pin_out:
213+
type: File?
214+
outputBinding:
215+
glob: $(inputs.pin_out)
216+
cwlVersion: v1.2
217+
class: CommandLineTool
218+
baseCommand:
219+
- CometAdapter
220+
requirements:
221+
InlineJavascriptRequirement: {}
222+
InitialWorkDirRequirement:
223+
listing:
224+
- entryname: cwl_inputs.json
225+
entry: $(JSON.stringify(inputs))
226+
arguments:
227+
- -ini
228+
- cwl_inputs.json

tests/test_examples.py

+12
Original file line numberDiff line numberDiff line change
@@ -1894,3 +1894,15 @@ def test_input_named_id() -> None:
18941894
]
18951895
)
18961896
assert exit_code == 0, stderr
1897+
1898+
1899+
def test_make_template() -> None:
1900+
"""End-to-end test of --make-template, especially for mypyc mode."""
1901+
exit_code, stdout, stderr = get_main_output(
1902+
[
1903+
"--make-template",
1904+
"--debug",
1905+
get_data("tests/CometAdapter.cwl"),
1906+
]
1907+
)
1908+
assert exit_code == 0, stderr

0 commit comments

Comments
 (0)