-
Notifications
You must be signed in to change notification settings - Fork 7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Assembly.download module and Events.dump logging updated #203
Changes from 5 commits
ce9be8c
e9396b1
96de600
28db808
1d8de79
686815e
c6030f6
27f52a1
4fb1f2c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -239,13 +239,6 @@ def retrieve_assembly_data( | |||||||||||||||||||||||||||||||||||||||||||||||||||
download_path = Path(download_dir) | ||||||||||||||||||||||||||||||||||||||||||||||||||||
download_dir = download_path / accession | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||
# Configure logging | ||||||||||||||||||||||||||||||||||||||||||||||||||||
log_file = f"{accession}_download.log" | ||||||||||||||||||||||||||||||||||||||||||||||||||||
reload(logging) | ||||||||||||||||||||||||||||||||||||||||||||||||||||
logging.basicConfig( | ||||||||||||||||||||||||||||||||||||||||||||||||||||
filename=log_file, format="%(levelname)s:%(message)s", filemode="w", level=logging.DEBUG | ||||||||||||||||||||||||||||||||||||||||||||||||||||
) | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||
# Set and create dedicated dir for download | ||||||||||||||||||||||||||||||||||||||||||||||||||||
if not download_dir.is_dir(): | ||||||||||||||||||||||||||||||||||||||||||||||||||||
download_dir.mkdir(parents=True) | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
@@ -277,10 +270,35 @@ def retrieve_assembly_data( | |||||||||||||||||||||||||||||||||||||||||||||||||||
def main() -> None: | ||||||||||||||||||||||||||||||||||||||||||||||||||||
"""Module's entry-point.""" | ||||||||||||||||||||||||||||||||||||||||||||||||||||
parser = ArgumentParser(description="Download an assembly data files from INSDC or RefSeq.") | ||||||||||||||||||||||||||||||||||||||||||||||||||||
parser.add_argument("-v", "--verbose", action="store_true", required=False, | ||||||||||||||||||||||||||||||||||||||||||||||||||||
help="Verbose level logging") | ||||||||||||||||||||||||||||||||||||||||||||||||||||
parser.add_argument("-d", "--debug", action="store_true", required=False, | ||||||||||||||||||||||||||||||||||||||||||||||||||||
help="Debug level logging") | ||||||||||||||||||||||||||||||||||||||||||||||||||||
parser.add_argument("--accession", required=True, help="Genome assembly accession") | ||||||||||||||||||||||||||||||||||||||||||||||||||||
parser.add_argument_dst_path( | ||||||||||||||||||||||||||||||||||||||||||||||||||||
"--download_dir", default=Path.cwd(), help="Folder where the data will be downloaded" | ||||||||||||||||||||||||||||||||||||||||||||||||||||
) | ||||||||||||||||||||||||||||||||||||||||||||||||||||
args = parser.parse_args() | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||
retrieve_assembly_data(**vars(args)) | ||||||||||||||||||||||||||||||||||||||||||||||||||||
# Configure logging | ||||||||||||||||||||||||||||||||||||||||||||||||||||
log_file = ("assembly_download.log") | ||||||||||||||||||||||||||||||||||||||||||||||||||||
JAlvarezJarreta marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||||||||||||||||||||||||||||||||||||||||||||
date_format='%m/%d/%Y_%I:%M:%S(%p)' | ||||||||||||||||||||||||||||||||||||||||||||||||||||
JAlvarezJarreta marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||||||||||||||||||||||||||||||||||||||||||||
logging_format='%(asctime)s - %(levelname)s - %(message)s' | ||||||||||||||||||||||||||||||||||||||||||||||||||||
reload(logging) | ||||||||||||||||||||||||||||||||||||||||||||||||||||
if args.verbose: | ||||||||||||||||||||||||||||||||||||||||||||||||||||
logging.basicConfig( | ||||||||||||||||||||||||||||||||||||||||||||||||||||
filename=log_file, format=logging_format, datefmt=date_format, | ||||||||||||||||||||||||||||||||||||||||||||||||||||
filemode="w", level=logging.INFO | ||||||||||||||||||||||||||||||||||||||||||||||||||||
) | ||||||||||||||||||||||||||||||||||||||||||||||||||||
elif args.debug: | ||||||||||||||||||||||||||||||||||||||||||||||||||||
logging.basicConfig( | ||||||||||||||||||||||||||||||||||||||||||||||||||||
filename=log_file, format=logging_format, datefmt=date_format, | ||||||||||||||||||||||||||||||||||||||||||||||||||||
filemode="w", level=logging.DEBUG | ||||||||||||||||||||||||||||||||||||||||||||||||||||
) | ||||||||||||||||||||||||||||||||||||||||||||||||||||
else: | ||||||||||||||||||||||||||||||||||||||||||||||||||||
logging.basicConfig( | ||||||||||||||||||||||||||||||||||||||||||||||||||||
filename=log_file, format=logging_format, datefmt=date_format, | ||||||||||||||||||||||||||||||||||||||||||||||||||||
filemode="w", level=logging.WARNING | ||||||||||||||||||||||||||||||||||||||||||||||||||||
) | ||||||||||||||||||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We can factorize this further with something like:
Suggested change
Note that I've put debug before verbose: assuming we get the 2 params, I suppose debug should take priority. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. done There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is actually better handled by the |
||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||
retrieve_assembly_data(args.accession, args.download_dir) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we should place these after the mandatory arguments ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure I can do, only reason I put them there was I thought it was needed given they are optional flag not positional args
"The add_argument() method must know whether an optional argument, like -f or --foo, or a positional argument, like a list of filenames, is expected. The first arguments passed to add_argument() must therefore be either a series of flags, or a simple argument name."
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe that sentence refers to the first arguments passed to the function
add_argument()
, i.e.add_argument("-f", "--foo", ...)
, and not to the parser.