def __init__(self): if not BaseTestClass.TEST_LOGGER: BaseTestClass.TEST_LOGGER = standard_logger.get_logger('tests', level_str='DEBUG') self.logger = BaseTestClass.TEST_LOGGER self.conf = JsonConfig.conf(logger=self.logger, package_name='prolix') self.conf.config_name = 'prolix_conf.json' self.conf_data = self.conf.get_data()
def __init__(self, *args, **kwargs): self.all_args = list(args) self.args = self.all_args self.cli = True if 'cli' in kwargs and kwargs['cli'] else False # Should be from config file self.frequency_file_name = 'frequencies-1.json' self.minimum_input_text_length = 4 self.letter_randomizer_file_name = "letter_randomizer_ascii.json" self.min_padding_size = 8 self.max_padding_size = 64 self.logger = kwargs['logger'] if 'logger' in kwargs \ else standard_logger.get_logger('randascii', level_str='DEBUG', console=True) # Define properties self.input_file_name = None self.input_data = None self.input_data_length = None self.frequency_data = None self.letters_by_frequency = None self.normalized_frequency_data = None self.lookup_letter_data = None self.lookup_letter_data_len = None self.secure_rng = random.SystemRandom()
def __init__(self, logger=None): self.logger = logger if logger else standard_logger.get_logger("Store") self.conf = JsonConfig.conf(logger=self.logger, package_name='prolix') self.conf.config_name = 'prolix_conf.json' self.conf_data = self.conf.get_data() self.default_expiration_seconds = self.conf_data['default_store_expiration_secs'] self.expiration_seconds = self.default_expiration_seconds
def __init__(self, logger=None): self.logger = logger if logger else standard_logger.get_logger("Index") self.object_type = "IndexType" self.object_type_version = "V1" self.storage_key = "" self.steno_seq = [] self.ttl_seconds = 60 * IndexEntry.DEFAULT_TTL_MINS
def __init__(self, **kwargs): self.logger = kwargs['logger'] if 'logger' in kwargs else standard_logger.get_logger('prolix_api') self.conf = JsonConfig.conf(logger=self.logger, package_name='prolix') self.conf.config_name = 'prolix_conf.json' self.conf_data = self.conf.get_data() self.default_store_expiration_secs = self.conf_data['default_store_expiration_secs'] self.steno = steno.Steno(logger=self.logger)
def __init__(self, logger=None): self.logger = logger if logger else standard_logger.get_logger("Store") self.conf = JsonConfig.conf(logger=self.logger, package_name='prolix') self.conf.config_name = 'prolix_conf.json' self.conf_data = self.conf.get_data() self.default_expiration_seconds = self.conf_data[ 'default_store_expiration_secs'] self.redis_store = store.RedisStore(logger=self.logger) # Initialize RandomAsciiStringByFrequency because of file loads needed self.rasbf = rand.RandomAsciiStringByFrequency( logger=self.logger).dispatch()
def main(data=None, logger=None): """ Standalone entry point for installation package Args: data (list(dict)): Data structure. See package_data.py or README for examples. logger (obj): logger instance Returns: Nothing returned """ if not logger: logger = get_logger(application_name="macos_installer", console=True) PackageManager.all_actions(data=data, logger=logger) return
def __init__(self, logger=None, package_name=None, package_dir=None): self.package_name = package_name if package_name else paths.guess_package() self.package_dir = package_dir if package_dir else paths.get_package_path(package_name=self.package_name) self.data_dir = paths.get_data_path(package_name=self.package_name) self.search_paths = [] self.full_search_paths = [] self.loaded_search_paths = [] self.config_name = 'conf.json' self.use_default_sym_names = True self.default_sym_names = ['package', 'home', 'env'] self.sym_names = [] self.conf_data = {} self.env_conf_dir_name = "JSON_CONF_DIR" self.env_conf_name = "JSON_CONF" self.loaded = False self.paths_expanded = False self.logger = logger if logger else standard_logger.get_logger('JsonConfig', level_str="DEBUG")
def load_data_5000_words(logger=None): """ Load data for '5000 common words' dataset' :return: Dataset or empty dict if any errors :rtype: dict """ try: logger = logger if logger else get_logger("words") json_data_file_name = "5000_common_words.json" json_data_file_path = path.normpath( path.join(BASEDIR, json_data_file_name)) with open(json_data_file_path, 'r') as jf: json_str = jf.read() json_dict = json.loads(json_str) return json_dict except Exception as e: logger.error("Error loading word data {0}".format(e)) return {}
def __init__(self, logger=None): self.logger = logger if logger else standard_logger.get_logger("RandomString")
def __init__(self,logger=None): self.logger = logger if logger else standard_logger.get_logger("RandValues") self.word_dict = words.load_data(dataset='5000words', logger=self.logger) self.word_count = len(self.word_dict) self.rng = RandomInts(self.logger)
def main(): parser = argparse.ArgumentParser() parser.add_argument("-i", "--dbg", required=True, help="Directory with DBG output") parser.add_argument("-o", "--outdir", required=True) parser.add_argument("--ref") parser.add_argument("--refhpc", action='store_true') parser.add_argument("--no_export_pdf", action='store_true') parser.add_argument("-K", type=int, default=40002) params = parser.parse_args() params.dbg = expandpath(params.dbg) params.outdir = expandpath(params.outdir) smart_makedirs(params.outdir) logfn = os.path.join(params.outdir, 'inc_k.log') global logger logger = get_logger(logfn, logger_name='centroFlye: inc_k') logger.info(f'cmd: {sys.argv}') logger.info(f'git hash: {get_git_revision_short_hash()}') db_fn = os.path.join(params.dbg, 'graph.fasta') align_fn = os.path.join(params.dbg, 'alignments.txt') dbg_log_fn = os.path.join(params.dbg, 'dbg.log') with open(dbg_log_fn) as f: cmd = f.readline().strip().split(' ') i = 0 while cmd[i] != '-k': i += 1 k = int(cmd[i+1]) + 1 logger.info(f'init k = {k}') logger.info(f'Reading DBG output from {params.dbg}') lpdb = PathMultiKGraph.fromDR(db_fn=db_fn, align_fn=align_fn, k=k, K=params.K) logger.info(f'# vertices = {nx.number_of_nodes(lpdb.nx_graph)}') logger.info(f'# edges = {nx.number_of_edges(lpdb.nx_graph)}') logger.info(f'Finished reading DBG output') logger.info(f'Starting increasing k') lpdb.transform_fast_until_saturated() logger.info(f'Finished increasing k') logger.info(f'# vertices = {nx.number_of_nodes(lpdb.nx_graph)}') logger.info(f'# edges = {nx.number_of_edges(lpdb.nx_graph)}') outac = os.path.join(params.outdir, f'active_connections.txt') logger.info(f'Active connections output to {outac}') with open(outac, 'w') as f: ac = lpdb.idb_mappings.get_active_connections() ac = sorted(list(ac)) for i, j in ac: print(f'{i} {j}', file=f) outuniquedges = os.path.join(params.outdir, f'unique_edges.txt') logger.info(f'Unique edges output to {outuniquedges}') with open(outuniquedges, 'w') as f: for index in sorted(list(lpdb.unique_edges)): print(index, file=f) outdot = os.path.join(params.outdir, f'dbg_{k}-{lpdb.init_k+lpdb.niter}') logger.info(f'Writing final graph to {outdot}') outfasta = outdot + '.fasta' logger.info(f'Writing graph edges to {outfasta}') edges = {key: ''.join(edge) for key, edge in lpdb.edge2seq.items()} write_bio_seqs(outfasta, edges) lpdb.write_dot(params.outdir, compact=True, reffn=params.ref, refhpc=params.refhpc, export_pdf=not params.no_export_pdf) logger.info(f'Finished writing final graph (dot)') out = open(outdot + ".graph", "w") for edge in lpdb.nx_graph.edges(keys=True): index = lpdb.edge2index[edge] seq = lpdb.edge2seq[index] out.write(">" + "_".join([str(index), str(edge[0]), str(lpdb.node2len[edge[0]]), str(edge[1]), str(lpdb.node2len[edge[1]])]) + "\n") out.write("".join(seq)) out.write("\n") out.close()
def setUpClass(cls): if not cls.TEST_LOGGER: cls.TEST_LOGGER = standard_logger.get_logger('tests', level_str='DEBUG', console=True) cls.logger = cls.TEST_LOGGER
import sys import os from os import path import tempfile import standard_logger LOGGER = standard_logger.get_logger('prolix_server', level_str='ERROR', console=True) from pyxutils import paths as pxpaths TEMPLATES_DIR = path.normpath( path.join(pxpaths.get_package_path('prolix'), 'server', 'templates')) from flask import Flask, render_template, request app = Flask("prolix_server", template_folder=TEMPLATES_DIR) import prolix @app.route("/", methods=['GET']) def display_form(): if request.method == 'GET': return render_template('main_form.html', clear_text="Enter some text here") else: return "Error in server"