## TITLE('Biochemistry: Cross-Communication in a Merging Pathway')
## DESCRIPTION
## Five-part progressive problem about feed-forward cross-activation in a
## merging metabolic pathway. The diagram shows two input branches that
## converge into a shared trunk. Students must identify feed-forward
## activators, cross-activation targets, and predict coordination effects.
## Parts A and B use checkboxes (select all that apply). Part C randomly
## selects between overproduction, lost cross-activation, or imbalance
## scenarios. Part D examines blocked branch effects. Part E tests
## understanding of why cross-activation exists.
## ENDDESCRIPTION
## KEYWORDS('feed-forward','cross-activation','metabolic pathway','committed step','anabolic pathway','merging pathway','convergent pathway','coordination')
## DBsubject('Biochemistry')
## DBchapter('Enzymes')
## DBsection('Regulation')
## Level(4)
## Date('2026-03-30')
## Author('Dr. Neil R. Voss')
## Institution('Roosevelt University')
## Language(en)
# https://github.com/vosslab
# https://bsky.app/profile/neilvosslab.bsky.social
# This work is licensed under CC BY 4.0 (Creative Commons Attribution 4.0
# International License).
# https://creativecommons.org/licenses/by/4.0/
# Source code portions are licensed under LGPLv3.

DOCUMENT();

# ----------------------------
# 1) Preamble
# ----------------------------
loadMacros(
	'PGstandard.pl',
	'MathObjects.pl',
	'PGML.pl',
	'niceTables.pl',
	'parserCheckboxList.pl',
	'parserRadioButtons.pl',
	'PGcourse.pl',
);

$showPartialCorrectAnswers = 0;

# ============================================
# 2) Setup
# ============================================

# ----------------------------
# 2a) Deterministic local RNG
# ----------------------------
my $local_random = PGrandom->new();
$local_random->srand($problemSeed);

# ----------------------------
# 2b) Pathway data
# ----------------------------
my $b1_len    = $local_random->random(3, 4, 1);
my $b2_len    = $local_random->random(3, 4, 1);
my $trunk_len = $local_random->random(3, 4, 1);
my $total_mols = $b1_len + $b2_len + $trunk_len;

