<commit_before>import os
import shutil
import os.path as op

# from collections import Counter
from bcbio.utils import splitext_plus, file_exists, safe_makedir, chdir
from bcbio.provenance import do
from bcbio.distributed.transaction import file_transaction, tx_tmpdir
from bcbio import broad
from bcbio.bam import index

from ichwrapper import log

def _align(in_fastq, sample, workdir, genome_index, is_directional, reference, config):
    """
    align with bismark
    """
    bismark = do.find_cmd("bismark")
    num_cores = config['algorithm'].get('cores', 1)
    basename = sample
    if is_directional:
        is_directional = ""
    else:
        is_directional = "--non_directional"
    cmd = "{bismark} --bowtie2 -p {num_cores} -n 1 -o {tx_dir} --basename {sample} --unmapped {is_directional} {genome_index} {in_fastq}"
    out_dir = op.join(workdir, sample)
    out_bam = op.join(out_dir, sample + ".bam")

    with chdir(workdir):
        if not file_exists(out_bam):
            with tx_tmpdir() as tx_dir:
                cmd = cmd.format(**locals())<commit_msg>use less resources<commit_after>import os
import shutil
import os.path as op

# from collections import Counter
from bcbio.utils import splitext_plus, file_exists, safe_makedir, chdir
from bcbio.provenance import do
from bcbio.distributed.transaction import file_transaction, tx_tmpdir
from bcbio import broad
from bcbio.bam import index

from ichwrapper import log

def _align(in_fastq, sample, workdir, genome_index, is_directional, reference, config):
    """
    align with bismark
    """
    bismark = do.find_cmd("bismark")
    num_cores = int(config['algorithm'].get('cores', 1) / 2)
    basename = sample
    if is_directional:
        is_directional = ""
    else:
        is_directional = "--non_directional"
    cmd = "{bismark} --bowtie2 -p {num_cores} -n 1 -o {tx_dir} --basename {sample} --unmapped {is_directional} {genome_index} {in_fastq}"
    out_dir = op.join(workdir, sample)
    out_bam = op.join(out_dir, sample + ".bam")

    with chdir(workdir):
        if not file_exists(out_bam):
            with tx_tmpdir() as tx_dir:
                cmd = cmd.format(**locals())
{'fraction_non_alphanumeric': 0.1064516129032258, 'fraction_numerical': 0.0032258064516129032, 'mean_word_length': 3.5229166666666667, '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': '6131834', 'n_tokens_mistral': 753, 'n_tokens_neox': 725, 'n_words': 196}