Пример #1
0
    def exploratory_job(self, assay_caller_uuid):
        """
        Create and run an exploratory job.

        @param assay_caller_uuid:   String indicating assay caller uuid which
                                    will be used as an input for genotyper.
        @return:                    String, uuid of job, String, status of job
        """
        job_name = self.parameters[JOB_NAME] + generate_random_str(5)
        # create a callable and a callback
        callable = SaExploratoryCallable(
            assay_caller_uuid=assay_caller_uuid,
            exp_def_name=self.parameters[EXP_DEF],
            required_drops=self.parameters[REQUIRED_DROPS],
            db_connector=self.db_connector,
            job_name=job_name)
        callback = ep_make_process_callback(uuid=callable.uuid,
                                            outfile_path=callable.tsv_path,
                                            db_connector=self.db_connector)

        # enter genotyper uuid into full analysis database entry
        self.db_connector.update(
            FA_PROCESS_COLLECTION, self.query, {
                "$set": {
                    EP_DOCUMENT: {
                        START_DATESTAMP: datetime.today(),
                        SA_EXPLORATORY_UUID: callable.uuid,
                        REQUIRED_DROPS: self.parameters[REQUIRED_DROPS]
                    }
                }
            })

        # run genotyper job
        with ThreadPoolExecutor(max_workers=1) as executor:
            future = executor.submit(callable)
            future.add_done_callback(callback)

        # update full analysis entry with results from genotyper
        result = self.db_connector.find_one(SA_EXPLORATORY_COLLECTION, UUID,
                                            callable.uuid)
        keys = [
            UUID, URL, PNG_URL, PNG_SUM_URL, KDE_PNG_URL, KDE_PNG_SUM_URL,
            STATUS, ERROR, START_DATESTAMP, FINISH_DATESTAMP
        ]
        document = {key: result[key] for key in keys if key in result}
        update = {"$set": {EP_DOCUMENT: document}}
        self.db_connector.update(FA_PROCESS_COLLECTION, {UUID: self.uuid},
                                 update)

        # return genotyper status and uuid
        return callable.uuid, result[STATUS], 'exploratory'
Пример #2
0
    def genotyper_job(self, assay_caller_uuid):
        """
        Create and run a genotyper job.

        @param assay_caller_uuid:   String indicating assay caller uuid which
                                    will be used as an input for genotyper.
        @return:                    String, uuid of job, String, status of job
        """
        job_name = self.parameters[JOB_NAME] + generate_random_str(5)
        mask_code = self.parameters[
            VARIANT_MASK] if VARIANT_MASK in self.parameters else None
        # create a callable and a callback
        callable = SaGenotyperCallable(
            assay_caller_uuid=assay_caller_uuid,
            exp_def_name=self.parameters[EXP_DEF],
            required_drops=self.parameters[REQUIRED_DROPS],
            db_connector=self.db_connector,
            job_name=job_name,
            mask_code=mask_code,
            combine_alleles=True)
        callback = gt_make_process_callback(
            uuid=callable.uuid,
            exp_def_name=self.parameters[EXP_DEF],
            ac_result_path=callable.ac_result_path,
            ignored_dyes=callable.ignored_dyes,
            outfile_path=callable.outfile_path,
            db_connector=self.db_connector,
            cur_job_name=job_name)

        # enter genotyper uuid into full analysis database entry
        self.db_connector.update(
            FA_PROCESS_COLLECTION, self.query, {
                "$set": {
                    GT_DOCUMENT: {
                        START_DATESTAMP: datetime.today(),
                        SA_GENOTYPER_UUID: callable.uuid,
                        REQUIRED_DROPS: self.parameters[REQUIRED_DROPS]
                    }
                }
            })

        # run genotyper job
        with ThreadPoolExecutor(max_workers=1) as executor:
            future = executor.submit(callable)
            future.add_done_callback(callback)

        # update full analysis entry with results from genotyper
        result = self.db_connector.find_one(SA_GENOTYPER_COLLECTION, UUID,
                                            callable.uuid)
        keys = [
            UUID, URL, PDF_URL, PNG_URL, PNG_SUM_URL, KDE_PNG_URL,
            KDE_PNG_SUM_URL, STATUS, ERROR, START_DATESTAMP, FINISH_DATESTAMP,
            REQUIRED_DROPS, VARIANT_MASK
        ]
        document = {key: result[key] for key in keys if key in result}
        update = {"$set": {GT_DOCUMENT: document}}
        self.db_connector.update(FA_PROCESS_COLLECTION, {UUID: self.uuid},
                                 update)

        # return genotyper status and uuid
        return callable.uuid, result[STATUS], 'genotyper'
Пример #3
0
    def identity_job(self, primary_analysis_uuid):
        """
        Create and run a identity job.

        @param primary_analysis_uuid:   String indicating primary analysis uuid which
                                        will be used as an input for identity.
        @return:                        String, uuid of job, String, status of job
        """
        job_name = self.parameters[JOB_NAME] + generate_random_str(5)
        # create a callable and a callback
        callable = SaIdentityCallable(
            primary_analysis_uuid=primary_analysis_uuid,
            num_probes=self.parameters[NUM_PROBES],
            training_factor=self.parameters[ID_TRAINING_FACTOR],
            assay_dye=self.parameters[ASSAY_DYE],
            use_pico1_filter=self.parameters[USE_PICO1_FILTER],
            use_pico2_filter=self.parameters[USE_PICO2_FILTER],
            pico1_dye=self.parameters[PICO1_DYE],
            pico2_dye=self.parameters[PICO2_DYE],
            dye_levels=self.parameters[DYE_LEVELS],
            ignored_dyes=self.parameters[IGNORED_DYES],
            filtered_dyes=self.parameters[FILTERED_DYES],
            ui_threshold=self.parameters[UI_THRESHOLD],
            max_uninj_ratio=self.parameters[MAX_UNINJECTED_RATIO],
            db_connector=self.db_connector,
            job_name=job_name,
            use_pico_thresh=self.parameters[CONTINUOUS_PHASE],
            ignore_lowest_barcode=self.parameters[IGNORE_LOWEST_BARCODE],
            dev_mode=self.parameters[DEV_MODE],
            drift_compensate=self.parameters[DRIFT_COMPENSATE])
        callback = id_make_process_callback(
            uuid=callable.uuid,
            outfile_path=callable.outfile_path,
            plot_path=callable.plot_path,
            report_path=callable.report_path,
            plate_plot_path=callable.plate_plot_path,
            temporal_plot_path=callable.temporal_plot_path,
            drop_count_plot_path=callable.drop_count_plot_path,
            db_connector=self.db_connector)

        # enter identity uuid into full analysis database entry
        self.db_connector.update(
            FA_PROCESS_COLLECTION, self.query, {
                "$set": {
                    ID_DOCUMENT: {
                        START_DATESTAMP:
                        datetime.today(),
                        SA_IDENTITY_UUID:
                        callable.uuid,
                        TRAINING_FACTOR:
                        self.parameters[ID_TRAINING_FACTOR],
                        UI_THRESHOLD:
                        self.parameters[UI_THRESHOLD],
                        IGNORE_LOWEST_BARCODE:
                        self.parameters[IGNORE_LOWEST_BARCODE],
                        PICO1_DYE:
                        self.parameters[PICO1_DYE],
                        MAX_UNINJECTED_RATIO:
                        self.parameters[MAX_UNINJECTED_RATIO],
                        USE_PICO1_FILTER:
                        self.parameters[USE_PICO1_FILTER],
                        USE_PICO2_FILTER:
                        self.parameters[USE_PICO2_FILTER],
                        DEV_MODE:
                        self.parameters[DEV_MODE],
                        DRIFT_COMPENSATE:
                        self.parameters[DRIFT_COMPENSATE]
                    }
                }
            })

        # run identity job
        with ThreadPoolExecutor(max_workers=1) as executor:
            future = executor.submit(callable)
            future.add_done_callback(callback)

        # update full analysis entry with results from identity
        result = self.db_connector.find_one(SA_IDENTITY_COLLECTION, UUID,
                                            callable.uuid)
        keys = [
            UUID, URL, REPORT_URL, PLOT_URL, STATUS, ERROR, START_DATESTAMP,
            FINISH_DATESTAMP, TRAINING_FACTOR, UI_THRESHOLD,
            MAX_UNINJECTED_RATIO, PLATE_PLOT_URL, TEMPORAL_PLOT_URL,
            IGNORE_LOWEST_BARCODE, PICO1_DYE, USE_PICO1_FILTER, DEV_MODE,
            DRIFT_COMPENSATE, USE_PICO2_FILTER, DROP_COUNT_PLOT_URL
        ]
        document = {key: result[key] for key in keys if key in result}
        update = {"$set": {ID_DOCUMENT: document}}
        self.db_connector.update(FA_PROCESS_COLLECTION, {UUID: self.uuid},
                                 update)

        # return identity status and uuid
        return callable.uuid, result[STATUS], 'identity'
Пример #4
0
    def assay_caller_job(self, identity_uuid):
        """
        Create and run a assay caller job.

        @param identity_uuid:   String indicating identity uuid which
                                will be used as an input for assay caller.
        @return:                String, uuid of job, String, status of job
        """
        job_name = self.parameters[JOB_NAME] + generate_random_str(5)
        ac_model = None
        if AC_MODEL in self.parameters:
            ac_model = self.parameters[AC_MODEL]

        # create a callable and a callback
        callable = SaAssayCallerCallable(
            identity_uuid=identity_uuid,
            exp_def_name=self.parameters[EXP_DEF],
            training_factor=self.parameters[AC_TRAINING_FACTOR],
            ctrl_thresh=self.parameters[CTRL_THRESH],
            db_connector=self.db_connector,
            job_name=job_name,
            ctrl_filter=self.parameters[CTRL_FILTER],
            ac_method=self.parameters[AC_METHOD],
            ac_model=ac_model)
        callback = ac_make_process_callback(
            uuid=callable.uuid,
            outfile_path=callable.outfile_path,
            scatter_plot_path=callable.scatter_plot_path,
            dyes_scatter_plot_path=callable.dyes_plot_path,
            db_connector=self.db_connector)

        # enter assay caller uuid into full analysis database entry
        self.db_connector.update(
            FA_PROCESS_COLLECTION, self.query, {
                "$set": {
                    AC_DOCUMENT: {
                        START_DATESTAMP: datetime.today(),
                        SA_ASSAY_CALLER_UUID: callable.uuid,
                        TRAINING_FACTOR: self.parameters[AC_TRAINING_FACTOR],
                        CTRL_THRESH: self.parameters[CTRL_THRESH],
                        CTRL_FILTER: self.parameters[CTRL_FILTER],
                        AC_METHOD: self.parameters[AC_METHOD],
                        AC_MODEL: ac_model
                    }
                }
            })

        # run assay caller job
        with ThreadPoolExecutor(max_workers=1) as executor:
            future = executor.submit(callable)
            future.add_done_callback(callback)

        # update full analysis entry with results from assay caller
        result = self.db_connector.find_one(SA_ASSAY_CALLER_COLLECTION, UUID,
                                            callable.uuid)
        keys = [
            UUID, URL, SCATTER_PLOT_URL, STATUS, ERROR, START_DATESTAMP,
            FINISH_DATESTAMP, TRAINING_FACTOR, CTRL_THRESH, CTRL_FILTER,
            AC_METHOD, DYES_SCATTER_PLOT_URL, AC_MODEL
        ]
        document = {key: result[key] for key in keys if key in result}
        update = {"$set": {AC_DOCUMENT: document}}
        self.db_connector.update(FA_PROCESS_COLLECTION, {UUID: self.uuid},
                                 update)

        # return assay caller status and uuid
        return callable.uuid, result[STATUS], 'assay_caller'
Пример #5
0
    def primary_analysis_job(self, _):
        """
        Create and run a primary analysis job.

        @param _:   Placeholder, isn't used it's here because all jobs run in this
                    callable must have a uuid from the previous job. A primary analysis
                    job is the only exception because it doesn't need a uuid to start.
        @return:    String, uuid of job, String, status of job
        """
        dyes = self.parameters[DYES] + [
            self.parameters[ASSAY_DYE], self.parameters[PICO2_DYE]
        ]
        if self.parameters[PICO1_DYE] is not None and self.parameters[
                PICO1_DYE] not in dyes:
            dyes.append(self.parameters[PICO1_DYE])

        job_name = self.parameters[JOB_NAME] + generate_random_str(5)
        # create a callable and a callback
        callable = PaProcessCallable(archive=self.parameters[ARCHIVE],
                                     is_hdf5=self.parameters[IS_HDF5],
                                     dyes=dyes,
                                     device=self.parameters[DEVICE],
                                     major=self.parameters[MAJOR],
                                     minor=self.parameters[MINOR],
                                     offset=self.parameters[OFFSETS],
                                     use_iid=self.parameters[USE_IID],
                                     job_name=job_name,
                                     db_connector=self.db_connector)
        callback = pa_make_process_callback(uuid=callable.uuid,
                                            outfile_path=callable.outfile_path,
                                            config_path=callable.config_path,
                                            db_connector=self.db_connector)

        # enter primary analysis uuid into full analysis database entry
        self.db_connector.update(
            FA_PROCESS_COLLECTION, self.query, {
                "$set": {
                    PA_DOCUMENT: {
                        START_DATESTAMP: datetime.today(),
                        PA_PROCESS_UUID: callable.uuid,
                        OFFSETS: self.parameters[OFFSETS]
                    }
                }
            })

        # run primary analysis job
        with ThreadPoolExecutor(max_workers=1) as executor:
            future = executor.submit(callable)
            future.add_done_callback(callback)

        # update full analysis entry with results from primary analysis
        result = self.db_connector.find_one(PA_PROCESS_COLLECTION, UUID,
                                            callable.uuid)
        keys = [
            UUID, URL, CONFIG_URL, STATUS, ERROR, START_DATESTAMP,
            FINISH_DATESTAMP, MAJOR, MINOR, OFFSETS
        ]
        document = {key: result[key] for key in keys if key in result}
        update = {"$set": {PA_DOCUMENT: document}}
        self.db_connector.update(FA_PROCESS_COLLECTION, {UUID: self.uuid},
                                 update)

        # return primary analysis status and uuid
        return callable.uuid, result[STATUS], 'primary_analysis'