Coverage for src/python/ensembl/core/models.py: 100%

787 statements  

« 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"""Ensembl Core 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,fixme 

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

18 

19# WIP: This module is not complete nor fully tested and will most likely change its public interface 

20# TODO: 

21# - Please help defining/fixing relationships. 

22# There are several relationships that have not been mapped yet, please help 

23# adding them to the models if you find they're missing 

24# https://docs.sqlalchemy.org/en/14/orm/basic_relationships.html 

25# - Please help with better names. 

26# Class names and attributes were generated directly 

27# from the SQL schema but might not be suitable for a ORM. 

28# For instance, several class attributes are prepended with the class name. 

29# That's redundant most of the times and will result in less readable code. 

30# Some class names are somehow reserved (e.g. class Meta) and some attributes names 

31# are actually reserved (e.g. type, map, id) please help changing them into 

32# meaningful ones 

33 

34from typing import Any 

35 

36import sqlalchemy 

37from sqlalchemy import ( 

38 Column, 

39 DECIMAL, 

40 DateTime, 

41 Enum, 

42 Float, 

43 ForeignKey, 

44 Index, 

45 String, 

46 Table, 

47 Text, 

48 UniqueConstraint, 

49 text, 

50) 

51from sqlalchemy.dialects.mysql import ( 

52 BIGINT, 

53 DOUBLE, 

54 INTEGER, 

55 LONGTEXT, 

56 MEDIUMTEXT, 

57 SET, 

58 SMALLINT, 

59 TINYINT, 

60 TINYTEXT, 

61 VARCHAR, 

62) 

63from sqlalchemy.ext.compiler import compiles 

64from sqlalchemy.orm import declarative_base, relationship 

65 

66Base = declarative_base() 

67metadata = Base.metadata 

68 

69 

70class AltAlleleGroup(Base): 

71 __tablename__ = "alt_allele_group" 

72 

73 alt_allele_group_id: Column = Column(INTEGER(10), primary_key=True) 

74 

75 

76class Analysis(Base): 

77 __tablename__ = "analysis" 

78 

79 analysis_id: Column = Column(SMALLINT(5), primary_key=True) 

80 created: Column = Column(DateTime) 

81 logic_name: Column = Column(String(128), nullable=False, unique=True) 

82 db: Column = Column(String(120)) 

83 db_version: Column = Column(String(40)) 

84 db_file: Column = Column(String(120)) 

85 program: Column = Column(String(80)) 

86 program_version: Column = Column(String(40)) 

87 program_file: Column = Column(String(80)) 

88 parameters: Column = Column(Text) 

89 module: Column = Column(String(80)) 

90 module_version: Column = Column(String(40)) 

91 gff_source: Column = Column(String(40)) 

92 gff_feature: Column = Column(String(40)) 

93 

94 

95class AssociatedGroup(Base): 

96 __tablename__ = "associated_group" 

97 

98 associated_group_id: Column = Column(INTEGER(10), primary_key=True) 

99 description: Column = Column(String(128)) 

100 

101 

102class AttribType(Base): 

103 __tablename__ = "attrib_type" 

104 

105 attrib_type_id: Column = Column(SMALLINT(5), primary_key=True) 

106 code: Column = Column(String(20), nullable=False, unique=True, server_default=text("''")) 

107 name: Column = Column(String(255), nullable=False, server_default=text("''")) 

108 description: Column = Column(Text) 

109 

110 seq_region_attrib = relationship("SeqRegionAttrib", back_populates="attrib_type") 

111 

112 

113class Biotype(Base): 

114 __tablename__ = "biotype" 

115 __table_args__ = (Index("name_type_idx", "name", "object_type", unique=True),) 

116 

117 biotype_id: Column = Column(INTEGER(10), primary_key=True) 

118 name: Column = Column(String(64), nullable=False) 

119 object_type: Column = Column(Enum("gene", "transcript"), nullable=False, server_default=text("'gene'")) 

120 db_type: Column = Column( 

121 SET( 

122 "cdna", 

123 "core", 

124 "coreexpressionatlas", 

125 "coreexpressionest", 

126 "coreexpressiongnf", 

127 "funcgen", 

128 "otherfeatures", 

129 "rnaseq", 

130 "variation", 

131 "vega", 

132 "presite", 

133 "sangervega", 

134 ), 

135 nullable=False, 

136 server_default=text("'core'"), 

137 ) 

138 attrib_type_id: Column = Column(INTEGER(11)) 

139 description: Column = Column(Text) 

140 biotype_group: Column = Column( 

141 Enum( 

142 "coding", 

143 "pseudogene", 

144 "snoncoding", 

145 "lnoncoding", 

146 "mnoncoding", 

147 "LRG", 

148 "undefined", 

149 "no_group", 

150 ) 

151 ) 

152 so_acc: Column = Column(String(64)) 

153 so_term: Column = Column(String(1023)) 

154 

155 

156class CoordSystem(Base): 

157 __tablename__ = "coord_system" 

158 __table_args__ = ( 

159 Index("name_idx", "name", "version", "species_id", unique=True), 

160 Index("rank_idx", "rank", "species_id", unique=True), 

161 ) 

162 

163 coord_system_id: Column = Column(INTEGER(10), primary_key=True) 

164 species_id: Column = Column(INTEGER(10), nullable=False, index=True, server_default=text("'1'")) 

165 name: Column = Column(String(40), nullable=False) 

166 version: Column = Column(String(255)) 

167 rank: Column = Column(INTEGER(11), nullable=False) 

168 attrib: Column = Column(SET("default_version", "sequence_level")) 

169 # Many to one relationship 

170 seq_region = relationship("SeqRegion", back_populates="coord_system") 

171 meta = relationship("Meta", back_populates="coord_system") 

172 

173 

174class Ditag(Base): 

175 __tablename__ = "ditag" 

176 

177 ditag_id: Column = Column(INTEGER(10), primary_key=True) 

178 name: Column = Column(String(30), nullable=False) 

179 tag_type: Column = Column("type", String(30), nullable=False) 

180 tag_count: Column = Column(SMALLINT(6), nullable=False, server_default=text("'1'")) 

181 sequence: Column = Column(TINYTEXT, nullable=False) 

182 

183 

184class DNAAlignFeatureAttrib(Base): 

185 __tablename__ = "dna_align_feature_attrib" 

186 __table_args__ = ( 

187 Index( 

188 "dna_align_feature_attribx", 

189 "dna_align_feature_id", 

190 "attrib_type_id", 

191 "value", 

192 unique=True, 

193 mysql_length={"value": 10}, 

194 ), 

195 Index("ditag_type_val_idx", "attrib_type_id", "value", mysql_length={"value": 10}), 

196 Index("ditag_value_idx", "value", mysql_length=10), 

197 ) 

198 

199 dna_align_feature_id: Column = Column( 

200 INTEGER(10), 

201 ForeignKey("dna_align_feature.dna_align_feature_id"), 

202 nullable=False, 

203 index=True, 

204 primary_key=True, 

205 ) 

206 attrib_type_id: Column = Column(SMALLINT(5), nullable=False, primary_key=True) 

207 value: Column = Column(String(500), nullable=False, primary_key=True) 

208 

209 

210class ExternalDb(Base): 

211 __tablename__ = "external_db" 

212 __table_args__ = (Index("db_name_db_release_idx", "db_name", "db_release", unique=True),) 

213 

214 external_db_id: Column = Column(INTEGER(10), primary_key=True) 

215 db_name: Column = Column(String(100), nullable=False) 

216 db_release: Column = Column(String(255)) 

217 status: Column = Column(Enum("KNOWNXREF", "KNOWN", "XREF", "PRED", "ORTH", "PSEUDO"), nullable=False) 

218 priority: Column = Column(INTEGER(11), nullable=False) 

219 db_display_name: Column = Column(String(255)) 

220 db_type: Column = Column( 

221 "type", 

222 Enum( 

223 "ARRAY", 

224 "ALT_TRANS", 

225 "ALT_GENE", 

226 "MISC", 

227 "LIT", 

228 "PRIMARY_DB_SYNONYM", 

229 "ENSEMBL", 

230 ), 

231 nullable=False, 

232 ) 

233 secondary_db_name: Column = Column(String(255)) 

234 secondary_db_table: Column = Column(String(255)) 

235 description: Column = Column(Text) 

236 seq_region_synonym = relationship("SeqRegionSynonym", back_populates="external_db") 

237 

238 

239class Gene(Base): 

240 __tablename__ = "gene" 

241 __table_args__ = ( 

242 Index("gene_seq_region_idx", "seq_region_id", "seq_region_start"), 

243 Index("gene_stable_id_idx", "stable_id", "version"), 

244 ) 

245 

246 gene_id: Column = Column(INTEGER(10), primary_key=True) 

247 biotype: Column = Column(String(40), nullable=False) 

248 analysis_id: Column = Column( 

249 ForeignKey("analysis.analysis_id"), 

250 nullable=False, 

251 index=True, 

252 ) 

253 seq_region_id: Column = Column( 

254 ForeignKey("seq_region.seq_region_id"), 

255 nullable=False, 

256 ) 

257 seq_region_start: Column = Column(INTEGER(10), nullable=False) 

258 seq_region_end: Column = Column(INTEGER(10), nullable=False) 

259 seq_region_strand: Column = Column(TINYINT(2), nullable=False) 

260 display_xref_id: Column = Column(ForeignKey("xref.xref_id"), index=True) 

261 source: Column = Column(String(40), nullable=False) 

262 description: Column = Column(Text) 

263 is_current: Column = Column(TINYINT(1), nullable=False, server_default=text("'1'")) 

264 canonical_transcript_id: Column = Column( 

265 ForeignKey("transcript.transcript_id"), 

266 nullable=False, 

267 index=True, 

268 ) 

269 stable_id: Column = Column(String(128)) 

270 version: Column = Column(SMALLINT(5)) 

271 created_date: Column = Column(DateTime) 

272 modified_date: Column = Column(DateTime) 

273 

274 analysis = relationship("Analysis", primaryjoin="Gene.analysis_id == Analysis.analysis_id") 

275 canonical_transcript = relationship( 

276 "Transcript", 

277 primaryjoin="Gene.canonical_transcript_id == Transcript.transcript_id", 

278 ) 

279 display_xref = relationship("Xref", primaryjoin="Gene.display_xref_id == Xref.xref_id") 

280 seq_region = relationship("SeqRegion", primaryjoin="Gene.seq_region_id == SeqRegion.seq_region_id") 

281 

282 

283class GenomeStatistics(Base): 

284 __tablename__ = "genome_statistics" 

285 __table_args__ = (Index("stats_uniq", "statistic", "attrib_type_id", "species_id", unique=True),) 

286 

287 genome_statistics_id: Column = Column(INTEGER(10), primary_key=True) 

288 statistic: Column = Column(String(128), nullable=False) 

289 value: Column = Column(BIGINT(11), nullable=False, server_default=text("'0'")) 

290 species_id: Column = Column(INTEGER(10), server_default=text("'1'")) 

291 attrib_type_id: Column = Column(INTEGER(10)) 

292 timestamp: Column = Column(DateTime) 

293 

294 

295t_interpro = Table( 

296 "interpro", 

297 metadata, 

298 Column("interpro_ac", String(40), nullable=False), 

299 Column("id", VARCHAR(40), nullable=False, index=True), 

300 Index("accession_idx", "interpro_ac", "id", unique=True), 

301) 

302 

303 

304class Map(Base): 

305 __tablename__ = "map" 

306 

307 map_id: Column = Column(INTEGER(10), primary_key=True) 

308 map_name: Column = Column(String(30), nullable=False) 

309 

310 

311class MappingSession(Base): 

312 __tablename__ = "mapping_session" 

313 

314 mapping_session_id: Column = Column(INTEGER(10), primary_key=True) 

315 old_db_name: Column = Column(String(80), nullable=False, server_default=text("''")) 

316 new_db_name: Column = Column(String(80), nullable=False, server_default=text("''")) 

317 old_release: Column = Column(String(5), nullable=False, server_default=text("''")) 

318 new_release: Column = Column(String(5), nullable=False, server_default=text("''")) 

319 old_assembly: Column = Column(String(80), nullable=False, server_default=text("''")) 

320 new_assembly: Column = Column(String(80), nullable=False, server_default=text("''")) 

321 created: Column = Column(DateTime, nullable=False) 

322 

323 

324class MappingSet(Base): 

325 __tablename__ = "mapping_set" 

326 __table_args__ = (Index("mapping_idx", "internal_schema_build", "external_schema_build", unique=True),) 

327 

328 mapping_set_id: Column = Column(INTEGER(10), primary_key=True) 

329 internal_schema_build: Column = Column(String(20), nullable=False) 

330 external_schema_build: Column = Column(String(20), nullable=False) 

331 

332 

333class Marker(Base): 

334 __tablename__ = "marker" 

335 __table_args__ = (Index("marker_idx", "marker_id", "priority"),) 

336 

337 marker_id: Column = Column(INTEGER(10), primary_key=True) 

338 display_marker_synonym_id: Column = Column( 

339 ForeignKey("marker_synonym.marker_synonym_id"), 

340 index=True, 

341 ) 

342 left_primer: Column = Column(String(100), nullable=False) 

343 right_primer: Column = Column(String(100), nullable=False) 

344 min_primer_dist: Column = Column(INTEGER(10), nullable=False) 

345 max_primer_dist: Column = Column(INTEGER(10), nullable=False) 

346 priority: Column = Column(INTEGER(11)) 

347 marker_type: Column = Column("type", Enum("est", "microsatellite")) 

348 

349 display_marker_synonym = relationship( 

350 "MarkerSynonym", 

351 primaryjoin="Marker.display_marker_synonym_id == MarkerSynonym.marker_synonym_id", 

352 ) 

353 

354 

355class MarkerSynonym(Base): 

356 __tablename__ = "marker_synonym" 

357 __table_args__ = (Index("marker_synonym_idx", "marker_synonym_id", "name"),) 

358 

359 marker_synonym_id: Column = Column(INTEGER(10), primary_key=True) 

360 marker_id: Column = Column( 

361 ForeignKey("marker.marker_id"), 

362 nullable=False, 

363 index=True, 

364 ) 

365 source: Column = Column(String(20)) 

366 name: Column = Column(String(50)) 

367 

368 marker = relationship("Marker", primaryjoin="MarkerSynonym.marker_id == Marker.marker_id") 

369 

370 

371class PeptideArchive(Base): 

372 __tablename__ = "peptide_archive" 

373 

374 peptide_archive_id: Column = Column(INTEGER(10), primary_key=True) 

375 md5_checksum: Column = Column(String(32), index=True) 

376 peptide_seq: Column = Column(MEDIUMTEXT, nullable=False) 

377 

378 

379class RepeatConsensus(Base): 

380 __tablename__ = "repeat_consensus" 

381 __table_args__ = (Index("repeat_consensus_idx", "repeat_consensus", unique=True, mysql_length=10),) 

382 

383 repeat_consensus_id: Column = Column(INTEGER(10), primary_key=True) 

384 repeat_name: Column = Column(String(255), nullable=False, index=True) 

385 repeat_class: Column = Column(String(100), nullable=False, index=True) 

386 repeat_type: Column = Column(String(40), nullable=False, index=True) 

387 repeat_consensus: Column = Column(Text) 

388 

389 

390class Rnaproduct(Base): 

391 __tablename__ = "rnaproduct" 

392 __table_args__ = (Index("rnaproduct_stable_id_idx", "stable_id", "version"),) 

393 

394 rnaproduct_id: Column = Column(INTEGER(10), primary_key=True) 

395 rnaproduct_type_id: Column = Column(SMALLINT(5), nullable=False) 

396 transcript_id: Column = Column(INTEGER(10), nullable=False, index=True) 

397 seq_start: Column = Column(INTEGER(10), nullable=False) 

398 start_exon_id: Column = Column(INTEGER(10)) 

399 seq_end: Column = Column(INTEGER(10), nullable=False) 

400 end_exon_id: Column = Column(INTEGER(10)) 

401 stable_id: Column = Column(String(128)) 

402 version: Column = Column(SMALLINT(5)) 

403 created_date: Column = Column(DateTime) 

404 modified_date: Column = Column(DateTime) 

405 

406 

407class RNAproductAttrib(Base): 

408 __tablename__ = "rnaproduct_attrib" 

409 __table_args__ = ( 

410 Index( 

411 "rnaproduct_attribx", 

412 "rnaproduct_id", 

413 "attrib_type_id", 

414 "value", 

415 unique=True, 

416 mysql_length={"value": 10}, 

417 ), 

418 Index("rnaproduct_type_val_idx", "attrib_type_id", "value", mysql_length={"value": 10}), 

419 Index("rnaproduct_value_idx", "value", mysql_length=10), 

420 ) 

421 rnaproduct_id: Column = Column( 

422 ForeignKey("rnaproduct.rnaproduct_id"), nullable=False, index=True, primary_key=True 

423 ) 

424 attrib_type_id: Column = Column(SMALLINT(5), nullable=False, primary_key=True) 

425 value: Column = Column(String(500), nullable=False, primary_key=True) 

426 

427 

428class RnaproductType(Base): 

429 __tablename__ = "rnaproduct_type" 

430 

431 rnaproduct_type_id: Column = Column(SMALLINT(5), primary_key=True) 

432 code: Column = Column(String(20), nullable=False, unique=True, server_default=text("''")) 

433 name: Column = Column(String(255), nullable=False, server_default=text("''")) 

434 description: Column = Column(Text) 

435 

436 

437class Transcript(Base): 

438 __tablename__ = "transcript" 

439 __table_args__ = ( 

440 Index("transcript_seq_region_idx", "seq_region_id", "seq_region_start"), 

441 Index("transcript_stable_id_idx", "stable_id", "version"), 

442 ) 

443 

444 transcript_id: Column = Column(INTEGER(10), primary_key=True) 

445 gene_id: Column = Column(ForeignKey("gene.gene_id"), index=True) 

446 analysis_id: Column = Column( 

447 ForeignKey("analysis.analysis_id"), 

448 nullable=False, 

449 index=True, 

450 ) 

451 seq_region_id: Column = Column( 

452 ForeignKey("seq_region.seq_region_id"), 

453 nullable=False, 

454 ) 

455 seq_region_start: Column = Column(INTEGER(10), nullable=False) 

456 seq_region_end: Column = Column(INTEGER(10), nullable=False) 

457 seq_region_strand: Column = Column(TINYINT(2), nullable=False) 

458 display_xref_id: Column = Column(ForeignKey("xref.xref_id"), index=True) 

459 source: Column = Column(String(40), nullable=False, server_default=text("'ensembl'")) 

460 biotype: Column = Column(String(40), nullable=False) 

461 description: Column = Column(Text) 

462 is_current: Column = Column(TINYINT(1), nullable=False, server_default=text("'1'")) 

463 canonical_translation_id: Column = Column( 

464 ForeignKey("translation.translation_id"), 

465 unique=True, 

466 ) 

467 stable_id: Column = Column(String(128)) 

468 version: Column = Column(SMALLINT(5)) 

469 created_date: Column = Column(DateTime) 

470 modified_date: Column = Column(DateTime) 

471 

472 analysis = relationship("Analysis", primaryjoin="Transcript.analysis_id == Analysis.analysis_id") 

473 canonical_translation = relationship( 

474 "Translation", 

475 primaryjoin="Transcript.canonical_translation_id == Translation.translation_id", 

476 ) 

477 display_xref = relationship("Xref", primaryjoin="Transcript.display_xref_id == Xref.xref_id") 

478 gene = relationship("Gene", primaryjoin="Transcript.gene_id == Gene.gene_id") 

479 seq_region = relationship("SeqRegion", primaryjoin="Transcript.seq_region_id == SeqRegion.seq_region_id") 

480 

481 

482class TranscriptIntronSupportingEvidence(Base): 

483 __tablename__ = "transcript_intron_supporting_evidence" 

484 

485 transcript_id: Column = Column(INTEGER(10), primary_key=True, nullable=False, index=True) 

486 intron_supporting_evidence_id: Column = Column(INTEGER(10), primary_key=True, nullable=False) 

487 previous_exon_id: Column = Column(INTEGER(10), nullable=False) 

488 next_exon_id: Column = Column(INTEGER(10), nullable=False) 

489 

490 

491class Translation(Base): 

492 __tablename__ = "translation" 

493 __table_args__ = (Index("translation_stable_id_idx", "stable_id", "version"),) 

494 

495 translation_id: Column = Column(INTEGER(10), primary_key=True) 

496 transcript_id: Column = Column( 

497 ForeignKey("transcript.transcript_id"), 

498 nullable=False, 

499 index=True, 

500 ) 

501 seq_start: Column = Column(INTEGER(10), nullable=False) 

502 start_exon_id: Column = Column( 

503 ForeignKey("exon.exon_id"), 

504 nullable=False, 

505 index=True, 

506 ) 

507 seq_end: Column = Column(INTEGER(10), nullable=False) 

508 end_exon_id: Column = Column( 

509 ForeignKey("exon.exon_id"), 

510 nullable=False, 

511 index=True, 

512 ) 

513 stable_id: Column = Column(String(128)) 

514 version: Column = Column(SMALLINT(5)) 

515 created_date: Column = Column(DateTime) 

516 modified_date: Column = Column(DateTime) 

517 

518 end_exon = relationship("Exon", primaryjoin="Translation.end_exon_id == Exon.exon_id") 

519 start_exon = relationship("Exon", primaryjoin="Translation.start_exon_id == Exon.exon_id") 

520 transcript = relationship( 

521 "Transcript", 

522 primaryjoin="Translation.transcript_id == Transcript.transcript_id", 

523 ) 

524 

525 

526class UnmappedReason(Base): 

527 __tablename__ = "unmapped_reason" 

528 

529 unmapped_reason_id: Column = Column(INTEGER(10), primary_key=True) 

530 summary_description: Column = Column(String(255)) 

531 full_description: Column = Column(String(255)) 

532 

533 

534class AltAllele(Base): 

535 __tablename__ = "alt_allele" 

536 __table_args__ = (Index("alt_allele_gene_id_idx", "gene_id", "alt_allele_group_id"),) 

537 

538 alt_allele_id: Column = Column(INTEGER(10), primary_key=True) 

539 alt_allele_group_id: Column = Column( 

540 ForeignKey("alt_allele_group.alt_allele_group_id"), 

541 nullable=False, 

542 index=True, 

543 ) 

544 gene_id: Column = Column( 

545 ForeignKey("gene.gene_id"), 

546 nullable=False, 

547 unique=True, 

548 ) 

549 

550 alt_allele_group = relationship( 

551 "AltAlleleGroup", 

552 primaryjoin="AltAllele.alt_allele_group_id == AltAlleleGroup.alt_allele_group_id", 

553 ) 

554 gene = relationship("Gene", primaryjoin="AltAllele.gene_id == Gene.gene_id") 

555 

556 

557class AnalysisDescription(Base): 

558 __tablename__ = "analysis_description" 

559 

560 analysis_id: Column = Column( 

561 SMALLINT(5), 

562 ForeignKey("analysis.analysis_id"), 

563 primary_key=True, 

564 nullable=False, 

565 unique=True, 

566 ) 

567 description: Column = Column(Text) 

568 display_label: Column = Column(String(255), nullable=False) 

569 displayable: Column = Column(TINYINT(1), nullable=False, server_default=text("'1'")) 

570 web_data: Column = Column(Text) 

571 

572 

573class DataFile(Base): 

574 __tablename__ = "data_file" 

575 __table_args__ = ( 

576 Index( 

577 "df_unq_idx", 

578 "coord_system_id", 

579 "analysis_id", 

580 "name", 

581 "file_type", 

582 unique=True, 

583 ), 

584 ) 

585 

586 data_file_id: Column = Column(INTEGER(10), primary_key=True) 

587 coord_system_id: Column = Column( 

588 ForeignKey("coord_system.coord_system_id"), 

589 nullable=False, 

590 ) 

591 analysis_id: Column = Column( 

592 ForeignKey("analysis.analysis_id"), 

593 nullable=False, 

594 index=True, 

595 ) 

596 name: Column = Column(String(100), nullable=False, index=True) 

597 version_lock: Column = Column(TINYINT(1), nullable=False, server_default=text("'0'")) 

598 absolute: Column = Column(TINYINT(1), nullable=False, server_default=text("'0'")) 

599 url: Column = Column(Text) 

600 file_type: Column = Column(Enum("BAM", "BAMCOV", "BIGBED", "BIGWIG", "VCF")) 

601 

602 analysis = relationship("Analysis", primaryjoin="DataFile.analysis_id == Analysis.analysis_id") 

603 coord_system = relationship( 

604 "CoordSystem", 

605 primaryjoin="DataFile.coord_system_id == CoordSystem.coord_system_id", 

606 ) 

607 

608 

609class DensityType(Base): 

610 __tablename__ = "density_type" 

611 __table_args__ = (Index("analysis_idx", "analysis_id", "block_size", "region_features", unique=True),) 

612 

613 density_type_id: Column = Column(INTEGER(10), primary_key=True) 

614 analysis_id: Column = Column( 

615 ForeignKey("analysis.analysis_id"), 

616 nullable=False, 

617 ) 

618 block_size: Column = Column(INTEGER(11), nullable=False) 

619 region_features: Column = Column(INTEGER(11), nullable=False) 

620 value_type: Column = Column(Enum("sum", "ratio"), nullable=False) 

621 

622 analysis = relationship("Analysis", primaryjoin="DensityType.analysis_id == Analysis.analysis_id") 

623 

624 

625t_gene_archive = Table( 

626 "gene_archive", 

627 metadata, 

628 Column("gene_stable_id", String(128), nullable=False), 

629 Column("gene_version", SMALLINT(6), nullable=False, server_default=text("'1'")), 

630 Column("transcript_stable_id", String(128), nullable=False), 

631 Column("transcript_version", SMALLINT(6), nullable=False, server_default=text("'1'")), 

632 Column("translation_stable_id", String(128)), 

633 Column("translation_version", SMALLINT(6), nullable=False, server_default=text("'1'")), 

634 Column( 

635 "peptide_archive_id", 

636 ForeignKey("peptide_archive.peptide_archive_id"), 

637 index=True, 

638 ), 

639 Column( 

640 "mapping_session_id", 

641 ForeignKey("mapping_session.mapping_session_id"), 

642 nullable=False, 

643 index=True, 

644 ), 

645 Index("transcript_idx", "transcript_stable_id", "transcript_version"), 

646 Index("translation_idx", "translation_stable_id", "translation_version"), 

647 Index("gene_idx", "gene_stable_id", "gene_version"), 

648) 

649 

650 

651class GeneAttrib(Base): 

652 __tablename__ = "gene_attrib" 

653 __table_args__ = ( 

654 Index("gene_attribx", "gene_id", "attrib_type_id", "value", unique=True, mysql_length={"value": 10}), 

655 Index("gene_attrib_type_val_idx", "attrib_type_id", "value", mysql_length={"value": 10}), 

656 Index("gene_attrib_value_idx", "value", mysql_length=10), 

657 ) 

658 

659 gene_id: Column = Column( 

660 INTEGER(10), 

661 ForeignKey("gene.gene_id"), 

662 nullable=False, 

663 index=True, 

664 server_default=text("'0'"), 

665 primary_key=True, 

666 ) 

667 attrib_type_id: Column = Column( 

668 SMALLINT(5), 

669 ForeignKey("attrib_type.attrib_type_id"), 

670 nullable=False, 

671 server_default=text("'0'"), 

672 primary_key=True, 

673 ) 

674 value: Column = Column(String(500), nullable=False, primary_key=True) 

675 

676 

677class MarkerMapLocation(Base): 

678 __tablename__ = "marker_map_location" 

679 __table_args__ = (Index("map_idx", "map_id", "chromosome_name", "position"),) 

680 

681 marker_id: Column = Column( 

682 ForeignKey("marker.marker_id"), 

683 primary_key=True, 

684 nullable=False, 

685 ) 

686 map_id: Column = Column( 

687 ForeignKey("map.map_id"), 

688 primary_key=True, 

689 nullable=False, 

690 ) 

691 chromosome_name: Column = Column(String(15), nullable=False) 

692 marker_synonym_id: Column = Column( 

693 ForeignKey("marker_synonym.marker_synonym_id"), 

694 nullable=False, 

695 index=True, 

696 ) 

697 position: Column = Column(String(15), nullable=False) 

698 lod_score: Column = Column(Float(asdecimal=True)) 

699 

700 map_r = relationship("Map", primaryjoin="MarkerMapLocation.map_id == Map.map_id") 

701 marker = relationship("Marker", primaryjoin="MarkerMapLocation.marker_id == Marker.marker_id") 

702 marker_synonym = relationship( 

703 "MarkerSynonym", 

704 primaryjoin="MarkerMapLocation.marker_synonym_id == MarkerSynonym.marker_synonym_id", 

705 ) 

706 

707 

708class Meta(Base): 

709 __tablename__ = "meta" 

710 __table_args__ = ( 

711 Index("species_value_idx", "species_id", "meta_value"), 

712 Index("species_key_value_idx", "species_id", "meta_key", "meta_value", unique=True), 

713 ) 

714 

715 meta_id: Column = Column(INTEGER(11), primary_key=True) 

716 species_id: Column = Column( 

717 ForeignKey("coord_system.species_id"), 

718 server_default=text("'1'"), 

719 ) 

720 meta_key: Column = Column(String(40), nullable=False) 

721 meta_value: Column = Column(String(255), nullable=False) 

722 

723 coord_system = relationship("CoordSystem", back_populates="meta") 

724 

725 

726class MetaCoord(Base): 

727 __tablename__ = "meta_coord" 

728 __table_args__ = (Index("cs_table_name_idx", "coord_system_id", "table_name", unique=True),) 

729 

730 table_name: Column = Column(String(40), primary_key=True, nullable=False) 

731 coord_system_id: Column = Column( 

732 INTEGER(10), 

733 ForeignKey("coord_system.coord_system_id"), 

734 primary_key=True, 

735 nullable=False, 

736 ) 

737 max_length: Column = Column(INTEGER(11)) 

738 

739 

740class ProteinFeature(Base): 

741 __tablename__ = "protein_feature" 

742 __table_args__ = ( 

743 Index( 

744 "aln_idx", 

745 "translation_id", 

746 "hit_name", 

747 "seq_start", 

748 "seq_end", 

749 "hit_start", 

750 "hit_end", 

751 "analysis_id", 

752 unique=True, 

753 ), 

754 ) 

755 

756 protein_feature_id: Column = Column(INTEGER(10), primary_key=True) 

757 translation_id: Column = Column( 

758 ForeignKey("translation.translation_id"), 

759 nullable=False, 

760 index=True, 

761 ) 

762 seq_start: Column = Column(INTEGER(10), nullable=False) 

763 seq_end: Column = Column(INTEGER(10), nullable=False) 

764 hit_start: Column = Column(INTEGER(10), nullable=False) 

765 hit_end: Column = Column(INTEGER(10), nullable=False) 

766 hit_name: Column = Column(VARCHAR(40), nullable=False, index=True) 

767 analysis_id: Column = Column( 

768 ForeignKey("analysis.analysis_id"), 

769 nullable=False, 

770 index=True, 

771 ) 

772 score: Column = Column(Float(asdecimal=True)) 

773 evalue: Column = Column(Float(asdecimal=True)) 

774 perc_ident: Column = Column(Float) 

775 external_data: Column = Column(Text) 

776 hit_description: Column = Column(Text) 

777 cigar_line: Column = Column(Text) 

778 align_type: Column = Column(Enum("ensembl", "cigar", "cigarplus", "vulgar", "mdtag")) 

779 

780 analysis = relationship("Analysis", primaryjoin="ProteinFeature.analysis_id == Analysis.analysis_id") 

781 translation = relationship( 

782 "Translation", 

783 primaryjoin="ProteinFeature.translation_id == Translation.translation_id", 

784 ) 

785 

786 

787class SeqRegion(Base): 

788 __tablename__ = "seq_region" 

789 __table_args__ = (Index("name_cs_idx", "name", "coord_system_id", unique=True),) 

790 

791 seq_region_id: Column = Column(INTEGER(10), primary_key=True) 

792 name: Column = Column(String(255), nullable=False) 

793 coord_system_id: Column = Column( 

794 ForeignKey("coord_system.coord_system_id"), 

795 nullable=False, 

796 index=True, 

797 ) 

798 length: Column = Column(INTEGER(10), nullable=False) 

799 # Many to one relationship 

800 coord_system = relationship("CoordSystem", back_populates="seq_region") 

801 seq_region_attrib = relationship("SeqRegionAttrib", back_populates="seq_region") 

802 seq_region_synonym = relationship("SeqRegionSynonym", back_populates="seq_region") 

803 karyotype = relationship("Karyotype", back_populates="seq_region") 

804 

805 

806class Dna(SeqRegion): 

807 __tablename__ = "dna" 

808 

809 seq_region_id: Column = Column( 

810 ForeignKey("seq_region.seq_region_id"), 

811 primary_key=True, 

812 ) 

813 sequence: Column = Column(LONGTEXT, nullable=False) 

814 

815 seq_region = relationship( 

816 "SeqRegion", 

817 uselist=False, 

818 primaryjoin="Dna.seq_region_id == SeqRegion.seq_region_id", 

819 ) 

820 

821 

822class StableIdEvent(Base): 

823 __tablename__ = "stable_id_event" 

824 __table_args__ = ( 

825 Index( 

826 "uni_idx", 

827 "mapping_session_id", 

828 "old_stable_id", 

829 "new_stable_id", 

830 "type", 

831 unique=True, 

832 ), 

833 ) 

834 

835 old_stable_id: Column = Column(String(128), primary_key=True, index=True) 

836 old_version: Column = Column(SMALLINT(6)) 

837 new_stable_id: Column = Column(String(128), primary_key=True, index=True) 

838 new_version: Column = Column(SMALLINT(6)) 

839 mapping_session_id: Column = Column( 

840 INTEGER(10), 

841 ForeignKey("mapping_session.mapping_session_id"), 

842 primary_key=True, 

843 nullable=False, 

844 server_default=text("'0'"), 

845 ) 

846 id_type: Column = Column( 

847 "type", 

848 Enum("gene", "transcript", "translation", "rnaproduct"), 

849 primary_key=True, 

850 nullable=False, 

851 ) 

852 score: Column = Column(Float, nullable=False, server_default=text("'0'")) 

853 

854 

855class TranscriptAttrib(Base): 

856 __tablename__ = "transcript_attrib" 

857 __table_args__ = ( 

858 Index("transcript_attrib_type_val_idx", "attrib_type_id", "value", mysql_length={"value": 10}), 

859 Index( 

860 "transcript_attribx", 

861 "transcript_id", 

862 "attrib_type_id", 

863 "value", 

864 unique=True, 

865 mysql_length={"value": 10}, 

866 ), 

867 Index("transcript_attrib_value_idx", "value", mysql_length=10), 

868 ) 

869 

870 transcript_id: Column = Column( 

871 INTEGER(10), 

872 ForeignKey("transcript.transcript_id"), 

873 nullable=False, 

874 index=True, 

875 server_default=text("'0'"), 

876 primary_key=True, 

877 ) 

878 attrib_type_id: Column = Column( 

879 SMALLINT(5), 

880 ForeignKey("attrib_type.attrib_type_id"), 

881 nullable=False, 

882 server_default=text("'0'"), 

883 primary_key=True, 

884 ) 

885 value: Column = Column(String(500), nullable=False, primary_key=True) 

886 

887 

888class TranscriptSupportingFeature(Base): 

889 __tablename__ = "transcript_supporting_feature" 

890 __table_args__ = ( 

891 Index("transcript_supporting_feature_idx", "feature_type", "feature_id"), 

892 Index( 

893 "transcript_supporting_feature_all_idx", 

894 "transcript_id", 

895 "feature_type", 

896 "feature_id", 

897 unique=True, 

898 ), 

899 ) 

900 

901 transcript_id: Column = Column( 

902 INTEGER(10), 

903 ForeignKey("transcript.transcript_id"), 

904 primary_key=True, 

905 nullable=False, 

906 server_default=text("'0'"), 

907 ) 

908 feature_type: Column = Column(Enum("dna_align_feature", "protein_align_feature"), primary_key=True) 

909 feature_id: Column = Column(INTEGER(10), primary_key=True, nullable=False, server_default=text("'0'")) 

910 

911 

912class TranslationAttrib(Base): 

913 __tablename__ = "translation_attrib" 

914 __table_args__ = ( 

915 Index("translation_attrib_type_val_idx", "attrib_type_id", "value", mysql_length={"value": 10}), 

916 Index( 

917 "translation_attribx", 

918 "translation_id", 

919 "attrib_type_id", 

920 "value", 

921 unique=True, 

922 mysql_length={"value": 10}, 

923 ), 

924 Index("translation_attrib_value_idx", "value", mysql_length=10), 

925 ) 

926 

927 translation_id: Column = Column( 

928 ForeignKey("translation.translation_id"), 

929 nullable=False, 

930 index=True, 

931 server_default=text("'0'"), 

932 primary_key=True, 

933 ) 

934 attrib_type_id: Column = Column( 

935 ForeignKey("attrib_type.attrib_type_id"), 

936 nullable=False, 

937 server_default=text("'0'"), 

938 primary_key=True, 

939 ) 

940 value: Column = Column(String(500), nullable=False, primary_key=True) 

941 

942 

943class UnmappedObject(Base): 

944 __tablename__ = "unmapped_object" 

945 __table_args__ = ( 

946 Index( 

947 "unique_unmapped_obj_idx", 

948 "ensembl_id", 

949 "ensembl_object_type", 

950 "identifier", 

951 "unmapped_reason_id", 

952 "parent", 

953 "external_db_id", 

954 unique=True, 

955 ), 

956 Index("anal_exdb_idx", "analysis_id", "external_db_id"), 

957 Index("ext_db_identifier_idx", "external_db_id", "identifier"), 

958 ) 

959 

960 unmapped_object_id: Column = Column(INTEGER(10), primary_key=True) 

961 unmapped_object_type: Column = Column("type", Enum("xref", "cDNA", "Marker"), nullable=False) 

962 analysis_id: Column = Column( 

963 ForeignKey("analysis.analysis_id"), 

964 nullable=False, 

965 ) 

966 external_db_id: Column = Column( 

967 ForeignKey("external_db.external_db_id"), 

968 ) 

969 identifier: Column = Column(String(255), nullable=False, index=True) 

970 unmapped_reason_id: Column = Column( 

971 ForeignKey("unmapped_reason.unmapped_reason_id"), 

972 nullable=False, 

973 index=True, 

974 ) 

975 query_score: Column = Column(Float(asdecimal=True)) 

976 target_score: Column = Column(Float(asdecimal=True)) 

977 ensembl_id: Column = Column(INTEGER(10), server_default=text("'0'")) 

978 ensembl_object_type: Column = Column( 

979 Enum("RawContig", "Transcript", "Gene", "Translation"), 

980 server_default=text("'RawContig'"), 

981 ) 

982 parent: Column = Column(String(255)) 

983 

984 analysis = relationship("Analysis", primaryjoin="UnmappedObject.analysis_id == Analysis.analysis_id") 

985 external_db = relationship( 

986 "ExternalDb", 

987 primaryjoin="UnmappedObject.external_db_id == ExternalDb.external_db_id", 

988 ) 

989 unmapped_reason = relationship( 

990 "UnmappedReason", 

991 primaryjoin="UnmappedObject.unmapped_reason_id == UnmappedReason.unmapped_reason_id", 

992 ) 

993 

994 

995class Xref(Base): 

996 __tablename__ = "xref" 

997 __table_args__ = ( 

998 Index( 

999 "id_index", 

1000 "dbprimary_acc", 

1001 "external_db_id", 

1002 "info_type", 

1003 "info_text", 

1004 "version", 

1005 unique=True, 

1006 ), 

1007 ) 

1008 

1009 xref_id: Column = Column(INTEGER(10), primary_key=True) 

1010 external_db_id: Column = Column( 

1011 ForeignKey("external_db.external_db_id"), 

1012 nullable=False, 

1013 index=True, 

1014 ) 

1015 dbprimary_acc: Column = Column(String(512), nullable=False) 

1016 display_label: Column = Column(String(512), nullable=False, index=True) 

1017 version: Column = Column(String(10)) 

1018 description: Column = Column(Text) 

1019 info_type: Column = Column( 

1020 Enum( 

1021 "NONE", 

1022 "PROJECTION", 

1023 "MISC", 

1024 "DEPENDENT", 

1025 "DIRECT", 

1026 "SEQUENCE_MATCH", 

1027 "INFERRED_PAIR", 

1028 "PROBE", 

1029 "UNMAPPED", 

1030 "COORDINATE_OVERLAP", 

1031 "CHECKSUM", 

1032 ), 

1033 nullable=False, 

1034 index=True, 

1035 server_default=text("'NONE'"), 

1036 ) 

1037 info_text: Column = Column(String(255), nullable=False, server_default=text("''")) 

1038 

1039 external_db = relationship("ExternalDb", primaryjoin="Xref.external_db_id == ExternalDb.external_db_id") 

1040 

1041 

1042t_alt_allele_attrib = Table( 

1043 "alt_allele_attrib", 

1044 metadata, 

1045 Column( 

1046 "alt_allele_id", 

1047 ForeignKey("alt_allele.alt_allele_id"), 

1048 ), 

1049 Column( 

1050 "attrib", 

1051 Enum( 

1052 "IS_REPRESENTATIVE", 

1053 "IS_MOST_COMMON_ALLELE", 

1054 "IN_CORRECTED_ASSEMBLY", 

1055 "HAS_CODING_POTENTIAL", 

1056 "IN_ARTIFICIALLY_DUPLICATED_ASSEMBLY", 

1057 "IN_SYNTENIC_REGION", 

1058 "HAS_SAME_UNDERLYING_DNA_SEQUENCE", 

1059 "IN_BROKEN_ASSEMBLY_REGION", 

1060 "IS_VALID_ALTERNATE", 

1061 "SAME_AS_REPRESENTATIVE", 

1062 "SAME_AS_ANOTHER_ALLELE", 

1063 "MANUALLY_ASSIGNED", 

1064 "AUTOMATICALLY_ASSIGNED", 

1065 ), 

1066 ), 

1067 Index("aa_idx", "alt_allele_id", "attrib"), 

1068) 

1069 

1070 

1071class Assembly(Base): 

1072 __tablename__ = "assembly" 

1073 __table_args__ = ( 

1074 Index("asm_seq_region_idx", "asm_seq_region_id", "asm_start"), 

1075 Index( 

1076 "asm_all_idx", 

1077 "asm_seq_region_id", 

1078 "cmp_seq_region_id", 

1079 "asm_start", 

1080 "asm_end", 

1081 "cmp_start", 

1082 "cmp_end", 

1083 "ori", 

1084 unique=True, 

1085 ), 

1086 ) 

1087 

1088 asm_seq_region_id: Column = Column( 

1089 INTEGER(10), 

1090 ForeignKey("seq_region.seq_region_id"), 

1091 primary_key=True, 

1092 nullable=False, 

1093 ) 

1094 cmp_seq_region_id: Column = Column( 

1095 INTEGER(10), 

1096 ForeignKey("seq_region.seq_region_id"), 

1097 primary_key=True, 

1098 nullable=False, 

1099 ) 

1100 asm_start: Column = Column(INTEGER(10), primary_key=True, nullable=False) 

1101 asm_end: Column = Column(INTEGER(10), primary_key=True, nullable=False) 

1102 cmp_start: Column = Column(INTEGER(10), primary_key=True, nullable=False) 

1103 cmp_end: Column = Column(INTEGER(10), primary_key=True, nullable=False) 

1104 ori: Column = Column(TINYINT(4), primary_key=True, nullable=False) 

1105 

1106 

1107class AssemblyException(Base): 

1108 __tablename__ = "assembly_exception" 

1109 __table_args__ = ( 

1110 Index("ex_idx", "exc_seq_region_id", "exc_seq_region_start"), 

1111 Index("sr_idx", "seq_region_id", "seq_region_start"), 

1112 ) 

1113 

1114 assembly_exception_id: Column = Column(INTEGER(10), primary_key=True) 

1115 seq_region_id: Column = Column( 

1116 ForeignKey("seq_region.seq_region_id"), 

1117 nullable=False, 

1118 ) 

1119 seq_region_start: Column = Column(INTEGER(10), nullable=False) 

1120 seq_region_end: Column = Column(INTEGER(10), nullable=False) 

1121 exc_type: Column = Column(Enum("HAP", "PAR", "PATCH_FIX", "PATCH_NOVEL"), nullable=False) 

1122 exc_seq_region_id: Column = Column( 

1123 ForeignKey("seq_region.seq_region_id"), 

1124 nullable=False, 

1125 ) 

1126 exc_seq_region_start: Column = Column(INTEGER(10), nullable=False) 

1127 exc_seq_region_end: Column = Column(INTEGER(10), nullable=False) 

1128 ori: Column = Column(INTEGER(11), nullable=False) 

1129 

1130 exc_seq_region = relationship( 

1131 "SeqRegion", 

1132 primaryjoin="AssemblyException.exc_seq_region_id == SeqRegion.seq_region_id", 

1133 ) 

1134 seq_region = relationship( 

1135 "SeqRegion", 

1136 primaryjoin="AssemblyException.seq_region_id == SeqRegion.seq_region_id", 

1137 ) 

1138 

1139 

1140class DensityFeature(Base): 

1141 __tablename__ = "density_feature" 

1142 __table_args__ = ( 

1143 Index("density_seq_region_idx", "density_type_id", "seq_region_id", "seq_region_start"), 

1144 ) 

1145 

1146 density_feature_id: Column = Column(INTEGER(10), primary_key=True) 

1147 density_type_id: Column = Column( 

1148 ForeignKey("density_type.density_type_id"), 

1149 nullable=False, 

1150 ) 

1151 seq_region_id: Column = Column( 

1152 ForeignKey("seq_region.seq_region_id"), 

1153 nullable=False, 

1154 index=True, 

1155 ) 

1156 seq_region_start: Column = Column(INTEGER(10), nullable=False) 

1157 seq_region_end: Column = Column(INTEGER(10), nullable=False) 

1158 density_value: Column = Column(Float, nullable=False) 

1159 

1160 density_type = relationship( 

1161 "DensityType", 

1162 primaryjoin="DensityFeature.density_type_id == DensityType.density_type_id", 

1163 ) 

1164 seq_region = relationship( 

1165 "SeqRegion", 

1166 primaryjoin="DensityFeature.seq_region_id == SeqRegion.seq_region_id", 

1167 ) 

1168 

1169 

1170class DitagFeature(Base): 

1171 __tablename__ = "ditag_feature" 

1172 __table_args__ = (Index("ditag_seq_region_idx", "seq_region_id", "seq_region_start", "seq_region_end"),) 

1173 

1174 ditag_feature_id: Column = Column(INTEGER(10), primary_key=True) 

1175 ditag_id: Column = Column( 

1176 ForeignKey("ditag.ditag_id"), 

1177 nullable=False, 

1178 index=True, 

1179 server_default=text("'0'"), 

1180 ) 

1181 ditag_pair_id: Column = Column(INTEGER(10), nullable=False, index=True, server_default=text("'0'")) 

1182 seq_region_id: Column = Column( 

1183 ForeignKey("seq_region.seq_region_id"), 

1184 nullable=False, 

1185 server_default=text("'0'"), 

1186 ) 

1187 seq_region_start: Column = Column(INTEGER(10), nullable=False, server_default=text("'0'")) 

1188 seq_region_end: Column = Column(INTEGER(10), nullable=False, server_default=text("'0'")) 

1189 seq_region_strand: Column = Column(TINYINT(1), nullable=False, server_default=text("'0'")) 

1190 analysis_id: Column = Column( 

1191 ForeignKey("analysis.analysis_id"), 

1192 nullable=False, 

1193 index=True, 

1194 server_default=text("'0'"), 

1195 ) 

1196 hit_start: Column = Column(INTEGER(10), nullable=False, server_default=text("'0'")) 

1197 hit_end: Column = Column(INTEGER(10), nullable=False, server_default=text("'0'")) 

1198 hit_strand: Column = Column(TINYINT(1), nullable=False, server_default=text("'0'")) 

1199 cigar_line: Column = Column(TINYTEXT, nullable=False) 

1200 ditag_side: Column = Column(Enum("F", "L", "R"), nullable=False) 

1201 

1202 analysis = relationship("Analysis", primaryjoin="DitagFeature.analysis_id == Analysis.analysis_id") 

1203 ditag = relationship("Ditag", primaryjoin="DitagFeature.ditag_id == Ditag.ditag_id") 

1204 seq_region = relationship( 

1205 "SeqRegion", primaryjoin="DitagFeature.seq_region_id == SeqRegion.seq_region_id" 

1206 ) 

1207 

1208 

1209class DnaAlignFeature(Base): 

1210 __tablename__ = "dna_align_feature" 

1211 __table_args__ = ( 

1212 Index("dna_align_seq_region_idx_2", "seq_region_id", "seq_region_start"), 

1213 Index( 

1214 "dna_align_seq_region_idx", 

1215 "seq_region_id", 

1216 "analysis_id", 

1217 "seq_region_start", 

1218 "score", 

1219 ), 

1220 ) 

1221 

1222 dna_align_feature_id: Column = Column(INTEGER(10), primary_key=True) 

1223 seq_region_id: Column = Column( 

1224 ForeignKey("seq_region.seq_region_id"), 

1225 nullable=False, 

1226 ) 

1227 seq_region_start: Column = Column(INTEGER(10), nullable=False) 

1228 seq_region_end: Column = Column(INTEGER(10), nullable=False) 

1229 seq_region_strand: Column = Column(TINYINT(1), nullable=False) 

1230 hit_start: Column = Column(INTEGER(11), nullable=False) 

1231 hit_end: Column = Column(INTEGER(11), nullable=False) 

1232 hit_strand: Column = Column(TINYINT(1), nullable=False) 

1233 hit_name: Column = Column(String(40), nullable=False, index=True) 

1234 analysis_id: Column = Column( 

1235 ForeignKey("analysis.analysis_id"), 

1236 nullable=False, 

1237 index=True, 

1238 ) 

1239 score: Column = Column(Float(asdecimal=True)) 

1240 evalue: Column = Column(Float(asdecimal=True)) 

1241 perc_ident: Column = Column(Float) 

1242 cigar_line: Column = Column(Text) 

1243 external_db_id: Column = Column( 

1244 ForeignKey("external_db.external_db_id"), 

1245 index=True, 

1246 ) 

1247 hcoverage: Column = Column(Float(asdecimal=True)) 

1248 align_type: Column = Column(Enum("ensembl", "cigar", "vulgar", "mdtag"), server_default=text("'ensembl'")) 

1249 

1250 analysis = relationship("Analysis", primaryjoin="DnaAlignFeature.analysis_id == Analysis.analysis_id") 

1251 external_db = relationship( 

1252 "ExternalDb", 

1253 primaryjoin="DnaAlignFeature.external_db_id == ExternalDb.external_db_id", 

1254 ) 

1255 seq_region = relationship( 

1256 "SeqRegion", 

1257 primaryjoin="DnaAlignFeature.seq_region_id == SeqRegion.seq_region_id", 

1258 ) 

1259 

1260 

1261class Exon(Base): 

1262 __tablename__ = "exon" 

1263 __table_args__ = ( 

1264 Index("exon_seq_region_idx", "seq_region_id", "seq_region_start"), 

1265 Index("exon_stable_id_idx", "stable_id", "version"), 

1266 ) 

1267 

1268 exon_id: Column = Column(INTEGER(10), primary_key=True) 

1269 seq_region_id: Column = Column( 

1270 ForeignKey("seq_region.seq_region_id"), 

1271 nullable=False, 

1272 ) 

1273 seq_region_start: Column = Column(INTEGER(10), nullable=False) 

1274 seq_region_end: Column = Column(INTEGER(10), nullable=False) 

1275 seq_region_strand: Column = Column(TINYINT(2), nullable=False) 

1276 phase: Column = Column(TINYINT(2), nullable=False) 

1277 end_phase: Column = Column(TINYINT(2), nullable=False) 

1278 is_current: Column = Column(TINYINT(1), nullable=False, server_default=text("'1'")) 

1279 is_constitutive: Column = Column(TINYINT(1), nullable=False, server_default=text("'0'")) 

1280 stable_id: Column = Column(String(128)) 

1281 version: Column = Column(SMALLINT(5)) 

1282 created_date: Column = Column(DateTime) 

1283 modified_date: Column = Column(DateTime) 

1284 

1285 seq_region = relationship("SeqRegion", primaryjoin="Exon.seq_region_id == SeqRegion.seq_region_id") 

1286 

1287 

1288class ExternalSynonym(Base): 

1289 __tablename__ = "external_synonym" 

1290 

1291 xref_id: Column = Column( 

1292 ForeignKey("xref.xref_id"), 

1293 primary_key=True, 

1294 nullable=False, 

1295 ) 

1296 synonym: Column = Column(String(100), primary_key=True, nullable=False, index=True) 

1297 

1298 xref = relationship("Xref", primaryjoin="ExternalSynonym.xref_id == Xref.xref_id") 

1299 

1300 

1301class IntronSupportingEvidence(Base): 

1302 __tablename__ = "intron_supporting_evidence" 

1303 __table_args__ = ( 

1304 Index( 

1305 "analysis_id", 

1306 "analysis_id", 

1307 "seq_region_id", 

1308 "seq_region_start", 

1309 "seq_region_end", 

1310 "seq_region_strand", 

1311 "hit_name", 

1312 unique=True, 

1313 ), 

1314 Index("intron_evidence_seq_region_idx", "seq_region_id", "seq_region_start"), 

1315 ) 

1316 

1317 intron_supporting_evidence_id: Column = Column(INTEGER(10), primary_key=True) 

1318 analysis_id: Column = Column( 

1319 ForeignKey("analysis.analysis_id"), 

1320 nullable=False, 

1321 ) 

1322 seq_region_id: Column = Column( 

1323 ForeignKey("seq_region.seq_region_id"), 

1324 nullable=False, 

1325 ) 

1326 seq_region_start: Column = Column(INTEGER(10), nullable=False) 

1327 seq_region_end: Column = Column(INTEGER(10), nullable=False) 

1328 seq_region_strand: Column = Column(TINYINT(2), nullable=False) 

1329 hit_name: Column = Column(String(100), nullable=False) 

1330 score: Column = Column(DECIMAL(10, 3)) 

1331 score_type: Column = Column(Enum("NONE", "DEPTH"), server_default=text("'NONE'")) 

1332 is_splice_canonical: Column = Column(TINYINT(1), nullable=False, server_default=text("'0'")) 

1333 

1334 analysis = relationship( 

1335 "Analysis", 

1336 primaryjoin="IntronSupportingEvidence.analysis_id == Analysis.analysis_id", 

1337 ) 

1338 seq_region = relationship( 

1339 "SeqRegion", 

1340 primaryjoin="IntronSupportingEvidence.seq_region_id == SeqRegion.seq_region_id", 

1341 ) 

1342 

1343 

1344class Karyotype(Base): 

1345 __tablename__ = "karyotype" 

1346 __table_args__ = (Index("region_band_idx", "seq_region_id", "band"),) 

1347 

1348 karyotype_id: Column = Column(INTEGER(10), primary_key=True) 

1349 seq_region_id: Column = Column( 

1350 ForeignKey("seq_region.seq_region_id"), 

1351 nullable=False, 

1352 ) 

1353 seq_region_start: Column = Column(INTEGER(10), nullable=False) 

1354 seq_region_end: Column = Column(INTEGER(10), nullable=False) 

1355 band: Column = Column(String(40)) 

1356 stain: Column = Column(String(40)) 

1357 

1358 seq_region = relationship("SeqRegion", primaryjoin="Karyotype.seq_region_id == SeqRegion.seq_region_id") 

1359 

1360 

1361class MarkerFeature(Base): 

1362 __tablename__ = "marker_feature" 

1363 __table_args__ = (Index("marker_seq_region_idx", "seq_region_id", "seq_region_start"),) 

1364 

1365 marker_feature_id: Column = Column(INTEGER(10), primary_key=True) 

1366 marker_id: Column = Column( 

1367 ForeignKey("marker.marker_id"), 

1368 nullable=False, 

1369 index=True, 

1370 ) 

1371 seq_region_id: Column = Column( 

1372 ForeignKey("seq_region.seq_region_id"), 

1373 nullable=False, 

1374 ) 

1375 seq_region_start: Column = Column(INTEGER(10), nullable=False) 

1376 seq_region_end: Column = Column(INTEGER(10), nullable=False) 

1377 analysis_id: Column = Column( 

1378 ForeignKey("analysis.analysis_id"), 

1379 nullable=False, 

1380 index=True, 

1381 ) 

1382 map_weight: Column = Column(INTEGER(10)) 

1383 

1384 analysis = relationship("Analysis", primaryjoin="MarkerFeature.analysis_id == Analysis.analysis_id") 

1385 marker = relationship("Marker", primaryjoin="MarkerFeature.marker_id == Marker.marker_id") 

1386 seq_region = relationship( 

1387 "SeqRegion", 

1388 primaryjoin="MarkerFeature.seq_region_id == SeqRegion.seq_region_id", 

1389 ) 

1390 

1391 

1392t_misc_feature_misc_set = Table( 

1393 "misc_feature_misc_set", 

1394 metadata, 

1395 Column( 

1396 "misc_feature_id", 

1397 ForeignKey("misc_feature.misc_feature_id"), 

1398 primary_key=True, 

1399 nullable=False, 

1400 server_default=text("'0'"), 

1401 ), 

1402 Column( 

1403 "misc_set_id", 

1404 ForeignKey("misc_set.misc_set_id"), 

1405 primary_key=True, 

1406 nullable=False, 

1407 server_default=text("'0'"), 

1408 ), 

1409 Index("reverse_idx", "misc_set_id", "misc_feature_id"), 

1410) 

1411 

1412 

1413class MiscSet(Base): 

1414 __tablename__ = "misc_set" 

1415 

1416 misc_set_id: Column = Column(SMALLINT(5), primary_key=True) 

1417 code: Column = Column(String(25), nullable=False, unique=True, server_default=text("''")) 

1418 name: Column = Column(String(255), nullable=False, server_default=text("''")) 

1419 description: Column = Column(Text, nullable=False) 

1420 max_length: Column = Column(INTEGER(10), nullable=False) 

1421 

1422 # misc_features = relationship("MiscFeature", secondary=t_misc_feature_misc_set) 

1423 

1424 

1425class MiscFeature(Base): 

1426 __tablename__ = "misc_feature" 

1427 __table_args__ = (Index("misc_seq_region_idx", "seq_region_id", "seq_region_start"),) 

1428 

1429 misc_feature_id: Column = Column(INTEGER(10), primary_key=True) 

1430 seq_region_id: Column = Column( 

1431 ForeignKey("seq_region.seq_region_id"), 

1432 nullable=False, 

1433 server_default=text("'0'"), 

1434 ) 

1435 seq_region_start: Column = Column(INTEGER(10), nullable=False, server_default=text("'0'")) 

1436 seq_region_end: Column = Column(INTEGER(10), nullable=False, server_default=text("'0'")) 

1437 seq_region_strand: Column = Column(TINYINT(4), nullable=False, server_default=text("'0'")) 

1438 

1439 seq_region = relationship("SeqRegion", primaryjoin="MiscFeature.seq_region_id == SeqRegion.seq_region_id") 

1440 # misc_sets = relationship("MiscSet", secondary=t_misc_feature_misc_set) 

1441 

1442 

1443class ObjectXref(Base): 

1444 __tablename__ = "object_xref" 

1445 __table_args__ = ( 

1446 Index("ensembl_idx", "ensembl_object_type", "ensembl_id"), 

1447 Index( 

1448 "xref_idx", 

1449 "xref_id", 

1450 "ensembl_object_type", 

1451 "ensembl_id", 

1452 "analysis_id", 

1453 unique=True, 

1454 ), 

1455 ) 

1456 

1457 object_xref_id: Column = Column(INTEGER(10), primary_key=True) 

1458 ensembl_id: Column = Column(INTEGER(10), nullable=False) 

1459 ensembl_object_type: Column = Column( 

1460 Enum( 

1461 "RawContig", 

1462 "Transcript", 

1463 "Gene", 

1464 "Translation", 

1465 "Operon", 

1466 "OperonTranscript", 

1467 "Marker", 

1468 "RNAProduct", 

1469 ), 

1470 nullable=False, 

1471 ) 

1472 xref_id: Column = Column(ForeignKey("xref.xref_id"), nullable=False) 

1473 linkage_annotation: Column = Column(String(255)) 

1474 analysis_id: Column = Column( 

1475 ForeignKey("analysis.analysis_id"), 

1476 index=True, 

1477 ) 

1478 

1479 analysis = relationship("Analysis", primaryjoin="ObjectXref.analysis_id == Analysis.analysis_id") 

1480 xref = relationship("Xref", primaryjoin="ObjectXref.xref_id == Xref.xref_id") 

1481 

1482 

1483class DependentXref(ObjectXref): 

1484 __tablename__ = "dependent_xref" 

1485 

1486 object_xref_id: Column = Column( 

1487 ForeignKey("object_xref.object_xref_id"), 

1488 primary_key=True, 

1489 ) 

1490 master_xref_id: Column = Column( 

1491 ForeignKey("xref.xref_id"), 

1492 nullable=False, 

1493 index=True, 

1494 ) 

1495 dependent_xref_id: Column = Column( 

1496 ForeignKey("xref.xref_id"), 

1497 nullable=False, 

1498 index=True, 

1499 ) 

1500 

1501 

1502class IdentityXref(ObjectXref): 

1503 __tablename__ = "identity_xref" 

1504 

1505 object_xref_id: Column = Column( 

1506 ForeignKey("object_xref.object_xref_id"), 

1507 primary_key=True, 

1508 ) 

1509 xref_identity: Column = Column(INTEGER(5)) 

1510 ensembl_identity: Column = Column(INTEGER(5)) 

1511 xref_start: Column = Column(INTEGER(11)) 

1512 xref_end: Column = Column(INTEGER(11)) 

1513 ensembl_start: Column = Column(INTEGER(11)) 

1514 ensembl_end: Column = Column(INTEGER(11)) 

1515 cigar_line: Column = Column(Text) 

1516 score: Column = Column(Float(asdecimal=True)) 

1517 evalue: Column = Column(Float(asdecimal=True)) 

1518 

1519 object_xref = relationship( 

1520 "ObjectXref", 

1521 uselist=False, 

1522 primaryjoin="IdentityXref.object_xref_id == ObjectXref.object_xref_id", 

1523 ) 

1524 

1525 

1526class Operon(Base): 

1527 __tablename__ = "operon" 

1528 __table_args__ = ( 

1529 Index("operon_seq_region_idx", "seq_region_id", "seq_region_start"), 

1530 Index("operon_stable_id_idx", "stable_id", "version"), 

1531 ) 

1532 

1533 operon_id: Column = Column(INTEGER(10), primary_key=True) 

1534 seq_region_id: Column = Column( 

1535 ForeignKey("seq_region.seq_region_id"), 

1536 nullable=False, 

1537 ) 

1538 seq_region_start: Column = Column(INTEGER(10), nullable=False) 

1539 seq_region_end: Column = Column(INTEGER(10), nullable=False) 

1540 seq_region_strand: Column = Column(TINYINT(2), nullable=False) 

1541 display_label: Column = Column(String(255), index=True) 

1542 analysis_id: Column = Column( 

1543 ForeignKey("analysis.analysis_id"), 

1544 nullable=False, 

1545 index=True, 

1546 ) 

1547 stable_id: Column = Column(String(128)) 

1548 version: Column = Column(SMALLINT(5)) 

1549 created_date: Column = Column(DateTime) 

1550 modified_date: Column = Column(DateTime) 

1551 

1552 analysis = relationship("Analysis", primaryjoin="Operon.analysis_id == Analysis.analysis_id") 

1553 seq_region = relationship("SeqRegion", primaryjoin="Operon.seq_region_id == SeqRegion.seq_region_id") 

1554 

1555 

1556class PredictionTranscript(Base): 

1557 __tablename__ = "prediction_transcript" 

1558 __table_args__ = (Index("prediction_transcript_seq_region_idx", "seq_region_id", "seq_region_start"),) 

1559 

1560 prediction_transcript_id: Column = Column(INTEGER(10), primary_key=True) 

1561 seq_region_id: Column = Column( 

1562 ForeignKey("seq_region.seq_region_id"), 

1563 nullable=False, 

1564 ) 

1565 seq_region_start: Column = Column(INTEGER(10), nullable=False) 

1566 seq_region_end: Column = Column(INTEGER(10), nullable=False) 

1567 seq_region_strand: Column = Column(TINYINT(4), nullable=False) 

1568 analysis_id: Column = Column( 

1569 ForeignKey("analysis.analysis_id"), 

1570 nullable=False, 

1571 index=True, 

1572 ) 

1573 display_label: Column = Column(String(255)) 

1574 

1575 analysis = relationship( 

1576 "Analysis", 

1577 primaryjoin="PredictionTranscript.analysis_id == Analysis.analysis_id", 

1578 ) 

1579 seq_region = relationship( 

1580 "SeqRegion", 

1581 primaryjoin="PredictionTranscript.seq_region_id == SeqRegion.seq_region_id", 

1582 ) 

1583 

1584 

1585class ProteinAlignFeature(Base): 

1586 __tablename__ = "protein_align_feature" 

1587 __table_args__ = ( 

1588 Index("protein_align_seq_region_idx_2", "seq_region_id", "seq_region_start"), 

1589 Index( 

1590 "seq_region_idx", 

1591 "seq_region_id", 

1592 "analysis_id", 

1593 "seq_region_start", 

1594 "score", 

1595 ), 

1596 ) 

1597 

1598 protein_align_feature_id: Column = Column(INTEGER(10), primary_key=True) 

1599 seq_region_id: Column = Column( 

1600 ForeignKey("seq_region.seq_region_id"), 

1601 nullable=False, 

1602 ) 

1603 seq_region_start: Column = Column(INTEGER(10), nullable=False) 

1604 seq_region_end: Column = Column(INTEGER(10), nullable=False) 

1605 seq_region_strand: Column = Column(TINYINT(1), nullable=False, server_default=text("'1'")) 

1606 hit_start: Column = Column(INTEGER(10), nullable=False) 

1607 hit_end: Column = Column(INTEGER(10), nullable=False) 

1608 hit_name: Column = Column(String(40), nullable=False, index=True) 

1609 analysis_id: Column = Column( 

1610 ForeignKey("analysis.analysis_id"), 

1611 nullable=False, 

1612 index=True, 

1613 ) 

1614 score: Column = Column(Float(asdecimal=True)) 

1615 evalue: Column = Column(Float(asdecimal=True)) 

1616 perc_ident: Column = Column(Float) 

1617 cigar_line: Column = Column(Text) 

1618 external_db_id: Column = Column( 

1619 ForeignKey("external_db.external_db_id"), 

1620 index=True, 

1621 ) 

1622 hcoverage: Column = Column(Float(asdecimal=True)) 

1623 align_type: Column = Column(Enum("ensembl", "cigar", "vulgar", "mdtag"), server_default=text("'ensembl'")) 

1624 

1625 analysis = relationship( 

1626 "Analysis", 

1627 primaryjoin="ProteinAlignFeature.analysis_id == Analysis.analysis_id", 

1628 ) 

1629 external_db = relationship( 

1630 "ExternalDb", 

1631 primaryjoin="ProteinAlignFeature.external_db_id == ExternalDb.external_db_id", 

1632 ) 

1633 seq_region = relationship( 

1634 "SeqRegion", 

1635 primaryjoin="ProteinAlignFeature.seq_region_id == SeqRegion.seq_region_id", 

1636 ) 

1637 

1638 

1639class RepeatFeature(Base): 

1640 __tablename__ = "repeat_feature" 

1641 __table_args__ = (Index("repeat_feature_seq_region_idx", "seq_region_id", "seq_region_start"),) 

1642 

1643 repeat_feature_id: Column = Column(INTEGER(10), primary_key=True) 

1644 seq_region_id: Column = Column( 

1645 ForeignKey("seq_region.seq_region_id"), 

1646 nullable=False, 

1647 ) 

1648 seq_region_start: Column = Column(INTEGER(10), nullable=False) 

1649 seq_region_end: Column = Column(INTEGER(10), nullable=False) 

1650 seq_region_strand: Column = Column(TINYINT(1), nullable=False, server_default=text("'1'")) 

1651 repeat_start: Column = Column(INTEGER(10), nullable=False) 

1652 repeat_end: Column = Column(INTEGER(10), nullable=False) 

1653 repeat_consensus_id: Column = Column( 

1654 ForeignKey("repeat_consensus.repeat_consensus_id"), 

1655 nullable=False, 

1656 index=True, 

1657 ) 

1658 analysis_id: Column = Column( 

1659 ForeignKey("analysis.analysis_id"), 

1660 nullable=False, 

1661 index=True, 

1662 ) 

1663 score: Column = Column(Float(asdecimal=True)) 

1664 

1665 analysis = relationship("Analysis", primaryjoin="RepeatFeature.analysis_id == Analysis.analysis_id") 

1666 repeat_consensus = relationship( 

1667 "RepeatConsensus", 

1668 primaryjoin="RepeatFeature.repeat_consensus_id == RepeatConsensus.repeat_consensus_id", 

1669 ) 

1670 seq_region = relationship( 

1671 "SeqRegion", 

1672 primaryjoin="RepeatFeature.seq_region_id == SeqRegion.seq_region_id", 

1673 ) 

1674 

1675 

1676class SeqRegionAttrib(Base): 

1677 __tablename__ = "seq_region_attrib" 

1678 __table_args__ = ( 

1679 Index( 

1680 "region_attribx", 

1681 "seq_region_id", 

1682 "attrib_type_id", 

1683 "value", 

1684 unique=True, 

1685 mysql_length={"value": 10}, 

1686 ), 

1687 Index("region_attrib_type_val_idx", "attrib_type_id", "value", mysql_length={"value": 10}), 

1688 Index("region_attrib_value_idx", "value", mysql_length=10), 

1689 ) 

1690 

1691 seq_region_id: Column = Column( 

1692 ForeignKey("seq_region.seq_region_id"), 

1693 nullable=False, 

1694 index=True, 

1695 server_default=text("'0'"), 

1696 primary_key=True, 

1697 ) 

1698 attrib_type_id: Column = Column( 

1699 ForeignKey("attrib_type.attrib_type_id"), 

1700 nullable=False, 

1701 server_default=text("'0'"), 

1702 primary_key=True, 

1703 ) 

1704 value: Column = Column(String(500), nullable=False, primary_key=True) 

1705 

1706 UniqueConstraint("seq_region_id", "attrib_type_id", "value", name="region_attribx") 

1707 seq_region = relationship("SeqRegion", back_populates="seq_region_attrib") 

1708 attrib_type = relationship("AttribType", back_populates="seq_region_attrib") 

1709 

1710 

1711# Not in first normal form, can't be mapped (i.e. it has fully duplicated rows for homo_sapiens_core) 

1712t_seq_region_mapping = Table( 

1713 "seq_region_mapping", 

1714 metadata, 

1715 Column("external_seq_region_id", INTEGER(10), nullable=False), 

1716 Column( 

1717 "internal_seq_region_id", 

1718 ForeignKey("seq_region.seq_region_id"), 

1719 nullable=False, 

1720 index=True, 

1721 ), 

1722 Column( 

1723 "mapping_set_id", 

1724 ForeignKey("mapping_set.mapping_set_id"), 

1725 nullable=False, 

1726 index=True, 

1727 ), 

1728) 

1729 

1730 

1731class SeqRegionSynonym(Base): 

1732 __tablename__ = "seq_region_synonym" 

1733 __table_args__ = (Index("syn_idx", "synonym", "seq_region_id", unique=True),) 

1734 

1735 seq_region_synonym_id: Column = Column(INTEGER(10), primary_key=True) 

1736 seq_region_id: Column = Column( 

1737 ForeignKey("seq_region.seq_region_id"), 

1738 nullable=False, 

1739 index=True, 

1740 ) 

1741 synonym: Column = Column(String(250), nullable=False) 

1742 external_db_id: Column = Column(ForeignKey("external_db.external_db_id")) 

1743 

1744 seq_region = relationship("SeqRegion", back_populates="seq_region_synonym") 

1745 external_db = relationship("ExternalDb", back_populates="seq_region_synonym") 

1746 

1747 

1748class SimpleFeature(Base): 

1749 __tablename__ = "simple_feature" 

1750 __table_args__ = (Index("simple_feature_seq_region_idx", "seq_region_id", "seq_region_start"),) 

1751 

1752 simple_feature_id: Column = Column(INTEGER(10), primary_key=True) 

1753 seq_region_id: Column = Column( 

1754 ForeignKey("seq_region.seq_region_id"), 

1755 nullable=False, 

1756 ) 

1757 seq_region_start: Column = Column(INTEGER(10), nullable=False) 

1758 seq_region_end: Column = Column(INTEGER(10), nullable=False) 

1759 seq_region_strand: Column = Column(TINYINT(1), nullable=False) 

1760 display_label: Column = Column(String(255), nullable=False, index=True) 

1761 analysis_id: Column = Column( 

1762 ForeignKey("analysis.analysis_id"), 

1763 nullable=False, 

1764 index=True, 

1765 ) 

1766 score: Column = Column(Float(asdecimal=True)) 

1767 

1768 analysis = relationship("Analysis", primaryjoin="SimpleFeature.analysis_id == Analysis.analysis_id") 

1769 seq_region = relationship( 

1770 "SeqRegion", 

1771 primaryjoin="SimpleFeature.seq_region_id == SeqRegion.seq_region_id", 

1772 ) 

1773 

1774 

1775class AssociatedXref(Base): 

1776 __tablename__ = "associated_xref" 

1777 __table_args__ = ( 

1778 Index( 

1779 "object_associated_source_type_idx", 

1780 "object_xref_id", 

1781 "xref_id", 

1782 "source_xref_id", 

1783 "condition_type", 

1784 "associated_group_id", 

1785 unique=True, 

1786 ), 

1787 ) 

1788 

1789 associated_xref_id: Column = Column(INTEGER(10), primary_key=True) 

1790 object_xref_id: Column = Column( 

1791 ForeignKey("object_xref.object_xref_id"), 

1792 nullable=False, 

1793 index=True, 

1794 server_default=text("'0'"), 

1795 ) 

1796 xref_id: Column = Column( 

1797 ForeignKey("xref.xref_id"), 

1798 nullable=False, 

1799 index=True, 

1800 server_default=text("'0'"), 

1801 ) 

1802 source_xref_id: Column = Column(INTEGER(10), index=True) 

1803 condition_type: Column = Column(String(128)) 

1804 associated_group_id: Column = Column( 

1805 ForeignKey("associated_group.associated_group_id"), 

1806 index=True, 

1807 ) 

1808 rank: Column = Column(INTEGER(10), server_default=text("'0'")) 

1809 

1810 associated_group = relationship( 

1811 "AssociatedGroup", 

1812 primaryjoin="AssociatedXref.associated_group_id == AssociatedGroup.associated_group_id", 

1813 ) 

1814 object_xref = relationship( 

1815 "ObjectXref", 

1816 primaryjoin="AssociatedXref.object_xref_id == ObjectXref.object_xref_id", 

1817 ) 

1818 xref = relationship("Xref", primaryjoin="AssociatedXref.xref_id == Xref.xref_id") 

1819 

1820 

1821class ExonTranscript(Base): 

1822 __tablename__ = "exon_transcript" 

1823 

1824 exon_id: Column = Column( 

1825 ForeignKey("exon.exon_id"), 

1826 primary_key=True, 

1827 nullable=False, 

1828 index=True, 

1829 ) 

1830 transcript_id: Column = Column( 

1831 ForeignKey("transcript.transcript_id"), 

1832 primary_key=True, 

1833 nullable=False, 

1834 index=True, 

1835 ) 

1836 rank: Column = Column(INTEGER(10), primary_key=True, nullable=False) 

1837 

1838 exon = relationship("Exon", primaryjoin="ExonTranscript.exon_id == Exon.exon_id") 

1839 transcript = relationship( 

1840 "Transcript", 

1841 primaryjoin="ExonTranscript.transcript_id == Transcript.transcript_id", 

1842 ) 

1843 

1844 

1845class MiscAttrib(Base): 

1846 __tablename__ = "misc_attrib" 

1847 __table_args__ = ( 

1848 Index("misc_attrib_type_val_idx", "attrib_type_id", "value", mysql_length={"value": 10}), 

1849 Index( 

1850 "misc_attribx", 

1851 "misc_feature_id", 

1852 "attrib_type_id", 

1853 "value", 

1854 unique=True, 

1855 mysql_length={"value": 10}, 

1856 ), 

1857 Index("misc_attrib_value_idx", "value", mysql_length=10), 

1858 ) 

1859 

1860 misc_feature_id: Column = Column( 

1861 INTEGER(10), 

1862 ForeignKey("misc_feature.misc_feature_id"), 

1863 nullable=False, 

1864 index=True, 

1865 server_default=text("'0'"), 

1866 primary_key=True, 

1867 ) 

1868 attrib_type_id: Column = Column( 

1869 SMALLINT(5), 

1870 ForeignKey("attrib_type.attrib_type_id"), 

1871 nullable=False, 

1872 server_default=text("'0'"), 

1873 primary_key=True, 

1874 ) 

1875 value: Column = Column(String(500), nullable=False, primary_key=True) 

1876 

1877 

1878class OntologyXref(Base): 

1879 __tablename__ = "ontology_xref" 

1880 __table_args__ = ( 

1881 Index( 

1882 "object_source_type_idx", 

1883 "object_xref_id", 

1884 "source_xref_id", 

1885 "linkage_type", 

1886 unique=True, 

1887 ), 

1888 ) 

1889 

1890 object_xref_id: Column = Column( 

1891 INTEGER(10), 

1892 ForeignKey("object_xref.object_xref_id"), 

1893 primary_key=True, 

1894 nullable=False, 

1895 index=True, 

1896 server_default=text("'0'"), 

1897 ) 

1898 source_xref_id: Column = Column( 

1899 INTEGER(10), 

1900 ForeignKey("xref.xref_id"), 

1901 primary_key=True, 

1902 index=True, 

1903 ) 

1904 linkage_type: Column = Column(String(3), primary_key=True) 

1905 

1906 

1907class OperonTranscript(Base): 

1908 __tablename__ = "operon_transcript" 

1909 __table_args__ = ( 

1910 Index("operon_transcript_stable_id_idx", "stable_id", "version"), 

1911 Index("operon_transcript_seq_region_idx", "seq_region_id", "seq_region_start"), 

1912 ) 

1913 

1914 operon_transcript_id: Column = Column(INTEGER(10), primary_key=True) 

1915 seq_region_id: Column = Column( 

1916 ForeignKey("seq_region.seq_region_id"), 

1917 nullable=False, 

1918 ) 

1919 seq_region_start: Column = Column(INTEGER(10), nullable=False) 

1920 seq_region_end: Column = Column(INTEGER(10), nullable=False) 

1921 seq_region_strand: Column = Column(TINYINT(2), nullable=False) 

1922 operon_id: Column = Column( 

1923 ForeignKey("operon.operon_id"), 

1924 nullable=False, 

1925 index=True, 

1926 ) 

1927 display_label: Column = Column(String(255)) 

1928 analysis_id: Column = Column( 

1929 ForeignKey("analysis.analysis_id"), 

1930 nullable=False, 

1931 index=True, 

1932 ) 

1933 stable_id: Column = Column(String(128)) 

1934 version: Column = Column(SMALLINT(5)) 

1935 created_date: Column = Column(DateTime) 

1936 modified_date: Column = Column(DateTime) 

1937 

1938 analysis = relationship("Analysis", primaryjoin="OperonTranscript.analysis_id == Analysis.analysis_id") 

1939 operon = relationship("Operon", primaryjoin="OperonTranscript.operon_id == Operon.operon_id") 

1940 seq_region = relationship( 

1941 "SeqRegion", 

1942 primaryjoin="OperonTranscript.seq_region_id == SeqRegion.seq_region_id", 

1943 ) 

1944 

1945 

1946class PredictionExon(Base): 

1947 __tablename__ = "prediction_exon" 

1948 __table_args__ = (Index("prediction_exon_seq_region_idx", "seq_region_id", "seq_region_start"),) 

1949 

1950 prediction_exon_id: Column = Column(INTEGER(10), primary_key=True) 

1951 prediction_transcript_id: Column = Column( 

1952 ForeignKey("prediction_transcript.prediction_transcript_id"), 

1953 nullable=False, 

1954 index=True, 

1955 ) 

1956 exon_rank: Column = Column(SMALLINT(5), nullable=False) 

1957 seq_region_id: Column = Column( 

1958 ForeignKey("seq_region.seq_region_id"), 

1959 nullable=False, 

1960 ) 

1961 seq_region_start: Column = Column(INTEGER(10), nullable=False) 

1962 seq_region_end: Column = Column(INTEGER(10), nullable=False) 

1963 seq_region_strand: Column = Column(TINYINT(4), nullable=False) 

1964 start_phase: Column = Column(TINYINT(4), nullable=False) 

1965 score: Column = Column(Float(asdecimal=True)) 

1966 p_value: Column = Column(Float(asdecimal=True)) 

1967 

1968 prediction_transcript = relationship( 

1969 "PredictionTranscript", 

1970 primaryjoin=( 

1971 "PredictionExon.prediction_transcript_id ==" "PredictionTranscript.prediction_transcript_id" 

1972 ), 

1973 ) 

1974 seq_region = relationship( 

1975 "SeqRegion", 

1976 primaryjoin="PredictionExon.seq_region_id == SeqRegion.seq_region_id", 

1977 ) 

1978 

1979 

1980class SupportingFeature(Base): 

1981 __tablename__ = "supporting_feature" 

1982 __table_args__ = ( 

1983 Index("supporting_feature_all_idx", "exon_id", "feature_type", "feature_id", unique=True), 

1984 Index("supporting_feature_idx", "feature_type", "feature_id"), 

1985 ) 

1986 

1987 exon_id: Column = Column( 

1988 INTEGER(10), 

1989 ForeignKey("exon.exon_id"), 

1990 primary_key=True, 

1991 nullable=False, 

1992 server_default=text("'0'"), 

1993 ) 

1994 feature_type: Column = Column(Enum("dna_align_feature", "protein_align_feature"), primary_key=True) 

1995 feature_id: Column = Column(INTEGER(10), primary_key=True, nullable=False, server_default=text("'0'")) 

1996 

1997 

1998t_operon_transcript_gene = Table( 

1999 "operon_transcript_gene", 

2000 metadata, 

2001 Column( 

2002 "operon_transcript_id", 

2003 ForeignKey("operon_transcript.operon_transcript_id"), 

2004 ), 

2005 Column("gene_id", ForeignKey("gene.gene_id"), index=True), 

2006 Index("operon_transcript_gene_idx", "operon_transcript_id", "gene_id"), 

2007) 

2008 

2009 

2010@compiles(SET, "sqlite") 

2011def compile_set_sqlite( 

2012 type_: sqlalchemy.sql.expression.ColumnClause, # pylint: disable=unused-argument 

2013 compiler: sqlalchemy.engine.interfaces.Compiled, # pylint: disable=unused-argument 

2014 **kw: Any, # pylint: disable=unused-argument 

2015) -> str: 

2016 """Cast MySQL SET to SQLite TEXT.""" 

2017 return "TEXT" 

2018 

2019 

2020@compiles(TINYTEXT, "sqlite") 

2021def compile_tinytext_sqlite( 

2022 type_: sqlalchemy.sql.expression.ColumnClause, # pylint: disable=unused-argument 

2023 compiler: sqlalchemy.engine.interfaces.Compiled, # pylint: disable=unused-argument 

2024 **kw: Any, # pylint: disable=unused-argument 

2025) -> str: 

2026 """Cast MySQL TINYTEXT to SQLite TEXT.""" 

2027 return "TEXT" 

2028 

2029 

2030@compiles(MEDIUMTEXT, "sqlite") 

2031def compile_mediumtext_sqlite( 

2032 type_: sqlalchemy.sql.expression.ColumnClause, # pylint: disable=unused-argument 

2033 compiler: sqlalchemy.engine.interfaces.Compiled, # pylint: disable=unused-argument 

2034 **kw: Any, # pylint: disable=unused-argument 

2035) -> str: 

2036 """Cast MySQL MEDIUMTEXT to SQLite TEXT.""" 

2037 return "TEXT" 

2038 

2039 

2040@compiles(LONGTEXT, "sqlite") 

2041def compile_longtext_sqlite( 

2042 type_: sqlalchemy.sql.expression.ColumnClause, # pylint: disable=unused-argument 

2043 compiler: sqlalchemy.engine.interfaces.Compiled, # pylint: disable=unused-argument 

2044 **kw: Any, # pylint: disable=unused-argument 

2045) -> str: 

2046 """Cast MySQL LONGTEXT to SQLite TEXT.""" 

2047 return "TEXT" 

2048 

2049 

2050@compiles(TINYINT, "sqlite") 

2051def compile_tinyint_sqlite( 

2052 type_: sqlalchemy.sql.expression.ColumnClause, # pylint: disable=unused-argument 

2053 compiler: sqlalchemy.engine.interfaces.Compiled, # pylint: disable=unused-argument 

2054 **kw: Any, # pylint: disable=unused-argument 

2055) -> str: 

2056 """Cast MySQL TINYINT to SQLite INT.""" 

2057 return "INT" 

2058 

2059 

2060@compiles(DOUBLE, "sqlite") 

2061def compile_double_sqlite( 

2062 type_: sqlalchemy.sql.expression.ColumnClause, # pylint: disable=unused-argument 

2063 compiler: sqlalchemy.engine.interfaces.Compiled, # pylint: disable=unused-argument 

2064 **kw: Any, # pylint: disable=unused-argument 

2065) -> str: 

2066 """Cast MySQL DOUBLE to SQLite NUMBER.""" 

2067 return "NUMBER"