Example #1
0
    def plot_compounds(self, qc_corrected_file, plot_location):
        """ plot a list of compounds """

        # load measurements file
        mea = Mea(mea_file=qc_corrected_file)

        # init plot class
        qcplot = Qcplot(mea=mea)

        # plot the compound
        for compound in mea.get_compounds():
            qcplot.plot_compound_qc_data(compound=compound,
                                         location=plot_location)
Example #2
0
    def export_measurements(self,
                            file,
                            column,
                            export_location,
                            include_is=False):
        """ exports data as samples vs compounds"""

        # load measurements file
        mea = Mea(file)

        # store as table
        mea.as_table(column=column,
                     location=export_location,
                     include_is=include_is)
Example #3
0
    def summary(self, mea_file):
        """ Report a summary of the measurements ... """

        try:
            # load measurements file
            mea = Mea(mea_file)

            # build summary dict
            summary = {
                'batches': mea.get_batches().tolist(),
                'samples': mea.get_samples().tolist(),
                'compounds': mea.get_compounds().tolist()
            }
        except:
            summary = {}

        # return a json encoded dict
        return json.JSONEncoder().encode(summary)
Example #4
0
    def plot_compound(self, qc_corrected_file, compound, plot_location):
        """ plot an individual compound """

        # load measurements file
        mea = Mea(mea_file=qc_corrected_file)

        # init plot class
        qcplot = Qcplot(mea=mea)

        # plot the compound
        qcplot.plot_compound_qc_data(compound=compound, location=plot_location)
Example #5
0
    def plot_compounds_zipped(self, qc_corrected_file, zip_file):
        """ plot a list of compounds and store them as a zip file """

        # load measurements file
        mea = Mea(mea_file=qc_corrected_file)

        # init plot class
        qcplot = Qcplot(mea=mea)

        # plot the compound
        with tempfile.TemporaryDirectory() as tmpdir:
            for compound in mea.get_compounds():
                qcplot.plot_compound_qc_data(compound=compound,
                                             location=tmpdir)

            zipf = zipfile.ZipFile(zip_file, 'w', zipfile.ZIP_DEFLATED)
            for root, dirs, files in os.walk(tmpdir):
                for file in files:
                    if not os.path.isdir(file) and file.split(
                            '.')[-1].lower() == 'html':
                        zipf.write(os.path.join(root, file), file)
            zipf.close()
Example #6
0
    def rep_rsd(self, qc_corrected_file, rep_rsd_file, by_batch=False):
        """ Calculate the Replicate RSD's ... """

        # load measurements file
        mea = Mea(qc_corrected_file)

        # init calc class
        qccalc = Qccalc(mea=mea)

        # calculate qc rsd's
        rsdrep = qccalc.rsdrep(by_batch=by_batch)

        # save results to file
        rsdrep.to_csv(rep_rsd_file, sep="\t", index=False, encoding='utf-8')
Example #7
0
    def qc_correction(self, mea_file, qc_corrected_file):
        """ Calculate the QC corrected data ... """

        # load measurements file
        mea = Mea(mea_file)

        # init calc class
        qccalc = Qccalc(mea=mea)

        # calculate qc corrected data
        qc_corrected = qccalc.qc_correction()

        # save results to file
        qc_corrected.to_csv(qc_corrected_file,
                            sep="\t",
                            index=False,
                            encoding='utf-8')
Example #8
0
    def rt_shifts(self, mea_file, rt_shifts_file):
        """ Calculate the RT shifts of each compound per batch ... """

        # load measurements file
        mea = Mea(mea_file)

        # init calc class
        qccalc = Qccalc(mea=mea)

        # calculate qc rsd's
        rt_shifts = qccalc.rt_shifts()

        # save results to file
        rt_shifts.to_csv(rt_shifts_file,
                         sep="\t",
                         index=False,
                         encoding='utf-8')
Example #9
0
    def blank_effect(self, mea_file, blank_effect_file, by_batch=False):
        """ Calculate the blank effect of ... """

        # load measurements file
        mea = Mea(mea_file)

        # init calc class
        qccalc = Qccalc(mea=mea)

        # calculate blank effect
        blank_effect = qccalc.blank_effect(by_batch=by_batch)

        # save results to file
        blank_effect.to_csv(blank_effect_file,
                            sep="\t",
                            index=False,
                            encoding='utf-8')
Example #10
0
    def internal_standard_rsd(self,
                              qc_corrected_file,
                              is_rsd_file,
                              by_batch=False):
        """ Calculate the Internal Standard RSD's ... """

        # load measurements file
        mea = Mea(qc_corrected_file)

        # init calc class
        qccalc = Qccalc(mea=mea)

        # calculate qc rsd's
        rsdis = qccalc.rsdis(by_batch=by_batch)

        # save results to file
        rsdis.to_csv(is_rsd_file, sep="\t", index=False, encoding='utf-8')