<commit_before>from app.drivers.basedrivers import PycolatorDriver
from app.preparation import pycolator as preparation
from app.readers import pycolator as readers


class SplitDriver(PycolatorDriver):
    def __init__(self, **kwargs):
        super(SplitDriver, self).__init__(**kwargs)
        self.targetsuffix = kwargs.get('targetsuffix', '_target.xml')
        self.decoysuffix = kwargs.get('decoysuffix', '_decoy.xml')

    def prepare(self):
        self.ns, self.static_xml = self.prepare_percolator_output(self.fn)

    def run(self):
        td = {'target': self.targetsuffix, 'decoy': self.decoysuffix}
        for filter_type in ['target', 'decoy']:
            self.prepare()
            self.set_features(filter_type)
            self.outsuffix = td[filter_type]
            self.write(filter_type)

    def set_features(self, filter_type):
        """ Calls splitter to split percolator output into target/decoy elements.
            Writes two new xml files with features. Currently only psms and
            peptides. Proteins not here, since one cannot do protein inference
            before having merged and remapped multifraction data anyway.
        """
        elements_to_split = {'psm': self.allpsms, 'peptide': self.allpeps}
        self.features = preparation.split_target_decoy(elements_to_split,
                                                       self.ns, filter_type)


class MergeDriver(PycolatorDriver):<commit_msg>Fixed bugs in splitdriver<commit_after>from app.drivers.basedrivers import PycolatorDriver
from app.preparation import pycolator as preparation
from app.readers import pycolator as readers


class SplitDriver(PycolatorDriver):
    def __init__(self, **kwargs):
        super(SplitDriver, self).__init__(**kwargs)
        self.targetsuffix = kwargs.get('targetsuffix', '_target.xml')
        self.decoysuffix = kwargs.get('decoysuffix', '_decoy.xml')

    def run(self):
        td = {'target': self.targetsuffix, 'decoy': self.decoysuffix}
        for filter_type in ['target', 'decoy']:
            self.prepare(self.fn)
            self.set_features(filter_type)
            self.outsuffix = td[filter_type]
            self.write()

    def set_features(self, filter_type):
        """ Calls splitter to split percolator output into target/decoy elements.
            Writes two new xml files with features. Currently only psms and
            peptides. Proteins not here, since one cannot do protein inference
            before having merged and remapped multifraction data anyway.
        """
        elements_to_split = {'psm': self.allpsms, 'peptide': self.allpeps}
        self.features = preparation.split_target_decoy(elements_to_split,
                                                       self.ns, filter_type)


class MergeDriver(PycolatorDriver):
{'fraction_non_alphanumeric': 0.09023090586145649, 'fraction_numerical': 0.0, 'mean_word_length': 2.7546666666666666, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 7}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6326155', 'n_tokens_mistral': 793, 'n_tokens_neox': 761, 'n_words': 205}