コード例 #1
0
def regions_worker(worker_id, configuration, regions_chuncks, regions_dict,
                   msg_dict, errors_dict):
    try:

        args = {}
        if "debug" in configuration:
            args["debug"] = configuration["debug"]

        args["sam_read_config"] = configuration["sam_read_config"]
        windowsize = configuration["window_size"]

        chromosome = configuration["chromosome"]
        ref_filename = configuration["reference_file"]['filename']

        tstart = time.perf_counter()
        for rid in regions_chuncks.keys():
            worker_chunck = regions_chuncks[rid][worker_id]

            args["start_idx"] = worker_chunck[0]
            args["end_idx"] = worker_chunck[1]
            args["windowsize"] = windowsize

            wga_windows = []
            no_wga_windows = []

            bam_filename = configuration['wga_file']['filename']
            wga_windows = extract_windows(chromosome=chromosome,
                                          ref_filename=ref_filename,
                                          bam_filename=bam_filename,
                                          **args)

            bam_filename = configuration['no_wga_file']['filename']
            no_wga_windows = extract_windows(chromosome=chromosome,
                                             ref_filename=ref_filename,
                                             bam_filename=bam_filename,
                                             **args)

            regions_dict[rid][worker_id] = {
                "wga_windows": wga_windows,
                "no_wga_windows": no_wga_windows
            }
        tend = time.perf_counter()
        msg = ("Process {0} finished in {1} secs").format(
            worker_id, tend - tstart)
        msg_dict[worker_id] = msg
    except Exception as e:
        msg = "An exception occured in worker {0}. Exception message {1}".format(
            worker_id, str(e))
        errors_dict[worker_id] = msg
        return
コード例 #2
0
    def make_no_wga_windows(self, chromosome, ref_filename, test_filename,
                            **kwargs):

        args = {
            "start_idx": self._start,
            "end_idx": self._end,
            "windowsize": self._w_size
        }

        if "quality_theshold" in kwargs:
            args["quality_theshold"] = kwargs["quality_theshold"]

        if "debug" in kwargs:
            args["debug"] = kwargs["debug"]

        windows = extract_windows(chromosome=chromosome,
                                  ref_filename=ref_filename,
                                  test_filename=test_filename,
                                  **args)

        print("{0} Start Window: Start/End idx {1}".format(
            INFO, windows[0].get_start_end_pos()))
        print("{0} End Window: Start/End idx {1}".format(
            INFO, windows[-1].get_start_end_pos()))
        self._windows[WindowType.NO_WGA] = windows
コード例 #3
0
    def make_no_wga_windows(self, chromosome,
                            ref_filename,
                            bam_filename, **kwargs):

        args = {"start_idx": self._start,
                "end_idx": self._end,
                "windowsize": self._w_size}

        if "debug" in kwargs:
            args["debug"] = kwargs["debug"]

        args["sam_read_config"] = kwargs["sam_read_config"]

        windows = extract_windows(chromosome=chromosome,
                                  ref_filename=ref_filename,
                                  bam_filename=bam_filename,
                                  **args)

        print("{0} Region Start Window "
              "Coords: Start/End idx {1}".format(INFO, windows[0].start_end_pos))
        print("{0} Region End Window "
              "Coords: Start/End idx {1}".format(INFO, windows[-1].start_end_pos))
        self._windows[WindowType.NO_WGA] = windows