Skip to content

Commit

Permalink
Add log files for all modules.
Browse files Browse the repository at this point in the history
  • Loading branch information
ABignaud committed Nov 27, 2023
1 parent 021906b commit 3956deb
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions metator/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -1259,6 +1259,11 @@ class Contactmap(AbstractCommand):

def execute(self):

# Enable file logging
now = time.strftime("%Y%m%d%H%M%S")
log_file = join(self.args["--outdir"], (f"metator_contactmap_{now}.log"))
generate_log_header(log_file, cmd="contactmap", args=self.args)

# Defined the temporary directory.
if not self.args["--tmpdir"]:
self.args["--tmpdir"] = "./tmp"
Expand Down Expand Up @@ -1294,6 +1299,7 @@ def execute(self):
# Delete pyfastx index:
os.remove(self.args["--assembly"] + ".fxi")

generate_log_footer(log_file)

class Scaffold(AbstractCommand):
"""Scaffold a bin from metator.
Expand Down Expand Up @@ -1330,6 +1336,7 @@ class Scaffold(AbstractCommand):
"""

def execute(self):

# Generate log
now = time.strftime("%Y%m%d%H%M%S")
log_file = f"metator_scaffold_{now}.log"
Expand Down Expand Up @@ -1381,10 +1388,12 @@ class Pairs(AbstractCommand):
"""

def execute(self):

# Generate log
now = time.strftime("%Y%m%d%H%M%S")
log_file = f"metator_pairs_{now}.log"
generate_log_header(log_file, cmd="pairs", args=self.args)

# Iterates on pairfiles given.
pairsfiles = self.args["<pairsfile>"]
for pairsfile in pairsfiles:
Expand All @@ -1396,6 +1405,7 @@ def execute(self):
remove=self.args["--remove"],
force=self.args["--force"],
)

generate_log_footer(log_file)


Expand All @@ -1422,6 +1432,12 @@ class Host(AbstractCommand):
"""

def execute(self):

# Generate log
now = time.strftime("%Y%m%d%H%M%S")
log_file = f"metator_host_{now}.log"
generate_log_header(log_file, cmd="host", args=self.args)

# Defined the output file if none are given
if not self.args["--outfile"]:
self.args["--outfile"] = "./mges_data_host.tsv"
Expand All @@ -1444,6 +1460,7 @@ def execute(self):
self.args["--threshold"],
)

generate_log_footer(log_file)



Expand Down Expand Up @@ -1501,6 +1518,12 @@ class Mge(AbstractCommand):
"""

def execute(self):

# Generate log
now = time.strftime("%Y%m%d%H%M%S")
log_file = f"metator_mge_{now}.log"
generate_log_header(log_file, cmd="mge", args=self.args)

# Defined the temporary directory.
if not self.args["--tmpdir"]:
self.args["--tmpdir"] = "./tmp"
Expand Down Expand Up @@ -1562,6 +1585,7 @@ def execute(self):
# Delete pyfastx index:
os.remove(self.args["--fasta"] + ".fxi")

generate_log_footer(log_file)

def generate_log_header(log_path, cmd, args):
mtl.set_file_handler(log_path, formatter=logging.Formatter(""))
Expand Down

0 comments on commit 3956deb

Please sign in to comment.