# color palette (14 high-contrast colors)
my @palette = (
	'#d40000', '#b74300', '#935d00', '#6c6c00', '#3b7600',
	'#007a00', '#00775f', '#007576', '#076dad', '#003fff',
	'#0067cc', '#a719db', '#c80085', '#cc0066',
);
my $c_shift = $local_random->random(0, $#palette, 1);
my @dbl_pal = (@palette, @palette);
my @colors = @dbl_pal[$c_shift .. $c_shift + $total_mols - 1];

# letter assignment
my @alpha = ('A'..'Z');
my $l_shift = $local_random->random(0, 26 - $total_mols - 1, 1);
my @letters = @alpha[$l_shift .. $l_shift + $total_mols - 1];

# assign metabolites: b1 first, then b2, then trunk
my @b1 = ();
for my $i (0 .. $b1_len - 1) {
	push @b1, { L => $letters[$i], C => $colors[$i] };
}
my @b2 = ();
for my $i (0 .. $b2_len - 1) {
	my $idx = $b1_len + $i;
	push @b2, { L => $letters[$idx], C => $colors[$idx] };
}
my @trunk = ();
for my $i (0 .. $trunk_len - 1) {
	my $idx = $b1_len + $b2_len + $i;
	push @trunk, { L => $letters[$idx], C => $colors[$idx] };
}

# ----------------------------
# 2c) Enzyme numbering and feedback biology
# ----------------------------
# In a merging pathway:
#   - First enzymes of each input branch are committed steps
#   - Trunk end product inhibits the committed steps of both input branches
#   - Enzyme numbering: b1 internal, merge, trunk internal, b2 internal
#   - E1..E(b1_len-1) = b1 arrows, E(b1_len) = merge, E(b1_len+1).. = trunk, then b2
my $e_b1_first = 1;
my $e_merge = $b1_len;
my $e_trunk_first = $b1_len + 1;
my $e_b2_first = $b1_len + $trunk_len;
my $total_enzymes = $b1_len + $b2_len + $trunk_len - 1;

my $b1_start = $b1[0];
my $b2_start = $b2[0];
my $mp_mol = $trunk[0];  # first trunk metabolite (merge point)
my $trunk_end = $trunk[$#trunk];

# pick one branch randomly for parts C-D
my $focus_branch = $local_random->random(1, 2, 1);
my $focus_name = ($focus_branch == 1) ? 'first' : 'second';
my $other_name = ($focus_branch == 1) ? 'second' : 'first';
my $focus_enzyme = ($focus_branch == 1) ? $e_b1_first : $e_b2_first;
my $focus_branch_start = ($focus_branch == 1) ? $b1_start : $b2_start;
my $other_branch_start = ($focus_branch == 1) ? $b2_start : $b1_start;
my $focus_branch_obj = ($focus_branch == 1) ? \@b1 : \@b2;
my $other_branch_obj = ($focus_branch == 1) ? \@b2 : \@b1;
my $other_enzyme = ($focus_branch == 1) ? $e_b2_first : $e_b1_first;
my $focus_branch_end = ($focus_branch == 1) ? $b1[$#b1] : $b2[$#b2];
my $other_branch_end = ($focus_branch == 1) ? $b2[$#b2] : $b1[$#b1];

# ============================================
# 2d) HTML helpers
# ============================================
my $css_met   = 'border:0; text-align:center; padding:2px 4px;';
my $css_arr   = 'border:0; text-align:center; padding:2px 2px; font-size:150%;';
my $css_lbl   = 'border:0; text-align:center; padding:0 2px; '
	. 'font-size:75%; vertical-align:bottom;';
my $css_empty = 'border:0; padding:2px 4px;';
my $css_dots  = 'border:0; text-align:center; padding:2px 2px; '
	. 'font-size:120%; color:#888; letter-spacing:2px;';

sub met_node {
	my ($letter, $color) = @_;
	return "<span style='display:inline-block; width:38px; height:38px; "
		. "line-height:38px; border-radius:50%; background:${color}; "
		. "color:#fff; font-weight:700; font-size:16px; "
		. "border:2px solid #333; text-align:center;'>${letter}</span>";
}

sub met_txt {
	my ($letter, $color) = @_;
	return "<strong><span style='color:${color};'>${letter}</span></strong>";
}

# ============================================
# 2e) Grid geometry
# ============================================
# Grid layout for merging pathway:
# Branches on LEFT, trunk on RIGHT
# Two branches (top and bottom) converge into a single trunk
my $max_branch_len = ($b1_len > $b2_len) ? $b1_len : $b2_len;
my $branch_cols = 2 * $max_branch_len - 1;  # met + arrow + met + ... pairs
my $merge_col = $branch_cols;
my $trunk_arrow_col = $merge_col + 1;
my $trunk_met_start = $trunk_arrow_col + 1;
my $total_cols = $trunk_met_start + 2 * $trunk_len;

# ============================================
# 2f) Build diagram rows (no feedback arrows)
# ============================================
# 6-row layout using LayoutTable:
# Row 0: Branch 1 enzyme labels (left-padded if shorter than max)
# Row 1: Branch 1 metabolites + NE arrow at merge point
# Row 2: Trunk enzyme labels (right side)
# Row 3: Trunk metabolites + arrows
# Row 4: Branch 2 metabolites + SE arrow at merge point
# Row 5: Branch 2 enzyme labels (left-padded if shorter than max)

# --- Branch 1 enzyme label row ---
my @b1_enzyme_row = ();
for (1 .. $total_cols) { push @b1_enzyme_row, ['', cellcss => $css_empty]; }
# Add padding if b1 is shorter than max_branch_len
my $b1_padding = $max_branch_len - $b1_len;
# enzyme labels go above arrows (odd columns between metabolites)
for my $i (0 .. $b1_len - 2) {
	my $en = $e_b1_first + $i;
	# arrow column is at offset 1 from the metabolite column
	my $col = 2 * ($b1_padding + $i) + 1;
	$b1_enzyme_row[$col] = ["E<sub>${en}</sub>", cellcss => $css_lbl];
}

# --- Branch 1 structure row ---
my @b1_struct_row = ();
for (1 .. $total_cols) { push @b1_struct_row, ['', cellcss => $css_empty]; }
# Merge point arrow (SE, upper branch goes down to merge)
$b1_struct_row[$merge_col] = ['&#8600;', cellcss => $css_arr];
# Metabolites and arrows
for my $i (0 .. $b1_len - 1) {
	my $col = 2 * ($b1_padding + $i);
	$b1_struct_row[$col] = [met_node($b1[$i]->{L}, $b1[$i]->{C}),
		cellcss => $css_met];
	if ($i < $b1_len - 1) {
		$b1_struct_row[$col + 1] = ['&rarr;', cellcss => $css_arr];
	}
}

# --- Trunk enzyme label row ---
my @trunk_enzyme_row = ();
for (1 .. $total_cols) { push @trunk_enzyme_row, ['', cellcss => $css_empty]; }
# merge enzyme label at the merge column
$trunk_enzyme_row[$merge_col] = ["E<sub>${e_merge}</sub>", cellcss => $css_lbl];
# trunk internal enzyme labels
for my $i (0 .. $trunk_len - 2) {
	my $en = $e_trunk_first + $i;
	my $col = $trunk_met_start + 1 + 2 * $i;
	$trunk_enzyme_row[$col] = ["E<sub>${en}</sub>", cellcss => $css_lbl];
}

# --- Trunk structure row ---
my @trunk_struct_row = ();
for (1 .. $total_cols) { push @trunk_struct_row, ['', cellcss => $css_empty]; }
# merge arrow-tail + regular arrow before first trunk metabolite
$trunk_struct_row[$merge_col] = ['&#x291A;', cellcss => $css_arr];
$trunk_struct_row[$trunk_arrow_col] = ['&rarr;', cellcss => $css_arr];
# Metabolites and arrows
for my $i (0 .. $trunk_len - 1) {
	my $col = $trunk_met_start + 2 * $i;
	$trunk_struct_row[$col] = [met_node($trunk[$i]->{L}, $trunk[$i]->{C}),
		cellcss => $css_met];
	if ($i < $trunk_len - 1) {
		$trunk_struct_row[$col + 1] = ['&rarr;', cellcss => $css_arr];
	}
}
# Add ellipsis at far right
$trunk_struct_row[$total_cols - 1] = ['&middot;&middot;&middot;',
	cellcss => $css_dots];

# --- Branch 2 enzyme label row ---
my @b2_enzyme_row = ();
for (1 .. $total_cols) { push @b2_enzyme_row, ['', cellcss => $css_empty]; }
# Add padding if b2 is shorter than max_branch_len
my $b2_padding = $max_branch_len - $b2_len;
# enzyme labels go above arrows (odd columns between metabolites)
for my $i (0 .. $b2_len - 2) {
	my $en = $e_b2_first + $i;
	my $col = 2 * ($b2_padding + $i) + 1;
	$b2_enzyme_row[$col] = ["E<sub>${en}</sub>", cellcss => $css_lbl];
}

# --- Branch 2 structure row ---
my @b2_struct_row = ();
for (1 .. $total_cols) { push @b2_struct_row, ['', cellcss => $css_empty]; }
# Merge point arrow (NE, lower branch goes up to merge)
$b2_struct_row[$merge_col] = ['&#8599;', cellcss => $css_arr];
# Metabolites and arrows
for my $i (0 .. $b2_len - 1) {
	my $col = 2 * ($b2_padding + $i);
	$b2_struct_row[$col] = [met_node($b2[$i]->{L}, $b2[$i]->{C}),
		cellcss => $css_met];
	if ($i < $b2_len - 1) {
		$b2_struct_row[$col + 1] = ['&rarr;', cellcss => $css_arr];
	}
}

# --- Assemble: b1 above trunk above b2 ---
my @all_rows = ();
push @all_rows, [@b1_enzyme_row];
push @all_rows, [@b1_struct_row];
push @all_rows, [@trunk_enzyme_row];
push @all_rows, [@trunk_struct_row];
push @all_rows, [@b2_struct_row];
push @all_rows, [@b2_enzyme_row];

$diagram = LayoutTable(
	[@all_rows],
	center => 0,
	tablecss => 'border-collapse:collapse; border:0;',
	allcellcss => 'border:0; padding:2px;',
);

# ============================================
# 2g) Text references
# ============================================
my $b1_start_txt   = met_txt($b1_start->{L}, $b1_start->{C});
my $b2_start_txt   = met_txt($b2_start->{L}, $b2_start->{C});
my $mp_txt         = met_txt($mp_mol->{L}, $mp_mol->{C});
my $trunk_end_txt  = met_txt($trunk_end->{L}, $trunk_end->{C});
my $focus_start_txt = met_txt($focus_branch_start->{L}, $focus_branch_start->{C});
my $other_start_txt = met_txt($other_branch_start->{L}, $other_branch_start->{C});
my $focus_end_txt   = met_txt($focus_branch_end->{L}, $focus_branch_end->{C});
my $other_end_txt   = met_txt($other_branch_end->{L}, $other_branch_end->{C});

# color lookup
my %met_color = ();
for my $m (@b1) { $met_color{$m->{L}} = $m->{C}; }
for my $m (@b2) { $met_color{$m->{L}} = $m->{C}; }
for my $m (@trunk) { $met_color{$m->{L}} = $m->{C}; }

# ============================================
# 2h) Part A: Identify feed-forward activators (CheckboxList)
# ============================================
# In a merging pathway, each branch's end product activates the committed
# step of the OTHER branch (cross-activation for coordinated supply).
# Correct: both branch end products. Distractors: starting mols, intermediates.

# collect all candidate metabolites for Part A, then order by letter
my @pA_pool = (
	$b1_start,
	$b2_start,
	$focus_branch_end,
	$other_branch_end,
	$mp_mol,
);
if ($b1_len >= 3) {
	push @pA_pool, $b1[1];
}
# insertion sort by letter (avoids blocked 'sort' in safe compartment)
my @pA_selected = ($pA_pool[0]);
for my $k (1 .. $#pA_pool) {
	my $inserted = 0;
	for my $j (0 .. $#pA_selected) {
		if ($pA_pool[$k]->{L} lt $pA_selected[$j]->{L}) {
			splice(@pA_selected, $j, 0, $pA_pool[$k]);
			$inserted = 1;
			last;
		}
	}
	if (!$inserted) { push @pA_selected, $pA_pool[$k]; }
}

my @pA_choices = ();
my @pA_correct_indices = ();
for my $i (0 .. $#pA_selected) {
	my $m = $pA_selected[$i];
	push @pA_choices, "metabolite " . met_txt($m->{L}, $m->{C});
	# correct: both branch end products
	if ($m->{L} eq $focus_branch_end->{L}
		|| $m->{L} eq $other_branch_end->{L}) {
		push @pA_correct_indices, $i;
	}
}

$cbA = CheckboxList(
	[@pA_choices],
	[@pA_correct_indices],
	separator => '<br/>',
);

$qA = "<b>Which metabolites provide positive regulatory signals "
	. "to enzymes in the other branch? "
	. "(Select all that apply.)</b>";

$solA = "The two feed-forward activators are: ${focus_end_txt} "
	. "(end product of the ${focus_name} branch, activates "
	. "E<sub>${other_enzyme}</sub>) and ${other_end_txt} "
	. "(end product of the ${other_name} branch, activates "
	. "E<sub>${focus_enzyme}</sub>). Each branch's end product "
	. "cross-activates the other branch's committed step, coordinating "
	. "supply of both substrates for the merge reaction.";

# ============================================
# 2i) Part B: Identify cross-activation targets (CheckboxList)
# ============================================
# Correct: E(e_b1_first) and E(e_b2_first) -- the committed steps
# These are targets of feed-forward cross-activation from the other branch
# Distractors: merge enzyme, trunk enzymes, downstream branch enzymes

my @pB_selected_nums = ();
# committed steps of both branches (correct -- targets of cross-activation)
push @pB_selected_nums, $e_b1_first;
push @pB_selected_nums, $e_b2_first;
# merge enzyme as distractor
push @pB_selected_nums, $e_merge;
# downstream branch enzymes as distractors
if ($b1_len >= 2) {
	push @pB_selected_nums, $e_b1_first + 1;
}
if ($b2_len >= 2) {
	push @pB_selected_nums, $e_b2_first + 1;
}

# deduplicate and keep order
my %pB_seen;
my @pB_unique = ();
for my $e (@pB_selected_nums) {
	next if $pB_seen{$e}++;
	push @pB_unique, $e;
}

my @pB_choices = ();
my @pB_correct_indices = ();
for my $i (0 .. $#pB_unique) {
	my $e = $pB_unique[$i];
	push @pB_choices, "enzyme E<sub>${e}</sub>";
	# correct: committed steps (targets of cross-activation)
	if ($e == $e_b1_first || $e == $e_b2_first) {
		push @pB_correct_indices, $i;
	}
}

$cbB = CheckboxList(
	[@pB_choices],
	[@pB_correct_indices],
	separator => '<br/>',
);

$qB = "<b>Which enzymes receive positive regulatory signals "
	. "from a metabolite in the other branch? "
	. "(Select all that apply.)</b>";

$solB = "The two cross-activation targets are: "
	. "E<sub>${e_b1_first}</sub> (committed step of the ${focus_name} branch, "
	. "activated by ${other_end_txt}) and "
	. "E<sub>${e_b2_first}</sub> (committed step of the ${other_name} branch, "
	. "activated by ${focus_end_txt}). The committed step is the first enzyme "
	. "unique to each branch. Cross-activation ensures coordinated "
	. "substrate supply for the merge reaction.";

# ============================================
# 2j) Part C: Coordination reasoning (3 sub-scenarios)
# ============================================
# Randomly select: 1=overproduction, 2=lost cross-activation, 3=branch imbalance
my $pC_subscenario = $local_random->random(1, 3, 1);

if ($pC_subscenario == 1) {
	# Sub-scenario 1: One branch overproduces (cross-activation consequence)
	$qC = "If the ${focus_name} branch overproduces ${focus_end_txt}, "
		. "what is the most likely effect on the ${other_name} branch?";

	my $pC_correct = "the ${other_name} branch is stimulated because "
		. "${focus_end_txt} activates E<sub>${other_enzyme}</sub>, "
		. "tending to increase ${other_end_txt} production";

	my @pC_choices = (
		$pC_correct,
		"the ${other_name} branch slows because "
		. "${focus_end_txt} inhibits E<sub>${other_enzyme}</sub>",
		"the ${other_name} branch is unaffected because "
		. "the two branches are independent",
		"the excess ${focus_end_txt} is rerouted into "
		. "the ${other_name} branch",
		"the ${other_name} branch shuts down because "
		. "only one branch is needed",
	);
	for my $i (reverse 1 .. $#pC_choices) {
		my $j = $local_random->random(0, $i, 1);
		@pC_choices[$i, $j] = @pC_choices[$j, $i];
	}

	$rbC = RadioButtons(
		[[@pC_choices]], $pC_correct,
		labels => 'ABC', displayLabels => 1,
		separator => '<div style="margin-bottom: 0.4em;"></div>',
	);

	$solC = "When the ${focus_name} branch overproduces ${focus_end_txt}, "
		. "the excess ${focus_end_txt} cross-activates "
		. "E<sub>${other_enzyme}</sub> (the committed step of the "
		. "${other_name} branch). This stimulates the ${other_name} branch "
		. "to increase ${other_end_txt} production, coordinating substrate "
		. "supply for the merge reaction.";
}
elsif ($pC_subscenario == 2) {
	# Sub-scenario 2: Lost cross-activation (mutation)
	$qC = "If a mutation eliminates the activation of "
		. "E<sub>${other_enzyme}</sub> by ${focus_end_txt}, "
		. "but all enzymes remain functional, "
		. "what is the most likely effect on the pathway?";

	my $pC_correct = "the ${other_name} branch loses feed-forward "
		. "stimulation; substrate supply becomes imbalanced; the merge "
		. "step tends to be limited by ${other_end_txt} availability";

	my @pC_choices = (
		$pC_correct,
		"the ${other_name} branch shuts down completely because "
		. "E<sub>${other_enzyme}</sub> requires activation to function",
		"the ${focus_name} branch compensates by increasing its "
		. "own production of ${focus_end_txt}",
		"the pathway is unaffected because feed-forward activation "
		. "is not essential for enzyme function",
		"${mp_txt} production increases because the "
		. "${other_name} branch runs unchecked",
	);
	my $pC_lost_correct = $pC_correct;
	for my $i (reverse 1 .. $#pC_choices) {
		my $j = $local_random->random(0, $i, 1);
		@pC_choices[$i, $j] = @pC_choices[$j, $i];
	}

	$rbC = RadioButtons(
		[[@pC_choices]], $pC_lost_correct,
		labels => 'ABC', displayLabels => 1,
		separator => '<div style="margin-bottom: 0.4em;"></div>',
	);

	$solC = "Without feed-forward activation from ${focus_end_txt}, "
		. "E<sub>${other_enzyme}</sub> still functions but at its basal "
		. "rate. The ${other_name} branch is no longer stimulated when the "
		. "${focus_name} branch speeds up, breaking the coordination "
		. "mechanism. The merge step tends to become limited by "
		. "${other_end_txt} availability because the two branches "
		. "are no longer balanced.";
}
else {
	# Sub-scenario 3: Branch imbalance (core constraint question)
	$qC = "If the ${focus_name} branch produces an excess of "
		. "${focus_end_txt} but the ${other_name} branch produces "
		. "less ${other_end_txt} than normal, what is the most "
		. "likely effect on ${mp_txt} production?";

	my $pC_correct = "${mp_txt} production is limited by the "
		. "${other_name} branch; excess ${focus_end_txt} cannot "
		. "compensate for insufficient ${other_end_txt}";

	my @pC_choices = (
		$pC_correct,
		"${mp_txt} increases because more ${focus_end_txt} "
		. "is available for the merge reaction",
		"excess ${focus_end_txt} drives the merge reaction forward "
		. "despite low ${other_end_txt}",
		"the excess ${focus_end_txt} is rerouted to increase "
		. "${other_end_txt} production",
		"${mp_txt} is unchanged because the branches "
		. "are independent of each other",
	);
	my $pC_imb_correct = $pC_correct;
	for my $i (reverse 1 .. $#pC_choices) {
		my $j = $local_random->random(0, $i, 1);
		@pC_choices[$i, $j] = @pC_choices[$j, $i];
	}

	$rbC = RadioButtons(
		[[@pC_choices]], $pC_imb_correct,
		labels => 'ABC', displayLabels => 1,
		separator => '<div style="margin-bottom: 0.4em;"></div>',
	);

	$solC = "The merge reaction requires both ${focus_end_txt} and "
		. "${other_end_txt} as substrates. When the ${other_name} branch "
		. "produces less ${other_end_txt} than normal, the merge step "
		. "becomes limited by ${other_end_txt} availability. Excess "
		. "${focus_end_txt} from the ${focus_name} branch cannot "
		. "compensate, because the merge reaction requires both inputs. "
		. "This is the key constraint in converging pathways: flux is "
		. "limited by whichever input branch is slower.";
}

# ============================================
# 2k) Part D: Blocked input branch (MC)
# ============================================
$qD = "If enzyme <b>E<sub>${focus_enzyme}</sub></b> is completely "
	. "inactivated, what happens to the production of ${mp_txt}?";

my @pD_choices = (
	"metabolite ${mp_txt} "
	. "<span style='color:#c93030; font-weight:700;'>decreases</span> "
	. "because the ${focus_name} input branch is blocked; "
	. "the ${other_name} branch alone cannot supply enough substrate",
	"metabolite ${mp_txt} "
	. "<span style='color:#1a7a1a; font-weight:700;'>increases</span> "
	. "because the ${other_name} branch compensates fully",
	"metabolite ${mp_txt} production is "
	. "<span style='font-weight:700;'>unchanged</span> because "
	. "both branches contribute equally",
	"metabolite ${mp_txt} production "
	. "<span style='color:#c93030; font-weight:700;'>stops completely</span> "
	. "because the merge reaction requires input from both branches",
);
my $pD_correct = $pD_choices[0];
for my $i (reverse 1 .. $#pD_choices) {
	my $j = $local_random->random(0, $i, 1);
	@pD_choices[$i, $j] = @pD_choices[$j, $i];
}

$rbD = RadioButtons(
	[[@pD_choices]], $pD_correct,
	labels => 'ABC', displayLabels => 1,
	separator => '<div style="margin-bottom: 0.4em;"></div>',
);

$solD = "When E<sub>${focus_enzyme}</sub> is inactivated, the "
	. "${focus_name} input branch can no longer supply substrate for "
	. "the merge. The ${other_name} branch alone must supply all the "
	. "input to produce ${mp_txt}. Because the merge reaction requires "
	. "both substrates (no rerouting is possible), ${mp_txt} production "
	. "decreases but does not stop entirely, since the ${other_name} "
	. "branch still provides some input.";

# ============================================
# 2l) Part E: Feed-forward coordination (advanced, MC)
# ============================================
$qE = "In many converging pathways, each branch's end product activates "
	. "the committed step of the <i>other</i> branch (feed-forward "
	. "cross-activation). If ${focus_end_txt} activates "
	. "E<sub>${other_enzyme}</sub>, what problem does this "
	. "regulatory mechanism solve?";

my @pE_choices = (
	"it matches production of both substrates required for the "
	. "merge reaction; when one branch increases output, it stimulates "
	. "the other branch to keep pace",
	"it provides a backup pathway if one branch fails, ensuring "
	. "${trunk_end_txt} is still produced",
	"it inhibits the ${other_name} branch to prevent overproduction "
	. "of ${other_end_txt}",
	"it has no functional advantage; it is an evolutionary artifact "
	. "with no effect on pathway flux",
);
my $pE_correct = $pE_choices[0];
for my $i (reverse 1 .. $#pE_choices) {
	my $j = $local_random->random(0, $i, 1);
	@pE_choices[$i, $j] = @pE_choices[$j, $i];
}

$rbE = RadioButtons(
	[[@pE_choices]], $pE_correct,
	labels => 'ABC', displayLabels => 1,
	separator => '<div style="margin-bottom: 0.4em;"></div>',
);

$solE = "Feed-forward cross-activation solves the stoichiometric "
	. "coordination problem in converging pathways. The merge reaction "
	. "requires both ${focus_end_txt} and ${other_end_txt} as substrates. "
	. "When the ${focus_name} branch produces more ${focus_end_txt}, "
	. "that excess activates E<sub>${other_enzyme}</sub>, stimulating "
	. "the ${other_name} branch to increase ${other_end_txt} production "
	. "to match. This ensures balanced supply of both substrates for "
	. "the merge step (Tymoczko et al., Biochemistry: A Short Course).";

# ============================================
# 3) Statement (PGML)
# ============================================

BEGIN_PGML

*Negative Feedback in a Converging Metabolic Pathway*

A series of enzymes catalyze reactions involving the metabolites in the merging metabolic pathway shown below. Two independent input branches converge into a shared trunk pathway. The ellipsis (...) indicates that additional downstream steps are not shown.

[$diagram]*

---

*Part A: Identify the Feed-Forward Activators*

[$qA]*

[_]{$cbA}

---

*Part B: Identify the Cross-Activation Targets*

[$qB]*

[_]{$cbB}

---

*Part C: Perturbation Reasoning*

[$qC]*

[_]{$rbC}

---

*Part D: Blocked Input Branch*

[$qD]*

[_]{$rbD}

---

*Part E: Feed-Forward Coordination (Advanced)*

[$qE]*

[_]{$rbE}

END_PGML

# ----------------------------
# 4) Hint
# ----------------------------
BEGIN_PGML_HINT
*Part A:* Look at the regulatory signals in the diagram. Which metabolites send positive signals across branches?

*Part B:* Follow the positive regulatory arrows. Where do they point?

*Part C:* If one metabolite increases, trace its regulatory arrows to predict what changes downstream.

*Part D:* The merge reaction requires both substrates. What happens if one source is removed?

*Part E:* Consider what would happen without this coordination. What problem would arise at the merge step?
END_PGML_HINT

# ----------------------------
# 5) Solution
# ----------------------------
BEGIN_PGML_SOLUTION
*Part A:* [$solA]*

*Part B:* [$solB]*

*Part C:* [$solC]*

*Part D:* [$solD]*

*Part E:* [$solE]*
END_PGML_SOLUTION

ENDDOCUMENT();
