<commit_before>from os import path
from Bio import SeqIO
from secmet.record import Record

def get_testfile(filename):
    return path.join(path.dirname(__file__), 'data', filename)

def test_init_empty():
    rec = Record()
    assert isinstance(rec, Record)
    assert rec.id == "NO_ID_ASSIGNED"
    assert rec.annotations == {}
    assert rec.description == ""
    assert rec.clusters == []


def test_from_genbank():
    testfile = get_testfile('nisin.gbk')
    bp_rec = SeqIO.read(testfile, 'genbank')
    rec = Record.from_genbank(testfile)
    assert isinstance(rec, Record)
    assert rec.id == bp_rec.id
    assert rec.annotations == bp_rec.annotations
    assert rec.description == bp_rec.description


def test_clusters():
    testfile = get_testfile('nisin.gbk')
    rec = Record.from_genbank(testfile)
    assert len(rec.clusters) == 1
<commit_msg>tests: avoid uncomparable Biopython Reference objects<commit_after>from os import path
from Bio import SeqIO
from secmet.record import Record

def get_testfile(filename):
    return path.join(path.dirname(__file__), 'data', filename)

def test_init_empty():
    rec = Record()
    assert isinstance(rec, Record)
    assert rec.id == "NO_ID_ASSIGNED"
    assert rec.annotations == {}
    assert rec.description == ""
    assert rec.clusters == []


def test_from_genbank():
    testfile = get_testfile('nisin.gbk')
    bp_rec = SeqIO.read(testfile, 'genbank')
    rec = Record.from_genbank(testfile)
    assert isinstance(rec, Record)
    assert rec.id == bp_rec.id
    # SNAG: Can't compare Reference objects in Biopython :(
    # So delete them to make the test work.
    del rec.annotations['references']
    del bp_rec.annotations['references']
    assert rec.annotations == bp_rec.annotations
    assert rec.description == bp_rec.description


def test_clusters():
    testfile = get_testfile('nisin.gbk')
    rec = Record.from_genbank(testfile)
    assert len(rec.clusters) == 1

{'fraction_non_alphanumeric': 0.11105398457583547, 'fraction_numerical': 0.0010282776349614395, 'mean_word_length': 3.9265822784810127, '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': '2057541', 'n_tokens_mistral': 630, 'n_tokens_neox': 613, 'n_words': 152}