Ejemplo n.º 1
0
    def create_ensembles_section(self, ample_dict):
        self.rm_pending_section()
        ensembles_data = ample_dict['ensembles_data']
        self.summary_tab_ensemble_sec_id = "ensembles"
        pyrvapi.rvapi_add_section(self.summary_tab_ensemble_sec_id,
                                  "Ensembles", self.summary_tab_id, 0, 0, 1, 1, True)
        if ample_dict['import_ensembles']:
            rstr = 'Imported {0} ensembles.'.format(len(ensembles_data))
            pyrvapi.rvapi_add_text(rstr, self.summary_tab_ensemble_sec_id, 0, 0, 1, 1)
        else:
            # Get the ensembling data
            d = ensembler.collate_cluster_data(ensembles_data)
            clusters = d['clusters']

            rstr = ""
            rstr += "Ensemble Results<br/>"
            rstr += "----------------<br/><br/>"
            rstr += "Cluster method: {0}<br/>".format(d['cluster_method'])
            rstr += "Cluster score type: {0}<br/>".format(d['cluster_score_type'])
            rstr += "Truncation method: {0}<br/>".format(d['truncation_method'])
            rstr += "Percent truncation: {0}<br/>".format(d['percent_truncation'])
            rstr += "Side-chain treatments: {0}<br/>".format(d['side_chain_treatments'])
            rstr += "Number of clusters: {0}<br/><br/>".format(len(clusters.keys()))
            rstr += "Generated {0} ensembles<br/><br/>".format(len(ensembles_data))
            pyrvapi.rvapi_add_text(rstr, self.summary_tab_ensemble_sec_id, 0, 0, 1, 1)
            ensemble_table = "ensemble_table"
            pyrvapi.rvapi_add_table1(self.summary_tab_ensemble_sec_id + "/" + ensemble_table, "Ensembling Results", 1, 0, 1, 1, True)
            tdata = []
            for i, cluster_num in enumerate(sorted(d['clusters'].keys())):
                header = True if i == 0 else False
                tdata += ensembler.cluster_table_data(clusters, cluster_num, d['side_chain_treatments'], header=header)
            self.fill_table(ensemble_table, tdata, tooltips=self._ensemble_tooltips)
        return
Ejemplo n.º 2
0
 def create_summary_tab(self, ample_dict):
     self._create_summary_tab()
     if self.do_create_ensembles_section(ample_dict):
         self.create_ensembles_section(ample_dict)
     if not self._got_mrbump_results(ample_dict):
         return self.summary_tab_id
     if not self.summary_tab_results_sec_id:
         self.rm_pending_section()
         # Only create the table once
         self.summary_tab_results_sec_id = "mrbump"
         pyrvapi.rvapi_add_section(self.summary_tab_results_sec_id,
                                   "MRBUMP", self.summary_tab_id, 0, 0, 1, 1, True)
         self.summary_tab_results_sec_table_id = "mrbump_table"
         pyrvapi.rvapi_add_table1(self.summary_tab_results_sec_id + "/" + self.summary_tab_results_sec_table_id,
                                  "MRBUMP Results", 1, 0, 1, 1, True)
     mrb_results = ample_dict.get('mrbump_results')
     if not mrb_results == self.old_mrbump_results:
         # We set old_mrbump_results when we create the results_tab
         self.fill_table(self.summary_tab_results_sec_table_id,
                         mrbump_util.ResultsSummary().results_table(mrb_results),
                         tooltips=self._mrbump_tooltips)
     if not self.summary_tab_survey_sec_id and not self.ccp4i2:
         # Only create the table once
         self.summary_tab_survey_sec_id = "survey"
         pyrvapi.rvapi_add_section(self.summary_tab_survey_sec_id, "Feedback", self.summary_tab_id, 0, 0, 1, 1, True)
         rstr = "<h2>How did we do?</h2><h3>Please follow this link and leave some feedback:</h3><a href='{0}' style='color: blue'>{0}</a>".format(reference_manager.survey_url)
         pyrvapi.rvapi_add_text(rstr, self.summary_tab_survey_sec_id, 0, 0, 1, 1)
     return self.summary_tab_id
Ejemplo n.º 3
0
    def __init__(self, parent, title, column_sort_index=None, column_sort_order_reverse=False, opened=False):
        self._identifier = parent.identifier + "/" + self.unique_id("table")
        super(Table, self).__init__(parent)

        self._content = []
        self._opened = opened
        self._column_sort_index = column_sort_index 
        self._column_sort_order_reverse = column_sort_order_reverse
        self._title = title

        pyrvapi.rvapi_add_table1(self._identifier, self._title, 1, 0, 1, 1, self._opened) 
