Skip to content
Permalink
9b258c6d1f
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
48 lines (41 sloc) 1.85 KB
import os.path
from Modules.Ensembl.ActivityTableGenerator import ATGenerator
class ActivityTable:
"""
Class for checking activity_table and generating them.
ActivityTable = Byte Representation of Activity Status
corresponding to the generator Schema default:
0, "activity=ACTIVE",
1, "activity=POISED",
2, "activity=REPRESSED",
3, "activity=INACTIVE",
4, "activity=NA"
"""
def __init__(self, organism, current_release, wd):
self.link = os.path.join(wd + "/EnsemblData/", current_release, organism, "activity")
self.folders = next(os.walk(self.link))[1]
self.generator = ATGenerator(["activity=ACTIVE",
"activity=POISED",
"activity=REPRESSED",
"activity=INACTIVE",
"activity=NA"])
def check_and_generate_activity_table(self):
for subfolder in self.folders:
folder_link = os.path.join(self.link, subfolder)
sf_link = os.path.join(folder_link, "table.bin")
if not os.path.isfile(sf_link):
print("No ActivityTable for "+subfolder+" found, generating new one.")
self.generate_table(folder_link)
print("All ActivityTables found, proceeding")
def generate_table(self, link):
for root, dirs, files in os.walk(link):
for file in files:
if file.endswith(".gff.gz"):
originpath = os.path.join(root, file)
file_path = os.path.join(root, "table.bin")
with open(file_path, "wb") as f:
f.write(self.generator.read_table(originpath))
print("New ActivityTable generated in: " + root)
# Debug
#e = ActivityTable("homo_sapiens", "release-94")
#e.check_and_generate_activity_table()