pybedtools.bedtool.BedTool.mask_fasta¶
- BedTool.mask_fasta(*args, **kwargs)[source]¶
Wraps
bedtools maskfasta
.Masks a fasta file at the positions in a BED file and saves result as ‘out’ and stores the filename in seqfn.
>>> a = pybedtools.BedTool('chr1 100 110', from_string=True) >>> fasta_fn = pybedtools.example_filename('test.fa') >>> a = a.mask_fasta(fi=fasta_fn, fo='masked.fa.example') >>> b = a.slop(b=2, genome='hg19') >>> b = b.sequence(fi=a.seqfn) >>> print(open(b.seqfn).read()) >chr1:98-112 TTNNNNNNNNNNAT >>> os.unlink('masked.fa.example') >>> if os.path.exists('masked.fa.example.fai'): ... os.unlink('masked.fa.example.fai')
For convenience, the file or stream this BedTool points to is implicitly passed as the
-bed
argument tomaskFastaFromBed
Original BEDTools help::
Tool: bedtools maskfasta (aka maskFastaFromBed) Version: v2.31.1 Summary: Mask a fasta file based on feature coordinates. Usage: bedtools maskfasta [OPTIONS] -fi <fasta> -fo <fasta> -bed <bed/gff/vcf> Options: -fi Input FASTA file -bed BED/GFF/VCF file of ranges to mask in -fi -fo Output FASTA file -soft Enforce "soft" masking. Mask with lower-case bases, instead of masking with Ns. -mc Replace masking character. Use another character, instead of masking with Ns. -fullHeader Use full fasta header. By default, only the word before the first space or tab is used.