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

read gzipped gtf files #228

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
9 changes: 7 additions & 2 deletions velocyto/counter.py
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,7 @@ def read_repeats(self, gtf_file: str, tolerance: int=5) -> Dict[str, List[vcy.Fe
repeat_ivls_list: List[vcy.Feature] = []

# fin = open(gtf_file)
gtf_lines = [line for line in open(gtf_file) if not line.startswith('#')]
gtf_lines = read_gtf_lines(gtf_file)

def sorting_key(entry: str) -> Tuple[str, bool, int, str]:
"""This sorting strategy is equivalent to sort -k1,1 -k7,7 -k4,4n"""
Expand Down Expand Up @@ -460,7 +460,7 @@ def read_transcriptmodels(self, gtf_file: str) -> Dict[str, Dict[str, vcy.Transc
# Initialize containers
# headerlines: List[str] = []

gtf_lines = [line for line in open(gtf_file) if not line.startswith('#')]
gtf_lines = read_gtf_lines(gtf_file)

def sorting_key(entry: str) -> Tuple[str, bool, int, str]:
"""This sorting strategy is equivalent to sort -k1,1 -k7,7 -k4,4n"""
Expand Down Expand Up @@ -1265,6 +1265,11 @@ def pcount_cell_batch(self) -> Tuple[np.ndarray, np.ndarray, np.ndarray, List[st
raise NotImplementedError("This will be a used by .pcount")


def read_gtf_lines(gtf_file: str) -> List[str]:
return [line for line in (open(gtf_file) if not gtf_file.endswith('.gz') else gzip.open(gtf_file)) if
not line.startswith('#')]


def reverse(strand: str) -> str:
if strand == "+":
return "-"
Expand Down