Ejemplo n.º 4
0
    def create_summary_tab(self, ample_dict):
        #
        # Summary Tab
        #
        self._create_summary_tab()

        if not (ample_dict['single_model_mode'] or ample_dict['homologs'] or ample_dict['ideal_helices']) and \
            bool(ample_dict['ensembles_data']) and not self.summary_tab_ensemble_sec_id:

            self.rm_pending_section()

            ensembles_data = ample_dict['ensembles_data']
            self.summary_tab_ensemble_sec_id = "ensembles"
            pyrvapi.rvapi_add_section(self.summary_tab_ensemble_sec_id,
                                      "Ensembles", self.summary_tab_id, 0, 0,
                                      1, 1, True)

            # Get the ensembling data
            d = ensembler.collate_cluster_data(ensembles_data)
            clusters = d['clusters']

            rstr = ""
            rstr += "Ensemble Results<br/>"
            rstr += "----------------<br/><br/>"
            rstr += "Cluster method: {0}<br/>".format(d['cluster_method'])
            rstr += "Cluster score type: {0}<br/>".format(
                d['cluster_score_type'])
            rstr += "Truncation method: {0}<br/>".format(
                d['truncation_method'])
            rstr += "Percent truncation: {0}<br/>".format(
                d['percent_truncation'])
            rstr += "Side-chain treatments: {0}<br/>".format(
                d['side_chain_treatments'])
            rstr += "Number of clusters: {0}<br/><br/>".format(
                len(clusters.keys()))
            rstr += "Generated {0} ensembles<br/><br/>".format(
                len(ensembles_data))
            pyrvapi.rvapi_add_text(rstr, self.summary_tab_ensemble_sec_id, 0,
                                   0, 1, 1)

            ensemble_table = "ensemble_table"
            pyrvapi.rvapi_add_table1(
                self.summary_tab_ensemble_sec_id + "/" + ensemble_table,
                "Ensembling Results", 1, 0, 1, 1, True)
            # for cluster_num in sorted(clusters.keys()):
            #     rstr += "\n"
            #     rstr += "Cluster {0}\n".format(cluster_num)
            #     rstr += "Number of models: {0}\n".format(clusters[cluster_num]['cluster_num_models'])
            #     rstr += "Cluster centroid: {0}\n".format(clusters[cluster_num]['cluster_centroid'])
            #     rstr += "\n"
            #     tdata = cluster_table_data(clusters, cluster_num)
            #     rstr += tableFormat.pprint_table(tdata)
            #
            cluster_num = 1
            tdata = ensembler.cluster_table_data(clusters, cluster_num,
                                                 d['side_chain_treatments'])
            self.fill_table(ensemble_table,
                            tdata,
                            tooltips=self._ensemble_tooltips)

        #
        # MRBUMP Results
        #
        if not self._got_mrbump_results(ample_dict): return self.summary_tab_id
        if not self.summary_tab_results_sec_id:
            self.rm_pending_section()
            # Only create the table once
            self.summary_tab_results_sec_id = "mrbump"
            pyrvapi.rvapi_add_section(self.summary_tab_results_sec_id,
                                      "MRBUMP", self.summary_tab_id, 0, 0, 1,
                                      1, True)
            self.summary_tab_results_sec_table_id = "mrbump_table"
            pyrvapi.rvapi_add_table1(
                self.summary_tab_results_sec_id + "/" +
                self.summary_tab_results_sec_table_id, "MRBUMP Results", 1, 0,
                1, 1, True)

        mrb_results = ample_dict['mrbump_results']
        if not mrb_results == self.old_mrbump_results:
            # We set old_mrbump_results when we create the results_tab
            self.fill_table(
                self.summary_tab_results_sec_table_id,
                mrbump_util.ResultsSummary().results_table(mrb_results),
                tooltips=self._mrbump_tooltips)

        #
        # Survey section
        #
        if not self.summary_tab_survey_sec_id and not self.ccp4i2:
            # Only create the table once
            self.summary_tab_survey_sec_id = "survey"
            pyrvapi.rvapi_add_section(self.summary_tab_survey_sec_id,
                                      "Feedback", self.summary_tab_id, 0, 0, 1,
                                      1, True)
            rstr = "<h2>How did we do?</h2><h3>Please follow this link and leave some feedback:</h3><a href='{0}' style='color: blue'>{0}</a>".format(
                ample_util.survey_url)
            pyrvapi.rvapi_add_text(rstr, self.summary_tab_survey_sec_id, 0, 0,
                                   1, 1)
        return self.summary_tab_id
