<commit_before>from sqlalchemy.ext.associationproxy import association_proxy

from database import db

from .model import BioModel


class Disease(BioModel):

    __table_args__ = (
      db.Index('idx_name', 'name', mysql_length=1024),
    )

    # CLNDBN: Variant disease name
    name = db.Column(db.Text, nullable=False, unique=True)


class ClinicalData(BioModel):

    inherited_id = db.Column(db.Integer, db.ForeignKey('inheritedmutation.id'))

    significance_codes = {
        0: 'Uncertain significance',
        1: 'Not provided',
        2: 'Benign',
        3: 'Likely benign',
        4: 'Likely pathogenic',
        5: 'Pathogenic',
        6: 'Drug response',
        7: 'Histocompatibility',
        255: 'Other'
    }

    # CLNSIG: Variant Clinical Significance:
    sig_code = db.Column(db.Integer)

    # CLNDBN: Variant disease name
    disease_id = db.Column(db.Integer, db.ForeignKey('disease.id'))
    disease = db.relationship('Disease')
    disease_name = association_proxy('disease', 'name')

    @property
    def significance(self):
        return self.significance_codes.get(self.sig_code, None)

    # CLNREVSTAT: ?
    # no_assertion - No assertion provided,
    # no_criteria - No assertion criteria provided,
    # single - Criteria provided single submitter,
    # mult - Criteria provided multiple submitters no conflicts,
    # conf - Criteria provided conflicting interpretations,
    # exp - Reviewed by expert panel,
    # guideline - Practice guideline
    rev_status = db.Column(db.Text)

    def to_json(self, filter=lambda x: x):
        return {
            'Disease': self.disease_name,
            'Significance': self.significance,
            'Review status': self.rev_status
        }

    significance_subsets = {
        'all': ['Pathogenic', 'Drug response', 'Likely pathogenic', 'Likely benign', 'Benign', 'Uncertain significance', 'Other', 'Not provided'],
        'strict': ['Pathogenic', 'Drug response', 'Likely pathogenic'],
        'not_benign': ['Pathogenic', 'Drug response', 'Likely pathogenic', 'Uncertain significance', 'Other'],
    }


class Cancer(BioModel):
    code = db.Column(db.String(16), unique=True)
    name = db.Column(db.String(64), unique=True)

    def __repr__(self):
        return f'<Cancer with code: {self.code}, named: {self.name}>'
<commit_msg>Limit the lenght of disease name to 255 characters<commit_after>from sqlalchemy.ext.associationproxy import association_proxy

from database import db

from .model import BioModel


class Disease(BioModel):

    # CLNDBN: Variant disease name
    name = db.Column(db.String(255), nullable=False, unique=True, index=True)


class ClinicalData(BioModel):

    inherited_id = db.Column(db.Integer, db.ForeignKey('inheritedmutation.id'))

    significance_codes = {
        0: 'Uncertain significance',
        1: 'Not provided',
        2: 'Benign',
        3: 'Likely benign',
        4: 'Likely pathogenic',
        5: 'Pathogenic',
        6: 'Drug response',
        7: 'Histocompatibility',
        255: 'Other'
    }

    # CLNSIG: Variant Clinical Significance:
    sig_code = db.Column(db.Integer)

    # CLNDBN: Variant disease name
    disease_id = db.Column(db.Integer, db.ForeignKey('disease.id'))
    disease = db.relationship('Disease')
    disease_name = association_proxy('disease', 'name')

    @property
    def significance(self):
        return self.significance_codes.get(self.sig_code, None)

    # CLNREVSTAT: ?
    # no_assertion - No assertion provided,
    # no_criteria - No assertion criteria provided,
    # single - Criteria provided single submitter,
    # mult - Criteria provided multiple submitters no conflicts,
    # conf - Criteria provided conflicting interpretations,
    # exp - Reviewed by expert panel,
    # guideline - Practice guideline
    rev_status = db.Column(db.Text)

    def to_json(self, filter=lambda x: x):
        return {
            'Disease': self.disease_name,
            'Significance': self.significance,
            'Review status': self.rev_status
        }

    significance_subsets = {
        'all': ['Pathogenic', 'Drug response', 'Likely pathogenic', 'Likely benign', 'Benign', 'Uncertain significance', 'Other', 'Not provided'],
        'strict': ['Pathogenic', 'Drug response', 'Likely pathogenic'],
        'not_benign': ['Pathogenic', 'Drug response', 'Likely pathogenic', 'Uncertain significance', 'Other'],
    }


class Cancer(BioModel):
    code = db.Column(db.String(16), unique=True)
    name = db.Column(db.String(64), unique=True)

    def __repr__(self):
        return f'<Cancer with code: {self.code}, named: {self.name}>'

{'fraction_non_alphanumeric': 0.12114679887906876, 'fraction_numerical': 0.008622547962923045, 'mean_word_length': 3.1764176417641763, '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': '3373335', 'n_tokens_mistral': 1497, 'n_tokens_neox': 1380, 'n_words': 357}