Exemple #1
0
# Copyright (C) 2021 Vladyslav Synytsyn
"""This module contains decorators, used to manage command accessibility from different chat types."""
from typing import Callable, Any

from telegram import Update
from telegram.ext import CallbackContext

from app_logging import get_logger
from localization.replies import private_unaccepted


logger = get_logger(__name__)


def group_only_handler(handler: Callable[[Update, CallbackContext], Any]):
    """
    Decorator function. \n

    It is used to decorate handlers, that HAVE TO accept two arguments:
    :class:`telegram.Update` and :class:`telegram.CallbackContext` \n

    Note:
        The wrapped function will be called ONLY if the chat type is 'group' or 'supergroup'.
        Otherwise will be sent ``bot.constants.private_unaccepted``

        You can also use ``Filters.chat_type.private`` for filtering your messages.

    Args:
        handler: handler function for command
    Returns:
        given function wrapped with chat type check.
from app_logging import get_logger
log = get_logger()

from hotspots.database_util import sql_connection

INTERPRO_TABLE = 'interpro_domains'

class InterProEntryNotFound(Exception):
    def __init__(self, uniprot_id):
        self.message = uniprot_id

def get_protein_domain_data(uniprot_id):
    query_tpl = 'SELECT interpro_id, name, database, start, end ' \
                'FROM {interpro_table} ' \
                'WHERE uniprot_accession=?'
    query = query_tpl.format(interpro_table=INTERPRO_TABLE)

    log.debug("INTERPRO SQL: " + query)

    values = [uniprot_id]

    db = sql_connection()
    cursor = db.cursor()
    cursor.execute(query, tuple(values))

    items = []
    for row in cursor.fetchall():
        res = {k: row[k] for k in row.keys()}
        items.append(res)

    cursor.close()
Exemple #3
0
                                               new_group_created_handler)
from bot.handlers.command_handlers import (
    start_command, create_queue_command, delete_queue_command,
    show_queues_command, help_command, about_me_command,
    unsupported_command_handler, add_me_command, remove_me_command,
    skip_me_command, next_command, notify_all_command, show_members_command)
from bot.handlers.error_handler import error_handler
from bot.handlers.report_handler import report_command, DESCRIPTION, description_handler, \
    send_without_description_handler, cancel_handler, cancel_keyboard_button, without_description_keyboard_button
from sql import get_tables, get_database_revision

bot = Bot(BOT_TOKEN)

# Registering logger here
app_logging.register_bot(bot)
logger = app_logging.get_logger(__name__)


def setup():
    """
    Setting up updater.
    Checking the connectivity with the database.

    Registered all handlers (for commands)

    Returns:
        dispatcher and updater
    """
    logger.info(f'Bot version: {BOT_VERSION}')
    logger.info(
        f"\n\tDB revision: {get_database_revision()}; \n\ttables: {get_tables()}"
Exemple #4
0
import sys
import time
import RPi.GPIO as GPIO
import app_logging

# script to turn light on or off

logger = app_logging.get_logger()


def turn_on(parameter):

    GPIO.setwarnings(False)
    GPIO.setmode(GPIO.BOARD)
    # Pin 11 (GPIO 17) as output
    GPIO.setup(11, GPIO.OUT)
    logger.info("Automation light: checking parameter")

    msg = sys.argv[1]
    if (parameter == 1):
        #LED on
        logger.info("Automation light: turning on")
        GPIO.output(11, GPIO.HIGH)
    else:
        #LED off
        logger.info("Automation light: turning off")
        GPIO.output(11, GPIO.LOW)
import sys
import time
import RPi.GPIO as GPIO
import app_logging

# script to turn light on or off

logger = app_logging.get_logger()

def turn_on(parameter):

	GPIO.setwarnings(False)
	GPIO.setmode(GPIO.BOARD)
	# Pin 11 (GPIO 17) as output
	GPIO.setup(11, GPIO.OUT)
	logger.info("Automation light: checking parameter")

	msg = sys.argv[1]
	if(parameter==1):
		#LED on
		logger.info("Automation light: turning on")
		GPIO.output(11, GPIO.HIGH)
	else:
		#LED off
		logger.info("Automation light: turning off")
		GPIO.output(11, GPIO.LOW)
from flask import render_template

from hotspots.seqpeek.pathway_assoc_data import get_pathway_data
from hotspots.seqpeek.view import sanitize_normalize_tumor_type

from app_logging import get_logger

log = get_logger()

try:
    from hotspots.seqpeek.gene_list import gene_list as GENE_LIST
except ImportError:
    log.error("Loading gene list failed, using static list.")
    GENE_LIST = ['EGFR', 'TP53', 'PTEN']

TEMPLATE_NAME = 'hotspots/pathway_assoc.html'


def sanitize_gene_input(gene_param):
    gene_set = frozenset(GENE_LIST)
    if gene_param in gene_set:
        return gene_param
    else:
        log.error("{0} - Unknown gene '{1}'".format(__name__, gene_param))
        return None


def pathway_assoc_view(request_gene, request_tumor_type, request_cluster):
    template_args = {'data_found': False}

    gene = sanitize_gene_input(request_gene)