<commit_before>import numpy as np
import pandas as pd


class Gene:

    def __init__(self, name):
        self.name = name


class Sample:

    def __init__(self, data):
        self.data = data

    @classmethod
    def from_names(cls, data):
        return cls({
            Gene(name=name): value
            for name, value in data.items()
        })


class Phenotype:
    def __init__(self, name='', samples=None):
        self.samples = samples or []
        self.name = name

    def as_array(self):
        """
        For example as data_frame
        The idea is that it should be an object which can ba passed to ttest_ind
        :return:
        """
        pass

    def __add__(self, other):
        return self.samples + other.samples


class Experiment:

    def __init__(self, case: Phenotype, control: Phenotype):
        self.control = control
        self.case = case

    def get_all(self):
        return self.control + self.case

    @classmethod
    def from_tsv(cls, file_name):
        # TODO
        control = Phenotype(name='Some Hardcore Tumor', samples=[Sample()])
        case = Phenotype(name='reference', samples=[Sample()])
        return cls(control, case)
        """
        def read_tsv_data(file_name, control_samples):
            ""
            Args:
                # TODO
                file_name: file containing gene expression of the following structure:
                - names of samples separated by tab in first row
                - gene symbol/name followed by gene expression values for every sample in remaining rows
                control_samples: list of control_samples indexes (1 - based)
            Returns:
                data frames for two sets of samples
        ""
        with open(file_name, 'r') as f:
            case_samples = [x for x in range(len(f.readline().split('\t')[1:])) if x not in control_samples]<commit_msg>Some TODOs and small improves in models<commit_after>import numpy as np
import pandas as pd


class Gene:

    instances = {}

    def __new__(cls, name, *args, **kwargs):
        if name not in cls.instances:
            cls.instances[name] = super(Gene, cls).__new__(cls, *args, **kwargs)
        return cls.instances[name]

    def __init__(self, name):
        self.name = name


# TODO description about what is data?
class Sample:

    def __init__(self, name, data):
        self.name = name
        self.data = data

    @classmethod
    def from_names(cls, name, data):
        return cls(name, {Gene(_name) : value for _name, value in data.items()})


# TODO class variable with set of genes + method(s) for checking data integrity
class Phenotype:
    def __init__(self, name, samples=None):
        self.samples = samples or []
        self.name = name

    def as_array(self):
        """
        For example as data_frame
        The idea is that it should be an object which can ba passed to ttest_ind
        :return:
        """
        pass

    def __add__(self, other):
        return self.samples + other.samples

# TODO class variable with set of genes + method(s) for checking data integrity
# TODO unify file reading with argument_parser
class Experiment:

    def __init__(self, case: Phenotype, control: Phenotype):
        self.control = control
        self.case = case

    def get_all(self):
        return self.control + self.case

    @classmethod
    def from_tsv(cls, file_name):
        # TODO
        control = Phenotype(name='Some Hardcore Tumor', samples=[Sample()])
        case = Phenotype(name='reference', samples=[Sample()])
        return cls(control, case)
        """
        def read_tsv_data(file_name, control_samples):
            ""
            Args:
                # TODO
                file_name: file containing gene expression of the following structure:
                - names of samples separated by tab in first row
                - gene symbol/name followed by gene expression values for every sample in remaining rows
                control_samples: list of control_samples indexes (1 - based)
            Returns:
                data frames for two sets of samples
        ""
        with open(file_name, 'r') as f:
            case_samples = [x for x in range(len(f.readline().split('\t')[1:])) if x not in control_samples]
{'fraction_non_alphanumeric': 0.08817354793561931, 'fraction_numerical': 0.0009330534173081409, 'mean_word_length': 2.1460014673514305, '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': '1106964', 'n_tokens_mistral': 1193, 'n_tokens_neox': 1142, 'n_words': 413}