Permalink
Cannot retrieve contributors at this time
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
master_project_JLU2018/bin/3.1_create_gtf/Modules/Ensembl/ActivityTableGenerator.py
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
37 lines (23 sloc)
1.07 KB
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import gzip | |
class ATGenerator: | |
""" | |
Reads gzip files for activitydata and generates a bytearray with activitystatus. | |
@author: Sebastian Beyvers | |
@contact: sebastian.beyvers@med.uni-giessen.de | |
""" | |
def __init__(self, repre): | |
# Constructor with parameter representation: List of keywords with a corresponding index | |
# Only the Index as byte will be appended to a bytearray. | |
self.representation = repre | |
def read_table(self, file): | |
# Reads the activity-ensembl file ("/data/EnsemblData/release/organism/activity/*") | |
# and returns the activity as bytearray, based on the representation in self.representation. | |
# Only the index is saved -> see ActivityTable.py for current representation. | |
activity_table = [] | |
with gzip.open(file, 'rb') as f: | |
for line in f: | |
for index, re in enumerate(self.representation): | |
if re in str(line): | |
activity_table.append(index) | |
break | |
return bytearray(activity_table) | |