Giter Club home page Giter Club logo

Comments (9)

Hego-CCTB avatar Hego-CCTB commented on September 27, 2024 1

Scratch that, the problem was somewhere else!

from amalgkit.

Hego-CCTB avatar Hego-CCTB commented on September 27, 2024 1

Pushed the update here:

23a02c8

closing this for now, then.

from amalgkit.

kfuku52 avatar kfuku52 commented on September 27, 2024

yes/no options can be stored as bool using strtobool. Please check csubst for example.

from amalgkit.

kfuku52 avatar kfuku52 commented on September 27, 2024

I introduced strtobool for --tissue_detect as an example. Please check and apply it for other options.
f85b762

from amalgkit.

Hego-CCTB avatar Hego-CCTB commented on September 27, 2024

Just to add to this, I think we can simplify usage as well for arguments that use 'yes|no'. For example amalgkit getfastq --redo yes can be reduced to just amalgkit getfastq --redo, while amalgkit getfastq --redo no would just be amalgkit getfastq without the option.

from amalgkit.

kfuku52 avatar kfuku52 commented on September 27, 2024

I'm not positive about that. Here's how I often end up...

  1. Didn't work: my_progrem -i infile --hard-to-remember-flag
  2. Didn't work either: my_progrem -i infile
  3. Found another flag is important: my_progrem -i infile --another-flag
  4. Went program website to remember what was the flag I tried first
  5. Worked well: my_progrem -i infile --another-flag --hard-to-remember-flag

If it's like --hard-to-remember-flag yes, we don't have to open a webpage or print a very long help message every time we tweak the parameters.

from amalgkit.

Hego-CCTB avatar Hego-CCTB commented on September 27, 2024

So I don't 100% get how strtobool interacts with argparse. I assumed it would convert argument input yes to True and input no to False. So a flag --flag1 would be False if the default was no and there wasn't any additional input.

Assuming --flag1 no, in the code I could then ask:

     if args.flag1:
          print("true!")
     else:
          print("false!")

instead of

if args.flag1 == 'yes':
           ...

correct?

I switched the getfastq download flags to strtobool like this:

     pge.add_argument('--aws', metavar='yes|no', default='no', type=strtobool, required=False, action='store',
                 help='default=%(default)s: Download SRA files from Amazon Cloud (AWS), if available.')

But when getting args.aws inside getfastq, they are still stored as 'yes' and 'no`, rather than 'true' or 'false'.
This is actually not true, they were stored as 1 or 0.

from amalgkit.

Hego-CCTB avatar Hego-CCTB commented on September 27, 2024

I went through all of amalgkit to convert everything to strtobool where there are yes|no options.
I also introduced parent parsers to eliminate repeated code.

I couldn't figure out a way to do this with a single parent parser holding all the shared options. For example:
--out_dir is by every subcommand.
--metadata is used by most subcommands.
But putting both --out_dir and --metadata in the same parent parser, both options would show up for example for amalgkit metadata -h, which does have --out_dir but does not have --metadata.

So I put those options into different parent parsers parent_parser_out and parent_parser_meta. These can then be combined in any way for the specific subparsers, like so:

# Sub parser: integrate
pin = subparsers.add_parser('integrate', help='see `amalgkit proc -h`', parents=[parent_parser_out, parent_parser_meta, parent_parser_threads])

[...] subparser specific arguments


# Sub parser: sanity
psa = subparsers.add_parser('sanity', help='see `amalgkit sanity -h`', parents=[parent_parser_out, parent_parser_meta])

[...] subparser specific arguments


# Sub parser: curate
pcu = subparsers.add_parser('curate', help='see `amalgkit curate -h`', parents=[parent_parser_out, parent_parser_meta, parent_parser_batch])

[...] subparser specific arguments

from amalgkit.

kfuku52 avatar kfuku52 commented on September 27, 2024

Sounds good!

from amalgkit.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.