def update_ligand_information_in_panddaTable(inital_model_directory,xtal): if os.path.isfile(os.path.join(inital_model_directory, xtal, 'refine.pdb')): ligands_in_file=pdbtools(os.path.join(inital_model_directory, xtal, 'refine.pdb')).find_xce_ligand_details() for ligand in ligands_in_file: residue_name= ligand[0] residue_chain= ligand[1] residue_number= ligand[2] residue_altLoc= ligand[3] residue_xyz = pdbtools(os.path.join(inital_model_directory, xtal, 'refine.pdb')).get_center_of_gravity_of_residue_ish(residue_chain, residue_number) event = db.execute_statement("select PANDDA_site_x,PANDDA_site_y,PANDDA_site_z,PANDDA_site_index from panddaTable where CrystalName='%s'" % xtal) for coord in event: db_pandda_dict = {} event_x = float(str(coord[0])) event_y = float(str(coord[1])) event_z = float(str(coord[2])) site_index = str(coord[3]) distance = misc().calculate_distance_between_coordinates(residue_xyz[0], residue_xyz[1],residue_xyz[2], event_x, event_y,event_z) # if coordinate of ligand and event are closer than 7A, then we assume they belong together if distance < 7: db_pandda_dict['PANDDA_site_ligand_resname'] = residue_name db_pandda_dict['PANDDA_site_ligand_chain'] = residue_chain db_pandda_dict['PANDDA_site_ligand_sequence_number'] = residue_number db_pandda_dict['PANDDA_site_ligand_altLoc'] = residue_altLoc db_pandda_dict['PANDDA_site_ligand_placed'] = 'True' if db_pandda_dict != {}: print '==> XCE: updating pandda Table of data source' db.update_panddaTable(xtal, site_index, db_pandda_dict)
def update_ligand_information_in_panddaTable(inital_model_directory, xtal): if os.path.isfile(os.path.join(inital_model_directory, xtal, 'refine.pdb')): # ligands_in_file=pdbtools(os.path.join(inital_model_directory, xtal, 'refine.pdb')).find_xce_ligand_details() ligands_in_file = pdbtools( os.path.join(inital_model_directory, xtal, 'refine.pdb')).get_residues_with_resname('LIG') for ligand in ligands_in_file: # residue_name= ligand[0] # residue_chain= ligand[1] # residue_number= ligand[2] # residue_altLoc= ligand[3] residue_name = ligand[0] residue_chain = ligand[2] residue_number = ligand[1] residue_altLoc = 'X' residue_xyz = pdbtools( os.path.join( inital_model_directory, xtal, 'refine.pdb')).get_center_of_gravity_of_residue_ish( residue_chain, residue_number) event = db.execute_statement( "select PANDDA_site_x,PANDDA_site_y,PANDDA_site_z,PANDDA_site_index from panddaTable where CrystalName='{0!s}'" .format(xtal)) for coord in event: db_pandda_dict = {} event_x = float(str(coord[0])) event_y = float(str(coord[1])) event_z = float(str(coord[2])) site_index = str(coord[3]) distance = misc().calculate_distance_between_coordinates( residue_xyz[0], residue_xyz[1], residue_xyz[2], event_x, event_y, event_z) # if coordinate of ligand and event are closer than 7A, then we assume they belong together if distance < 7: db_pandda_dict['PANDDA_site_ligand_resname'] = residue_name db_pandda_dict['PANDDA_site_ligand_chain'] = residue_chain db_pandda_dict[ 'PANDDA_site_ligand_sequence_number'] = residue_number db_pandda_dict[ 'PANDDA_site_ligand_altLoc'] = residue_altLoc db_pandda_dict['PANDDA_site_ligand_placed'] = 'True' if db_pandda_dict != {}: print '==> XCE: updating pandda Table of data source' db.update_panddaTable(xtal, site_index, db_pandda_dict)
def parse_ligand_validation(inital_model_directory,refinement_directory,xtal): if os.path.isfile(os.path.join(refinement_directory, 'residue_scores.csv')): with open(os.path.join(refinement_directory, 'residue_scores.csv'), 'rb') as csv_import: csv_dict = csv.DictReader(csv_import) for i, line in enumerate(csv_dict): db_pandda_dict = {} residue = line[''] if len(residue.split('-')) == 3: residue_name = residue.split('-')[0] print residue_name residue_chain = residue.split('-')[1] residue_number = residue.split('-')[2] residue_xyz = pdbtools(os.path.join(inital_model_directory, xtal, 'refine.pdb')).get_center_of_gravity_of_residue_ish(residue_chain, residue_number) event = db.execute_statement("select PANDDA_site_x,PANDDA_site_y,PANDDA_site_z,PANDDA_site_index from panddaTable where CrystalName='%s'" % xtal) for coord in event: db_pandda_dict = {} event_x = float(str(coord[0])) event_y = float(str(coord[1])) event_z = float(str(coord[2])) site_index = str(coord[3]) distance = misc().calculate_distance_between_coordinates(residue_xyz[0], residue_xyz[1],residue_xyz[2], event_x, event_y,event_z) print 'distance',distance # if coordinate of ligand and event are closer than 7A, then we assume they belong together if distance < 7: db_pandda_dict['PANDDA_site_ligand_id'] = residue db_pandda_dict['PANDDA_site_occupancy'] = line['Occupancy'] db_pandda_dict['PANDDA_site_B_average'] = line['Average B-factor (Residue)'] db_pandda_dict['PANDDA_site_B_ratio_residue_surroundings'] = line['Surroundings B-factor Ratio'] db_pandda_dict['PANDDA_site_rmsd'] = line['Model RMSD'] db_pandda_dict['PANDDA_site_RSCC'] = line['RSCC'] db_pandda_dict['PANDDA_site_RSR'] = line['RSR'] db_pandda_dict['PANDDA_site_RSZD'] = line['RSZD'] if os.path.isfile(os.path.join(refinement_directory, 'residue_plots', residue + '.png')): db_pandda_dict['PANDDA_site_spider_plot'] = os.path.join(refinement_directory, 'residue_plots', residue + '.png') else: db_pandda_dict['PANDDA_site_spider_plot'] = '' if db_pandda_dict != {}: print '==> XCE: updating pandda Table of data source' db.update_panddaTable(xtal, site_index, db_pandda_dict)
def parse_ligand_validation(inital_model_directory, refinement_directory, xtal): if os.path.isfile(os.path.join(refinement_directory, 'residue_scores.csv')): with open(os.path.join(refinement_directory, 'residue_scores.csv'), 'rb') as csv_import: csv_dict = csv.DictReader(csv_import) for i, line in enumerate(csv_dict): db_pandda_dict = {} residue = line[''].replace(' ', '') residueFilename = line[''] if len(residue.split('-')) == 2: # residue_name = residue.split('-')[0] # print residue_name residue_chain = residue.split('-')[0] residue_number = residue.split('-')[1] residue_xyz = pdbtools( os.path.join(inital_model_directory, xtal, 'refine.pdb' )).get_center_of_gravity_of_residue_ish( residue_chain, residue_number) event = db.execute_statement( "select PANDDA_site_x,PANDDA_site_y,PANDDA_site_z,PANDDA_site_index from panddaTable where CrystalName='{0!s}'" .format(xtal)) for coord in event: db_pandda_dict = {} event_x = float(str(coord[0])) event_y = float(str(coord[1])) event_z = float(str(coord[2])) site_index = str(coord[3]) distance = misc( ).calculate_distance_between_coordinates( residue_xyz[0], residue_xyz[1], residue_xyz[2], event_x, event_y, event_z) print 'distance', distance # if coordinate of ligand and event are closer than 7A, then we assume they belong together if distance < 7: db_pandda_dict['PANDDA_site_ligand_id'] = residue db_pandda_dict['PANDDA_site_occupancy'] = line[ 'Occupancy'] db_pandda_dict['PANDDA_site_B_average'] = line[ 'Average B-factor (Residue)'] db_pandda_dict[ 'PANDDA_site_B_ratio_residue_surroundings'] = line[ 'Surroundings B-factor Ratio'] db_pandda_dict['PANDDA_site_rmsd'] = line[ 'Model RMSD'] db_pandda_dict['PANDDA_site_RSCC'] = line['RSCC'] db_pandda_dict['PANDDA_site_RSR'] = line['RSR'] db_pandda_dict['PANDDA_site_RSZD'] = line['RSZD'] if os.path.isfile( os.path.join(refinement_directory, 'residue_plots', residueFilename + '.png')): db_pandda_dict[ 'PANDDA_site_spider_plot'] = os.path.join( refinement_directory, 'residue_plots', residueFilename + '.png') else: db_pandda_dict['PANDDA_site_spider_plot'] = '' if db_pandda_dict != {}: print '==> XCE: updating pandda Table of data source' db.update_panddaTable(xtal, site_index, db_pandda_dict)