Ejemplo n.º 5
0
    def create_morda_db_results_tab(self, morda_db_results, morda_db_mr_results, results_to_display):
        """Function to create the MoRDa Database results tab

        Parameters
        ----------
        morda_db_results : str
            Path to the file containing the MoRDa db results
        morda_db_mr_results : str
            Path to the file containing the MoRDa db MR results
        results_to_display : int
            Number of results to display

        Returns
        -------
        object
            Page containing the results from the MoRDa db search
        """
        self._create_morda_db_results_tab()

        if os.path.isfile(morda_db_results):
            section_title = 'MoRDa database AMORE Rotation Search Results'
            uid = str(uuid.uuid4())

            sec = section_title.replace(" ", "_") + uid
            tab = self.morda_db_results_tab_id
            table = "table" + uid

            pyrvapi.rvapi_add_section(sec, section_title, tab, 0, 0, 1, 1, False)

            table_title = "MoRDa datbase AMORE Rotation Search Results"
            pyrvapi.rvapi_add_table1(sec + "/" + table, table_title, 2, 0, 1, 1, 100)
            df = pandas.read_csv(morda_db_results)
            self.create_table(df, table)

            section_title = "AMORE Rotation Search Graphs"
            uid = str(uuid.uuid4())
            graph_sec = section_title.replace(" ", "_") + uid
            graph_widget = "graphWidget" + uid
            pyrvapi.rvapi_add_section(graph_sec, section_title, tab, 0, 0, 1, 1, True)
            self.create_graphs(df, graph_sec, graph_widget)

        if os.path.isfile(morda_db_mr_results):
            section_title = 'Molecular Replacement Search Results'
            uid = str(uuid.uuid4())

            sec = section_title.replace(" ", "_") + uid
            tab = self.morda_db_results_tab_id
            table = "table" + uid

            pyrvapi.rvapi_add_section(sec, section_title, tab, 0, 0, 1, 1, False)

            table_title = "Molecular Replacement Search Results"
            pyrvapi.rvapi_add_table1(sec + "/" + table, table_title, 2, 0, 1, 1, 100)
            df = pandas.read_csv(morda_db_mr_results)
            self.create_table(df, table)

            self.morda_db_df = df

            section_title = 'Top {0} MoRDa database Search Downloads'.format(results_to_display)
            uid = str(uuid.uuid4())
            download_sec = section_title.replace(" ", "_") + uid
            pyrvapi.rvapi_add_section(download_sec, section_title, tab, 0, 0, 1, 1, True)

            section_title = 'Top {0} MoRDa database Search Log Files'.format(results_to_display)
            uid = str(uuid.uuid4())
            logfile_sec = section_title.replace(" ", "_") + uid
            pyrvapi.rvapi_add_section(logfile_sec, section_title, tab, 0, 0, 1, 1, False)

            for i in range(0, results_to_display):
                try:
                    pdb_code = df.loc[i][0]
                    mr_workdir = os.path.join(self.work_dir, 'output_files')
                    mr_log = os.path.join(mr_workdir, '{0}_mr.log'.format(pdb_code))
                    ref_pdb = os.path.join(mr_workdir, '{0}_refinement_output.pdb'.format(pdb_code))
                    ref_mtz = os.path.join(mr_workdir, '{0}_refinement_output.mtz'.format(pdb_code))
                    ref_log = os.path.join(mr_workdir, '{0}_ref.log'.format(pdb_code))
                    ref_map = os.path.join(mr_workdir, '{0}_refmac_2fofcwt.map'.format(pdb_code))
                    diff_map = os.path.join(mr_workdir, '{0}_refmac_fofcwt.map'.format(pdb_code))

                    pdb, mtz, map_, dmap, mr_log, ref_log = list(self.adjust_paths_of_files(
                        [ref_pdb, ref_mtz, ref_map, diff_map, mr_log, ref_log]
                    ))

                    self.store_entry_in_rvapi_meta(
                        i + 1, "full", pdb_code, pdb, mtz, map_, dmap, False)
                    self.output_result_files(
                        download_sec, dmap, map_, mtz, pdb)
                    self.output_log_files(logfile_sec, mr_log, ref_log)

                except KeyError:
                    logger.debug("No result found at position %s", (i + 1))
