<commit_before>#! /usr/bin/env python

"""Assembly execution drivers.

This module provides the default parameters and handling of
assembler-specific configurations.

Assembler defaults are set in the 'arast.conf' file

"""
import logging
import os
import re
import subprocess
import shutil
import tarfile
import glob

import metadata as meta

from ConfigParser import SafeConfigParser

def get_default(key):
    """Get assemblers default value from config file."""
    return parser.get('assemblers', key)

def is_available(assembler):
    """ Check if ASSEMBLER is a valid/available assembler.
    """
    assemblers = ['kiki','velvet']
    if assembler in assemblers:
        return True
    else:
        return False

def run(assembler, datapath, uid, bwa):
    logging.info("Running assembler: %s" % assembler)
#    metadata.update_job(uid, 'status', 'running:')
    if assembler == 'kiki':
#        metadata.update_job(uid, 'status', 'running: kiki')
        result_tar = run_kiki(datapath, bwa)
    elif assembler == 'velvet':
#        metadata.update_job(uid, 'status', 'running: velvet')
        result_tar = run_velvet(datapath, uid, bwa)
    return result_tar

def run_kiki(datapath, bwa):
    """ Runs kiki assembler on ONLY FASTA files. """
    ki_exec = basepath + get_default('kiki.path')
    ki_exec += get_default('kiki.exec')
    threshold = 1000
    raw_path = datapath + '/raw/'
    
    args = [ki_exec, '-k', '29', '-i']
    fasta_files = get_fasta(raw_path)
    readfiles = []
    tmp_files = []
    for file in fasta_files:
        readfile = raw_path + file
        print readfile
        args.append(readfile)
        readfiles.append(readfile)
    #args.append('-o')
    #args.append('ki/')
    ki_data = raw_path + 'ki/'    <commit_msg>add fastq file support to kiki<commit_after>#! /usr/bin/env python

"""Assembly execution drivers.

This module provides the default parameters and handling of
assembler-specific configurations.

Assembler defaults are set in the 'arast.conf' file

"""
import logging
import os
import re
import subprocess
import shutil
import tarfile
import glob

import metadata as meta

from ConfigParser import SafeConfigParser

def get_default(key):
    """Get assemblers default value from config file."""
    return parser.get('assemblers', key)

def is_available(assembler):
    """ Check if ASSEMBLER is a valid/available assembler.
    """
    assemblers = ['kiki','velvet']
    if assembler in assemblers:
        return True
    else:
        return False

def run(assembler, datapath, uid, bwa):
    logging.info("Running assembler: %s" % assembler)
#    metadata.update_job(uid, 'status', 'running:')
    if assembler == 'kiki':
#        metadata.update_job(uid, 'status', 'running: kiki')
        result_tar = run_kiki(datapath, bwa)
    elif assembler == 'velvet':
#        metadata.update_job(uid, 'status', 'running: velvet')
        result_tar = run_velvet(datapath, uid, bwa)
    return result_tar

def run_kiki(datapath, bwa):
    """ Runs kiki assembler on ONLY FASTA files. """
    ki_exec = basepath + get_default('kiki.path')
    ki_exec += get_default('kiki.exec')
    threshold = 1000
    raw_path = datapath + '/raw/'
    
    args = [ki_exec, '-k', '29', '-i']
    valid_files  = get_fasta(raw_path)
    valid_files += get_fastq(raw_path)

    readfiles = []
    tmp_files = []
    for file in valid_files:
        readfile = raw_path + file
        print readfile
        args.append(readfile)
        readfiles.append(readfile)
    #args.append('-o')
    #args.append('ki/')
    ki_data = raw_path + 'ki/'    
{'fraction_non_alphanumeric': 0.11594202898550725, 'fraction_numerical': 0.0033444816053511705, 'mean_word_length': 3.267538644470868, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1625763', 'n_tokens_mistral': 1185, 'n_tokens_neox': 1153, 'n_words': 325}