Skip to content

Commit

Permalink
Minor bug fixes; Improve debug loggin
Browse files Browse the repository at this point in the history
  • Loading branch information
BBQuercus committed Jun 29, 2022
1 parent 9423d7c commit 2e42659
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 6 deletions.
5 changes: 3 additions & 2 deletions eFISHent/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,9 +146,10 @@ def create_custom_config(args: argparse.Namespace, config_file: str) -> None:

def set_logging_level(verbose: bool, debug: bool) -> logging.Logger:
"""Set the logging level of luigi and custom logger."""
LOG_FORMAT = "%(asctime)s %(levelname)-4s [%(name)s] %(message)s"
log_format = "%(asctime)s %(levelname)-4s %(message)s"

if debug:
log_format = "%(asctime)s %(levelname)-4s [%(name)s] %(filename)s %(funcName)s %(lineno)d / %(thread)d - %(message)s"
luigi_level = "DEBUG"
custom_level = logging.DEBUG
logfile = "eFISHent.log"
Expand All @@ -161,7 +162,7 @@ def set_logging_level(verbose: bool, debug: bool) -> logging.Logger:
custom_level = logging.WARNING
logfile = None

logging.basicConfig(filename=logfile,format=LOG_FORMAT, force=True)
logging.basicConfig(filename=logfile,format=log_format, force=True)
logging.getLogger("luigi").setLevel(luigi_level)
logging.getLogger("luigi-interface").setLevel(luigi_level)
luigi.interface.core.log_level = luigi_level
Expand Down
2 changes: 1 addition & 1 deletion eFISHent/prepare_sequence.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ class BuildBlastDatabase(luigi.Task):
def output(self):
return [
luigi.LocalTarget(f"{util.get_genome_name()}.{extension}")
for extension in ["ndb", "nhr", "nin", "not", "nsq", "ntf", "nto"]
for extension in ["nhr", "nin", "nsq"]
]

def run(self):
Expand Down
2 changes: 1 addition & 1 deletion eFISHent/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def get_gene_name(hashed: bool = True, config: luigi.Config = SequenceConfig) ->
"""Return the gene name without extension."""
# Name based on gene fasta file
sequence_file = config().sequence_file
if sequence_file is not None and os.path.isfile(sequence_file):
if sequence_file and os.path.isfile(sequence_file):
basename = secure_filename(os.path.splitext(os.path.basename(sequence_file))[0])
# Using Ensembl ID
elif config().ensembl_id:
Expand Down
9 changes: 7 additions & 2 deletions tests/test_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,10 @@ def test_gene_name():

# Gene file
class Config(luigi.Config):
sequence_file = luigi.Parameter("./tests/renilla.fa")
sequence_file = luigi.Parameter("./tests/renilla.fasta")
ensembl_id = luigi.Parameter("")
gene_name = luigi.Parameter("")
organism_name = luigi.Parameter("")

assert get_gene_name(config=Config).startswith("renilla")
assert get_gene_name(hashed=False, config=Config) == "renilla"
Expand All @@ -68,6 +71,8 @@ class Config(luigi.Config):
class Config(luigi.Config):
sequence_file = luigi.Parameter("")
ensembl_id = luigi.Parameter("ENSG00000026025")
gene_name = luigi.Parameter("")
organism_name = luigi.Parameter("")

assert get_gene_name(config=Config).startswith("ENSG00000026025")

Expand All @@ -82,7 +87,7 @@ class Config(luigi.Config):

# Gene file > NCBI
class Config(luigi.Config):
sequence_file = luigi.Parameter("./tests/renilla.fa")
sequence_file = luigi.Parameter("./tests/renilla.fasta")
ensembl_id = luigi.Parameter("")
gene_name = luigi.Parameter("ACOOLGene123")
organism_name = luigi.Parameter("Latin name")
Expand Down

0 comments on commit 2e42659

Please sign in to comment.