biopython icon indicating copy to clipboard operation
biopython copied to clipboard

Update argument handling in PDBList.py, possibly by creating a new module.

Open JoaoRodrigues opened this issue 3 years ago • 3 comments

The command-line interface for the PDBList.py module is quite clunky, using a series of complicated ifs and sys.argv calls to parse input from the user. It would be super nicer to simply use argparse, although this will break compatibility with previous versions.

The solution here might pass through copying the code to a new module and along with other issues (#3988, #3987) upgrade PDBList.py and break backwards compability. We could then slap a deprecation warning on PDBList to warn users to move to the new code.

JoaoRodrigues avatar Jul 18 '22 03:07 JoaoRodrigues

Can you please assign me this issue

RUCHI21CODES avatar Oct 24 '22 03:10 RUCHI21CODES

@RUCHI21CODES No, there are already people working on this with open pull requests. If you can spot improvements or otherwise usefully comment on those PRs, that could be helpful.

peterjc avatar Oct 25 '22 10:10 peterjc

pdblist_args.py

import argparse

def parse_args(): parser = argparse.ArgumentParser(description='PDB List arguments') parser.add_argument('-i', '--input_file', help='Input file path', required=True) parser.add_argument('-o', '--output_file', help='Output file path', required=True) parser.add_argument('-v', '--verbose', help='Verbose mode', action='store_true') return parser.parse_args()

PDBList.py

import pdblist_args

def main(): args = pdblist_args.parse_args() # Use the parsed arguments here print(f'Input file: {args.input_file}') print(f'Output file: {args.output_file}') if args.verbose: print('Verbose mode enabled')

if name == 'main': main()

@JoaoRodrigues I have made a contribution you can see it if u want

onhgomat avatar Oct 07 '24 04:10 onhgomat