Exemplo n.º 1
0
def mutate_DesignGroups(experiment, mn):
    """Make the initial mutants of the Design Groups"""
    # Move into the folder to do the initial calculations in
    folder = "initial_mutant" + str(mn)
    os.chdir(folder)
    # Loop through the Design Groups
    for group in experiment:
        # The calculations will be stored in this folder
        folder = "Group" + str(group.number)
        # Try to claim the calculations
        do = SHARING.claim_calculations(folder)
        # If this processor is doing those calculations
        if do:
            # Time stamp when this started
            experiment["Summary"] = "Started" + SHARING.time_stamp()
            # Move into the folder
            os.chdir(folder)
            # Copy in the C++ and force field files
            SHARING.copy_standard_files(experiment)
            # Use the Current structures
            for molecule in experiment[group.number]:
                text =format(experiment["Current"][group.number][molecule.name])
                molecule.load(text)
            # Set the permissions for the Molecules
            permission_setter(experiment, group.number, mn)
            # Mutate the Residues
            refinement = IPRO_FUNCTIONS.Optimal_Rotamers(experiment, \
                                                         group.number)
            refinement = IPRO_FUNCTIONS.Relaxation(experiment, group.number, \
                                                   True)
            energies, refinement = IPRO_FUNCTIONS.Calculate_Energy(experiment, \
                                                                   group.number)
            # Start sharing
            SHARING.Start(experiment)
            # Write a brief summary file
            name = SHARING.summary_name(SHARING.get_current())
            f = open(name, "w")
            f.write(experiment["Summary"])
            f.close()
            # Move up a folder
            os.chdir("../")
            # Store the structures in the Current dictionary
            IPRO_FUNCTIONS.store_structures(experiment, group.number)
            IPRO_FUNCTIONS.store_energies(experiment, energies, group.number)
            # Write the structures to the Current folder
            SHARING.output_Current(experiment, "./Current/", group.number)
            SHARING.output_Energies(experiment, "./Current/", group.number)
            # End sharing
            SHARING.End(experiment)
Exemplo n.º 2
0
def mutate_DesignGroups(experiment, mn):
    """Make the initial mutants of the Design Groups"""
    # Move into the folder to do the initial calculations in 
    folder = "initial_mutant" + str(mn)
    os.chdir(folder)
    # Loop through the Design Groups
    for group in experiment:
        # The calculations will be stored in this folder
        folder = "Group" + str(group.number)
        # Try to claim the calculations
        do = SHARING.claim_calculations(folder)
        # If this processor is doing those calculations
        if do:
            # Time stamp when this started
            experiment["Summary"] = "Started" + SHARING.time_stamp()
            # Move into the folder
            os.chdir(folder)
            # Copy in the C++ and force field files
            SHARING.copy_standard_files(experiment)
            # Use the Current structures
            for molecule in experiment[group.number]:
                text =format(experiment["Current"][group.number][molecule.name])
                molecule.load(text)
            # Set the permissions for the Molecules
            permission_setter(experiment, group.number, mn)
            # Mutate the Residues
            refinement = IPRO_FUNCTIONS.Optimal_Rotamers(experiment, \
                                                         group.number)
            refinement = IPRO_FUNCTIONS.Relaxation(experiment, group.number, \
                                                   True)
            energies, refinement = IPRO_FUNCTIONS.Calculate_Energy(experiment, \
                                                                   group.number) 
            # Start sharing
            SHARING.Start(experiment)
            # Write a brief summary file
            name = SHARING.summary_name(SHARING.get_current())
            f = open(name, "w")
            f.write(experiment["Summary"])
            f.close()
            # Move up a folder
            os.chdir("../")
            # Store the structures in the Current dictionary
            IPRO_FUNCTIONS.store_structures(experiment, group.number)
            IPRO_FUNCTIONS.store_energies(experiment, energies, group.number)
            # Write the structures to the Current folder
            SHARING.output_Current(experiment, "./Current/", group.number)
            SHARING.output_Energies(experiment, "./Current/", group.number)
            # End sharing
            SHARING.End(experiment)
