<commit_before>""" Test parameters """

__author__ = '<NAME>'

from torsionfit.tests.utils import get_fun
from torsionfit.backends import sqlite_plus
import torsionfit.parameters as par
from parmed.charmm.parameters import CharmmParameterSet
from parmed.charmm import CharmmPsfFile
import torsionfit.database.qmdatabase as qmdb
import unittest
from simtk import unit


class TestParameters(unittest.TestCase):
    """ Test parameters.py """

    def test_add_missing(self):
        """ Test add missing parameters """
        param = CharmmParameterSet(get_fun('par_all36_cgenff.prm'), get_fun('top_all36_cgenff.rtf'))
        torsion = ('CG331', 'CG321', 'CG321', 'CG331')
        self.assertEqual(len(param.dihedral_types[torsion]), 2)
        par.add_missing(param=param, param_list=torsion)
        self.assertEqual(len(param.dihedral_types[torsion]), 5)
        par.add_missing(param=param, param_list=torsion, sample_n5=True)
        self.assertEqual(len(param.dihedral_types[torsion]), 6)

    def test_set_phase_0(self):
        """ Test set phases to 0 """
        param = CharmmParameterSet(get_fun('par_all36_cgenff.prm'), get_fun('top_all36_cgenff.rtf'))
        torsion = ('CG331', 'CG321', 'CG321', 'CG331')
        self.assertEqual(param.dihedral_types[torsion][1].phase, 180.0)
        par.set_phase_0(torsion, param)
        self.assertEqual(param.dihedral_types[torsion][1].phase, 0.0)

    def test_param_from_db(self):
        """ Tests parameterizing from database """
        param = CharmmParameterSet(get_fun('par_all36_cgenff.prm'), get_fun('top_all36_cgenff.rtf'))
        torsion = ('CG331', 'CG321', 'CG321', 'CG331')
        db = sqlite_plus.load(get_fun('butane.db'))<commit_msg>ignore warnings<commit_after>""" Test parameters """

__author__ = '<NAME>'

from torsionfit.tests.utils import get_fun
from torsionfit.backends import sqlite_plus
import torsionfit.parameters as par
from parmed.charmm.parameters import CharmmParameterSet
from parmed.charmm import CharmmPsfFile
import torsionfit.database.qmdatabase as qmdb
import unittest
from simtk import unit
import warnings
warnings.filterwarnings('ignore')


class TestParameters(unittest.TestCase):
    """ Test parameters.py """

    def test_add_missing(self):
        """ Test add missing parameters """
        param = CharmmParameterSet(get_fun('par_all36_cgenff.prm'), get_fun('top_all36_cgenff.rtf'))
        torsion = ('CG331', 'CG321', 'CG321', 'CG331')
        self.assertEqual(len(param.dihedral_types[torsion]), 2)
        par.add_missing(param=param, param_list=torsion)
        self.assertEqual(len(param.dihedral_types[torsion]), 5)
        par.add_missing(param=param, param_list=torsion, sample_n5=True)
        self.assertEqual(len(param.dihedral_types[torsion]), 6)

    def test_set_phase_0(self):
        """ Test set phases to 0 """
        param = CharmmParameterSet(get_fun('par_all36_cgenff.prm'), get_fun('top_all36_cgenff.rtf'))
        torsion = ('CG331', 'CG321', 'CG321', 'CG331')
        self.assertEqual(param.dihedral_types[torsion][1].phase, 180.0)
        par.set_phase_0(torsion, param)
        self.assertEqual(param.dihedral_types[torsion][1].phase, 0.0)

    def test_param_from_db(self):
        """ Tests parameterizing from database """
        param = CharmmParameterSet(get_fun('par_all36_cgenff.prm'), get_fun('top_all36_cgenff.rtf'))
        torsion = ('CG331', 'CG321', 'CG321', 'CG331')
        db = sqlite_plus.load(get_fun('butane.db'))
{'fraction_non_alphanumeric': 0.1288184438040346, 'fraction_numerical': 0.03631123919308357, 'mean_word_length': 4.3730650154798765, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '1768622', 'n_tokens_mistral': 1275, 'n_tokens_neox': 1170, 'n_words': 205}