import fasta
import nested
import util


PAML_ERROR_MSG = 'paml_error'
FORWARD_DIRECTION = 0
REVERSE_DIRECTION = 1
DASHLEN_RE = re.compile('^(-*)(.*?)(-*)$')

MAX_HITS = 3
MATRIX_PATH = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'jones.dat')
CODEML_CONTROL_PATH = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'codeml.ctl')

# Constants used when aligning seqs with clustalw.  Kalign does not need these.
USE_CLUSTALW = util.getBoolFromEnv('RSD_USE_CLUSTALW', False)
CLUSTAL_INPUT_FILENAME = 'clustal_fasta.faa'
CLUSTAL_ALIGNMENT_FILENAME = 'clustal_fasta.aln'


#################
# BLAST FUNCTIONS
#################
#
# Used to compute blast hits between two genomes, parse the results, and save the best hits to a file
#

def formatForBlast(fastaPath):
    # os.chdir(os.path.dirname(fastaPath))
    # cmd = 'formatdb -p -o -i'+os.path.basename(fastaPath)
    # cmd = 'formatdb -p -o -i'+fastaPath
Exemple #2
0
######################################
# DATABASE CREDENTIALS AND CONNECTIONS
######################################

# Get credentials from the environment
# MYSQL_HOST = os.environ.get('ROUNDUP_MYSQL_HOST')
# MYSQL_DB = os.environ.get('ROUNDUP_MYSQL_DB')
# MYSQL_USER = os.environ.get('ROUNDUP_MYSQL_USER')
# MYSQL_PASSWORD = os.environ.get('ROUNDUP_MYSQL_PASSWORD')
# Get credentials from a configuration file
MYSQL_HOST = secrets.MYSQL_HOST
MYSQL_DB = secrets.MYSQL_DATABASE
MYSQL_USER = secrets.MYSQL_USER
MYSQL_PASSWORD = secrets.MYSQL_PASSWORD
# Get credentials from a ~/.my.cnf file
if util.getBoolFromEnv('ROUNDUP_MYSQL_CREDS_FROM_CNF', USE_MYCNF):
    MYSQL_USER = getpass.getuser()
    MYSQL_PASSWORD = orchmysql.getCnf()['password']

MYSQL_URL = 'mysql://{user}:{password}@{host}/{db}'.format(
    user=MYSQL_USER, password=MYSQL_PASSWORD, host=MYSQL_HOST, db=MYSQL_DB)
os.environ['ROUNDUP_MYSQL_URL'] = MYSQL_URL
os.environ['DONES_DB_URL'] = MYSQL_URL


def openDbConn(host=MYSQL_HOST, db=MYSQL_DB, user=MYSQL_USER, password=MYSQL_PASSWORD):
    '''
    returns: an open python DB API connection to the mysql host and db.  caller is responsible for closing the connection.
    '''
    # include one paused retry in case db is getting hammered.
    return orchmysql.openConn(host, db, user, password, retries=1, sleep=1)
import re
import shutil
import subprocess
import time

import fasta
import nested
import util


PAML_ERROR_MSG = 'paml_error'
FORWARD_DIRECTION = 0
REVERSE_DIRECTION = 1
DASHLEN_RE = re.compile('^(-*)(.*?)(-*)$')

JIKE_DEBUG = util.getBoolFromEnv('ROUNDUP_RSD_DEBUG', False)

MAX_HITS = 3
MATRIX_PATH = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'jones.dat')
CODEML_CONTROL_PATH = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'codeml.ctl')

# Constants used when aligning seqs with clustalw.  Kalign does not need these.
USE_CLUSTALW = util.getBoolFromEnv('RSD_USE_CLUSTALW', False)
CLUSTAL_INPUT_FILENAME = 'clustal_fasta.faa'
CLUSTAL_ALIGNMENT_FILENAME = 'clustal_fasta.aln'


#################
# BLAST FUNCTIONS
#################
#
import nested
import util

PAML_ERROR_MSG = 'paml_error'
FORWARD_DIRECTION = 0
REVERSE_DIRECTION = 1
DASHLEN_RE = re.compile('^(-*)(.*?)(-*)$')

MAX_HITS = 3
MATRIX_PATH = os.path.join(os.path.dirname(os.path.abspath(__file__)),
                           'jones.dat')
CODEML_CONTROL_PATH = os.path.join(os.path.dirname(os.path.abspath(__file__)),
                                   'codeml.ctl')

# Constants used when aligning seqs with clustalw.  Kalign does not need these.
USE_CLUSTALW = util.getBoolFromEnv('RSD_USE_CLUSTALW', False)
CLUSTAL_INPUT_FILENAME = 'clustal_fasta.faa'
CLUSTAL_ALIGNMENT_FILENAME = 'clustal_fasta.aln'

#################
# BLAST FUNCTIONS
#################
#
# Used to compute blast hits between two genomes, parse the results, and save the best hits to a file
#


def formatForBlast(fastaPath):
    # os.chdir(os.path.dirname(fastaPath))
    # cmd = 'formatdb -p -o -i'+os.path.basename(fastaPath)
    # cmd = 'formatdb -p -o -i'+fastaPath