Repository navigation
Expand file tree
/
Copy pathSnakefile
More file actions
75 lines (54 loc) · 2.28 KB
/
Copy pathSnakefile
File metadata and controls
75 lines (54 loc) · 2.28 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
# -*- coding: utf-8
import os
import json
import os.path
import argparse
import numpy as np
import pandas as pd
import anvio
import anvio.db as db
import anvio.utils as u
import anvio.tables as t
import anvio.workflows as w
from Bio import SeqIO
from anvio.errors import ConfigError
from anvio.dbops import ContigsDatabase
from anvio.workflows.ecophylo import EcoPhyloWorkflow
__copyright__ = "Copyleft 2015-2025, The Anvi'o Project (http://anvio.org/)"
__credits__ = ["mschecht", "FlorianTrigodet"]
__license__ = "GPL 3.0"
__version__ = anvio.__version__
__maintainer__ = "Matthew S. Schechter"
__email__ = "mschechter@uchicago.edu"
M = EcoPhyloWorkflow(argparse.Namespace(config=config))
M.init()
dirs_dict = M.dirs_dict
def rule_log(rule_name, log_file_name="log"):
"""Return a canonical workflow log path under 00_LOGS/<rule_name>/."""
if not log_file_name.endswith(".log"):
log_file_name = f"{log_file_name}.log"
log_path = os.path.join(dirs_dict["LOGS_DIR"], rule_name, log_file_name)
# Ensure the per-rule log subdirectory exists. This is essential for cluster
# submission (e.g. via clusterize), where the submit command opens the log file
# at submission time and fails if its parent directory does not already exist.
# Doing it here guarantees the directory exists for *every* rule that declares a
# log, regardless of whether the rule is registered in `self.rules`.
os.makedirs(os.path.dirname(log_path), exist_ok=True)
return log_path
rule ECOPHYLO_WORKFLOW_target_rule:
"""The rule creates all target files for the Snakefile"""
input:
targets=M.target_files,
# Workflow rule modules. Keep this order to preserve existing rule dependencies.
include: w.get_workflow_rule_file_path("ecophylo", "hmm_processing.smk")
include: w.get_workflow_rule_file_path("ecophylo", "sequence_data.smk")
include: w.get_workflow_rule_file_path("ecophylo", "clustering_alignment.smk")
include: w.get_workflow_rule_file_path("ecophylo", "profile_inputs.smk")
include: w.get_workflow_rule_file_path("ecophylo", "tree_building.smk")
include: w.get_workflow_rule_file_path("ecophylo", "misc_taxonomy.smk")
if M.samples_txt_file:
# PROFILE-MODE with read recruitment
include: "rules/profile_mode.smk"
else:
# TREE-MODE
include: "rules/tree_mode.smk"