<commit_before>"""Test the loading of the optional GO term fields."""
# https://owlcollab.github.io/oboformat/doc/GO.format.obo-1_4.html

__copyright__ = "Copyright (C) 2010-2018, <NAME>, <NAME>, All rights reserved."
__author__ = "<NAME>"


import os
import sys
import timeit
import datetime
from goatools.obo_parser import GODag
from goatools.base import download_go_basic_obo


# pylint: disable=too-few-public-methods
class GoDagTimed(object):
    """Load and store GO-DAG. Report elapsed time."""

    def __init__(self, fin_obo, opt_field=None, keep_alt_ids=False):
        self.opt = opt_field  # None causes all fields to read to exp dict
        self.obo = fin_obo
        self._init_dnld_dag()
        self.go2obj = self._init_go2obj(keep_alt_ids)

    def _init_go2obj(self, keep_alt_ids):
        """GO DAG with or without alternate GO IDs."""
        go2obj = self.load_dag(self.opt)
        return go2obj if keep_alt_ids else {o.id:o for o in go2obj.values()}

    def _init_dnld_dag(self):
        """If dag does not exist, download it."""
        if not os.path.exists(self.obo):
            download_go_basic_obo(self.obo, loading_bar=None)

    def load_dag(self, opt_fields=None):
        """Run numerous tests for various self.reports."""
        tic = timeit.default_timer()
        dag = GODag(self.obo, opt_fields)<commit_msg>GODag will be a data member to access DAG VERSION<commit_after>"""Test the loading of the optional GO term fields."""
# https://owlcollab.github.io/oboformat/doc/GO.format.obo-1_4.html

__copyright__ = "Copyright (C) 2010-2018, <NAME>, <NAME>, All rights reserved."
__author__ = "<NAME>"


import os
import sys
import timeit
import datetime
from goatools.obo_parser import GODag
from goatools.base import download_go_basic_obo


# pylint: disable=too-few-public-methods
class GoDagTimed(object):
    """Load and store GO-DAG. Report elapsed time."""

    def __init__(self, fin_obo, opt_field=None, keep_alt_ids=False):
        self.opt = opt_field  # None causes all fields to read to exp dict
        self.obo = fin_obo
        self._init_dnld_dag()
        self.godag = self.load_dag(self.opt)
        self.go2obj = self.godag if keep_alt_ids else {o.id:o for o in self.godag.values()}

    def _init_dnld_dag(self):
        """If dag does not exist, download it."""
        if not os.path.exists(self.obo):
            download_go_basic_obo(self.obo, loading_bar=None)

    def load_dag(self, opt_fields=None):
        """Run numerous tests for various self.reports."""
        tic = timeit.default_timer()
        dag = GODag(self.obo, opt_fields)
{'fraction_non_alphanumeric': 0.1111111111111111, 'fraction_numerical': 0.010380622837370242, 'mean_word_length': 3.373109243697479, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 6, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6867040', 'n_tokens_mistral': 903, 'n_tokens_neox': 838, 'n_words': 235}