Coverage for src/python/ensembl/xrefs/xref_source_db_model.py: 100%
28 statements
« prev ^ index » next coverage.py v7.6.1, created at 2024-09-17 13:09 +0000
« prev ^ index » next coverage.py v7.6.1, created at 2024-09-17 13:09 +0000
1# See the NOTICE file distributed with this work for additional information
2# regarding copyright ownership.
3#
4# Licensed under the Apache License, Version 2.0 (the "License");
5# you may not use this file except in compliance with the License.
6# You may obtain a copy of the License at
7# http://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS,
11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12# See the License for the specific language governing permissions and
13# limitations under the License.
14"""Xref Source database ORM."""
15# Ignore some pylint and mypy checks due to the nature of SQLAlchemy ORMs
16# pylint: disable=missing-class-docstring,too-many-lines
17# mypy: disable-error-code="misc, valid-type"
19from sqlalchemy import Column, Index, ForeignKey, text
20from sqlalchemy.dialects.mysql import INTEGER, VARCHAR, BOOLEAN
21from sqlalchemy.orm import declarative_base
23Base = declarative_base()
26class ChecksumXref(Base):
27 __tablename__ = "checksum_xref"
28 __table_args__ = (Index("checksum_idx", "checksum", mysql_length=10),)
30 checksum_xref_id: Column = Column(INTEGER, primary_key=True, autoincrement=True)
31 source_id: Column = Column(INTEGER, nullable=False)
32 accession: Column = Column(VARCHAR(14), nullable=False)
33 checksum: Column = Column(VARCHAR(32), nullable=False)
36class Source(Base):
37 __tablename__ = "source"
39 source_id: Column = Column(INTEGER(10), primary_key=True, autoincrement=True)
40 name: Column = Column(VARCHAR(128), index=True, unique=True)
41 active: Column = Column(BOOLEAN, nullable=False, server_default=text("1"))
42 parser: Column = Column(VARCHAR(128))
45class Version(Base):
46 __tablename__ = "version"
47 __table_args__ = (Index("version_idx", "source_id", "revision"),)
49 version_id: Column = Column(INTEGER(10), primary_key=True, autoincrement=True)
50 source_id: Column = Column(INTEGER(10), ForeignKey("source.source_id"))
51 revision: Column = Column(VARCHAR(255))
52 count_seen: Column = Column(INTEGER(10), nullable=False)
53 uri: Column = Column(VARCHAR(255))
54 index_uri: Column = Column(VARCHAR(255))
55 clean_uri: Column = Column(VARCHAR(255))
56 preparse: Column = Column(BOOLEAN, nullable=False, server_default=text("0"))