Skip to content

Commit 8dc6f0e

Browse files
committed
Add log file and log level options, optimize code for speed, and update Julia version
1 parent 3388b87 commit 8dc6f0e

File tree

6 files changed

+54
-12
lines changed

6 files changed

+54
-12
lines changed

CHANGELOG.md

+2
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44

55
* FEATURE - Adding --no_output_header option to not print the header line in output. Useful for when you want to pipe this output to another tool.
66
* FEATURE - Adding --exclude_regions option to exclude any regions found in a passed-in BED file.
7+
* FEATURE - Adding --log_file and --log_level options to display or hide log messages of varying severity. Note that currently --log_level=DEBUG will print the line number, as I haven't figured out how to disable that for debug-level messages yet.
8+
* Optimized some pieces of code for speed (thanks Github Copilot). This should increase the speed where a GFF feature has 100,000s of overlaps with the BAM alignments
79

810
## v1.8.3
911

Dockerfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Wanted to do the alpine version but that tag does not support arm64 (Mac M1) architecture
2-
FROM julia:1.9
2+
FROM julia:1.7
33
LABEL maintainer="Shaun Adkins ([email protected])"
44

55
RUN mkdir -p /opt/FADU

README.md

+8-2
Original file line numberDiff line numberDiff line change
@@ -17,17 +17,18 @@ Most current available quantification tools for transcriptomics analyses have be
1717

1818
## Current FADU release
1919

20-
v1.8.3
20+
v1.9
2121

2222
## Requirements
2323

24-
Julia - v1.4.2 or later
24+
Julia - v1.7 or later
2525

2626
### Packages
2727

2828
NOTE: Packages installation instructions can be found at https://docs.julialang.org/en/v1.4/stdlib/Pkg/index.html#Getting-Started-1
2929

3030
* ArgParse
31+
* Logging
3132
* BGZFStreams.jl - v0.3.0
3233
* GenomicFeatures.jl - v2.0.0
3334
* GFF3 - v0.2.0
@@ -165,6 +166,11 @@ optional arguments:
165166
on multimapped read depth. Only applies if
166167
--remove_multimapped flag is not passed (is
167168
disabled) (type: Int64, default: 1)
169+
--log_level LEVEL Set the log level. Options are: DEBUG, INFO,
170+
WARNING, ERROR, CRITICAL. (default: "INFO")
171+
--log_file /path/to/logfile.log
172+
Path to log file. If not specified, log
173+
messages will be printed to STDERR.
168174
--version show version information and exit
169175
-h, --help show this help message and exit
170176
```

docs/index.md

+8-2
Original file line numberDiff line numberDiff line change
@@ -17,17 +17,18 @@ Most current available quantification tools for transcriptomics analyses have be
1717

1818
## Current FADU release
1919

20-
v1.8.3
20+
v1.9
2121

2222
## Requirements
2323

24-
Julia - v1.4.2 or later
24+
Julia - v1.7 or later
2525

2626
### Packages
2727

2828
NOTE: Packages installation instructions can be found at https://docs.julialang.org/en/v1.4/stdlib/Pkg/index.html#Getting-Started-1
2929

3030
* ArgParse
31+
* Logging
3132
* BGZFStreams.jl - v0.3.0
3233
* GenomicFeatures.jl - v2.0.0
3334
* GFF3 - v0.2.0
@@ -166,6 +167,11 @@ optional arguments:
166167
on multimapped read depth. Only applies if
167168
--remove_multimapped flag is not passed (is
168169
disabled) (type: Int64, default: 1)
170+
--log_level LEVEL Set the log level. Options are: DEBUG, INFO,
171+
WARNING, ERROR, CRITICAL. (default: "INFO")
172+
--log_file /path/to/logfile.log
173+
Path to log file. If not specified, log
174+
messages will be printed to STDERR.
169175
--version show version information and exit
170176
-h, --help show this help message and exit
171177
```

fadu.jl

