frag_pele/Growing/template_selector.py
def trajectory_selector(output, path_to_file="/growing_output", report="report", trajectory="trajectory.pdb",
                        criteria="Binding Energy"):
    """
    This function select the step of a trajectory of PELE
    with the minimum value of the criteria selected
    and extract it as a single pdb file.
    """
    # Storing the trajectory as a string
    with open(os.path.join(path_to_file, trajectory), 'r') as input_file:
        file_content = input_file.read()

    # Storing the report file as pandas data-frame
    data = pd.read_csv(os.path.join(path_to_file, report), sep='    ', engine='python')

    # Now, select only the columns correspondent to the numberOfAcceptedPeleSteps
    # (if you sum 1 to this number you can obtain the step in the trajectory) and the criteria
    selected_data = data.loc[1:, ['numberOfAcceptedPeleSteps', criteria]]

    # Find the minimum value of the criteria
    min_energy = selected_data.min(axis=0)[1]

    # Once we have this value, find the step that correspond to this minimum value
    min_trajectory = selected_data.loc[selected_data[criteria] == min_energy, 'numberOfAcceptedPeleSteps'].iloc[0]

    # Using this step number we will select the MODEL (step of the trajectory) that correspond to this value.
    # We do min_trajectory+1 because the difference between accepted steps and models numbers
    trajectory_selected = re.search('MODEL\s+%d(.*?)ENDMDL' %int(min_trajectory+1), file_content, re.DOTALL)

    # Writing this step into a PDB with a single structure. We will do it with a list in order to reduce
    # computing time
    output_file_content = []
    output_file_content.append("MODEL     {}".format(int(min_trajectory+1)))
    output_file_content.append("{}".format(trajectory_selected.group(1)))
    output_file_content.append("ENDMDL")
    output_file_content = "\n".join(output_file_content)
    with open(output, 'w') as output_file:
        output_file.write(output_file_content)
        logger.info(":::.MODEL     {} has been selected.:::".format(int(min_trajectory + 1)))

    This function select the step of a trajectory of PELE
    with the minimum value of the criteria selected
    and extract it as a single pdb file.
    
This function select the step of a trajectory of PELE
with the minimum value of the criteria selected
and extract it as a single pdb file.
This function select the step of a trajectory of PELE with the minimum value of the criteria selected and extract it as a single pdb file .
def trajectory_selector(output, path_to_file="/growing_output", report="report", trajectory="trajectory.pdb",
                        criteria="Binding Energy"):
    with open(os.path.join(path_to_file, trajectory), 'r') as input_file:
        file_content = input_file.read()
    data = pd.read_csv(os.path.join(path_to_file, report), sep='    ', engine='python')
    selected_data = data.loc[1:, ['numberOfAcceptedPeleSteps', criteria]]
    min_energy = selected_data.min(axis=0)[1]
    min_trajectory = selected_data.loc[selected_data[criteria] == min_energy, 'numberOfAcceptedPeleSteps'].iloc[0]
    trajectory_selected = re.search('MODEL\s+%d(.*?)ENDMDL' %int(min_trajectory+1), file_content, re.DOTALL)
    output_file_content = []
    output_file_content.append("MODEL     {}".format(int(min_trajectory+1)))
    output_file_content.append("{}".format(trajectory_selected.group(1)))
    output_file_content.append("ENDMDL")
    output_file_content = "\n".join(output_file_content)
    with open(output, 'w') as output_file:
        output_file.write(output_file_content)
        logger.info(":::.MODEL     {} has been selected.:::".format(int(min_trajectory + 1)))
def trajectory_selector ( output , path_to_file = "/growing_output" , report = "report" , trajectory = "trajectory.pdb" , criteria = "Binding Energy" ) : with open ( os . path . join ( path_to_file , trajectory ) , 'r' ) as input_file : file_content = input_file . read ( ) data = pd . read_csv ( os . path . join ( path_to_file , report ) , sep = '    ' , engine = 'python' ) selected_data = data . loc [ 1 : , [ 'numberOfAcceptedPeleSteps' , criteria ] ] min_energy = selected_data . min ( axis = 0 ) [ 1 ] min_trajectory = selected_data . loc [ selected_data [ criteria ] == min_energy , 'numberOfAcceptedPeleSteps' ] . iloc [ 0 ] trajectory_selected = re . search ( 'MODEL\s+%d(.*?)ENDMDL' % int ( min_trajectory + 1 ) , file_content , re . DOTALL ) output_file_content = [ ] output_file_content . append ( "MODEL     {}" . format ( int ( min_trajectory + 1 ) ) ) output_file_content . append ( "{}" . format ( trajectory_selected . group ( 1 ) ) ) output_file_content . append ( "ENDMDL" ) output_file_content = "\n" . join ( output_file_content ) with open ( output , 'w' ) as output_file : output_file . write ( output_file_content ) logger . info ( ":::.MODEL     {} has been selected.:::" . format ( int ( min_trajectory + 1 ) ) )
This function select the step of a trajectory of PELE
with the minimum value of the criteria selected
and extract it as a single pdb file.
This function select the step of a trajectory of PELE with the minimum value of the criteria selected and extract it as a single pdb file .
"""
    This function select the step of a trajectory of PELE
    with the minimum value of the criteria selected
    and extract it as a single pdb file.
    """ # Storing the trajectory as a string # Storing the report file as pandas data-frame # Now, select only the columns correspondent to the numberOfAcceptedPeleSteps # (if you sum 1 to this number you can obtain the step in the trajectory) and the criteria # Find the minimum value of the criteria # Once we have this value, find the step that correspond to this minimum value # Using this step number we will select the MODEL (step of the trajectory) that correspond to this value. # We do min_trajectory+1 because the difference between accepted steps and models numbers # Writing this step into a PDB with a single structure. We will do it with a list in order to reduce # computing time
output
path_to_file
report
trajectory
criteria