Example #1
0
    def __init__(self,panddas_directory,datasource,initial_model_directory,xce_logfile,update_datasource_only,which_models):
        QtCore.QThread.__init__(self)
        self.panddas_directory=panddas_directory
        self.datasource=datasource
        self.initial_model_directory=initial_model_directory
        self.db=XChemDB.data_source(self.datasource)
        self.db.create_missing_columns()
        self.db_list=self.db.get_empty_db_dict()
        self.external_software=XChemUtils.external_software(xce_logfile).check()
        self.xce_logfile=xce_logfile
        self.Logfile=XChemLog.updateLog(xce_logfile)
        self.update_datasource_only=update_datasource_only
        self.which_models=which_models
        self.already_exported_models=[]

        self.RefmacParams={ 'HKLIN':            '',                 'HKLOUT': '',
                            'XYZIN':            '',                 'XYZOUT': '',
                            'LIBIN':            '',                 'LIBOUT': '',
                            'TLSIN':            '',                 'TLSOUT': '',
                            'TLSADD':           '',
                            'NCYCLES':          '10',
                            'MATRIX_WEIGHT':    'AUTO',
                            'BREF':             '    bref ISOT\n',
                            'TLS':              '',
                            'NCS':              '',
                            'TWIN':             ''    }
Example #2
0
    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!'
                )
Example #3
0
    def __init__(self):

        ###########################################################################################
        # read in settings file from XChemExplorer to set the relevant paths
        print 'current dir',os.getcwd()
        self.settings = pickle.load(open(".xce_settings.pkl","rb"))
        print 'setting',self.settings
#        self.refine_model_directory=self.settings['refine_model_directory']
        self.database_directory=self.settings['database_directory']
        self.xce_logfile=self.settings['xce_logfile']
        self.data_source=self.settings['data_source']
        self.db=XChemDB.data_source(self.data_source)

        # checking for external software packages
        self.external_software=XChemUtils.external_software(self.xce_logfile).check()

        self.selection_criteria = [     '0 - All Datasets',
                                        '1 - Analysis Pending',
                                        '2 - PANDDA model',
                                        '3 - In Refinement',
                                        '4 - CompChem ready',
                                        '5 - Deposition ready',
                                        '6 - Deposited'         ]

        self.experiment_stage =     [   ['Review PANDDA export',    '2 - PANDDA model',     65000,  0,  0],
                                        ['In Refinement',           '3 - In Refinement',    65000,  0,  0],
                                        ['Comp Chem Ready!',        '4 - CompChem ready',   65000,  0,  0],
                                        ['Ready for Deposition!',   '5 - Deposition ready', 65000,  0,  0]   ]

        self.ligand_confidence_category = [     '0 - no ligand present',
                                                '1 - Low Confidence',
                                                '2 - Correct ligand, weak density',
                                                '3 - Clear density, unexpected ligand',
                                                '4 - High Confidence'   ]

        self.ligand_site_information =  self.db.get_list_of_pandda_sites_for_coot()
    

        # this decides which samples will be looked at
        self.selection_mode = ''
        self.selected_site=''

        # the Folder is kind of a legacy thing because my inital idea was to have separate folders
        # for Data Processing and Refinement
        self.project_directory = self.settings['initial_model_directory']
        self.Serial=0
        self.Refine=None
        self.index = -1
        self.Todo=[]

        self.xtalID=''
        self.compoundID=''
        self.spider_plot=''
        self.ligand_confidence=''
        self.refinement_folder=''
