Commit 04157769 authored by Blaise Li's avatar Blaise Li
Browse files

Preserving names when extracting genes from gtf.

The resulting BedTool is now in bed format.
parent 32004076
......@@ -2,7 +2,7 @@ from subprocess import check_output
__copyright__ = "Copyright (C) 2020-2021 Blaise Li"
__licence__ = "GNU GPLv3"
__version__ = 0.5
__version__ = 0.6
BEDTOOLS_VERSION = check_output(
["bedtools", "--version"]).decode("utf-8").strip().split()[-1]
......
......@@ -46,6 +46,7 @@ import seaborn as sns
# from rpy2.robjects.packages import importr
# deseq2 = importr("DESeq2")
from pybedtools import BedTool
from pybedtools.featurefuncs import gff2bed
import pyBigWig
import networkx as nx
from libworkflows import texscape
......@@ -225,8 +226,15 @@ def id_list_gtf2bed(
def feature_filter(feature):
return feature[2] == feature_type and feature[id_kwd] in ids
# def add_name(feature):
# feature.name = feature[id_kwd]
# return feature
gtf = BedTool(gtf_filename)
return gtf.filter(feature_filter)
# Apparently ignored when later using merge
# return gtf.filter(feature_filter).each(add_name)
return gtf.filter(feature_filter).each(gff2bed, id_kwd)
# https://stackoverflow.com/a/13243870/1878788
def empty_bed_generator():
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment