當前位置: 首頁>>代碼示例>>Python>>正文


Python GenomicRegionSet.read_sequence方法代碼示例

本文整理匯總了Python中rgt.GenomicRegionSet.GenomicRegionSet.read_sequence方法的典型用法代碼示例。如果您正苦於以下問題:Python GenomicRegionSet.read_sequence方法的具體用法?Python GenomicRegionSet.read_sequence怎麽用?Python GenomicRegionSet.read_sequence使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在rgt.GenomicRegionSet.GenomicRegionSet的用法示例。


在下文中一共展示了GenomicRegionSet.read_sequence方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: read_states_signals

# 需要導入模塊: from rgt.GenomicRegionSet import GenomicRegionSet [as 別名]
# 或者: from rgt.GenomicRegionSet.GenomicRegionSet import read_sequence [as 別名]
    def read_states_signals(self):
        # Read states from the annotation file
        states = ""
        with open(self.annotate_fname) as annotate_file:
            for line in annotate_file:
                if len(line) < 2 or "#" in line or "=" in line:
                    continue
                ll = line.strip().split(" ")
                for state in ll[1:-1]:
                    states += state

        # If need to estimate bias table
        bias_table = BiasTable(output_loc=self.output_locaiton)
        genome_data = GenomeData(self.organism)
        table = None
        if self.estimate_bias_correction:
            regions = GenomicRegionSet("Bias Regions")
            if self.original_regions.split(".")[-1] == "bed":
                regions.read_bed(self.original_regions)
            if self.original_regions.split(".")[-1] == "fa":
                regions.read_sequence(self.original_regions)

            if self.estimate_bias_type == "FRE":
                table = bias_table.estimate_table(regions=regions, dnase_file_name=self.bam_file,
                                                  genome_file_name=genome_data.get_genome(),
                                                  k_nb=self.k_nb,
                                                  forward_shift=self.atac_forward_shift,
                                                  reverse_shift=self.atac_reverse_shift)
            elif self.estimate_bias_type == "PWM":
                table = bias_table.estimate_table_pwm(regions=regions, dnase_file_name=self.bam_file,
                                                      genome_file_name=genome_data.get_genome(),
                                                      k_nb=self.k_nb,
                                                      forward_shift=self.atac_forward_shift,
                                                      reverse_shift=self.atac_reverse_shift)

            bias_fname = os.path.join(self.output_locaiton, "Bias", "{}_{}".format(self.k_nb, self.atac_forward_shift))
            bias_table.write_tables(bias_fname, table)

        # If the bias table is provided
        if self.bias_table:
            bias_table_list = self.bias_table.split(",")
            table = bias_table.load_table(table_file_name_F=bias_table_list[0],
                                          table_file_name_R=bias_table_list[1])

        # Get the normalization and slope signal from the raw bam file
        raw_signal = GenomicSignal(self.bam_file)
        raw_signal.load_sg_coefs(slope_window_size=9)
        norm_signal, slope_signal = raw_signal.get_signal(ref=self.chrom, start=self.start, end=self.end,
                                                          downstream_ext=self.atac_downstream_ext,
                                                          upstream_ext=self.atac_upstream_ext,
                                                          forward_shift=self.atac_forward_shift,
                                                          reverse_shift=self.atac_reverse_shift,
                                                          initial_clip=self.atac_initial_clip,
                                                          bias_table=table,
                                                          genome_file_name=genome_data.get_genome(),
                                                          print_raw_signal=self.print_raw_signal,
                                                          print_bc_signal=self.print_bc_signal,
                                                          print_norm_signal=self.print_norm_signal,
                                                          print_slope_signal=self.print_slope_signal)
        if self.print_bed_file:
            self.output_bed_file(states)

        return states, norm_signal, slope_signal
開發者ID:eggduzao,項目名稱:reg-gen,代碼行數:65,代碼來源:train.py


注:本文中的rgt.GenomicRegionSet.GenomicRegionSet.read_sequence方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。