forked from pilarlopez/illumitag
/
__init__.py
79 lines (62 loc) · 2.59 KB
/
__init__.py
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
b"""This module needs Python 2.7.x"""
# Special variables #
__version__ = '1.0.2'
# Built-in modules #
import os, sys, glob
# Get paths to module #
self = sys.modules[__name__]
module_dir = os.path.dirname(self.__file__)
# Dependencies #
#from plumbing import dependencies
#dependencies.check_setup(module_dir + 'setup.py')
# No need for an X display #
import matplotlib
matplotlib.use('Agg', warn=False)
# Internal modules #
from illumitag.groups.pools import Pool
from illumitag.groups.runs import Runs, Run
from illumitag.groups.aggregate import Aggregate
from illumitag.groups.projects import Projects, Project
from illumitag.groups.presamples import Presample
from illumitag.groups.pyrosample import Pyrosample, Demultiplexer454
from plumbing.git import GitRepo
# Constants #
home = os.environ['HOME'] + '/'
###############################################################################
# Output directory #
view_dir = out_dir = home + 'ILLUMITAG/views/'
# Get the repo #
repos_dir = os.path.abspath(module_dir + '/../') + '/'
git_repo = GitRepo(repos_dir)
# Load all standard pools #
pools_dir = repos_dir + 'json/pools/*/'
json_paths = glob.glob(pools_dir + '*.json')
pools = [Pool(j, view_dir + 'pools/') for j in json_paths]
pools.sort(key=lambda x: str(x))
# Load all presamples #
presamples_dir = repos_dir + 'json/presamples/*/'
json_paths = glob.glob(presamples_dir + '*.json')
presamples = [Presample(j, view_dir + 'presamples/') for j in json_paths]
presamples.sort(key=lambda x: str(x))
# Load all legacy pyrosamples #
pyrosamples_dir = repos_dir + 'json/pyrosamples/'
json_paths = glob.glob(pyrosamples_dir + '*.json')
pyrosamples = [Pyrosample(j, view_dir + 'pyrosamples/') for j in json_paths]
pyrosamples.sort(key=lambda x: str(x))
demultiplexer = Demultiplexer454(pyrosamples)
# All of them together #
all_objects = pools+presamples+pyrosamples
# Compose into runs #
run_nums = sorted(list(set([p.run_num for p in all_objects]))) # [1,2,3,4,5]
runs = [Run(num, [p for p in all_objects if p.run_num==num], view_dir + 'runs/') for num in run_nums]
runs = Runs(runs)
for p in all_objects: p.run = runs[p.run_num]
# Compose into projects #
proj_names = sorted(list(set([p.project_short_name for p in all_objects])))
projects = [Project(name, [p for p in all_objects if p.project_short_name==name], view_dir + 'projects/') for name in proj_names]
projects = Projects(projects)
for p in all_objects: p.project = projects[p.project_short_name]
# Make an aggregate with all pools #
aggregate = Aggregate('all', pools, view_dir + 'aggregates/')
# Make our favorite clusters #
__import__("illumitag.clustering.favorites")