Coverage for src/python/ensembl/xrefs/xref_source_db_model.py: 100%

26 statements  

« prev     ^ index     » next       coverage.py v7.15.1, created at 2026-07-13 09:48 +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 

16# Ignore some pylint and mypy checks due to the nature of SQLAlchemy ORMs 

17# pylint: disable=missing-class-docstring,too-many-lines 

18# mypy: disable-error-code="misc, valid-type" 

19 

20from sqlalchemy import Column, Index, ForeignKey 

21from sqlalchemy.dialects.mysql import INTEGER, VARCHAR 

22from sqlalchemy.orm import declarative_base 

23 

24Base = declarative_base() 

25 

26 

27class ChecksumXref(Base): 

28 __tablename__ = "checksum_xref" 

29 __table_args__ = (Index("checksum_idx", "checksum", mysql_length=10), {"mysql_engine": "MyISAM"}) 

30 

31 checksum_xref_id: Column = Column(INTEGER, primary_key=True, autoincrement=True) 

32 source_id: Column = Column(INTEGER, nullable=False) 

33 accession: Column = Column(VARCHAR(14), nullable=False) 

34 checksum: Column = Column(VARCHAR(32), nullable=False) 

35 

36 

37class Source(Base): 

38 __tablename__ = "source" 

39 

40 source_id: Column = Column(INTEGER(10), primary_key=True, autoincrement=True) 

41 name: Column = Column(VARCHAR(128), index=True, unique=True) 

42 parser: Column = Column(VARCHAR(128)) 

43 

44 

45class Version(Base): 

46 __tablename__ = "version" 

47 __table_args__ = (Index("version_idx", "source_id", "revision"),) 

48 

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 priority: Column = Column(INTEGER(10), nullable=False) 

53 file_path: Column = Column(VARCHAR(255)) 

54 db: Column = Column(VARCHAR(255)) 

55 clean_path: Column = Column(VARCHAR(255))