def update_overview(self): db_dict = XChemMain.get_datasource_summary(self.datasource) category = ('Crystals mounted', 'Data Collection', 'Maps', 'PANDDA', 'Refinement', 'Comp Chem') N = len(category) Success = np.array([ db_dict['nr_samples'], db_dict['nr_data_collection_success'], db_dict['nr_initial_maps_available'], db_dict['nr_pandda_hits'], 5, 6 ]) Processed = np.array([0, 0, 0, db_dict['nr_pandda_processed'], 0, 0]) Pending = np.array([ 0, db_dict['nr_data_collection_pending'], db_dict['nr_initial_maps_pending'], db_dict['nr_pandda_pending'], 2, 1 ]) Failure = np.array([ db_dict['nr_samples_failed_to_mount'], db_dict['nr_data_collection_failed'], db_dict['nr_initial_maps_fail'], db_dict['nr_pandda_reject'], 2, 3 ]) ind = np.arange(N) # the x locations for the groups width = 0.35 # the width of the bars p0 = self.overview_axes.bar(ind, Success, width, color='g') p1 = self.overview_axes.bar(ind, Processed, width, color='b', bottom=Success) p2 = self.overview_axes.bar(ind, Pending, width, color='y', bottom=Success + Processed) p3 = self.overview_axes.bar(ind, Failure, width, color='r', bottom=Pending + Success + Processed) # add some text for labels, title and axes ticks self.overview_axes.set_ylabel('N') self.overview_axes.set_title('Overview') self.overview_axes.set_xticks(ind + width) self.overview_axes.set_xticklabels(category) self.overview_axes.legend( (p0[0], p1[0], p2[0], p3[0]), ('Success', 'Processed', 'Pending', 'Failure'))
def write_html_file(self, html): os.chdir(self.htmlDir) self.Logfile.insert('writing index.html') html += XChemMain.html_footer() if os.path.isfile('index.html'): os.system('/bin/rm -f index.html') f = open('index.html', 'w') f.write(html) f.close()
def update_overview(self): db_dict=XChemMain.get_datasource_summary(self.datasource) category = ( 'Crystals mounted', 'Data Collection', 'Maps', 'PANDDA', 'Refinement', 'Comp Chem' ) N = len(category) Success = np.array([ db_dict['nr_samples'], db_dict['nr_data_collection_success'], db_dict['nr_initial_maps_available'], db_dict['nr_pandda_hits'], 5, 6 ]) Processed = np.array([ 0, 0, 0, db_dict['nr_pandda_processed'], 0, 0 ]) Pending = np.array([ 0, db_dict['nr_data_collection_pending'], db_dict['nr_initial_maps_pending'], db_dict['nr_pandda_pending'], 2, 1 ]) Failure = np.array([ db_dict['nr_samples_failed_to_mount'], db_dict['nr_data_collection_failed'], db_dict['nr_initial_maps_fail'], db_dict['nr_pandda_reject'], 2, 3 ]) ind = np.arange(N) # the x locations for the groups width = 0.35 # the width of the bars p0 = self.overview_axes.bar(ind, Success, width, color='g') p1 = self.overview_axes.bar(ind, Processed, width, color='b', bottom=Success) p2 = self.overview_axes.bar(ind, Pending, width, color='y', bottom=Success+Processed) p3 = self.overview_axes.bar(ind, Failure, width, color='r', bottom=Pending+Success+Processed) # add some text for labels, title and axes ticks self.overview_axes.set_ylabel('N') self.overview_axes.set_title('Overview') self.overview_axes.set_xticks(ind + width) self.overview_axes.set_xticklabels(category) self.overview_axes.legend((p0[0], p1[0], p2[0], p3[0]), ('Success', 'Processed', 'Pending', 'Failure'))
def prepare(self): self.Logfile.insert('======== preparing HTML summary ========') self.makeFolders() self.copy_jscss() html = XChemMain.html_header() for xtal in self.db.samples_for_html_summary(): self.db_dict = self.db.get_db_dict_for_sample(xtal) self.copy_pdb(xtal) self.copy_electron_density(xtal) self.copy_ligand_files(xtal) for ligand in self.ligands_in_pdbFile(xtal): eventMap = self.find_matching_event_map(xtal, ligand) x, y, z = self.pdb.get_centre_of_gravity_of_residue(ligand) self.copy_spider_plot(xtal, ligand) pdbID = self.db_dict['Deposition_PDB_ID'] compoundImage = xtal + '_' + self.db_dict[ 'CompoundCode'] + '.png' compoundCIF = xtal + '_' + self.db_dict['CompoundCode'] + '.cif' residuePlot = xtal + '_' + ligand + '.png' pdb = xtal + '.pdb' event = xtal + '_' + ligand + '.ccp4' thumbNail = xtal + '_' + ligand + '_thumb.png' resoHigh = self.db_dict['DataProcessingResolutionHigh'] spg = self.db_dict['RefinementSpaceGroup'] unitCell = self.db_dict['DataProcessingUnitCell'] FWT = xtal + '_2fofc.ccp4' DELFWT = xtal + '_fofc.ccp4' html += XChemMain.html_table_row(xtal, pdbID, ligand, compoundImage, residuePlot, pdb, event, thumbNail, resoHigh, spg, unitCell, FWT, DELFWT) self.make_thumbnail(xtal, x, y, z, ligand, eventMap) self.prepare_for_download(xtal, pdb, event, compoundCIF, ligand) self.write_html_file(html) self.Logfile.insert( '======== finished preparing HTML summary ========')
def make_thumbnail(self, xtal, x, y, z, ligID, eventMap): self.Logfile.insert('%s: making thumbnail of for %s and %s' % (xtal, ligID, eventMap)) sampleDir = os.path.join(self.projectDir, xtal) os.chdir(sampleDir) if not os.path.isfile('%s_%s_thumb.png' % (xtal, ligID)): self.Logfile.insert('%s: preparing thumbnail image of %s' % (xtal, ligID)) XChemMain.coot_prepare_input(x, y, z, ligID, sampleDir, eventMap) XChemMain.coot_write_raster_file(ligID, sampleDir) XChemMain.render_scene(xtal, ligID, sampleDir) XChemMain.make_thumbnail(xtal, ligID, sampleDir) if os.path.isfile('%s_%s_thumb.png' % (xtal, ligID)): self.Logfile.insert('%s: managed to prepare %s_%s_thumb.png' % (xtal, xtal, ligID)) self.copy_thumbnail(xtal, sampleDir, ligID) else: self.Logfile.error('%s: could not generate %s_%s_thumb.png' % (xtal, xtal, ligID))
def settings(self, xce_object): # set XCE version xce_object.xce_version = 'v1.4.0' # general settings xce_object.allowed_unitcell_difference_percent = 12 xce_object.acceptable_low_resolution_limit_for_data = 3.5 xce_object.filename_root = '${samplename}' xce_object.data_source_set = False xce_object.max_queue_jobs = 100 ## directory settings # set current directory and direct log to it xce_object.current_directory = os.getcwd() xce_object.xce_logfile = os.path.join(xce_object.current_directory, 'xce.log') # if in the correct place, set the various directories if 'labxchem' in xce_object.current_directory: if len(xce_object.current_directory.split('/') ) >= 9 and xce_object.current_directory.split( '/' )[6] == 'processing' and xce_object.current_directory.split( '/')[8] == 'processing': xce_object.labxchem_directory = '/' + os.path.join( *xce_object.current_directory.split('/') [1:8]) # need splat operator: * xce_object.labxchem_directory_current = '/' + os.path.join( *xce_object.current_directory.split('/')[1:9] ) # labxchem_directory_current is where they actually have write permission else: xce_object.labxchem_directory = '/' + os.path.join( *xce_object.current_directory.split('/') [1:6]) # need splat operator: * xce_object.labxchem_directory_current = '/' + os.path.join( *xce_object.current_directory.split('/') [1:7]) # need splat operator: * # xce_object.labxchem_directory = '/' + os.path.join( # *xce_object.current_directory.split('/')[1:6]) # need splat operator: * xce_object.beamline_directory = os.path.join( xce_object.labxchem_directory, 'processing', 'beamline') if os.path.isdir( os.path.join(xce_object.labxchem_directory, 'processing', 'analysis', 'model_building')): xce_object.initial_model_directory = os.path.join( xce_object.labxchem_directory, 'processing', 'analysis', 'model_building') else: xce_object.initial_model_directory = os.path.join( xce_object.labxchem_directory, 'processing', 'analysis', 'initial_model') xce_object.reference_directory = os.path.join( xce_object.labxchem_directory, 'processing', 'reference') xce_object.database_directory = os.path.join( xce_object.labxchem_directory, 'processing', 'database') xce_object.panddas_directory = os.path.join( xce_object.labxchem_directory, 'processing', 'analysis', 'panddas') xce_object.datasets_summary_file = os.path.join( xce_object.database_directory, str(os.getcwd().split('/')[5]) + '_summary.pkl') xce_object.data_source_file = '' xce_object.html_export_directory = os.path.join( xce_object.labxchem_directory, 'processing', 'html') xce_object.group_deposit_directory = os.path.join( xce_object.labxchem_directory, 'processing', 'group_deposition') if os.path.isfile( os.path.join(xce_object.labxchem_directory, 'processing', 'database', 'soakDBDataFile.sqlite')): xce_object.data_source_file = 'soakDBDataFile.sqlite' xce_object.database_directory = os.path.join( xce_object.labxchem_directory, 'processing', 'database') xce_object.data_source_set = True xce_object.db = XChemDB.data_source( os.path.join(xce_object.database_directory, xce_object.data_source_file)) xce_object.db.create_missing_columns() xce_object.ccp4_scratch_directory = os.path.join( xce_object.labxchem_directory, 'processing', 'tmp') directory_list = [ xce_object.beamline_directory, os.path.join(xce_object.labxchem_directory, 'processing', 'analysis'), xce_object.initial_model_directory, xce_object.panddas_directory, xce_object.reference_directory, xce_object.database_directory, xce_object.ccp4_scratch_directory, xce_object.html_export_directory, xce_object.group_deposit_directory ] for directory in directory_list: if not os.path.isdir(directory): os.mkdir(directory) # otherwise, use the current working directory else: xce_object.labxchem_directory_current = xce_object.current_directory xce_object.beamline_directory = xce_object.current_directory xce_object.initial_model_directory = xce_object.current_directory xce_object.reference_directory = xce_object.current_directory xce_object.database_directory = xce_object.current_directory xce_object.data_source_file = '' xce_object.ccp4_scratch_directory = os.getenv('CCP4_SCR') xce_object.panddas_directory = xce_object.current_directory xce_object.datasets_summary_file = '' xce_object.group_deposit_directory = xce_object.current_directory ## deposition xce_object.deposit_dict = {} ## internal lists and dictionaries xce_object.data_collection_list = [] xce_object.visit_list = [] xce_object.target = '' xce_object.dataset_outcome_combobox_dict = {} xce_object.data_collection_dict = {} xce_object.xtal_db_dict = {} xce_object.pandda_analyse_input_table_dict = {} xce_object.dewar_configuration_dict = {} xce_object.data_collection_statistics_dict = {} xce_object.initial_model_dimple_dict = { } # contains toggle button if dimple should be run xce_object.reference_file_list = [] xce_object.all_columns_in_data_source = XChemDB.data_source(os.path.join (xce_object.database_directory, xce_object.data_source_file)) \ .return_column_list() xce_object.albula_button_dict = { } # using dials.image_viewer instead of albula, but keep name for dictionary xce_object.xtalform_dict = {} xce_object.dataset_outcome_dict = { } # contains the dataset outcome buttons xce_object.data_collection_table_dict = { } # contains the dataset table xce_object.data_collection_image_dict = {} xce_object.data_collection_column_three_dict = {} xce_object.datasets_summary_dict = {} xce_object.diffraction_data_table_dict = {} xce_object.refinement_table_dict = {} xce_object.main_data_collection_table_exists = False xce_object.timer_to_check_for_new_data_collection = QtCore.QTimer() xce_object.agamemnon = False xce_object.target_list, xce_object.visit_list = XChemMain.get_target_and_visit_list( xce_object.beamline_directory, False) xce_object.diffraction_data_dict = {} ## internal switches and flags xce_object.explorer_active = 0 xce_object.coot_running = 0 xce_object.progress_bar_start = 0 xce_object.progress_bar_step = 0 xce_object.albula = None xce_object.albula_subframes = [] xce_object.show_diffraction_image = None xce_object.gdaLogInstructions = [0, False] # can be any widget to be displayed in data collection summary tab xce_object.data_collection_details_currently_on_display = None xce_object.dataset_outcome = [ "success", "Failed - centring failed", "Failed - no diffraction", "Failed - processing", "Failed - loop empty", "Failed - loop broken", "Failed - low resolution", "Failed - no X-rays", "Failed - unknown" ] xce_object.refinement_stage = [ '0 - All Datasets', '1 - Analysis Pending', '2 - PANDDA model', '3 - In Refinement', '4 - CompChem ready', '5 - Deposition ready', '6 - Deposited' ] self.set_xce_logfile(xce_object) ## external software packages xce_object.using_remote_qsub_submission = False xce_object.remote_qsub_submission = "/usr/bin/ssh <dls fed ID>@nx.diamond.ac.uk 'module load global/cluster; qsub'" xce_object.update_log = XChemLog.updateLog(xce_object.xce_logfile) xce_object.update_log.insert('new session started') xce_object.diffraction_data_directory = xce_object.current_directory xce_object.diffraction_data_search_info = 'n/a' xce_object.diffraction_data_reference_mtz = 'ignore' xce_object.html_export_directory = os.getcwd() xce_object.external_software = XChemUtils.external_software( xce_object.xce_logfile).check() xce_object.second_cif_file = None software_list = ['acedrg', 'phenix.elbow', 'grade'] for software in software_list: if xce_object.external_software[software]: xce_object.restraints_program = str(software) xce_object.update_log.insert( 'will use ' + str(software) + ' for generation of ligand coordinates and' ' restraints') else: xce_object.restraints_program = '' xce_object.update_log.insert( 'No program for generation of ligand coordinates and restraints available!' )
def setup(self, xce_object): ################################################################################################################ # # # DATASETS TAB # # # ################################################################################################################ # define subtab list, widget and dict datasets_tab_list = ['Summary', 'Reprocess'] xce_object.datasets_tab_widget = QtGui.QTabWidget() xce_object.datasets_tab_dict = {} # make subtabs self.layout_funcs.make_tab_dict(datasets_tab_list, xce_object.datasets_tab_widget, xce_object.datasets_tab_dict) # main body - things that are always displayed # add a container to hold everythting and add to main tab layout xce_object.datasets_data_collection_vbox = QtGui.QVBoxLayout() # add a horizontal box to hold option to autocheck for new data xce_object.autocheck_hbox = QtGui.QHBoxLayout() # checkbox for autocollect xce_object.check_for_new_data_collection = QtGui.QCheckBox('Check for new data collection every two minutes') xce_object.check_for_new_data_collection = QtGui.QCheckBox('Check for new data collection every two minutes') self.layout_funcs.add_checkbox(xce_object, xce_object.check_for_new_data_collection, 'xce_object.continously_check_for_new_data_collection') # select target dropdown select_target_label = QtGui.QLabel('<b>Select Target: </b>') select_target_label.setAlignment(QtCore.Qt.AlignRight | QtCore.Qt.AlignVCenter) xce_object.target_selection_combobox = QtGui.QComboBox() xce_object.populate_target_selection_combobox(xce_object.target_selection_combobox) xce_object.target_selection_combobox.activated[str].connect(xce_object.target_selection_combobox_activated) xce_object.target = str(xce_object.target_selection_combobox.currentText()) # array defining order of xce_objects to add xce_object.autocheck_hbox_widgets = [xce_object.check_for_new_data_collection, select_target_label, xce_object.target_selection_combobox] self.layout_funcs.add_to_box(xce_object.autocheck_hbox, xce_object.autocheck_hbox_widgets) # add xce_objects in order # add target dropdown to top bar xce_object.datasets_data_collection_vbox.addLayout(xce_object.autocheck_hbox) # summary sub-tab # table xce_object.datasets_summary_table = QtGui.QTableWidget() self.layout_funcs.table_setup(xce_object.datasets_summary_table, xce_object.datasets_summary_table_columns) xce_object.datasets_summarys_vbox_for_table = QtGui.QVBoxLayout() # setup layout to hold table xce_object.datasets_summarys_vbox_for_table.addWidget(xce_object.datasets_summary_table) # add table to layout xce_object.datasets_summarys_vbox_for_details = QtGui.QVBoxLayout() # vbox for details xce_object.data_collection_details_currently_on_display = None # switch for displaying/updating table xce_object.datasets_data_collection_vbox.addWidget(xce_object.datasets_tab_widget) # add subtab to main tab # reprocessing sub-tab # top options # data collection label dc_label = QtGui.QLabel('<b>Data collection directory: </b>') dc_label.setAlignment(QtCore.Qt.AlignLeft | QtCore.Qt.AlignVCenter) # align left and centre of container xce_object.diffraction_data_dir_label = QtGui.QLabel( xce_object.diffraction_data_directory) # add directory as text xce_object.diffraction_data_dir_label.setAlignment( QtCore.Qt.AlignLeft | QtCore.Qt.AlignVCenter) # align as above # select label select_button = QtGui.QPushButton("Select") select_button.clicked.connect(xce_object.select_diffraction_data_directory) # attach file open dialogue # search button search_button = QtGui.QPushButton("Search Datasets") search_button.clicked.connect(xce_object.search_for_datasets) # search for datasets in the selected directory # search info xce_object.diffraction_data_search_label = QtGui.QLabel(xce_object.diffraction_data_search_info) # translate label translate_label = QtGui.QLabel('<b>Translate:</b> datasetID -> sampleID') translate_label.setAlignment(QtCore.Qt.AlignCenter) # align in centre of container # CSV button csv_button = QtGui.QPushButton('Open CSV') csv_button.setStyleSheet("QPushButton { padding: 1px; margin: 1px }") csv_button.clicked.connect(xce_object.translate_datasetID_to_sampleID) # open the relevant csv file # create hbox to hold everything and add widgets to it xce_object.hbox_select = QtGui.QHBoxLayout() # top options box xce_object.hbox_select_widgets = [dc_label, xce_object.diffraction_data_dir_label, select_button, search_button, xce_object.diffraction_data_search_label, translate_label, csv_button] # array defining order of xce_objects to be added self.layout_funcs.add_to_box(xce_object.hbox_select, xce_object.hbox_select_widgets) # add xce_objects in order # frame to hold everything frame_select = QtGui.QFrame() frame_select.setLayout(xce_object.hbox_select) # apply to containing frame # table - main body xce_object.datasets_reprocess_table = QtGui.QTableWidget() self.layout_funcs.table_setup(xce_object.datasets_reprocess_table, xce_object.datasets_reprocess_columns) # setup # create context menu - no idea where this lives... xce_object.popMenu_for_datasets_reprocess_table = QtGui.QMenu() run_xia2_on_selected = QtGui.QAction("mark selected for reprocessing", xce_object.window) run_xia2_on_selected.triggered.connect(xce_object.select_sample_for_xia2) xce_object.popMenu_for_datasets_reprocess_table.addAction(run_xia2_on_selected) xce_object.datasets_reprocess_table.setContextMenuPolicy(QtCore.Qt.CustomContextMenu) xce_object.datasets_reprocess_table.customContextMenuRequested.connect( xce_object.on_context_menu_reprocess_data) # options at bottom of tab # data processing label label = QtGui.QLabel('<b>Data processing protocol: </b>') label.setAlignment(QtCore.Qt.AlignLeft | QtCore.Qt.AlignVCenter) # option checkboxes xce_object.xia2_3d_checkbox = QtGui.QCheckBox('xia2 3d') xce_object.xia2_3dii_checkbox = QtGui.QCheckBox('xia2 3dii') xce_object.xia2_dials_checkbox = QtGui.QCheckBox('Dials') # spacegroup label sg_label = QtGui.QLabel('<b>Space Group:</b>') # spacegroup dropdown menu xce_object.reprocess_space_group_comboxbox = QtGui.QComboBox() xce_object.reprocess_space_group_comboxbox.addItem('ignore') for sg in XChemMain.space_group_list(): xce_object.reprocess_space_group_comboxbox.addItem(sg) # mtz label mtz_label = QtGui.QLabel('<b>Reference MTZ:</b>') # file label xce_object.reprocess_reference_mtz_file_label = QtGui.QLabel(xce_object.diffraction_data_reference_mtz) # select button select_button = QtGui.QPushButton("Select") select_button.clicked.connect(xce_object.select_reprocess_reference_mtz) # define order of widgets to be added to options hbox hbox_options_widgets = [label, xce_object.xia2_3d_checkbox, xce_object.xia2_3dii_checkbox, xce_object.xia2_dials_checkbox, sg_label, xce_object.reprocess_space_group_comboxbox, mtz_label, xce_object.reprocess_reference_mtz_file_label, select_button] # create hbox, add everything to it and then put it in a frame hbox_options = QtGui.QHBoxLayout() self.layout_funcs.add_to_box(hbox_options, hbox_options_widgets) frame_options = QtGui.QFrame() frame_options.setLayout(hbox_options) # following are contained in vboxes # res limit isig label label = QtGui.QLabel('<b>Res.\nLimit:</b>\nMn<I/sig(I)>') label.setAlignment(QtCore.Qt.AlignCenter) # res limit isig dropdown menu xce_object.reprocess_isigma_combobox = QtGui.QComboBox() misigma = ['default', '4', '3', '2.5', '2', '1.5', '1', '0.5'] self.layout_funcs.populate_combobox(misigma, xce_object.reprocess_isigma_combobox) xce_object.reprocess_isigma_combobox.setCurrentIndex(0) xce_object.reprocess_isigma_combobox.setStyleSheet(" QComboBox { padding: 1px; margin: 1px }") # create vertical box to add labels and dropdowns to, create box and put in frame vbox_isigma = QtGui.QVBoxLayout() vbox_isigma_widgets = [label, xce_object.reprocess_isigma_combobox] self.layout_funcs.add_to_box(vbox_isigma, vbox_isigma_widgets) frame_isigma = QtGui.QFrame() frame_isigma.setLayout(vbox_isigma) # res limit cc half label res_cc_label = QtGui.QLabel('<b>Res.\nLimit:</b>\nCC 1/2') res_cc_label.setAlignment(QtCore.Qt.AlignCenter) # res limit cc half dropdown xce_object.reprocess_cc_half_combobox = QtGui.QComboBox() cc_half = ['default', '0.9', '0.8', '0.7', '0.6', '0.5', '0.4', '0.3', '0.2', '0.1'] self.layout_funcs.populate_combobox(cc_half, xce_object.reprocess_cc_half_combobox) xce_object.reprocess_cc_half_combobox.setCurrentIndex(0) xce_object.reprocess_cc_half_combobox.setStyleSheet(" QComboBox { padding: 1px; margin: 1px }") # create a vbox for label and dropdown, and add items to it vbox_cc_half = QtGui.QVBoxLayout() vbox_cc_half_widgets = [res_cc_label, xce_object.reprocess_cc_half_combobox] self.layout_funcs.add_to_box(vbox_cc_half, vbox_cc_half_widgets) # create frame to hold everything and add vbox frame_cc_half = QtGui.QFrame() frame_cc_half.setLayout(vbox_cc_half) # create a hbox to hold the bottom frames and add everything data_protocol_hbox = QtGui.QHBoxLayout() data_protocol_hbox_widgets = [frame_options, frame_isigma, frame_cc_half] self.layout_funcs.add_to_box(data_protocol_hbox, data_protocol_hbox_widgets) bottom_options_frame = QtGui.QFrame() # create frame to hold everything (horizontal) bottom_options_frame.setLayout(data_protocol_hbox) # code below sets final layout for whole subtab xce_object.reprocess_vbox = QtGui.QVBoxLayout() # box to hold reprocessing subtab content xce_object.reprocess_hbox_widgets = [frame_select, xce_object.datasets_reprocess_table, bottom_options_frame] self.layout_funcs.add_to_box(xce_object.reprocess_vbox, xce_object.reprocess_hbox_widgets)
def prepare(self): self.Logfile.insert('======== preparing HTML summary ========') self.makeFolders() self.copy_jscss() html = XChemMain.html_header() firstFile = True for xtal in self.db.samples_for_html_summary(): self.db_dict = self.db.get_db_dict_for_sample(xtal) if firstFile: if self.db_dict['ProteinName'] == 'None': self.Logfile.warning('could not determine protein name') try: self.protein_name = xtal.split('-')[0] self.Logfile.warning( 'xtal name = %s => setting protein name to %s' % (xtal, self.protein_name)) except IndexError: self.Logfile.warning( 'could not determine protein name from cystal name; setting to None' ) self.protein_name = '' else: self.protein_name = self.db_dict['ProteinName'] self.Logfile.insert('protein name is: ' + self.protein_name) self.copy_pdb(xtal) self.copy_mtz(xtal) # self.copy_electron_density(xtal) self.copy_ligand_files(xtal) for ligand in self.ligands_in_pdbFile(xtal): ligName = ligand.split('-')[0] ligChain = ligand.split('-')[1] ligNumber = ligand.split('-')[2] eventMap = self.find_matching_event_map_from_database( xtal, ligand) if eventMap: self.cut_and_copy_map(xtal, ligand + '.pdb', eventMap, xtal + '_' + ligand + '_event.ccp4', 'F', 'PHIF') x, y, z = self.pdb.get_centre_of_gravity_of_residue(ligand) self.copy_spider_plot(xtal, ligand) pdbID = self.db_dict['Deposition_PDB_ID'] compoundImage = xtal + '_' + self.db_dict[ 'CompoundCode'] + '.png' compoundCIF = xtal + '_' + self.db_dict['CompoundCode'] + '.cif' residuePlot = xtal + '_' + ligand + '.png' pdb = xtal + '.pdb' event = xtal + '_' + ligand + '_event.ccp4' thumbNail = xtal + '_' + ligand + '_thumb.png' resoHigh = self.db_dict['DataProcessingResolutionHigh'] spg = self.db_dict['RefinementSpaceGroup'] unitCell = self.db_dict['DataProcessingUnitCell'] os.chdir(os.path.join(self.projectDir, xtal)) FWT = xtal + '-' + ligand + '_2fofc.ccp4' self.cut_and_copy_map(xtal, ligand + '.pdb', '2fofc.map', FWT, 'FWT', 'PHWT') DELFWT = xtal + '-' + ligand + '_fofc.ccp4' self.cut_and_copy_map(xtal, ligand + '.pdb', 'fofc.map', DELFWT, 'DELFWT', 'PHDELWT') ligConfidence = self.db.get_ligand_confidence_for_ligand( xtal, ligChain, ligNumber, ligName) if ligConfidence.startswith('0'): self.Logfile.warning( '%s: ligand confidence of %s-%s-%s is %s; ignoring...' % (xtal, ligChain, ligNumber, ligName, ligConfidence)) continue modelStatus = self.db_dict['RefinementOutcome'] if firstFile: html += XChemMain.html_ngl( pdb, eventMap.replace(self.projectDir, ''), FWT, DELFWT, ligand) html += XChemMain.html_download(self.protein_name) html += XChemMain.html_guide() html += XChemMain.html_table_header() firstFile = False html += XChemMain.html_table_row(xtal, pdbID, ligand, compoundImage, residuePlot, pdb, event, thumbNail, resoHigh, spg, unitCell, FWT, DELFWT, ligConfidence, modelStatus) self.make_thumbnail(xtal, x, y, z, ligand, eventMap) self.prepare_for_download(xtal, pdb, event, compoundCIF, ligand) self.prepare_zip_archives() # html = XChemMain.html_download_all_section(html,self.protein_name) self.write_html_file(html) self.Logfile.insert( '======== finished preparing HTML summary ========')
def prepare(self, whichSamples): self.Logfile.insert('======== preparing HTML summary ========') self.makeFolders() self.copy_jscss() html = XChemMain.html_header() firstFile = True for xtal in self.db.samples_for_html_summary(whichSamples): self.db_dict = self.db.get_db_dict_for_sample(xtal) if firstFile: if self.db_dict['ProteinName'] == 'None': self.Logfile.warning('could not determine protein name') try: self.protein_name = xtal.split('-')[0] self.Logfile.warning( 'xtal name = %s => setting protein name to %s' % (xtal, self.protein_name)) except IndexError: self.Logfile.warning( 'could not determine protein name from cystal name; setting to None' ) self.protein_name = '' else: self.protein_name = self.db_dict['ProteinName'] self.Logfile.insert('protein name is: ' + self.protein_name) self.copy_pdb(xtal) self.copy_mtz(xtal) # self.copy_electron_density(xtal) self.copy_ligand_files(xtal) os.chdir(os.path.join(self.projectDir, xtal)) ligandDict = XChemUtils.pdbtools_gemmi( 'refine.pdb').center_of_mass_ligand_dict('LIG') self.Logfile.insert( xtal + ': saving ligand(s) of type LIG in refine.pdb as PDB files...') XChemUtils.pdbtools_gemmi('refine.pdb').save_ligands_to_pdb('LIG') for ligand in ligandDict: self.Logfile.insert(xtal + ': current ligand -> ' + ligand) os.chdir(os.path.join(self.projectDir, xtal)) # for ligand in self.ligands_in_pdbFile(xtal): ligName = ligand.split('-')[0] ligChain = ligand.split('-')[1] ligNumber = ligand.split('-')[2] # eventMap = self.find_matching_event_map_from_database(xtal, ligand) # if eventMap: # self.Logfile.insert('%s: using the following event map -> %s' %(xtal,eventMap)) # self.cut_and_copy_map(xtal, ligand+'.pdb', eventMap, xtal + '_' + ligand + '_event.ccp4','F','PHIF') # eventMap = xtal + '_' + ligand + '_event.ccp4' # else: # self.Logfile.error('%s: value of event map -> %s' %(xtal,eventMap)) eventMap = '' # self.Logfile.insert(xtal + ': looking for' + xtal + '_' + ligand + '_event.ccp4') if os.path.isfile(xtal + '_' + ligand + '_event.ccp4'): eventMap = xtal + '_' + ligand + '_event.ccp4' # self.Logfile.insert(xtal + ': found ' + eventMap) # else: # self.Logfile.error(xtal + ': cannot find' + xtal + '_' + ligand + '_event.ccp4') # x,y,z = self.pdb.get_centre_of_gravity_of_residue(ligand) x = ligandDict[ligand][0] y = ligandDict[ligand][1] z = ligandDict[ligand][2] self.copy_spider_plot(xtal, ligand) pdbID = self.db_dict['Deposition_PDB_ID'] compoundImage = xtal + '_' + self.db_dict[ 'CompoundCode'] + '.png' compoundCIF = xtal + '_' + self.db_dict['CompoundCode'] + '.cif' residuePlot = xtal + '_' + ligand + '.png' pdb = xtal + '.pdb' event = xtal + '_' + ligand + '_event.ccp4' thumbNail = xtal + '_' + ligand + '_thumb.png' resoHigh = self.db_dict['DataProcessingResolutionHigh'] spg = self.db_dict['RefinementSpaceGroup'] unitCell = self.db_dict['DataProcessingUnitCell'] t = '' for ax in unitCell.split(): t += str(round(float(ax), 1)) + ' ' unitCell = t[:-1] os.chdir(os.path.join(self.projectDir, xtal)) # FWT = xtal + '-' + ligand + '_2fofc.ccp4' # self.cut_and_copy_map(xtal, ligand + '.pdb', '2fofc.map', FWT,'FWT','PHWT') # DELFWT = xtal + '-' + ligand + '_fofc.ccp4' # self.cut_and_copy_map(xtal, ligand + '.pdb', 'fofc.map', DELFWT,'DELFWT','PHDELWT') if os.path.isfile('refine.mtz'): self.Logfile.insert('%s: found refine.mtz' % xtal) FWTmap, DELFWTmap = self.prepare_e_density_maps( xtal, ligand) self.copy_electron_density(xtal, ligand, eventMap) ligConfidence = self.db.get_ligand_confidence_for_ligand( xtal, ligChain, ligNumber, ligName) if ligConfidence.startswith('0'): self.Logfile.warning( '%s: ligand confidence of %s-%s-%s is %s; ignoring...' % (xtal, ligChain, ligNumber, ligName, ligConfidence)) self.Logfile.warning( '%s: this seems unlikely because this structure is apparently ready for deposition' % xtal) self.Logfile.warning( '%s: will set it to "not assigned" for now, but please update in soakDB' % xtal) ligConfidence = 'not assigned' modelStatus = self.db_dict['RefinementOutcome'] if firstFile: html += XChemMain.html_ngl( pdb, eventMap.replace(self.projectDir, ''), FWTmap, DELFWTmap, ligand) html += XChemMain.html_download(self.protein_name) html += XChemMain.html_guide() html += XChemMain.html_table_header() firstFile = False html += XChemMain.html_table_row(xtal, pdbID, ligand, compoundImage, residuePlot, pdb, event, thumbNail, resoHigh, spg, unitCell, FWTmap, DELFWTmap, ligConfidence, modelStatus) self.make_thumbnail(xtal, x, y, z, ligand, eventMap) self.prepare_for_download(xtal, pdb, event, compoundCIF, ligand) self.prepare_zip_archives() # html = XChemMain.html_download_all_section(html,self.protein_name) self.write_html_file(html) self.Logfile.insert( '======== finished preparing HTML summary ========')