Skip to content
Snippets Groups Projects
Commit 1843ade5 authored by Blaise Li's avatar Blaise Li
Browse files

Fix empty BedTool: need to pass file name, not fh.

parent 519923a0
No related branches found
No related tags found
No related merge requests found
...@@ -189,19 +189,18 @@ def id_list_gtf2bed(identifiers, gtf_filename, feature_type="transcript", id_kwd ...@@ -189,19 +189,18 @@ def id_list_gtf2bed(identifiers, gtf_filename, feature_type="transcript", id_kwd
in the feature annotations in the gtf_file. These feature IDs will be in the feature annotations in the gtf_file. These feature IDs will be
matched against the elements in *identifiers*. matched against the elements in *identifiers*.
""" """
with open(gtf_filename, "r") as gtf_file: if identifiers:
gtf = BedTool(gtf_file) ids = set(identifiers)
if identifiers: def feature_filter(feature):
ids = set(identifiers) return feature[2] == feature_type and feature[id_kwd] in ids
def feature_filter(feature): gtf = BedTool(gtf_filename)
return feature[2] == feature_type and feature[id_kwd] in ids return gtf.filter(feature_filter)
return gtf.filter(feature_filter) else:
else: # https://stackoverflow.com/a/13243870/1878788
# https://stackoverflow.com/a/13243870/1878788 def empty_bed_generator():
def empty_bed_generator(): return
return yield
yield return empty_bed_generator()
return empty_bed_generator()
def make_empty_bigwig(filename, chrom_sizes): def make_empty_bigwig(filename, chrom_sizes):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment