<commit_before>#!/usr/bin/env python3
# encoding: utf-8
'''

Test the OMSSA mop remap of e.g. TMT labeling

TMT labeling has the wrong unimod name in the OMSSA mods xml file

Probably more mods need remap

'K,fix,any,TMT6plex',
'*,opt,N-term,TMT6plex',
'K,fix,any,TMT2plex',
'*,opt,N-term,TMT2plex',

'''
import ursgal
import csv
import os
import pprint


TESTS = [
    {
        'modifications' : [ 'K,fix,any,TMT6plex' ],
        'result_dict': {
            '737' : {
                '198' : {
                    'aa_targets'  : ['K'],
                }
            }
        },
    },
    {
        'modifications' : [ '*,opt,N-term,TMT6plex' ],
        'result_dict': {
            '737' : {
                '199' : {
                    'aa_targets'  : ['N-term'],
                }
            }
        },
    },
    {
        'modifications' : [ 'K,fix,any,TMT2plex' ],
        'result_dict': {
            '738' : {
                '198' : {
                    'aa_targets'  : ['K'],
                }
            }
        },
    },
    {
        'modifications' : [ '*,opt,N-term,TMT2plex' ],
        'result_dict': {
            '738' : {
                '199' : {
                    'aa_targets'  : ['N-term'],
                }
            }
        },
    },

]

def map_mods_test():
    for test_id, test_dict in enumerate(TESTS):
        yield map_mods, test_dict

def map_mods( test_dict ):
    uc = ursgal.UController(
        params = {
            'modifications' : test_dict['modifications']
        }
    )
    omssa_class = cl=uc.unodes['omssa_2_1_9']['_wrapper_class']()
    cl.exe = os.path.join(uc.unodes['omssa_2_1_9']['resource_folder'],'omssacl')
    cl._load_omssa_xml()
    for unimod_id in test_dict['result_dict'].keys():
        assert unimod_id in cl.omssa_mod_Mapper.keys()
        for omssa_id in test_dict['result_dict'][unimod_id].keys():
            assert omssa_id in cl.omssa_mod_Mapper[unimod_id].keys()
            for k,v in test_dict['result_dict'][unimod_id][omssa_id].items():
                assert cl.omssa_mod_Mapper[unimod_id][omssa_id][k] == v


if __name__ == '__main__':
    print(__doc__)
    for test_id, test_dict in enumerate(TESTS):
        map_mods(test_dict)
<commit_msg>Updating main resource affected tests<commit_after>#!/usr/bin/env python3
# encoding: utf-8
'''

Test the OMSSA mop remap of e.g. TMT labeling

TMT labeling has the wrong unimod name in the OMSSA mods xml file

Probably more mods need remap

'K,fix,any,TMT6plex',
'*,opt,N-term,TMT6plex',
'K,fix,any,TMT2plex',
'*,opt,N-term,TMT2plex',

'''
import ursgal
import csv
import os
import pprint


TESTS = [
    {
        'modifications' : [ 'K,fix,any,TMT6plex' ],
        'result_dict': {
            '737' : {
                '198' : {
                    'aa_targets'  : ['K'],
                }
            }
        },
    },
    {
        'modifications' : [ '*,opt,N-term,TMT6plex' ],
        'result_dict': {
            '737' : {
                '199' : {
                    'aa_targets'  : ['N-term'],
                }
            }
        },
    },
    {
        'modifications' : [ 'K,fix,any,TMT2plex' ],
        'result_dict': {
            '738' : {
                '198' : {
                    'aa_targets'  : ['K'],
                }
            }
        },
    },
    {
        'modifications' : [ '*,opt,N-term,TMT2plex' ],
        'result_dict': {
            '738' : {
                '199' : {
                    'aa_targets'  : ['N-term'],
                }
            }
        },
    },

]

uc = ursgal.UController()
IS_AVAILABLE = uc.unodes['omssa_2_1_9']['available']

def map_mods_test():
    for test_id, test_dict in enumerate(TESTS):
        yield map_mods, test_dict


def map_mods( test_dict ):
    if IS_AVAILABLE:
        uc.params['modifications'] = test_dict['modifications']
        omssa_class = cl=uc.unodes['omssa_2_1_9']['_wrapper_class']()
        cl.exe = os.path.join(uc.unodes['omssa_2_1_9']['resource_folder'],'omssacl')
        cl._load_omssa_xml()
        for unimod_id in test_dict['result_dict'].keys():
            assert unimod_id in cl.omssa_mod_Mapper.keys()
            for omssa_id in test_dict['result_dict'][unimod_id].keys():
                assert omssa_id in cl.omssa_mod_Mapper[unimod_id].keys()
                for k,v in test_dict['result_dict'][unimod_id][omssa_id].items():
                    assert cl.omssa_mod_Mapper[unimod_id][omssa_id][k] == v


if __name__ == '__main__':
    print(__doc__)
    for test_id, test_dict in enumerate(TESTS):
        map_mods(test_dict)

{'fraction_non_alphanumeric': 0.14647456887142546, 'fraction_numerical': 0.018118314778432655, 'mean_word_length': 1.7854103343465046, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 4}, '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': '5513527', 'n_tokens_mistral': 1733, 'n_tokens_neox': 1640, 'n_words': 263}