예제 #1
0
        def update(self):
            '''Update the information for one reflection file.'''

            if not self._hklin_files:
                raise RuntimeError('no hklin files defined')

            if len(self._hklin_files) > 1:
                raise RuntimeError('can have only one hklin to update')

            hklin = self._hklin_files[0]

            self.check_hklout()

            column_names_by_file = {}
            dataset_names_by_file = {}

            md = Mtzdump()
            md.set_hklin(hklin)
            md.dump()
            columns = md.get_columns()

            column_names_by_file[hklin] = []
            dataset_names_by_file[hklin] = md.get_datasets()

            # get a dataset ID - see FIXME 03/NOV/06 below...

            dataset_ids = [md.get_dataset_info(d)['id'] for \
                           d in md.get_datasets()]

            for c in columns:
                name = c[0]
                if name in ['H', 'K', 'L']:
                    continue

                column_names_by_file[hklin].append(name)

            self.add_command_line('hklin1')
            self.add_command_line(hklin)
            self.start()

            dataset_id = dataset_ids[0]

            if self._pname and self._xname and self._dname:
                self.input('drename file_number 1 %d %s %s' % \
                           (dataset_id, self._xname, self._dname))
                self.input('dpname file_number 1 %d %s' % \
                           (dataset_id, self._pname))

            column_counter = 0
            labin_command = 'labin file_number 1'
            for column in column_names_by_file[hklin]:
                column_counter += 1
                labin_command += ' E%d=%s' % (column_counter, column)

            self.input(labin_command)

            # FIXME perhaps - ASSERT that we want only the information from
            # the first dataset here...

            pname, xname, dname = dataset_names_by_file[hklin][0].split('/')
            dataset_id = dataset_ids[0]

            # FIXME 03/NOV/06 this needs to id the dataset by it's number
            # not by pname/xname/dname, as the latter get's confused if the
            # xname is a number...

            if self._new_cell_parameters:
                a, b, c, alpha, beta, gamma = self._new_cell_parameters
                self.input('dcell file_number 1 %d %f %f %f %f %f %f' % \
                           (dataset_id, a, b, c, alpha, beta, gamma))

            if self._new_column_suffix:
                suffix = self._new_column_suffix
                column_counter = 0
                labout_command = 'labout file_number 1'
                for column in column_names_by_file[hklin]:
                    column_counter += 1
                    labout_command += ' E%d=%s_%s' % \
                                     (column_counter, column, suffix)

                self.input(labout_command)

            self.close_wait()

            try:
                self.check_for_errors()
                self.check_ccp4_errors()

            except RuntimeError as e:
                # something went wrong; remove the output file
                try:
                    os.remove(self.get_hklout())
                except Exception:
                    pass
                raise e

            return self.get_ccp4_status()
예제 #2
0
파일: Cad.py 프로젝트: graeme-winter/xia2
        def update(self):
            """Update the information for one reflection file."""

            if not self._hklin_files:
                raise RuntimeError("no hklin files defined")

            if len(self._hklin_files) > 1:
                raise RuntimeError("can have only one hklin to update")

            hklin = self._hklin_files[0]

            self.check_hklout()

            column_names_by_file = {}
            dataset_names_by_file = {}

            md = Mtzdump()
            md.set_hklin(hklin)
            md.dump()
            columns = md.get_columns()

            column_names_by_file[hklin] = []
            dataset_names_by_file[hklin] = md.get_datasets()

            # get a dataset ID - see FIXME 03/NOV/06 below...

            dataset_ids = [md.get_dataset_info(d)["id"] for d in md.get_datasets()]

            for c in columns:
                name = c[0]
                if name in ["H", "K", "L"]:
                    continue

                column_names_by_file[hklin].append(name)

            self.add_command_line("hklin1")
            self.add_command_line(hklin)
            self.start()

            dataset_id = dataset_ids[0]

            if self._pname and self._xname and self._dname:
                self.input(
                    "drename file_number 1 %d %s %s"
                    % (dataset_id, self._xname, self._dname)
                )
                self.input("dpname file_number 1 %d %s" % (dataset_id, self._pname))

            column_counter = 0
            labin_command = "labin file_number 1"
            for column in column_names_by_file[hklin]:
                column_counter += 1
                labin_command += " E%d=%s" % (column_counter, column)

            self.input(labin_command)

            # FIXME perhaps - ASSERT that we want only the information from
            # the first dataset here...

            dataset_id = dataset_ids[0]

            if self._new_cell_parameters:
                a, b, c, alpha, beta, gamma = self._new_cell_parameters
                self.input(
                    "dcell file_number 1 %d %f %f %f %f %f %f"
                    % (dataset_id, a, b, c, alpha, beta, gamma)
                )

            if self._new_column_suffix:
                suffix = self._new_column_suffix
                column_counter = 0
                labout_command = "labout file_number 1"
                for column in column_names_by_file[hklin]:
                    column_counter += 1
                    labout_command += " E%d=%s_%s" % (column_counter, column, suffix)

                self.input(labout_command)

            self.close_wait()

            try:
                self.check_for_errors()
                self.check_ccp4_errors()

            except RuntimeError as e:
                # something went wrong; remove the output file
                try:
                    os.remove(self.get_hklout())
                except Exception:
                    pass
                raise e

            return self.get_ccp4_status()