Пример #1
0
 def merge_ligand_into_protein(self,widget):
     print '===> XCE: merge ligand into protein structure'
     # merge_molecules(list(imols), imol) e.g. merge_molecules([1],0)
     coot.merge_molecules_py([self.mol_dict['ligand']],self.mol_dict['protein'])
     print '===> XCE: deleting ligand molecule'
     coot.close_molecule(self.mol_dict['ligand'])
Пример #2
0
    def RefreshData(self):
        # initialize Refinement library
        self.Refine=XChemRefine.Refine(self.project_directory,self.xtalID,self.compoundID,self.data_source)
        self.Serial=self.Refine.GetSerial()
        if self.Serial==1:
            # i.e. no refinement has been done; data is probably straight out of dimple
            if os.path.isfile(os.path.join(self.project_directory,self.xtalID,self.pdb_style)):
                print '==> XCE: updating quality indicators in data source for '+self.xtalID
                XChemUtils.parse().update_datasource_with_PDBheader(self.xtalID,self.data_source,os.path.join(self.project_directory,self.xtalID,self.pdb_style))
                XChemUtils.parse().update_datasource_with_phenix_validation_summary(self.xtalID,self.data_source,'')   # '' because file does not exist
            elif os.path.isfile(os.path.join(self.project_directory,self.xtalID,'dimple.pdb')):
                print '==> XCE: updating quality indicators in data source for '+self.xtalID
                XChemUtils.parse().update_datasource_with_PDBheader(self.xtalID,self.data_source,os.path.join(self.project_directory,self.xtalID,'dimple.pdb'))
                XChemUtils.parse().update_datasource_with_phenix_validation_summary(self.xtalID,self.data_source,'')   # '' because file does not exist

        # all this information is now updated in the datasource after each refinement cycle
        self.QualityIndicators=self.db.get_db_dict_for_sample(self.xtalID)
        if int(self.selected_site[0]) > 0:
            self.spider_plot_data=self.db.get_db_pandda_dict_for_sample_and_site(self.xtalID,self.selected_site[0])
            self.ligandIDValue.set_label(self.spider_plot_data['PANDDA_site_ligand_id'])
            try:
                self.ligand_occupancyValue.set_label(           str(round(float(self.spider_plot_data['PANDDA_site_occupancy']),2)) )
                self.ligand_BaverageValue.set_label(            str(round(float(self.spider_plot_data['PANDDA_site_B_average']),2)) )
                self.ligand_BratioSurroundingsValue.set_label(  str(round(float(self.spider_plot_data['PANDDA_site_B_ratio_residue_surroundings']),2)) )
                self.ligand_RSCCValue.set_label(                str(round(float(self.spider_plot_data['PANDDA_site_RSCC']),2)) )
                self.ligand_rmsdValue.set_label(                str(round(float(self.spider_plot_data['PANDDA_site_rmsd']),2)) )
                self.ligand_RSRValue.set_label(                 str(round(float(self.spider_plot_data['PANDDA_site_RSR']),2)) )
                self.ligand_RSZDValue.set_label(                str(round(float(self.spider_plot_data['PANDDA_site_RSZD']),2)) )
            except ValueError:
                self.ligand_occupancyValue.set_label('-')
                self.ligand_BaverageValue.set_label('-')
                self.ligand_BratioSurroundingsValue.set_label('-')
                self.ligand_RSCCValue.set_label('-')
                self.ligand_rmsdValue.set_label('-')
                self.ligand_RSRValue.set_label('-')
                self.ligand_RSZDValue.set_label('-')


        #########################################################################################
        # history
        # if the structure was previously refined, try to read the parameters
#        self.hbox_for_info_graphics.remove(self.canvas)
        if self.Serial > 1:
            self.RefmacParams=self.Refine.ParamsFromPreviousCycle(self.Serial-1)
