<commit_before># -*- python -*-
#
#  This file is part of cellnopt software
#
#  Copyright (c) 2014 - EBI-EMBL
#
#  File author(s): <NAME> <<EMAIL>>
#
#  Distributed under the GPLv3 License.
#  See accompanying file LICENSE.txt or copy at
#      http://www.gnu.org/licenses/gpl-3.0.html
#
#  website: http://github.com/cellnopt
#
##############################################################################
""""""
import importlib
from cno.datasets import registers


def cnodata(filename=None):
    """Return the full path name of a registered model or data set

    A register directory is one contained in cno.datasets with a PKN
    and MIDAS file and __init__.py

    If you do not know the registered directories, type cnodata without
    parameter::

        cnodata()

    else, it returns the full path of an existing file::

        cnodata("PKN-ToyPB.sif")


    """
    if filename is None:
        print("Valid names are:")
        print("\n".join(sorted(registers)))
        return

    msg = "Unknown filename. "
    msg += "Type cnodata() without argument to get the list"

    if filename in registers:
        tag = filename.split("-", 1)[1].split('.')[0]

        mod = importlib.import_module('cno.datasets.{0}'.format(tag))
        if filename.startswith("PKN-") and filename.endswith('.sif'):
            fullpath = mod.model_filename
        elif filename.startswith("PKN-") and filename.endswith('.xml'):
            fullpath = mod.model_filename.replace('.sif', '.xml')
        elif filename.startswith("MD-"):
            fullpath = mod.data_filename
        else:
            print(msg)
        return fullpath
    else:
        print(msg)<commit_msg>add a search tool in cnodata<commit_after># -*- python -*-
#
#  This file is part of cellnopt software
#
#  Copyright (c) 2014 - EBI-EMBL
#
#  File author(s): <NAME> <<EMAIL>.uk>
#
#  Distributed under the GPLv3 License.
#  See accompanying file LICENSE.txt or copy at
#      http://www.gnu.org/licenses/gpl-3.0.html
#
#  website: http://github.com/cellnopt
#
##############################################################################
""""""
import importlib
from cno.datasets import registers


def cnodata(filename=None):
    """Return the full path name of a registered model or data set

    A register directory is one contained in cno.datasets with a PKN
    and MIDAS file and __init__.py

    If you do not know the registered directories, type cnodata without
    parameter::

        cnodata()

    else, it returns the full path of an existing file::

        cnodata("PKN-ToyPB.sif")


    """
    if filename is None:
        print("Valid names are:")
        print("\n".join(sorted(registers)))
        return

    msg = "Unknown filename. "
    msg += "Type cnodata() without argument to get the list"

    if filename in registers:
        tag = filename.split("-", 1)[1].split('.')[0]

        mod = importlib.import_module('cno.datasets.{0}'.format(tag))
        if filename.startswith("PKN-") and filename.endswith('.sif'):
            fullpath = mod.model_filename
        elif filename.startswith("PKN-") and filename.endswith('.xml'):
            fullpath = mod.model_filename.replace('.sif', '.xml')
        elif filename.startswith("MD-"):
            fullpath = mod.data_filename
        else:
            print(msg)
        return fullpath
    elif "*" in filename:
        tags = [x for x in filename.split("*") if x]
        for register in registers:
            found = True
            for tag in tags:
                if tag not in register:
                    found = False
            if found:
                print(register)
    else:
        print(msg)



{'fraction_non_alphanumeric': 0.1571933641555616, 'fraction_numerical': 0.005983138428066358, 'mean_word_length': 2.5095419847328246, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '3589567', 'n_tokens_mistral': 1113, 'n_tokens_neox': 1056, 'n_words': 325}