コード例 #1
0
    def load(cls, filename):
        """
		Load an Experiment from file
	
		:param filename:
		:type filename:
		"""

        experiment_data = load_info_json(filename)

        expr = cls(**experiment_data, filename=filename)
        expr.gcms_data = pickle.load(
            get_file_from_archive(expr.filename.Path, "gcms_data.dat"))
        expr.expr = pickle.load(
            get_file_from_archive(expr.filename.Path, "experiment.expr"))
        expr.peak_list = pickle.load(
            get_file_from_archive(expr.filename.Path, "peaks.dat"))
        expr.intensity_matrix = pickle.load(
            get_file_from_archive(expr.filename.Path, "intensity_matrix.dat"))

        if expr.identification_performed:
            expr.ident_peaks = pickle.load(
                get_file_from_archive(expr.filename.Path, "ident_peaks.dat"))

        expr.tic = expr.tic_data[1]

        expr.get_info_from_gcms_data()

        return expr
コード例 #2
0
ファイル: project.py プロジェクト: domdfcoding/GunShotMatch
    def ammo_file(self):
        """
		Gets Ammunition Details from the Project tarfile and convert to BytesIO
		"""
        return BytesIO(
            get_file_from_archive(self.filename.value,
                                  filename_only(
                                      self.ammo_details.value)).read())
コード例 #3
0
ファイル: project.py プロジェクト: domdfcoding/GunShotMatch
    def load_consolidate_results(self):
        if self.consolidate_performed:
            archive = tarfile.open(self.filename.value, mode="r")
            raw_consolidated_peaks = json.load(
                get_file_from_archive(archive, "consolidate.json"))
            archive.close()

            self.consolidated_peaks = []

            for peak in raw_consolidated_peaks:
                self.consolidated_peaks.append(
                    ConsolidatedPeak.from_dict(peak))
コード例 #4
0
ファイル: project.py プロジェクト: domdfcoding/GunShotMatch
    def load_alignment_data(self):

        if self.alignment_performed:
            from pyms.Spectrum import MassSpectrum

            self.rt_alignment = pandas.read_json(
                get_file_from_archive(self.filename.Path, 'alignment_rt.json'))

            # To make sure that columns of dataframe are in the same order as the experiment name list
            if self.rt_alignment.columns.tolist() != self.experiment_name_list:
                self.rt_alignment = self.rt_alignment[
                    self.experiment_name_list]

            self.area_alignment = pandas.read_json(
                get_file_from_archive(self.filename.Path,
                                      'alignment_area.json'))

            # To make sure that columns of dataframe are in the same order as the experiment name list
            if self.area_alignment.columns.tolist(
            ) != self.experiment_name_list:
                self.area_alignment = self.area_alignment[
                    self.experiment_name_list]

            raw_ms_alignment = json.load(
                get_file_from_archive(self.filename.Path, 'alignment_ms.json'))

            ordered_ms_alignment = {}

            for expr, peaks in raw_ms_alignment.items():
                ordered_ms_alignment[expr] = []

                for peak_idx in range(len(peaks)):
                    peak_idx = str(peak_idx)
                    if peaks[peak_idx]:
                        peaks[peak_idx] = MassSpectrum.from_dict(
                            peaks[peak_idx])
                    ordered_ms_alignment[expr].append(peaks[peak_idx])

            self.ms_alignment = pandas.DataFrame(data=ordered_ms_alignment)
コード例 #5
0
ファイル: project.py プロジェクト: domdfcoding/GunShotMatch
    def _load_experiments(self):
        """
		Load the experiments from file
		"""

        for filename in self.experiment_file_list:
            # self._experiment_objects.append(Experiment.load(filename))

            # Get Experiment tarfile from the Project tarfile and convert to BytesIO
            expr_tarfile = BytesIO(
                get_file_from_archive(str(self.filename.value),
                                      filename_only(filename)).read())

            # Load the Experiment
            expr = Experiment.Experiment.load(expr_tarfile)

            # Add the Experiment to the list of Experiment objects
            self._experiment_objects.append(expr)
コード例 #6
0
    def tic_data(self):
        """
		Returns the TIC stored in the tic.dat file
	
		:return:
		:rtype:
		"""

        intensity_list = []
        time_list = []

        for row in get_file_from_archive(
                self.filename.Path,
                "tic.dat").read().decode("utf-8").split("\n"):
            row = list(filter(None, row.split(" ")))
            if len(row) == 0:
                break
            intensity_list.append(float(row[1]))
            time_list.append(float(row[0]))

        intensity_array = numpy.array(intensity_list)
        tic = IonChromatogram(intensity_array, time_list)

        return intensity_array, tic
コード例 #7
0
ファイル: project.py プロジェクト: domdfcoding/GunShotMatch
 def export_method(self, output_filename):
     with open(output_filename, 'w') as f:
         f.write(
             get_file_from_archive(
                 self.filename.Path,
                 self.method.filename).read().decode("utf-8"))