+33-5
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ By: Shaun Adkins ([email protected])
2222

2323
# The macro on modules and functions makes the code available to all worker processes
2424
using ArgParse
25+
using Logging
2526
using XAM: BAM, SAM
2627
using GenomicFeatures
2728
using GFF3
@@ -150,27 +151,54 @@ function parse_commandline()
150151
arg_type = Int
151152
range_tester = (x->x>0)
152153
dest_name = "em_iter"
154+
"--log_level"
155+
help = "Set the log level. Options are: DEBUG, INFO, WARNING, ERROR, CRITICAL."
156+
default = "INFO"
157+
metavar = "LEVEL"
158+
range_tester = (x->x in ["DEBUG", "INFO", "WARNING", "ERROR"])
159+
"--log_file"
160+
help = "Path to log file. If not specified, log messages will be printed to STDERR."
161+
metavar = "/path/to/logfile.log"
153162

154163
# Will not add log_file or debug options for now
155164
end
156165
# Converts the ArgParseSettings object into key/value pairs
157166
return parse_args(s)
158167
end
159168

169+
function setup_logger(args)
170+
"""Set up logging."""
171+
stream = args["log_file"] === nothing ? stderr : open(args["log_file"], "w")
172+
logleveldict = Dict("DEBUG" => -1000, "INFO" => 0, "WARNING" => 1000, "ERROR" => 2000)
173+
loglevel = get(logleveldict, uppercase(args["log_level"]), 0)
174+
logger = ConsoleLogger(stream, loglevel)
175+
global_logger(logger)
176+
# TODO: prevent debug messages from printing the file and line number
177+
178+
end
179+
160180
function validate_args(args)
161181
"""Validate the passed arguments."""
162-
isfile(args["gff3_file"]) || throw(SystemError("GFF3 file does not seem to exist. Please check supplied path."))
163-
isfile(args["bam_file"]) || throw(SystemError("BAM file does not seem to exist. Please check supplied path."))
182+
@info("Validating arguments...")
183+
isfile(args["bam_file"]) || error("BAM file does not exist. Please check supplied path")
184+
isfile(args["gff3_file"]) || error("GFF3 file does not exist. Please check supplied path")
164185
if !isdir(args["output_dir"])
165-
@debug("Creating output directory")
186+
@info("Creating output directory at ", args["output_dir"])
166187
mkdir(args["output_dir"])
167188
end
168-
args["stranded"] in ["yes", "no", "reverse"] || error("--stranded argument must be either 'yes', 'no', or 'reverse'.")
169189
end
170190

171191
function main()
172192
args = parse_commandline()
173-
#validate_args(args)
193+
setup_logger(args)
194+
195+
try
196+
validate_args(args)
197+
catch e
198+
@error(e)
199+
exit(1)
200+
end
201+
174202
@info("Parsed args:")
175203
for (arg,val) in args
176204
@info(" $arg => $val")

fadu_pkgs/Project.toml

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ BGZFStreams = "28d598bf-9b8f-59f1-b38c-5a06b4a0f5e6"
1010
GFF3 = "af1dc308-cb6b-11e8-32f0-31192efa90f6"
1111
GenomicFeatures = "899a7d2d-5c61-547b-bef9-6698a8d05446"
1212
Indexes = "4ffb77ac-cb80-11e8-1b35-4b78cc642f6d"
13-
Pkg = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f"
13+
Logging = "56ddb016-857b-54e1-b83d-db4d58db5568"
1414
StructArrays = "09ab397b-f2b6-538f-b94a-2f83cf4a842a"
1515
XAM = "d759349c-bcba-11e9-07c2-5b90f8f05f7c"
1616

@@ -22,4 +22,4 @@ GenomicFeatures = "2.0.0"
2222
Indexes = "0.1.1"
2323
StructArrays = "0.4.4"
2424
XAM = "0.2.6"
25-
julia = "1.4.2"
25+
julia = "1.7"

0 commit comments

Comments
 (0)