# Path: grit/config.py
# MAX_NUM_TRANSCRIPTS_TO_QUANTIFY = 1000
# MAX_NUM_CANDIDATE_TRANSCRIPTS = 50000
# CB_SIG_LEVEL = 0.025
# VERBOSE = None
# DEBUG_VERBOSE = None
# WRITE_DEBUG_DATA = None
# FIX_CHRM_NAMES_FOR_UCSC = None
# ONLY_BUILD_CANDIDATE_TRANSCRIPTS = None
# NTHREADS = None
# TOTAL_MAPPED_READS = None
# ESTIMATE_UPPER_CONFIDENCE_BOUNDS = True
# ESTIMATE_LOWER_CONFIDENCE_BOUNDS = True
# ELEMENT_FILTER_FRAC = 0.05
# MIN_INTRON_FLANKING_SIZE = 12 
# MIN_ENTROPY = 0
# MIN_INTRON_SIZE = 40
# MAX_EMPTY_REGION_SIZE = 200 #MIN_INTRON_SIZE
# MAX_INTRON_SIZE = int(1e6)
# MIN_GENE_LENGTH = 400
# MAX_GENE_EXPANSION = 1000
# NOISE_JN_FILTER_FRAC = 0.01
# MAX_JN_OFFSET_FILTER = 15
# MAX_FRAGMENT_LENGTH = 1000
# MIN_FRAGMENT_LENGTH = 75
# ONLY_USE_REFERENCE_JUNCTIONS = False
# MIN_EXON_FPKM = 0.1
# MAX_EXPRESSION_RATIO = 20
# BUILD_MODELS_WITH_RETAINED_INTRONS = False
# MIN_NUM_CAGE_TAGS = 5
# NUM_TSS_BASES_TO_SKIP = 200
# MIN_NUM_POLYA_TAGS = 2
# NUM_TES_BASES_TO_SKIP = 300
# TES_EXON_MERGE_DISTANCE = 0
# TSS_EXON_MERGE_DISTANCE = 0
# MAX_DISTAL_SIZE_FOR_MATCH_OFFSET = 100
# def get_gene_tmp_fname(gene_id, sample_type=None, rep_id=None):
# def get_fmat_tmp_fname(gene_id, sample_type=None, rep_id=None):
# def log_statement(*args, **kwargs):


import os, sys
import time
import curses
import multiprocessing
import grit
from grit import config
        self.pid_to_index_mapping.append( self.main_pid )
        for loop in xrange(self.nthreads):
            self.pid_to_index_mapping.append( None )


    def __init__(self, nthreads, use_ncurses=False, log_ofstream=None):
        self.use_ncurses = use_ncurses
        self.nthreads = nthreads
        self.log_ofstream = log_ofstream
        
        if self.use_ncurses:
            self._init_ncurses_manager()
        
        return
    
    def __call__( self, message, display=True, log=False ):
        message = str(message)
        if not self.use_ncurses:
            if log or (config.DEBUG_VERBOSE and message.strip() != ''): 
                self.log_ofstream.write(message.strip() + "\n" )
                self.log_ofstream.flush()
                sys.stderr.write(message.strip() + "\n" )
            return

        # if the message is empty, always display and never log
        if message == "": 
            display = True
            log = False
        # if we want to log this, and we have an output stream, write this
        # to the log

# Path: grit/config.py
# MAX_NUM_TRANSCRIPTS_TO_QUANTIFY = 1000
# MAX_NUM_CANDIDATE_TRANSCRIPTS = 50000
# CB_SIG_LEVEL = 0.025
# VERBOSE = None
# DEBUG_VERBOSE = None
# WRITE_DEBUG_DATA = None
# FIX_CHRM_NAMES_FOR_UCSC = None
# ONLY_BUILD_CANDIDATE_TRANSCRIPTS = None
# NTHREADS = None
# TOTAL_MAPPED_READS = None
# ESTIMATE_UPPER_CONFIDENCE_BOUNDS = True
# ESTIMATE_LOWER_CONFIDENCE_BOUNDS = True
# ELEMENT_FILTER_FRAC = 0.05
# MIN_INTRON_FLANKING_SIZE = 12 
# MIN_ENTROPY = 0
# MIN_INTRON_SIZE = 40
# MAX_EMPTY_REGION_SIZE = 200 #MIN_INTRON_SIZE
# MAX_INTRON_SIZE = int(1e6)
# MIN_GENE_LENGTH = 400
# MAX_GENE_EXPANSION = 1000
# NOISE_JN_FILTER_FRAC = 0.01
# MAX_JN_OFFSET_FILTER = 15
# MAX_FRAGMENT_LENGTH = 1000
# MIN_FRAGMENT_LENGTH = 75
# ONLY_USE_REFERENCE_JUNCTIONS = False
# MIN_EXON_FPKM = 0.1
# MAX_EXPRESSION_RATIO = 20
# BUILD_MODELS_WITH_RETAINED_INTRONS = False
# MIN_NUM_CAGE_TAGS = 5
# NUM_TSS_BASES_TO_SKIP = 200
# MIN_NUM_POLYA_TAGS = 2
# NUM_TES_BASES_TO_SKIP = 300
# TES_EXON_MERGE_DISTANCE = 0
# TSS_EXON_MERGE_DISTANCE = 0
# MAX_DISTAL_SIZE_FOR_MATCH_OFFSET = 100
# def get_gene_tmp_fname(gene_id, sample_type=None, rep_id=None):
# def get_fmat_tmp_fname(gene_id, sample_type=None, rep_id=None):
# def log_statement(*args, **kwargs):


# Path: grit/lib/logging.py
import os, sys
import time
import curses
import multiprocessing
import grit
from grit import config

        self.pid_to_index_mapping.append( self.main_pid )
        for loop in xrange(self.nthreads):
            self.pid_to_index_mapping.append( None )


    def __init__(self, nthreads, use_ncurses=False, log_ofstream=None):
        self.use_ncurses = use_ncurses
        self.nthreads = nthreads
        self.log_ofstream = log_ofstream
        
        if self.use_ncurses:
            self._init_ncurses_manager()
        
        return
    
    def __call__( self, message, display=True, log=False ):
        message = str(message)
        if not self.use_ncurses:
            if log or (config.DEBUG_VERBOSE and message.strip() != ''): 
                self.log_ofstream.write(message.strip() + "\n" )
                self.log_ofstream.flush()
                sys.stderr.write(message.strip() + "\n" )
            return

        # if the message is empty, always display and never log
        if message == "": 
            display = True
            log = False
        # if we want to log this, and we have an output stream, write this
        # to the log

        if (log or config.DEBUG_VERBOSE) and self.log_ofstream != None: