More intuitive peptide length argument in mhcflurry-predict-scan. See
@@ -126,11 +126,11 @@ input_args.add_argument(
results_args = parser.add_argument_group(title="Result options")
results_args.add_argument(
"--peptide-lengths",
- type=int,
- nargs="+",
- default=[8, 9, 10, 11],
+ default="8-11",
metavar="L",
- help="Peptide lengths to consider. Default: %(default)s.")
+ help="Peptide lengths to consider. Pass as START-END (e.g. 8-11) or a "
+ "comma-separated list (8,9,10,11). When using START-END, the range is "
+ "INCLUSIVE on both ends. Default: %(default)s.")
comparison_quantities = [
"presentation_score",
"processing_score",
@@ -204,6 +204,23 @@ model_args.add_argument(
help="Do not use flanking sequence information in predictions")
+def parse_peptide_lengths(value):
+ try:
+ if "-" in value:
+ (start, end) = value.split("-", 2)
+ start = int(start.strip())
+ end = int(end.strip())
+ peptide_lengths = list(range(start, end + 1))
+ else:
+ peptide_lengths = [
+ int(length.strip())
+ for length in value.split(",")
+ ]
+ except ValueError:
+ raise ValueError("Couldn't parse peptide lengths: ", value)
+ return peptide_lengths
+
+
def run(argv=sys.argv[1:]):
logging.getLogger('tensorflow').disabled = True
@@ -217,6 +234,8 @@ def run(argv=sys.argv[1:]):
if args.output_delimiter == "\\t":
args.output_delimiter = "\t"
+ peptide_lengths = parse_peptide_lengths(args.peptide_lengths)
+
result_args = {
"all": args.results_all,
"best": args.results_best,
@@ -324,7 +343,7 @@ def run(argv=sys.argv[1:]):
result=result,
comparison_quantity=result_comparison_quantity,
filter_value=result_filter_value,
- peptide_lengths=args.peptide_lengths,
+ peptide_lengths=peptide_lengths,
use_flanks=not args.no_flanking,
include_affinity_percentile=not args.no_affinity_percentile,
throw=not args.no_throw)
