Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Blaise LI
libhts
Commits
7e25a230
Commit
7e25a230
authored
Mar 15, 2019
by
Blaise Li
Browse files
Context-manage gff file opening.
parent
fcfaae6c
Changes
1
Hide whitespace changes
Inline
Side-by-side
libhts/libhts.py
View file @
7e25a230
...
...
@@ -188,19 +188,19 @@ 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
matched against the elements in *identifiers*.
"""
gtf_file
=
open
(
gtf_filename
,
"r"
)
gtf
=
BedTool
(
gtf_file
)
if
identifiers
:
ids
=
set
(
identifiers
)
def
feature_filter
(
feature
):
return
feature
[
2
]
==
feature_type
and
feature
[
id_kwd
]
in
ids
return
gtf
.
filter
(
feature_filter
)
else
:
# https://stackoverflow.com/a/13243870/1878788
def
empty_bed_generator
():
return
yield
return
empty_bed_generator
()
with
open
(
gtf_filename
,
"r"
)
as
gtf_file
:
gtf
=
BedTool
(
gtf_file
)
if
identifiers
:
ids
=
set
(
identifiers
)
def
feature_filter
(
feature
):
return
feature
[
2
]
==
feature_type
and
feature
[
id_kwd
]
in
ids
return
gtf
.
filter
(
feature_filter
)
else
:
# https://stackoverflow.com/a/13243870/1878788
def
empty_bed_generator
():
return
yield
return
empty_bed_generator
()
def
make_empty_bigwig
(
filename
,
chrom_sizes
):
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment