<commit_before># Copyright (C) 2017 by <NAME>
import os
import csv
import ast
import psutil
import subprocess as sp

def get_samples(config, logger):
    if config['settings'].get('sampleinfo') is None:
        logger.info("[snakemake_rules.settings]: no sampleinfo provided; not setting config['_sampleinfo']")
        return
    try:
        ## Get the sample information
        _include = config.get('samples', [])
        _exclude = config.get('ignore_samples', [])
        _ignored = []
        if len(_include) == 0:
            config['samples'] = []
        with open(config['settings']['sampleinfo']) as csvfile:
            dialect = csv.Sniffer().sniff(csvfile.read(1024))
            csvfile.seek(0)
            reader = csv.DictReader(csvfile, dialect=dialect)
            rows = [row for row in reader]
            config['_sampleinfo'] = []
            for row in rows:
                # Only excluded samples listed
                if len(_include) == 0 and row['SM'] not in _exclude:
                    config['_sampleinfo'].append(row)
                    config['samples'].append(row['SM'])
                # include takes precedence over exclude
                elif row['SM'] in _include:
                    config['_sampleinfo'].append(row)
                elif row['SM'] in _exclude:
                    _ignored.append(row['SM'])
                else:
                    logger.warning("[snakemake_rules.settings]: {} neither in include or exclude section of sampleinfo file".format(row['SM']))
            for s in _ignored:
                logger.info("[snakemake_rules.settings]: ignoring sample {} in current run".format(s))
        if len(_include) == 0:
            config['samples'] = sorted(list(set(config['samples'])))
            logger.info("[snakemake_rules.settings]: no samples listed in config; added {} samples to config['samples']".format(len(config['samples'])))
        logger.info("[snakemake_rules.settings]: successfully loaded {} entries from '{}'".format(len(config['_sampleinfo']), config['settings']['sampleinfo']))
    except Exception as e:
        logger.info("[snakemake_rules.settings]: parsing sampleinfo failed; not setting config['_sampleinfo']: {}".format(e))

        
def python2_path(config, logger):
    """Add python 2 path if possible"""
    try:
        output = sp.check_output(['conda', 'env', 'list', '--json'])<commit_msg>Increase sniffing<commit_after># Copyright (C) 2017 by <NAME>
import os
import csv
import ast
import psutil
import subprocess as sp

def get_samples(config, logger):
    if config['settings'].get('sampleinfo') is None:
        logger.info("[snakemake_rules.settings]: no sampleinfo provided; not setting config['_sampleinfo']")
        return
    try:
        ## Get the sample information
        _include = config.get('samples', [])
        _exclude = config.get('ignore_samples', [])
        _ignored = []
        if len(_include) == 0:
            config['samples'] = []
        with open(config['settings']['sampleinfo']) as csvfile:
            dialect = csv.Sniffer().sniff(csvfile.read(10240), delimiters=[',',';'])
            csvfile.seek(0)
            reader = csv.DictReader(csvfile, dialect=dialect)
            rows = [row for row in reader]
            config['_sampleinfo'] = []
            for row in rows:
                # Only excluded samples listed
                if len(_include) == 0 and row['SM'] not in _exclude:
                    config['_sampleinfo'].append(row)
                    config['samples'].append(row['SM'])
                # include takes precedence over exclude
                elif row['SM'] in _include:
                    config['_sampleinfo'].append(row)
                elif row['SM'] in _exclude:
                    _ignored.append(row['SM'])
                else:
                    logger.warning("[snakemake_rules.settings]: {} neither in include or exclude section of sampleinfo file".format(row['SM']))
            for s in _ignored:
                logger.info("[snakemake_rules.settings]: ignoring sample {} in current run".format(s))
        if len(_include) == 0:
            config['samples'] = sorted(list(set(config['samples'])))
            logger.info("[snakemake_rules.settings]: no samples listed in config; added {} samples to config['samples']".format(len(config['samples'])))
        logger.info("[snakemake_rules.settings]: successfully loaded {} entries from '{}'".format(len(config['_sampleinfo']), config['settings']['sampleinfo']))
    except Exception as e:
        logger.info("[snakemake_rules.settings]: parsing sampleinfo failed; not setting config['_sampleinfo']: {}".format(e))

        
def python2_path(config, logger):
    """Add python 2 path if possible"""
    try:
        output = sp.check_output(['conda', 'env', 'list', '--json'])
{'fraction_non_alphanumeric': 0.1387678904791537, 'fraction_numerical': 0.006015349512549264, 'mean_word_length': 2.5274323335771762, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '1518326', 'n_tokens_mistral': 1334, 'n_tokens_neox': 1276, 'n_words': 335}