#            refinement_cycle,Rfree,Rcryst=self.Refine.GetRefinementHistory()
#            self.canvas = FigureCanvas(self.update_plot(refinement_cycle,Rfree,Rcryst))
#        else:
#            self.canvas = FigureCanvas(self.update_plot([0],[0],[0]))  # a gtk.DrawingArea
#        self.canvas.set_size_request(190, 190)
#        self.hbox_for_info_graphics.add(self.canvas)
#        self.canvas.show()

        #########################################################################################
        # Spider plot
        # Note: refinement history was shown instead previously
        if os.path.isfile(self.spider_plot):
            spider_plot_pic = gtk.gdk.pixbuf_new_from_file(self.spider_plot)
        else:
            spider_plot_pic = gtk.gdk.pixbuf_new_from_file(os.path.join(os.getenv('XChemExplorer_DIR'),'image','NO_SPIDER_PLOT_AVAILABLE.png'))
        self.spider_plot_pic = spider_plot_pic.scale_simple(190, 190, gtk.gdk.INTERP_BILINEAR)
        self.spider_plot_image.set_from_pixbuf(self.spider_plot_pic)

        #########################################################################################
        # update pdb & maps

        #########################################################################################
        # delete old PDB and MAP files
        # - get a list of all molecules which are currently opened in COOT
        # - remove all molecules/ maps before loading a new set
        if len(coot_utils_XChem.molecule_number_list()) > 0:
            for item in coot_utils_XChem.molecule_number_list():
                coot.close_molecule(item)

        #########################################################################################
        # read new PDB files
        # read protein molecule after ligand so that this one is the active molecule
        coot.set_nomenclature_errors_on_read("ignore")
        if os.path.isfile(os.path.join(self.project_directory,self.xtalID,self.compoundID+'.pdb')):
            imol=coot.handle_read_draw_molecule_with_recentre(os.path.join(self.project_directory,self.xtalID,self.compoundID+'.pdb'),0)
            self.mol_dict['ligand']=imol
            coot.read_cif_dictionary(os.path.join(self.project_directory,self.xtalID,self.compoundID+'.cif'))
        if not os.path.isfile(os.path.join(self.project_directory,self.xtalID,self.pdb_style)):
            os.chdir(os.path.join(self.project_directory,self.xtalID))
            # we want to be able to check dimple results immediately, but don't want to interfere with refinement
#            if not os.path.isfile('REFINEMENT_IN_PROGRESS'):
#                if os.path.isfile(os.path.join(self.project_directory,self.xtalID,self.xtalID+'-ensemble-model.pdb')):
#                    os.symlink(self.xtalID+'-ensemble-model.pdb',self.pdb_style)
#                elif os.path.isfile(os.path.join(self.project_directory,self.xtalID,'dimple.pdb')):
#                    os.symlink('dimple.pdb',self.pdb_style)
#                else:
#                    self.go_to_next_xtal()
        if os.path.isfile(os.path.join(self.project_directory,self.xtalID,self.pdb_style)):
            os.chdir(os.path.join(self.project_directory,self.xtalID))
            imol=coot.handle_read_draw_molecule_with_recentre(os.path.join(self.project_directory,self.xtalID,self.pdb_style),0)
        elif os.path.isfile(os.path.join(self.project_directory,self.xtalID,'dimple.pdb')):
            os.chdir(os.path.join(self.project_directory,self.xtalID))
            imol=coot.handle_read_draw_molecule_with_recentre(os.path.join(self.project_directory,self.xtalID,'dimple.pdb'),0)
        else:
            self.go_to_next_xtal()
        self.mol_dict['protein']=imol
        for item in coot_utils_XChem.molecule_number_list():
            if coot.molecule_name(item).endswith(self.pdb_style):
                coot.set_show_symmetry_master(1)    # master switch to show symmetry molecules
                coot.set_show_symmetry_molecule(item,1) # show symm for model

        #########################################################################################
        # read fofo maps
        # - read ccp4 map: 0 - 2fofc map, 1 - fofc.map
        # read 2fofc map last so that one can change its contour level
        if os.path.isfile(os.path.join(self.project_directory,self.xtalID,'2fofc.map')):
            coot.set_default_initial_contour_level_for_difference_map(3)
            coot.handle_read_ccp4_map(os.path.join(self.project_directory,self.xtalID,'fofc.map'),1)
            coot.set_default_initial_contour_level_for_map(1)
            coot.handle_read_ccp4_map(os.path.join(self.project_directory,self.xtalID,'2fofc.map'),0)
            coot.set_last_map_colour(0,0,1)
        else:
            # try to open mtz file with same name as pdb file
            coot.set_default_initial_contour_level_for_map(1)