#        self.datasetOutcome=''

        self.pdb_style='refine.pdb'
        self.mtz_style='refine.mtz'

        # stores imol of currently loaded molecules and maps
        self.mol_dict = {   'protein':  -1,
                            'ligand':   -1,
                            '2fofc':    -1,
                            'fofc':     -1,
                            'event':    -1  }

        # two dictionaries which are flushed when a new crystal is loaded
        # and which contain information to update the data source if necessary
        self.db_dict_mainTable={}
        self.db_dict_panddaTable={}

        ###########################################################################################
        # some COOT settings
        coot.set_map_radius(15)
        coot.set_colour_map_rotation_for_map(0)
        coot.set_colour_map_rotation_on_read_pdb_flag(0)

        self.QualityIndicators = {  'RefinementRcryst':                         '-',
                                    'RefinementRfree':                          '-',
                                    'RefinementRfreeTraficLight':               'gray',
                                    'RefinementResolution':                     '-',
                                    'RefinementResolutionTL':                   'gray',
                                    'RefinementMolProbityScore':                '-',
                                    'RefinementMolProbityScoreTL':              'gray',
                                    'RefinementRamachandranOutliers':           '-',
                                    'RefinementRamachandranOutliersTL':         'gray',
                                    'RefinementRamachandranFavored':            '-',
                                    'RefinementRamachandranFavoredTL':          'gray',
                                    'RefinementRmsdBonds':                      '-',
                                    'RefinementRmsdBondsTL':                    'gray',
                                    'RefinementRmsdAngles':                     '-',
                                    'RefinementRmsdAnglesTL':                   'gray',
                                    'RefinementMatrixWeight':                   '-'   }

        self.spider_plot_data = {   'PANDDA_site_ligand_id':                    '-',
                                    'PANDDA_site_occupancy':                    '-',
                                    'PANDDA_site_B_average':                    '-',
                                    'PANDDA_site_B_ratio_residue_surroundings': '-',
                                    'PANDDA_site_RSCC':                         '-',
                                    'PANDDA_site_rmsd':                         '-',
                                    'PANDDA_site_RSR':                          '-',
                                    'PANDDA_site_RSZD':                         '-'     }


        # default refmac parameters
        self.RefmacParams={ 'HKLIN':            '',                 'HKLOUT': '',
                            'XYZIN':            '',                 'XYZOUT': '',
                            'LIBIN':            '',                 'LIBOUT': '',
                            'TLSIN':            '',                 'TLSOUT': '',
                            'TLSADD':           '',
                            'NCYCLES':          '10',
                            'MATRIX_WEIGHT':    'AUTO',
                            'BREF':             '    bref ISOT\n',
                            'TLS':              '',
                            'NCS':              '',
                            'TWIN':             ''    }
    def __init__(self):

        ###########################################################################################
        # read in settings file from XChemExplorer to set the relevant paths
        self.settings = pickle.load(open(".xce_settings.pkl", "rb"))
        remote_qsub_submission = self.settings['remote_qsub']
        self.database_directory = self.settings['database_directory']
        self.xce_logfile = self.settings['xce_logfile']
        self.Logfile = XChemLog.updateLog(self.xce_logfile)
        self.Logfile.insert('starting COOT gui for reference model refinement')
        self.data_source = self.settings['data_source']

        # checking for external software packages
        self.external_software = XChemUtils.external_software(
            self.xce_logfile).check()
        self.external_software['qsub_remote'] = remote_qsub_submission

        # the Folder is kind of a legacy thing because my inital idea was to have separate folders
        # for Data Processing and Refinement
        self.reference_directory = self.settings['reference_directory']
        self.refinementDir = ''
        self.Serial = 0
        self.Refine = None

        self.xtalID = ''
        self.compoundID = ''
        self.spider_plot = ''
        self.refinement_folder = ''
        self.pdbFile = ''
        self.mtzFree = ''

        self.pdb_style = 'refine.pdb'
        self.mtz_style = 'refine.mtz'

        # stores imol of currently loaded molecules and maps
        self.mol_dict = {
            'protein': -1,
            'ligand': -1,
            '2fofc': -1,
            'fofc': -1,
            'event': -1
        }

        self.ground_state_map_List = []
        self.job_running = False

        ###########################################################################################
        # some COOT settings
        coot.set_map_radius(17)
        coot.set_colour_map_rotation_for_map(0)
        #        coot.set_colour_map_rotation_on_read_pdb_flag(21)

        self.QualityIndicators = {
            'Rcryst': '-',
            'Rfree': '-',
            'RfreeTL': 'gray',
            'ResolutionHigh': '-',
            'ResolutionColor': 'gray',
            'MolprobityScore': '-',
            'MolprobityScoreColor': 'gray',
            'RamachandranOutliers': '-',
            'RamachandranOutliersColor': 'gray',
            'RamachandranFavored': '-',
            'RamachandranFavoredColor': 'gray',
            'rmsdBonds': '-',
            'rmsdBondsTL': 'gray',
            'rmsdAngles': '-',
            'rmsdAnglesTL': 'gray',
            'MatrixWeight': '-'
        }

        # default refmac parameters
        self.RefmacParams = {
            'HKLIN': '',
            'HKLOUT': '',
            'XYZIN': '',
            'XYZOUT': '',
            'LIBIN': '',
            'LIBOUT': '',
            'TLSIN': '',
            'TLSOUT': '',
            'TLSADD': '',
            'NCYCLES': '10',
            'MATRIX_WEIGHT': 'AUTO',
            'BREF': '    bref ISOT\n',
            'TLS': '',
            'NCS': '',
            'TWIN': ''
        }