Skip to content

Commit

Permalink
Merge pull request #61 from guoci/fix_argument_parsing
Browse files Browse the repository at this point in the history
[FIX] argument parsing
  • Loading branch information
grosenberger authored Jun 22, 2021
2 parents 9d44654 + c1c247b commit b57b979
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
6 changes: 4 additions & 2 deletions easypqp/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,11 @@ def cli():
# https://stackoverflow.com/a/47730333
class PythonLiteralOption(click.Option):
def type_cast_value(self, ctx, value):
if not isinstance(value, str): # required for Click>=8.0.0
return value
try:
return ast.literal_eval(value)
except:
except Exception:
raise click.BadParameter(value)


Expand All @@ -44,7 +46,7 @@ def type_cast_value(self, ctx, value):
@click.option('--enable_unannotated/--no-enable_unannotated', default=False, show_default=True, help='Enable mapping uf unannotated delta masses.')
@click.option('--enable_massdiff/--no-enable_massdiff', default=False, show_default=True, help='Enable mapping uf mass differences reported by legacy search engines.')
@click.option('--fragment_types', default="['b','y']", show_default=True, cls=PythonLiteralOption, help='Allowed fragment ion types (a,b,c,x,y,z).')
@click.option('--fragment_charges', default="[1,2,3,4]", show_default=True, cls=PythonLiteralOption, help='Allowed fragment ion charges.')
@click.option('--fragment_charges', default='[1,2,3,4]', show_default=True, cls=PythonLiteralOption, help='Allowed fragment ion charges.')
@click.option('--enable_specific_losses/--no-enable_specific_losses', default=False, show_default=True, help='Enable specific fragment ion losses.')
@click.option('--enable_unspecific_losses/--no-enable_unspecific_losses', default=False, show_default=True, help='Enable unspecific fragment ion losses.')
@click.option('--subsample_fraction', default=1.0, show_default=True, type=float, help='Data fraction used for subsampling.')
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
],
packages=find_packages(exclude=['contrib', 'docs', 'tests']),
include_package_data=True,
install_requires=['Click','numpy','scipy','scikit-learn','statsmodels','pandas>=1.1.0','biopython','pyopenms>=2.6.0','matplotlib','seaborn'],
install_requires=['Click>=8.0.0','numpy','scipy','scikit-learn','statsmodels','pandas>=1.1.0','biopython','pyopenms>=2.6.0','matplotlib','seaborn'],
# extras_require={ # Optional
# 'dev': ['check-manifest'],
# 'test': ['coverage'],
Expand Down

0 comments on commit b57b979

Please sign in to comment.