#            if not os.path.isfile(os.path.join(self.project_directory,self.xtalID,self.mtz_style)):
#                os.chdir(os.path.join(self.project_directory,self.xtalID))
#                if not os.path.isfile('REFINEMENT_IN_PROGRESS'):
#                    if os.path.isfile(os.path.join(self.project_directory,self.xtalID,self.xtalID+'-pandda-input.mtz')):
#                        os.symlink(self.xtalID+'-pandda-input.mtz',self.mtz_style)
#                    elif os.path.isfile(os.path.join(self.project_directory,self.xtalID,'dimple.mtz')):
#                        os.symlink('dimple.mtz',self.mtz_style)
            if os.path.isfile(os.path.join(self.project_directory,self.xtalID,self.mtz_style)):
                coot.auto_read_make_and_draw_maps(os.path.join(self.project_directory,self.xtalID,self.mtz_style))
            elif os.path.isfile(os.path.join(self.project_directory,self.xtalID,'dimple.mtz')):
                coot.auto_read_make_and_draw_maps(os.path.join(self.project_directory,self.xtalID,'dimple.mtz'))

        #########################################################################################
        # check for PANDDAs EVENT maps
        if os.path.isfile(self.event_map):
            coot.handle_read_ccp4_map((self.event_map),0)
            for imol in coot_utils_XChem.molecule_number_list():
                if self.event_map in coot.molecule_name(imol):
                    coot.set_contour_level_in_sigma(imol,2)
#                    coot.set_contour_level_absolute(imol,0.5)
                    coot.set_last_map_colour(0.4,0,0.4)


#        #########################################################################################
#        # update Ligand Confidence combobox
#        if str(self.ligand_confidence_of_sample)=='None':
#            self.ligand_confidence_of_sample='Analysis Pending'
#            db_dict={'RefinementLigandConfidence': self.ligand_confidence_of_sample}
##            self.db.update_data_source(self.xtalID,db_dict)
#        for n,criteria in enumerate(self.ligand_confidence):
#            if criteria.replace('Ligand Confidence: ','')==self.ligand_confidence_of_sample:
#                self.cb_ligand_confidence.set_active(n)

        #########################################################################################
        # update Quality Indicator table
        try:
            self.RRfreeValue.set_label(  str(round(float(self.QualityIndicators['RefinementRcryst']),3)) +' / '+str(round(float(self.QualityIndicators['RefinementRfree']),3)))
        except ValueError:
            self.RRfreeValue.set_label('-')

        try:
            self.RRfreeBox.modify_bg(gtk.STATE_NORMAL, gtk.gdk.color_parse(self.QualityIndicators['RefinementRfreeTraficLight']))
        except ValueError:
            pass
        self.ResolutionValue.set_label(self.QualityIndicators['RefinementResolution'])
        try:
            self.ResolutionBox.modify_bg(gtk.STATE_NORMAL, gtk.gdk.color_parse(self.QualityIndicators['RefinementResolutionTL']))
        except ValueError:
            pass
        self.MolprobityScoreValue.set_label(self.QualityIndicators['RefinementMolProbityScore'])
        try:
            self.MolprobityScoreBox.modify_bg(gtk.STATE_NORMAL, gtk.gdk.color_parse(self.QualityIndicators['RefinementMolProbityScoreTL']))
        except ValueError:
            pass
        self.RamachandranOutliersValue.set_label(self.QualityIndicators['RefinementRamachandranOutliers'])
        try:
            self.RamachandranOutliersBox.modify_bg(gtk.STATE_NORMAL, gtk.gdk.color_parse(self.QualityIndicators['RefinementRamachandranOutliersTL']))
        except ValueError:
            pass
        self.RamachandranFavoredValue.set_label(self.QualityIndicators['RefinementRamachandranFavored'])
        try:
            self.RamachandranFavoredBox.modify_bg(gtk.STATE_NORMAL, gtk.gdk.color_parse(self.QualityIndicators['RefinementRamachandranFavoredTL']))
        except ValueError:
            pass
        self.rmsdBondsValue.set_label(self.QualityIndicators['RefinementRmsdBonds'])
        try:
            self.rmsdBondsBox.modify_bg(gtk.STATE_NORMAL, gtk.gdk.color_parse(self.QualityIndicators['RefinementRmsdBondsTL']))
        except ValueError:
            pass
        self.rmsdAnglesValue.set_label(self.QualityIndicators['RefinementRmsdAngles'])
        try:
            self.rmsdAnglesBox.modify_bg(gtk.STATE_NORMAL, gtk.gdk.color_parse(self.QualityIndicators['RefinementRmsdAnglesTL']))
        except ValueError:
            pass
        self.MatrixWeightValue.set_label(self.QualityIndicators['RefinementMatrixWeight'])

        try:
            pic = gtk.gdk.pixbuf_new_from_file(os.path.join(self.project_directory,self.xtalID,self.compoundID+'.png'))
        except gobject.GError:
            pic = gtk.gdk.pixbuf_new_from_file(os.path.join(os.getenv('XChemExplorer_DIR'),'image','NO_COMPOUND_IMAGE_AVAILABLE.png'))
        self.pic = pic.scale_simple(190, 190, gtk.gdk.INTERP_BILINEAR)
        self.image.set_from_pixbuf(self.pic)