Skip to content
Permalink
4f40b11ca2
Switch branches/tags

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?
Go to file
 
 
Cannot retrieve contributors at this time
37 lines (23 sloc) 1.07 KB
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)