Skip to content
Navigation Menu
Toggle navigation
Sign in
In this repository
All GitHub Enterprise
↵
Jump to
↵
No suggested jump to results
In this repository
All GitHub Enterprise
↵
Jump to
↵
In this organization
All GitHub Enterprise
↵
Jump to
↵
In this repository
All GitHub Enterprise
↵
Jump to
↵
Sign in
Reseting focus
You signed in with another tab or window.
Reload
to refresh your session.
You signed out in another tab or window.
Reload
to refresh your session.
You switched accounts on another tab or window.
Reload
to refresh your session.
Dismiss alert
{{ message }}
loosolab
/
master_project_JLU2018
Public
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Issues
7
Pull requests
1
Actions
Projects
0
Wiki
Security
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Projects
Wiki
Security
Insights
Files
49c356b
bin
Modules
Ensembl
FTPHandling
ActivityCategorizer.py
ActivityTable.py
ActivityTableGenerator.py
Ensembl.py
GTFGen.py
__init__.py
checksums.py
ucsc
SaveResults.py
Uniquifier.py
__init__.py
RegGTFExtractor.py
bed_to_fasta.R
call_peaks.py
call_peaks.yaml
compareBed.sh
get_best_motif.py
maxScore.R
merge.R
config
.gitignore
README.md
masterenv.yml
nextflow.config
pipeline.nf
uropa.config
Breadcrumbs
master_project_JLU2018
/
bin
/
Modules
/
Ensembl
/
ActivityCategorizer.py
Copy path
Blame
Blame
Latest commit
History
History
103 lines (68 loc) · 3.11 KB
Breadcrumbs
master_project_JLU2018
/
bin
/
Modules
/
Ensembl
/
ActivityCategorizer.py
Top
File metadata and controls
Code
Blame
103 lines (68 loc) · 3.11 KB
Raw
import json import os class ActivityCategorizer: def __init__(self, release, organism, wd): # List of all Folders with Activity Tables self.folderlist = [] # Dictionary from celltypes_organism.json mit key = Kategorie und Value = [Ordner] self.c_dict = self.read_config(organism, wd) # Activity table from all files as dict self.activity = {} self.get_activity_data(release, organism, wd) # Categorized Activity from Json-config print("Categorization: This may take a while") self.categorization = self.generate_categorized_activity() print("Categorization finished !") def get_categorization(self): return self.categorization def read_config(self, organism, wd): c_dict = {} path_to_config = os.path.join(wd, "../config/celltypes_"+organism+".json") with open(path_to_config) as input_file: data = json.loads(input_file.read()) for x in data: c_dict[x["type"]] = x["alias_ensembl"] self.folderlist.extend(x["alias_ensembl"]) return c_dict def get_activity_data(self, release, organism, wd): for folder in self.folderlist: # Generate path to binary File file = os.path.join(wd, "/EnsemblData", release, organism, "activity", folder, "table.bin") with open(file, "rb") as tables: self.activity[folder] = bytearray(tables.read()) def generate_categorized_activity(self): category_activity = {} for category, aliases in self.c_dict.items(): # If an alias exists if aliases: # If theres only one alias if len(aliases) == 1: category_activity[category] = self.activity[aliases[0]] # If there are multiple alias else: category_activity[category] = self.activity_comparator(aliases) # If theres no alias all bytes were set to 4 = NA else: category_activity[category] = bytearray([4]*len(self.activity[self.folderlist[0]])) return category_activity def activity_comparator(self, aliaslist): concatenated_array = bytearray([]) length = len(self.activity[aliaslist[0]]) input_arrays = [self.activity[x] for x in aliaslist] for x in range(length): if any(y[x] == 0 for y in input_arrays): concatenated_array.append(0) elif any(y[x] == 1 for y in input_arrays): concatenated_array.append(1) elif any(y[x] == 2 for y in input_arrays): concatenated_array.append(2) elif any(y[x] == 3 for y in input_arrays): concatenated_array.append(3) elif any(y[x] == 4 for y in input_arrays): concatenated_array.append(4) return concatenated_array # Debugging # e = ActivityCategorizer("../../config/celltypes_human.json", "release-94", "homo_sapiens") # print(len(e.categorization)) # for x in e.categorization.values(): # print(len(x))
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
You can’t perform that action at this time.