# TODO, Not sure if needed
rule equil_results_check:
    input:
        gro_complex = expand(out_approach_path+"/{ligand_name}/{replica}/complex/equil-mdsim/boreschcalc/ClosestRestraintFrame.gro", ligand_name=config['ligand_names'], replica=list(map(str, range(1,1 + config['replicas'])))),
        top_complex = expand(out_approach_path+"/{ligand_name}/{replica}/complex/equil-mdsim/boreschcalc/BoreschRestraint.top", ligand_name=config['ligand_names'], replica=list(map(str, range(1,1 + config['replicas'])))),
        dG_off_complex = expand(out_approach_path+"/{ligand_name}/{replica}/complex/equil-mdsim/boreschcalc/dG_off.dat", ligand_name=config['ligand_names'], replica=list(map(str, range(1,1 + config['replicas'])))),
        finished_ligand = expand(out_approach_path+"/{ligand_name}/{replica}/ligand/equil-mdsim/prod/prod.finished", ligand_name=config['ligand_names'], replica=list(map(str, range(1,1 + config['replicas'])))),

if config["complex_type"] == 'soluble':

    #Setup: Build dir structure of equil
    if config["calculation_type"] == "fep":
        include: 'ligand/setup.smk'
    include: 'complex/soluble/setup.smk'
        
    #RUN: Equil
    if config["calculation_type"] == "fep":
        include: 'ligand/simulation.smk'
    include: 'complex/soluble/simulation.smk'

elif config["complex_type"] == 'membrane':
    
    #Setup: Build dir structure of equil
    if config["calculation_type"] == "fep":
        include: 'ligand/setup.smk'
    include: 'complex/membrane/setup.smk'
   
    #RUN: Equil
    if config["calculation_type"] == "fep":
        include: 'ligand/simulation.smk'
    include: 'complex/membrane/simulation.smk'

else:
    rule equi_not_implemented:
        output:
            out_approach_path+"/{ligand_name}/{replica}/equi_not_implemented.txt"
        shell:
            "echo 'equi simulations, you must give complex_type = soluble or membrane' > {output}"

if config["calculation_type"] == "fep":
    include: 'boresch.smk'