Ejemplo n.º 6
0
    def create_lattice_results_tab(self, lattice_results, lattice_mr_results, results_to_display):
        """Function to create the lattice results tab

        Parameters
        ----------
        lattice_results : str
            Path to the file containing the lattice results
        lattice_mr_results : str
            Path to the file containing the lattice MR results
        results_to_display : int
            Number of results to display

        Returns
        -------
        object
            Page containing the results from the lattice parameter search
        """

        self._create_lattice_results_tab()

        if os.path.isfile(lattice_results):
            section_title = 'Lattice Parameter Search Results'
            uid = str(uuid.uuid4())

            sec = section_title.replace(" ", "_") + uid
            tab = self.lattice_results_tab_id
            table = "table" + uid

            pyrvapi.rvapi_add_section(sec, section_title, tab, 0, 0, 1, 1, True)

            table_title = "Lattice Parameter Search Results"
            pyrvapi.rvapi_add_table1(sec + "/" + table, table_title, 2, 0, 1, 1, 100)
            df = pandas.read_csv(lattice_results)
            self.create_table(df, table)

        if os.path.isfile(lattice_mr_results):
            section_title = 'Molecular Replacement Search Results'

            uid = str(uuid.uuid4())
            sec = section_title.replace(" ", "_") + uid
            tab = self.lattice_results_tab_id
            table = "table" + uid

            pyrvapi.rvapi_add_section(sec, section_title, tab, 0, 0, 1, 1, True)

            table_title = "Molecular Replacement Search Results"
            pyrvapi.rvapi_add_table1(sec + "/" + table, table_title, 2, 0, 1, 1, 100)
            df = pandas.read_csv(lattice_mr_results)
            self.create_table(df, table)

            section_title = 'Top {0} Lattice Parameter Search Downloads'.format(results_to_display)
            uid = str(uuid.uuid4())
            download_sec = section_title.replace(" ", "_") + uid
            pyrvapi.rvapi_add_section(download_sec, section_title, tab, 0, 0, 1, 1, True)

            section_title = 'Top {0} Lattice Parameter Search Log Files'.format(results_to_display)
            uid = str(uuid.uuid4())
            logfile_sec = section_title.replace(" ", "_") + uid
            pyrvapi.rvapi_add_section(logfile_sec, section_title, tab, 0, 0, 1, 1, False)

            self.lattice_df = df

            for i in range(0, results_to_display):
                try:
                    pdb_code = df.loc[i][0]
                    mr_workdir = os.path.join(self.work_dir, 'output_files', pdb_code)
                    mr_log = os.path.join(mr_workdir, '{0}_mr.log'.format(pdb_code))
                    ref_pdb = os.path.join(mr_workdir, '{0}_refinement_output.pdb'.format(pdb_code))
                    ref_mtz = os.path.join(mr_workdir, '{0}_refinement_output.mtz'.format(pdb_code))
                    ref_log = os.path.join(mr_workdir, '{0}_ref.log'.format(pdb_code))
                    ref_map = os.path.join(mr_workdir, '{0}_refmac_2fofcwt.map'.format(pdb_code))
                    diff_map = os.path.join(mr_workdir, '{0}_refmac_fofcwt.map'.format(pdb_code))

                    pdb, mtz, map_, dmap, mr_log, ref_log = list(self.adjust_paths_of_files(
                        [ref_pdb, ref_mtz, ref_map, diff_map, mr_log, ref_log]
                    ))

                    self.store_entry_in_rvapi_meta(
                        i + 1, "latt", pdb_code, pdb, mtz, map_, dmap, False)
                    self.output_result_files(
                        download_sec, dmap, map_, mtz, pdb)
                    self.output_log_files(logfile_sec, mr_log, ref_log)

                except KeyError:
                    logger.debug("No result found at position %s", (i + 1))
        else:
            for i in range(0, results_to_display):
                try:
                    df = pandas.read_csv(lattice_results)
                    pdb_code = df.loc[i][0]
                    mr_log = None
                    ref_pdb = os.path.join(self.work_dir, 'latt', 'mr_search', 'mr_models', '{}.pdb'.format(pdb_code))
                    ref_mtz = None
                    ref_log = None
                    ref_map = None
                    diff_map = None
                    pdb, mtz, map_, dmap, mr_log, ref_log = list(self.adjust_paths_of_files(
                        [ref_pdb, ref_mtz, ref_map, diff_map, mr_log, ref_log]
                    ))

                    if i == 0:
                        best = True
                    else:
                        best = False

                    self.store_entry_in_rvapi_meta(
                        i + 1, "latt", pdb_code, pdb, mtz, map_, dmap, best)
                except KeyError:
                    logger.debug("No result found at position %s", (i + 1))
