<commit_before>import pytest

from locuspocus import Locus

'''
    Unit tests
'''

#def test_get_loci_from_ids(testRefGen):
#    random_loci = sorted(testRefGen.random_loci(n=10))
#    get_loci_from_ids = sorted(testRefGen.from_ids([x.id for x in random_loci]))
#    assert set(random_loci) == set(get_loci_from_ids)

def test_get_item(testRefGen):
    random_locus = testRefGen.rand()[0]
    assert random_locus == testRefGen[random_locus.id]

#def test_get_items_from_list(testRefGen):
#    random_loci = sorted(testRefGen.random_loci(n=10))
#    loci = sorted(testRefGen[[x.id for x in random_loci]])
#    assert set(random_loci) == set(loci)

def test_lowercase_get_item(testRefGen):
    random_locus = testRefGen.rand()[0]
    name = random_locus.name
    # Stupid mutability
    name.lower()
    assert random_locus == testRefGen[name]

def test_loci_within(testRefGen):
    random_locus = testRefGen.random_locus()
    bigger_locus = Locus(
        random_locus.chrom,
        start=random_locus.start-100,
        end=random_locus.end+100
    )
    genes = testRefGen.genes_within(bigger_locus)
    assert random_locus in genes

def test_locus_not_in_upstream_downstream(testRefGen):
    '''<commit_msg>update tests<commit_after>import pytest

from locuspocus import Locus

'''
    Unit tests
'''

def test_get_item(testRefGen):
    random_locus = testRefGen.rand()
    assert random_locus == testRefGen[random_locus.id]

def test_get_items_from_list(testRefGen):
    random_loci = sorted(testRefGen.random_loci(n=10))
    loci = sorted(testRefGen[[x.id for x in random_loci]])
    assert set(random_loci) == set(loci)

def test_lowercase_get_item(testRefGen):
    random_locus = testRefGen.rand()
    name = random_locus.name
    # Stupid mutability
    name.lower()
    assert random_locus == testRefGen[name]

def test_loci_within(testRefGen):
    random_locus = testRefGen.random_locus()
    bigger_locus = Locus(
        random_locus.chrom,
        start=random_locus.start-100,
        end=random_locus.end+100
    )
    genes = testRefGen.genes_within(bigger_locus)
    assert random_locus in genes

def test_locus_not_in_upstream_downstream(testRefGen):
    '''
{'fraction_non_alphanumeric': 0.10055096418732783, 'fraction_numerical': 0.009182736455463728, 'mean_word_length': 4.420398009950249, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '3180626', 'n_tokens_mistral': 821, 'n_tokens_neox': 805, 'n_words': 128}