77# ###############################################################################
88#
99# PURPOSE:
10- # Resolve ONE sequence-group set (orthogroups, annogroups, gene families, ...)
11- # onto the species-tree clades: standard membership (001), deconvolution (002),
12- # per-species sequence map (003), composite clades (004).
10+ # Resolve MANY sequence-group sets (orthogroups, annogroups pfam/go/panther,
11+ # gene families, gene groups, ...) onto the species-tree clades in ONE run:
12+ # 001 standard membership, 002 deconvolution (4-structure scope), 003 per-species map,
13+ # 006 annotation index (once), 004 composite clades (242 detail tables w/ annotations).
1314#
1415# USAGE: bash RUN-workflow.sh
1516#
1617# BEFORE RUNNING, edit START_HERE-user_config.yaml:
17- # - group_set_label (e.g. "species70_X_OrthoHMM" )
18- # - species_set_name, producer (e.g. "orthogroups" )
19- # - inputs.producer_membership / clade_species_mappings / composite_clades_manifest
20- # - composite_clades block (building-block clade groups)
18+ # - producers: (membership paths + optional group_attributes per producer )
19+ # - deconvolution_structures (default 001/003/031/032; [] = all 105 )
20+ # - annotation_index (paths for Script 006; required for annotated detail tables)
21+ # - inputs.clade_species_mappings / composite_clades_manifest
2122# - execution_mode ("local" or "slurm"); for slurm set slurm_account / slurm_qos
2223#
2324# OUTPUT:
@@ -41,9 +42,9 @@ read_config() {
4142}
4243
4344EXECUTION_MODE=$( read_config " execution_mode" " local" )
44- GROUP_SET_LABEL=$( read_config " group_set_label" " " )
45- PRODUCER=$( read_config " producer" " " )
4645SPECIES_SET=$( read_config " species_set_name" " " )
46+ # Multi-producer: ONE run resolves every entry under `producers:` in the config.
47+ PRODUCER_COUNT=$( grep -c ' ^[[:space:]]*- producer:' START_HERE-user_config.yaml)
4748
4849# Workflow directory name (used below to build output_to_input symlink targets).
4950WORKFLOW_DIR_NAME=" $( basename " ${SCRIPT_DIR} " ) "
@@ -88,7 +89,7 @@ echo ""
8889
8990# ---- validate prerequisites ------------------------------------------------
9091[ -f " START_HERE-user_config.yaml" ] || { echo " ERROR: START_HERE-user_config.yaml not found" ; exit 1; }
91- echo " Configuration: group_set= ${GROUP_SET_LABEL } producer= ${PRODUCER} species_set=${SPECIES_SET} "
92+ echo " Configuration: ${PRODUCER_COUNT } producer(s) species_set=${SPECIES_SET} "
9293echo " "
9394
9495# ---- run NextFlow ----------------------------------------------------------
@@ -103,53 +104,64 @@ if [ $EXIT_CODE -ne 0 ]; then
103104 exit $EXIT_CODE
104105fi
105106
106- # ---- output_to_input symlinks ---------------------------------------------
107- # Real files in OUTPUT_pipeline/{2,3,4}-output/; symlinks under
108- # ../../output_to_input/<group_set_label>/ for downstream consumers.
107+ # ---- output_to_input symlinks (per producer) ------------------------------
108+ # Real files live under <subproject>/<block>/<workflow>/OUTPUT_pipeline/<label>/{2,3,4}-output/;
109+ # downstream consumers read symlinks under the SUBPROJECT-root output_to_input/
110+ # in a per-producer namespace: output_to_input/<producer>/<group_set_label>/ so the
111+ # many group sets stay navigable (annogroups/, orthogroups/, gene_families/, gene_groups/).
109112echo " "
110- echo " Creating output_to_input symlinks for ${GROUP_SET_LABEL} ..."
111- # output_to_input lives at the SUBPROJECT root; real files live under
112- # <subproject>/<block>/<workflow>/OUTPUT_pipeline/. So a symlink at
113- # output_to_input/<label>/ reaches them via ../../<block>/<workflow>/...
113+ echo " Creating output_to_input symlinks for ${PRODUCER_COUNT} producer(s)..."
114114BLOCK_DIR_NAME=" $( basename " $( dirname " ${SCRIPT_DIR} " ) " ) "
115- # Per-producer namespace: output_to_input/<producer>/<group_set_label>/ so the many
116- # group sets stay navigable (annogroups/, orthogroups/, gene_families/, gene_groups/).
117- SHARED_DIR=" ../../output_to_input/${PRODUCER} /${GROUP_SET_LABEL} "
118- # replace stale state for this group set (output_to_input holds only symlinks)
119- find " ${SHARED_DIR} " -mindepth 1 -maxdepth 1 -name ' *.tsv' -type l -delete 2> /dev/null
120- rm -rf " ${SHARED_DIR} /composite_clades_detail_tables" 2> /dev/null
121- mkdir -p " ${SHARED_DIR} "
122- SYMLINK_COUNT=0
123- link_outputs () {
124- # link every .tsv in OUTPUT_pipeline/$1 into SHARED_DIR (flat)
125- for f in OUTPUT_pipeline/$1 /* .tsv; do
126- [ -f " $f " ] || continue
127- ln -sf " ../../../${BLOCK_DIR_NAME} /${WORKFLOW_DIR_NAME} /$f " " ${SHARED_DIR} /$( basename " $f " ) "
128- SYMLINK_COUNT=$(( SYMLINK_COUNT+ 1 ))
129- done
130- }
131- link_outputs " 2-output" # deconvolution union tables
132- link_outputs " 3-output" # per-species map
133- link_outputs " 4-output" # composite per-group + summary
134- # composite detail tables (a subdir)
135- if [ -d " OUTPUT_pipeline/4-output/composite_clades_detail_tables" ]; then
136- mkdir -p " ${SHARED_DIR} /composite_clades_detail_tables"
137- for f in OUTPUT_pipeline/4-output/composite_clades_detail_tables/* .tsv; do
138- [ -f " $f " ] || continue
139- ln -sf " ../../../../${BLOCK_DIR_NAME} /${WORKFLOW_DIR_NAME} /$f " " ${SHARED_DIR} /composite_clades_detail_tables/$( basename " $f " ) "
140- SYMLINK_COUNT=$(( SYMLINK_COUNT+ 1 ))
141- done
115+
116+ # (producer, group_set_label) pairs, parsed from the config with the workflow's Python.
117+ PRODUCER_SPECS=" $( python3 -c "
118+ import yaml
119+ with open( 'START_HERE-user_config.yaml' ) as handle:
120+ config = yaml.safe_load( handle )
121+ for producer in config.get( 'producers', [] ):
122+ print( producer[ 'producer' ] + '\t' + producer[ 'group_set_label' ] )
123+ " ) "
124+ if [ -z " ${PRODUCER_SPECS} " ]; then
125+ echo " ERROR: could not parse any producers from START_HERE-user_config.yaml" ; exit 1
142126fi
143- echo " output_to_input/${GROUP_SET_LABEL} / -> ${SYMLINK_COUNT} symlinks"
127+
128+ while IFS=$' \t ' read -r PRODUCER GROUP_SET_LABEL; do
129+ [ -n " ${GROUP_SET_LABEL} " ] || continue
130+ OUT_LABEL_DIR=" OUTPUT_pipeline/${GROUP_SET_LABEL} "
131+ SHARED_DIR=" ../../output_to_input/${PRODUCER} /${GROUP_SET_LABEL} "
132+ # replace stale state for this group set (output_to_input holds only symlinks)
133+ find " ${SHARED_DIR} " -mindepth 1 -maxdepth 1 -name ' *.tsv' -type l -delete 2> /dev/null
134+ rm -rf " ${SHARED_DIR} /composite_clades_detail_tables" 2> /dev/null
135+ mkdir -p " ${SHARED_DIR} "
136+ SYMLINK_COUNT=0
137+ for sub in 2-output 3-output 4-output; do
138+ for f in " ${OUT_LABEL_DIR} /${sub} " /* .tsv; do
139+ [ -f " $f " ] || continue
140+ ln -sf " ../../../${BLOCK_DIR_NAME} /${WORKFLOW_DIR_NAME} /$f " " ${SHARED_DIR} /$( basename " $f " ) "
141+ SYMLINK_COUNT=$(( SYMLINK_COUNT+ 1 ))
142+ done
143+ done
144+ # composite detail tables (a subdir)
145+ if [ -d " ${OUT_LABEL_DIR} /4-output/composite_clades_detail_tables" ]; then
146+ mkdir -p " ${SHARED_DIR} /composite_clades_detail_tables"
147+ for f in " ${OUT_LABEL_DIR} /4-output/composite_clades_detail_tables" /* .tsv; do
148+ [ -f " $f " ] || continue
149+ ln -sf " ../../../../${BLOCK_DIR_NAME} /${WORKFLOW_DIR_NAME} /$f " " ${SHARED_DIR} /composite_clades_detail_tables/$( basename " $f " ) "
150+ SYMLINK_COUNT=$(( SYMLINK_COUNT+ 1 ))
151+ done
152+ fi
153+ echo " output_to_input/${PRODUCER} /${GROUP_SET_LABEL} / -> ${SYMLINK_COUNT} symlinks"
154+ done <<< " ${PRODUCER_SPECS}"
144155
145156echo " "
146157echo " ========================================================================"
147158echo " SUCCESS! sequence_groups_X_species resolve_groups complete."
148- echo " OUTPUT_pipeline/1-output/ standard membership"
149- echo " OUTPUT_pipeline/2-output/ deconvolution (sequence + species counts per clade)"
150- echo " OUTPUT_pipeline/3-output/ per-species sequence map"
151- echo " OUTPUT_pipeline/4-output/ composite clades"
152- echo " output_to_input/${GROUP_SET_LABEL} /"
159+ echo " Per producer, under OUTPUT_pipeline/<group_set_label>/:"
160+ echo " 1-output/ standard membership"
161+ echo " 2-output/ deconvolution (sequence + species counts per clade)"
162+ echo " 3-output/ per-species sequence map"
163+ echo " 4-output/ composite clades"
164+ echo " Downstream symlinks: output_to_input/<producer>/<group_set_label>/"
153165echo " Completed: $( date) "
154166echo " ========================================================================"
155167
0 commit comments