Exemplo n.º 3
0
def first_group_refinement(experiment):
    """Start all ensembles for the Design Groups"""
    # Start sharing (for file creation reasons)
    SHARING.Start(experiment)
    # Loop through the design groups
    print "Check1"
    for group in experiment:
        gn = group.number
        # Generate the name for the Design Group's calculations
        folder = "Group" + str(gn)
        try:
            os.mkdir(folder)
        except OSError:
            pass
        os.chdir(folder)
        # Start each ensemble
        for en in range(1, experiment["Ensemble Number"] + 1):
            eFolder = "Ensemble" + str(en)
            do = SHARING.claim_calculations(eFolder)
            # If this processor has started the calculations for this ensemble
            print en, do
            if do:
                # Make sure the experiment has the right structures and energies
                SHARING.update_Current(experiment, "../Current/", gn)
                SHARING.update_Energies(experiment, "../Current/", gn)
                # Move into the folder
                os.chdir(eFolder)
                # Make a copy of the best structures and energies for the group
                os.mkdir("Current")
                SHARING.output_Current(experiment, "./Current/", gn, 0)
                os.mkdir("Best")
                SHARING.output_Current(experiment, "./Best/", gn)
                SHARING.output_Energies(experiment, "./Best/", gn)
                # Move out of the e Folder
                os.chdir("../")
                SHARING.End(experiment)
                # Do the ensemble refinement
                ensemble_refinement(experiment, gn, en)
                SHARING.Start(experiment)
        # Move out of the folder
        os.chdir("../")
    SHARING.End(experiment)
Exemplo n.º 4
0
def initialize_group(experiment, gn):
    """Initialize a Design Group"""
    # Create the folder's name
    folder = "Group" + str(gn)
    # Try to claim it for calculations
    do = SHARING.claim_calculations(folder)
    # If this processor is doing the calculations
    if do:
        # Make a summary
        experiment["Summary"] = "Started" + SHARING.time_stamp()
        # Move into the folder and copy in files
        os.chdir(folder)
        SHARING.copy_standard_files(experiment)
        # Relax everything
        refinement = Relaxation(experiment, gn, True)
        # Assign closest rotamers
        Closest_Rotamers(experiment, gn)
        # Do another relaxation
        refinement = Relaxation(experiment, gn, True)
        # Calculate the initial energies
        energies, refinement = Calculate_Energy(experiment, gn)
        # Store the structures and energies
        store_structures(experiment, gn)
        store_energies(experiment, energies, gn)
        # Create a summary file
        experiment["Summary"] += "Ended" + SHARING.time_stamp()
        name = SHARING.summary_name(SHARING.get_current())
        f = open(name, "w")
        f.write(experiment["Summary"])
        f.close()
        # Move up a folder
        os.chdir("../")
        # Start sharing
        SHARING.Start(experiment)
        # output the structures and energies to the Current folder
        SHARING.output_Current(experiment, "./Current/", gn)
        SHARING.output_Energies(experiment, "./Current/", gn)
        # End sharing
        SHARING.End(experiment)
    return do
Exemplo n.º 5
0
def Finish(experiment, mn):
    """Finish the initial creation of a mutant"""
    # Sharing was started in check finish
    # Load the structures and energies
    SHARING.update_Current(experiment, "./Current/")
    SHARING.update_Energies(experiment, "./Current/")
    # Create a brief summary of the information
    experiment["Summary"] = '\nMutant ' + str(mn) + " Creation\n"
    f = open("Group1/Group1_Summary.txt", "r")
    for line in f:
        if line.startswith("Started"):
            experiment["Summary"] += line
            break
    f.close()
    # Include information about the energies
    for group in experiment:
        experiment["Summary"] += \
            SHARING.format_energies(experiment["Energies"][group.number], \
                                    group.number, False)
    # Put this in the overall summary
    os.chdir(experiment["Folder"])
    name = SHARING.summary_name(SHARING.get_current())
    f = open(name, "a")
    f.write(experiment["Summary"])
    f.close()
    # Make a folder to do the structure refinements in
    folder = "mutant" + str(mn)
    os.mkdir(folder)
    folder += "/Current/"
    os.mkdir(folder)
    SHARING.output_Current(experiment, folder)
    SHARING.output_Energies(experiment, folder)
    f = open(folder + "iteration.txt", "w")
    f.write(str(mn))
    f.close()
    # Delete the current folder
    name = "initial_mutant" + str(mn)
    os.system("rm -rf " + name)
    # End sharing
    SHARING.End(experiment)
Exemplo n.º 6
0
def Finish(experiment, mn):
    """Finish the initial creation of a mutant"""
    # Sharing was started in check finish
    # Load the structures and energies
    SHARING.update_Current(experiment, "./Current/")
    SHARING.update_Energies(experiment, "./Current/")
    # Create a brief summary of the information
    experiment["Summary"] = '\nMutant ' + str(mn) + " Creation\n"
    f = open("Group1/Group1_Summary.txt", "r")
    for line in f:
        if line.startswith("Started"):
            experiment["Summary"] += line
            break
    f.close()
    # Include information about the energies
    for group in experiment:
        experiment["Summary"] += \
            SHARING.format_energies(experiment["Energies"][group.number], \
                                    group.number, False)
    # Put this in the overall summary
    os.chdir(experiment["Folder"])
    name = SHARING.summary_name(SHARING.get_current())
    f = open(name, "a")
    f.write(experiment["Summary"])
    f.close()
    # Make a folder to do the structure refinements in
    folder = "mutant" + str(mn)
    os.mkdir(folder)
    folder += "/Current/"
    os.mkdir(folder)
    SHARING.output_Current(experiment, folder)
    SHARING.output_Energies(experiment, folder)
    f = open(folder + "iteration.txt", "w")
    f.write(str(mn))
    f.close()
    # Delete the current folder
    name = "initial_mutant" + str(mn)
    os.system("rm -rf " + name)
    # End sharing
    SHARING.End(experiment)
Exemplo n.º 7
0
def first_group_refinement(experiment):
    """Start all ensembles for the Design Groups"""
    # Start sharing (for file creation reasons)
    SHARING.Start(experiment)
    # Loop through the design groups
    for group in experiment:
        gn = group.number
        # Generate the name for the Design Group's calculations
        folder = "Group" + str(gn)
        try:
            os.mkdir(folder)
        except OSError:
            pass
        os.chdir(folder)
        # Start each ensemble
        for en in range(1, experiment["Ensemble Number"] + 1):
            eFolder = "Ensemble" + str(en)
            do = SHARING.claim_calculations(eFolder)
            # If this processor has started the calculations for this ensemble
            if do:
                # Make sure the experiment has the right structures and energies
                SHARING.update_Current(experiment, "../Current/", gn)
                SHARING.update_Energies(experiment, "../Current/", gn)
                # Move into the folder
                os.chdir(eFolder)
                # Make a copy of the best structures and energies for the group
                os.mkdir("Current")
                SHARING.output_Current(experiment, "./Current/", gn, 0)
                os.mkdir("Best")
                SHARING.output_Current(experiment, "./Best/", gn)
                SHARING.output_Energies(experiment, "./Best/", gn)
                # Move out of the e Folder
                os.chdir("../")
                SHARING.End(experiment)
                # Do the ensemble refinement
                ensemble_refinement(experiment, gn, en)
                SHARING.Start(experiment)
        # Move out of the folder
        os.chdir("../")
    SHARING.End(experiment)
Exemplo n.º 8
0
def Start(experiment, iteration, gn=None):
    """Create a folder to run a refinement in."""
    # Only do this when appropriate
    if not experiment["Do Refinement"] or gn != None or experiment["Activity"] \
    != "Standard":
        return False
    # Try to make the directory
    if experiment["Type"] == "Mutator":
        folder = "wildtype"
    else:
        folder = "refinement"
    try:
        os.mkdir(folder)
    except OSError:
        return False
    # Assuming that was successful, prep that folder
    folder += "/Current/"
    os.mkdir(folder)
    SHARING.output_Current(experiment, folder)
    SHARING.output_Energies(experiment, folder)
    f = open(folder + "iteration.txt", "w")
    f.write(str(iteration))
    f.close()
    return True
Exemplo n.º 9
0
def Start(experiment, iteration, gn = None):
    """Create a folder to run a refinement in."""
    # Only do this when appropriate
    if not experiment["Do Refinement"] or gn != None or experiment["Activity"] \
    != "Standard":
        return False
    # Try to make the directory
    if experiment["Type"] == "Mutator":
        folder = "wildtype"
    else:
        folder = "refinement"
    try:
        os.mkdir(folder)
    except OSError:
        return False
    # Assuming that was successful, prep that folder
    folder += "/Current/"
    os.mkdir(folder)
    SHARING.output_Current(experiment, folder)
    SHARING.output_Energies(experiment, folder)
    f = open(folder + "iteration.txt", "w")
    f.write(str(iteration))
    f.close()
    return True