本文整理汇总了Python中rgt.GenomicRegionSet.GenomicRegionSet.any_chrom方法的典型用法代码示例。如果您正苦于以下问题:Python GenomicRegionSet.any_chrom方法的具体用法?Python GenomicRegionSet.any_chrom怎么用?Python GenomicRegionSet.any_chrom使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类rgt.GenomicRegionSet.GenomicRegionSet
的用法示例。
在下文中一共展示了GenomicRegionSet.any_chrom方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: read_bed
# 需要导入模块: from rgt.GenomicRegionSet import GenomicRegionSet [as 别名]
# 或者: from rgt.GenomicRegionSet.GenomicRegionSet import any_chrom [as 别名]
def read_bed(self, bedfile, genome_file_dir):
"""Read the sequences defined by BED file on the given genomce"""
# Read BED into GenomicRegionSet
bed = GenomicRegionSet(os.path.basename(bedfile))
bed.read_bed(bedfile)
# Parse each chromosome and fetch the defined region in this chromosome
chroms = list(set(bed.get_chrom()))
chro_files = [x.split(".")[0] for x in os.listdir(genome_file_dir)]
for ch in chroms:
if ch not in chro_files: print(" *** There is no genome FASTA file for: "+ch)
# Read genome in FASTA according to the given chromosome
ch_seq = SequenceSet(name=ch, seq_type=SequenceType.DNA)
try:
ch_seq.read_fasta(os.path.join(genome_file_dir, ch+".fa"))
except:
continue
# Regions in given chromosome
beds = bed.any_chrom(chrom=ch)
for s in beds:
seq = ch_seq[0].seq[s.initial:s.final]
try: strand = s.strand
except: strand = "+"
self.sequences.append(Sequence(seq=seq, name=s.__repr__(),
strand=strand))