diff iedb_api.py @ 3:e95d3221b7f0 draft

"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 863578373c7dadc5880633115b0c348f73dac782"
author iuc
date Fri, 11 Sep 2020 21:02:34 +0000
parents 6cf84410cb2e
children 7ed6dda64a81
line wrap: on
line diff
--- a/iedb_api.py	Wed Jul 29 17:29:56 2020 -0400
+++ b/iedb_api.py	Fri Sep 11 21:02:34 2020 +0000
@@ -35,7 +35,7 @@
                       'bcell': range(8, 16)}
 
 
-def parse_alleles(allelefile, lengths):
+def parse_alleles(allelefile, query_lengths):
     alleles = []
     lengths = []
     with open(allelefile, 'r') as fh:
@@ -47,8 +47,11 @@
                     for alen in fields[1:]:
                         alleles.append(allele)
                         lengths.append(alen)
-                elif lengths:
-                    for alen in str(lengths).split(','):
+                elif query_lengths:
+                    lens = []
+                    for ql in query_lengths:
+                        lens.extend(str(ql).split(','))
+                    for alen in lens:
                         alleles.append(allele)
                         lengths.append(alen)
                 else:
@@ -157,8 +160,7 @@
     parser.add_argument('-l', '--length',
                         action="append",
                         default=[],
-                        help='lengths for which to make predictions, '
-                             '1 per allele')
+                        help='lengths for which to make predictions for alleles')
     parser.add_argument('-w', '--window_size',
                         type=int,
                         default=None,
@@ -166,7 +168,7 @@
     parser.add_argument('-i', '--input',
                         default=None,
                         help='Input file for peptide sequences '
-                             '(fasta or tabular)')
+                             + '(fasta or tabular)')
     parser.add_argument('-c', '--column',
                         default=None,
                         help='Peptide Column in a tabular input file')
@@ -205,7 +207,7 @@
 
     if not (args.sequence or args.input):
         warn_err('NO Sequences given: '
-                 'either -s sequence or -i input_file is required\n',
+                 + 'either -s sequence or -i input_file is required\n',
                  exit_code=1)
 
     if args.output is not None:
@@ -228,7 +230,8 @@
         if args.allele:
             for i, allele in enumerate(args.allele):
                 alleles.append(allele)
-                alen = args.length[i] if i < len(args.length) else args.length[-1]
+                alen = args.length[i] if i < len(args.length)\
+                    else args.length[-1]
                 lengths.append(alen)
     allele = ','.join(alleles) if alleles else None
     length = ','.join(lengths) if lengths else None
@@ -238,7 +241,8 @@
         args.prediction
 
     # results
-    results = {'prediction': {'header': None, 'entries': []}, 'detail': {'header': None, 'entries': []}}
+    results = {'prediction': {'header': None, 'entries': []},
+               'detail': {'header': None, 'entries': []}}
 
     if args.sequence:
         for i, seq in enumerate(args.sequence):