Skip to content

Commit

Permalink
light cleanup & documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
Lioscro committed Apr 24, 2018
1 parent 0a3a369 commit 3b66f0f
Show file tree
Hide file tree
Showing 13 changed files with 184 additions and 306 deletions.
28 changes: 21 additions & 7 deletions src/scripts/Alaska.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,18 @@
"""Contains the Alaska class.
The Alaska class is inherited by all AlaskaX classes. The class contains
all shared variables among the Alaska family.
"""
Alaska.py

Author: Joseph Min (kmin@caltech.edu)
__author__ = 'Kyung Hoi (Joseph) Min'
__copyright__ = 'Copyright 2017 WormLabCaltech'
__credits__ = ['David Angeles', 'Raymond Lee', 'Juancarlos Chan']
__license__ = "MIT"
__version__ = "alpha"
__maintainer__ = "Kyung Hoi (Joseph) Min"
__email__ = "kmin@caltech.edu"
__status__ = "alpha"

This file contains the class Alaska, which is inherited by all Alaska scripts.
"""
import os
import random
import datetime as dt
Expand Down Expand Up @@ -95,23 +103,29 @@ class Alaska():
'read_quant': b'\x10', # perform read quantification
'diff_exp': b'\x11', # perform differential expression
'do_all': b'\x12', # perform qc, read quant, and diff exp
'proj_status': b'\x13', # check project status
'open_sleuth_server': b'\x13',
'proj_status': b'\x14', # check project status
'test_copy_reads': b'\x47',
'test_set_vars': b'\x48',
'test_qc': b'\x49',
'test_read_quant': b'\x50',
'test_diff_exp': b'\x51',
'test_all': b'\x52',
'get_status': b'\x93',
'save': b'\x94', # saves server state
'load': b'\x95', # loads server state
'log': b'\x96', # force log
'update_orgs': b'\x97', # force organism update
'update_orgs': b'\x97', # force organism update
'start': b'\x98', # start server
'stop': b'\x99' # stop server
}

# Progress notes
# Server state.
SERVER_STATE = {
0: 'under maintenance',
1: 'active',
}

# 0: This is a new project.
# 1: raw reads fetched
# 2: samples inferred.
Expand Down
22 changes: 15 additions & 7 deletions src/scripts/AlaskaDocker.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,20 @@
"""Contains the AlaskaDocker class.
The AlaskaDocker class is a wrapper around the Docker Python API, which is
used to manage the spawning/monitoring/termination of Docker images and
containers. All containers spawned by Alaska is spawned through an
AlaskaDocker object.
"""
AlaskaDocker.py

Author: Joseph Min (kmin@caltech.edu)
__author__ = 'Kyung Hoi (Joseph) Min'
__copyright__ = 'Copyright 2017 WormLabCaltech'
__credits__ = ['David Angeles', 'Raymond Lee', 'Juancarlos Chan']
__license__ = "MIT"
__version__ = "alpha"
__maintainer__ = "Kyung Hoi (Joseph) Min"
__email__ = "kmin@caltech.edu"
__status__ = "alpha"

This file contains the class AlaskaDocker, which deals with docker container
spawning and output.
Managed by AlaskaServer.
"""
import docker
from Alaska import Alaska
from threading import Thread
Expand Down Expand Up @@ -44,7 +52,7 @@ def out_listener(self):
Listens container output and records.
"""
for l in self.hook():
l = l.decode(self.ENCODING).strip()
l = l.decode(Alaska.ENCODING).strip()
self.output += l

self.running = False
Expand Down
25 changes: 18 additions & 7 deletions src/scripts/AlaskaJob.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,22 @@
"""Contains the AlaskaJob class.
Computationally-intense processes are managed by creating AlaskaJob objects.
The AlaskaJob class serves as an intermediary between the AlaskaServer and
AlaskaDocker. Specifically, this class provides abstractions that simplify
spawning containers, reading their output and terminating them. Quality
control, read alignment and differential expression analysis are done by using
this class.
"""
AlaskaJob.py

Author: Joseph Min (kmin@caltech.edu)
__author__ = 'Kyung Hoi (Joseph) Min'
__copyright__ = 'Copyright 2017 WormLabCaltech'
__credits__ = ['David Angeles', 'Raymond Lee', 'Juancarlos Chan']
__license__ = "MIT"
__version__ = "alpha"
__maintainer__ = "Kyung Hoi (Joseph) Min"
__email__ = "kmin@caltech.edu"
__status__ = "alpha"

This file contains the class AlaskaJob, which contains job information.
Managed by Alaskaserver.
"""
import io
import contextlib as cl
import json
Expand Down Expand Up @@ -64,7 +75,7 @@ def save(self, folder=None):
Saves job information to JSON.
"""
if folder is None: # if folder not given, save to project root
path = self.JOBS_DIR
path = Alaska.JOBS_DIR
else:
path = folder

Expand All @@ -76,7 +87,7 @@ def load(self, folder=None, proj=None):
Load job from JSON.
"""
if folder is None:
path = self.JOBS_DIR
path = Alaska.JOBS_DIR
else:
path = folder

Expand Down
25 changes: 15 additions & 10 deletions src/scripts/AlaskaOrganism.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,18 @@
"""
AlaskaOrganism.py
Author: Joseph Min (kmin@caltech.edu)
"""Contains the AlaskaOrganism class.
Contains AlaskaOrganism class.
AlaskaOrganism is an object that contains information of each organism.
(Including all available reference sequences.)
Contains all necessary information about a model organism. This class holds
multiple AlaskaReference objects, one for each reference version.
"""

__author__ = 'Kyung Hoi (Joseph) Min'
__copyright__ = 'Copyright 2017 WormLabCaltech'
__credits__ = ['David Angeles', 'Raymond Lee', 'Juancarlos Chan']
__license__ = "MIT"
__version__ = "alpha"
__maintainer__ = "Kyung Hoi (Joseph) Min"
__email__ = "kmin@caltech.edu"
__status__ = "alpha"

import os
import json
from Alaska import Alaska
Expand All @@ -28,7 +33,7 @@ def __init__(self, genus, species):
self.full = '{}_{}'.format(genus, species)
self.short = '{}_{}'.format(genus[0].lower(), species)
self.refs = {}
self.path = '{}/{}/{}'.format(self.ORGS_DIR, genus, species)
self.path = '{}/{}/{}'.format(Alaska.ORGS_DIR, genus, species)

def add_new_ref(self, version, cds, bed):
"""
Expand All @@ -42,7 +47,7 @@ def save(self, folder=None):
Saves organism data to JSON.
"""
if folder is None:
path = self.ORGS_DIR
path = Alaska.ORGS_DIR
else:
path = folder

Expand All @@ -56,7 +61,7 @@ def load(self, folder=None):
Loads organism from JSON.
"""
if folder is None:
path = self.ORGS_DIR
path = Alaska.ORGS_DIR
else:
path = folder

Expand Down

0 comments on commit 3b66f0f

Please sign in to comment.