Ejemplo n.º 7
0
    def create_morda_db_results_tab(self, morda_db_results, morda_db_mr_results, results_to_display):
        """Function to create the MoRDa Database results tab

        Parameters
        ----------
        morda_db_results : str
            Path to the file containing the MoRDa db results
        morda_db_mr_results : str
            Path to the file containing the MoRDa db MR results
        results_to_display : int
            Number of results to display

        Returns
        -------
        object
            Page containing the results from the MoRDa db search
        """
        self._create_morda_db_results_tab()

        if os.path.isfile(morda_db_results):
            section_title = 'MoRDa database AMORE Rotation Search Results'
            uid = str(uuid.uuid4())

            sec = section_title.replace(" ", "_") + uid
            tab = self.morda_db_results_tab_id
            table = "table" + uid

            pyrvapi.rvapi_add_section(sec, section_title, tab, 0, 0, 1, 1, False)

            table_title = "MoRDa datbase AMORE Rotation Search Results"
            pyrvapi.rvapi_add_table1(sec + "/" + table, table_title, 2, 0, 1, 1, 100)
            df = pandas.read_csv(morda_db_results)
            self.create_table(df, table)

            section_title = "AMORE Rotation Search Graphs"
            uid = str(uuid.uuid4())
            graph_sec = section_title.replace(" ", "_") + uid
            graph_widget = "graphWidget" + uid
            pyrvapi.rvapi_add_section(graph_sec, section_title, tab, 0, 0, 1, 1, True)
            self.create_graphs(df, graph_sec, graph_widget)

        if os.path.isfile(morda_db_mr_results):
            section_title = 'Molecular Replacement Search Results'
            uid = str(uuid.uuid4())

            sec = section_title.replace(" ", "_") + uid
            tab = self.morda_db_results_tab_id
            table = "table" + uid

            pyrvapi.rvapi_add_section(sec, section_title, tab, 0, 0, 1, 1, False)

            table_title = "Molecular Replacement Search Results"
            pyrvapi.rvapi_add_table1(sec + "/" + table, table_title, 2, 0, 1, 1, 100)
            df = pandas.read_csv(morda_db_mr_results)
            self.create_table(df, table)

            self.morda_db_df = df

            section_title = 'Top {0} MoRDa database Search Downloads'.format(results_to_display)
            uid = str(uuid.uuid4())
            download_sec = section_title.replace(" ", "_") + uid
            pyrvapi.rvapi_add_section(download_sec, section_title, tab, 0, 0, 1, 1, True)

            section_title = 'Top {0} MoRDa database Search Log Files'.format(results_to_display)
            uid = str(uuid.uuid4())
            logfile_sec = section_title.replace(" ", "_") + uid
            pyrvapi.rvapi_add_section(logfile_sec, section_title, tab, 0, 0, 1, 1, False)

            for i in range(0, results_to_display):
                pdb_code = df.loc[i][0]
                mr_workdir = os.path.join(self.work_dir, 'output_files')
                mr_log = os.path.join(mr_workdir, '{0}_mr.log'.format(pdb_code))
                ref_pdb = os.path.join(mr_workdir, '{0}_refinement_output.pdb'.format(pdb_code))
                ref_mtz = os.path.join(mr_workdir, '{0}_refinement_output.mtz'.format(pdb_code))
                ref_log = os.path.join(mr_workdir, '{0}_ref.log'.format(pdb_code))
                ref_map = os.path.join(mr_workdir, '{0}_refmac_2fofcwt.map'.format(pdb_code))
                diff_map = os.path.join(mr_workdir, '{0}_refmac_fofcwt.map'.format(pdb_code))

                pdb, mtz, map_, dmap, mr_log, ref_log = list(
                    self.adjust_paths_of_files([ref_pdb, ref_mtz, ref_map, diff_map, mr_log, ref_log]))
                try:
                    self.store_entry_in_rvapi_meta(i + 1, "full", pdb_code, pdb, mtz, map_, dmap, False)
                    self.output_result_files(download_sec, dmap, map_, mtz, pdb)
                    self.output_log_files(logfile_sec, mr_log, ref_log)

                except KeyError:
                    logger.debug("No result found at position %s", (i + 1))