<commit_before>import shutil
from pathlib import Path
from random import sample
from typing import Set, NamedTuple, List
from warnings import warn
from collections import Counter

from pandas import Series, to_numeric
from rpy2.robjects import pandas2ri, StrVector, ListVector, r
from rpy2.robjects.packages import importr
from tqdm import tqdm

from analyses.active_driver import prepare_active_driver_data
from models import Kinase, Site, SiteType, Protein, extract_padded_sequence


pandas2ri.activate()


def load_mimp():
    return importr("rmimp")


def save_kinase_sequences(kinase, sequences, seq_dir):

    if not sequences:
        warn(
            f'No sequences for {kinase.name} created in {seq_dir},'
            f' as no sequences were found.'
        )

    with open(seq_dir / f'{kinase.name}.sequences', 'w') as f:
        f.write(kinase.name + '\n')
        for sequence in sequences:
            f.write(sequence + '\n')


class NegativeSite(NamedTuple):<commit_msg>Always show rMIMP warnings<commit_after>import shutil
from pathlib import Path
from random import sample
from typing import Set, NamedTuple, List
from warnings import warn
from collections import Counter

from pandas import Series, to_numeric
from rpy2.robjects import pandas2ri, StrVector, ListVector, r
from rpy2.robjects.packages import importr
from tqdm import tqdm

from analyses.active_driver import prepare_active_driver_data
from models import Kinase, Site, SiteType, Protein, extract_padded_sequence


pandas2ri.activate()
r("options(warn=1)")


def load_mimp():
    return importr("rmimp")


def save_kinase_sequences(kinase, sequences, seq_dir):

    if not sequences:
        warn(
            f'No sequences for {kinase.name} created in {seq_dir},'
            f' as no sequences were found.'
        )

    with open(seq_dir / f'{kinase.name}.sequences', 'w') as f:
        f.write(kinase.name + '\n')
        for sequence in sequences:
            f.write(sequence + '\n')


class NegativeSite(NamedTuple):
{'fraction_non_alphanumeric': 0.08117529880478087, 'fraction_numerical': 0.004482071713147411, 'mean_word_length': 3.7719714964370548, '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': '3362207', 'n_tokens_mistral': 623, 'n_tokens_neox': 583, 'n_words': 199}