本文整理汇总了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