pybedtools.bedtool.BedTool.save_seqs

BedTool.save_seqs(fn)[source]

Save sequences, after calling BedTool.sequence.

In order to use this function, you need to have called the BedTool.sequence() method.

A new BedTool object is returned which references the newly saved file.

Example usage:

>>> a = pybedtools.BedTool('''
... chr1 1 10
... chr1 50 55''', from_string=True)
>>> fasta = pybedtools.example_filename('test.fa')
>>> a = a.sequence(fi=fasta)
>>> print(open(a.seqfn).read())
>chr1:1-10
GATGAGTCT
>chr1:50-55
CCATC

>>> b = a.save_seqs('example.fa')
>>> assert open(b.fn).read() == open(a.fn).read()
>>> if os.path.exists('example.fa'):
...     os.unlink('example.fa')