digraph pdb2pqr {
	rankdir=TB;
	/*splines=ortho;*/

	{
		/* Routine nodes */
		node [shape=box,fixedsize=shape, width=1.75, height=0.50,fillcolor=lightblue,style="filled, rounded"];
		drop_water_r [label="Drop water\nfrom list"];
		add_ligand_r [label="Add ligand\nto PDB list"];
		set_termini_r [label="Set Termini"];
		mult_occ_warn_r [label="Add multiple\noccupancy warning"];
		update_bonds_r [label="Setup bond\nnetwork"];
		extensions_r [label="Run\nExtension"];
		assign_ff_r [label="Assign FF\nparameters"];
		missing_heavy_r [label="Restore\nmissing heavy"];
		update_ss_bridge_r [label="Update SS\nbridge"];
		first_debump_r [label="Debump\nreconstructed atoms"];
		proka_r [label="Run PropKa"];
		pdb2pka_r [label="Run PDB2PKA"];
		add_hydrogens_r [label="Add missing\nhydrogens"];
		second_debump_r [label="Debump added\n hydrogens"];
		hydrogen_opt_all_r [label="Optimize hydrogen\nbonding network"];
		hydrogen_opt_water_r [label="Optimize water\nhydrogens"];
		hydrogen_cleanup_r [label="Cleanup GLH/ASH\n(both are added, fix)"];
		set_states_r [label="Set protonation\nstate"];
		assign_ff_r [label="Assign FF\nvalues"];
		typemap_r [label="Generate\ntype map"];
		ff_out_r [label="Apply alternate\nFF names"];
		header_r [label="Create PQR\nheadder"];
		atom_list_r [label="Create PQR\atom list"];
		ligand_misslist_r [label="Create list of ligand\natoms with no FF"];
		get_charge_r [label="Get protein charge"];
		routines_object_r [label="Create routines\nobject"];
		protein_object_r [label="Create protein\nobject"];
		parse_pdb_into_list_r [label="Parse PDB file\ninto list"];
		write_pqr_r  [label="Write PDB\nfile"];
		write_apbs_input_r [label="Write APBS\ninput file"];
	}

	{
		/* Output nodes */
		node [shape=box,fixedsize=shape, width=1.0, height=0.50,style="rounded, dashed"];
		propka_out [label="PropKA\noutput"];
		pdb2pka_out [label="PDB2PKA\noutput"];
		extentions_out [label="Extension\noutput"];
		header_out [label="Header"];
		atom_list_out [label="PQR atom\nlist"];
		misslist_out [label="Unassigned\nligands"];
		assigned_list_out [label="Atoms with\ncharges"];
		unassigned_list_out [label="Atoms without\ncharges", width=1.25];
		res_miss_list_out [label="Residues with\nnon-integral charges", width=1.75];
		charge_out [label="Protein\ntotal charge"];
		pqr_file_out [label="PDB\nfile"];
		apbs_input_out [label="APBS input\nfile"];
	}


	{
		/* Question nodes */
		node [shape=diamond,fixedsize=shape, width=1.75, height=1.25,fillcolor=lightblue,style=filled];
		typemap_q [label="Generate\ntype map?\n(User)"];
		ff_out_q [label="Alternate\nnaming?\n(User)"];
		drop_water_q [label="Drop water?\n(User)"];
		add_ligand_q [label="Add ligand?\n(User)"];
		mult_occ_warn_q [label="Multiple\noccupancies?"];
		missing_heavy_q [label="Heavy atoms\nmissing?"];
		second_debump_q [label="Debump\nprotein?\n(User)"];
		hydrogen_opt_q [label="Optimize\nall hydrogen?\n(User)"];
		clean__only_q [label="Clean only?\n(User)"];
		assign_only_q [label="Only assign\nparameters?\n(User)"];
		first_debump_q [label="Debump\nprotein?\n(User)"];
		calc_pka_q [label="Calculate PKA?\n(User)"];
		write_apbs_input_q [label="Create APBS\ninput file?\n(User)"];
	}

	/* Ranking stuff */


	subgraph cluster_runPDB2PQR {
		label="runPDB2PQR";
		color=blue;
		drop_water_r;
		add_ligand_r;
		set_termini_r;
		mult_occ_warn_r;
		update_bonds_r;
		extensions_r;
		assign_ff_r;
		missing_heavy_r;
		update_ss_bridge_r;
		first_debump_r;
		proka_r;
		pdb2pka_r;
		add_hydrogens_r;
		second_debump_r;
		hydrogen_opt_all_r;
		hydrogen_opt_water_r;
		hydrogen_cleanup_r;
		set_states_r;
		assign_ff_r;
		typemap_r;
		ff_out_r;
		header_r;
		atom_list_r;
		ligand_misslist_r;
		get_charge_r;
		routines_object_r;
		protein_object_r;
		propka_out;
		pdb2pka_out;
		extentions_out;
		header_out;
		atom_list_out;
		misslist_out;
		assigned_list_out;
		unassigned_list_out;
		res_miss_list_out;
		charge_out;
		typemap_q;
		ff_out_q;
		drop_water_q;
		add_ligand_q;
		mult_occ_warn_q;
		missing_heavy_q;
		second_debump_q;
		hydrogen_opt_q;
		clean__only_q;
		assign_only_q;
		first_debump_q;
		calc_pka_q;

		{rank=same;drop_water_q;drop_water_r;}
		{rank=same;add_ligand_q;add_ligand_r;}
		{rank=same;mult_occ_warn_q;mult_occ_warn_r;}
		{rank=same;missing_heavy_q;missing_heavy_r;}
		{rank=same;first_debump_q;first_debump_r;}
		{rank=same;second_debump_q;second_debump_r;}
		{rank=same;calc_pka_q;proka_r;pdb2pka_r;}
		{rank=same;hydrogen_opt_q;hydrogen_opt_all_r;}
		{rank=same;typemap_q;typemap_r;}
		{rank=same;ff_out_q;ff_out_r;}

	}

	{
		edge [style=dashed]
		{
			edge [label="No"]
			drop_water_q:s -> add_ligand_q:n;
			add_ligand_q:s -> protein_object_r:n;
			mult_occ_warn_q:s -> set_termini_r:n;
			clean__only_q:s -> assign_only_q:n;
			assign_only_q:s -> missing_heavy_q:n;
			missing_heavy_q:s -> update_ss_bridge_r:n;
			first_debump_q:s -> calc_pka_q:n;
			calc_pka_q:s -> add_hydrogens_r:n;
			second_debump_q:s -> hydrogen_opt_q:n;
			hydrogen_opt_q:s -> hydrogen_opt_water_r:n;
			typemap_q:s -> get_charge_r:n;
			ff_out_q:s -> header_r:n;
		}
		{
			edge [label="Yes"]
			drop_water_q -> drop_water_r;
			add_ligand_q -> add_ligand_r;
			mult_occ_warn_q -> mult_occ_warn_r;
			clean__only_q -> extensions_r;
			missing_heavy_q -> missing_heavy_r;
			first_debump_q -> first_debump_r;
			second_debump_q -> second_debump_r;
			hydrogen_opt_q -> hydrogen_opt_all_r;
			typemap_q -> typemap_r;
			ff_out_q -> ff_out_r;
			write_apbs_input_q -> write_apbs_input_r;
			assign_only_q -> assign_ff_r;
		}
		calc_pka_q -> proka_r [label="PropKa"];
		calc_pka_q -> pdb2pka_r [label="PDB2PKA"];
	}



	start -> parse_pdb_into_list_r;
	parse_pdb_into_list_r:s -> drop_water_q:n;
	drop_water_r -> add_ligand_q;
	add_ligand_r -> protein_object_r;
	protein_object_r -> routines_object_r;
	routines_object_r -> mult_occ_warn_q;
	mult_occ_warn_r -> set_termini_r;
	set_termini_r -> update_bonds_r;
	update_bonds_r -> clean__only_q;
	missing_heavy_r -> update_ss_bridge_r;
	update_ss_bridge_r -> first_debump_q;
	first_debump_r -> calc_pka_q;

	proka_r -> propka_out;
	proka_r -> add_hydrogens_r;
	pdb2pka_r -> add_hydrogens_r;
	pdb2pka_r -> pdb2pka_out;
	add_hydrogens_r -> second_debump_q;
	second_debump_r -> hydrogen_opt_q;
	hydrogen_opt_all_r -> hydrogen_cleanup_r;
	hydrogen_opt_water_r -> hydrogen_cleanup_r;
	hydrogen_cleanup_r -> set_states_r;
	set_states_r -> assign_ff_r;
	assign_ff_r -> assigned_list_out;
	assign_ff_r -> unassigned_list_out;
	assign_ff_r -> typemap_q;
	typemap_r -> get_charge_r;
	get_charge_r -> ff_out_q;
	get_charge_r -> res_miss_list_out;
	get_charge_r -> charge_out;
	ff_out_r -> header_r;
	header_r -> atom_list_r;
	atom_list_r -> ligand_misslist_r;
	ligand_misslist_r -> extensions_r;
	extensions_r -> extentions_out;
	parse_pdb_into_list_r -> header_r;
	unassigned_list_out -> header_r;
	res_miss_list_out -> header_r;
	charge_out -> header_r;
	header_r -> header_out;
	atom_list_r -> atom_list_out;
	ligand_misslist_r -> misslist_out;
	assigned_list_out -> atom_list_r;
	header_out -> write_pqr_r;
	atom_list_out -> write_pqr_r;
	write_pqr_r -> pqr_file_out;
	write_pqr_r -> write_apbs_input_q;
	pqr_file_out -> write_apbs_input_r;

	{rank=same;write_apbs_input_q;write_apbs_input_r;}


	write_apbs_input_r -> apbs_input_out;

	start [shape=box,label="PDB\n(start)",style=rounded];
}

