Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issues 190 and 113 #213

Merged
merged 3 commits into from
May 9, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 18 additions & 2 deletions pybedtools/bedtool.py
Original file line number Diff line number Diff line change
Expand Up @@ -603,7 +603,7 @@ def truncate_to_chrom(self, genome):

def tabix_intervals(self, interval_or_string):
"""
Retrieve all intervals within cooridnates from a "tabixed" BedTool.
Retrieve all intervals within coordinates from a "tabixed" BedTool.

Given either a string in "chrom:start-stop" format, or an interval-like
object with chrom, start, stop attributes, return a *streaming* BedTool
Expand Down Expand Up @@ -644,7 +644,11 @@ def tabix_intervals(self, interval_or_string):
def gen():
for i in results:
yield i + '\n'
return BedTool(gen())

# xref #190
x = BedTool(gen()).saveas()
tbx.close()
return x

def tabix(self, in_place=True, force=False, is_sorted=False):
"""
Expand Down Expand Up @@ -1991,6 +1995,14 @@ def genome_coverage(self):
"""
Wraps `bedtools genomecov`.

Note that some invocations of `bedtools genomecov` do not result in
a properly-formatted BED file. For example, the default behavior is to
report a histogram of coverage. Iterating over the resulting,
non-BED-format file will raise exceptions in pybedtools' parser.

Consider using the `BedTool.to_dataframe` method to convert these
non-BED files into a pandas DataFrame for further use.

Example usage:

BAM file input does not require a genome:
Expand All @@ -2011,6 +2023,10 @@ def genome_coverage(self):
chr2L 10212 10248 1
chr2L 10255 10291 1

Non-BED format results:
>>> a = pybedtools.example_bedtool('x.bed')
>>> b = a.genome_coverage(genome='dm3')
>>> df = b.to_dataframe(names=['chrom', 'depth', 'n', 'chromsize', 'fraction'])


"""
Expand Down