class TrackRecChildAssoc(db.Model): __tablename__ = "wts_trackrec_child" tr_key = db.Column(db.Integer, db.ForeignKey("wts_trackrec.key"), primary_key=True) child_tr_key = db.Column(db.Integer, db.ForeignKey("wts_trackrec.key"), primary_key=True)
class TRAreaAssoc(db.Model): __tablename__ = "wts_tr_area" tr_key = db.Column(db.Integer, db.ForeignKey("wts_trackrec.key"), index=True, primary_key=True) area_key = db.Column(db.Integer, db.ForeignKey("cv_wts_area.key"), index=True, primary_key=True)
class TRRequestedUserAssoc(db.Model): __tablename__ = "wts_tr_request_user" tr_key = db.Column(db.Integer, db.ForeignKey("wts_trackrec.key"), index=True, primary_key=True) user_key = db.Column(db.Integer, db.ForeignKey("cv_user.key"), index=True, primary_key=True)
class TRTypeAssoc(db.Model): __tablename__ = "wts_tr_type" tr_key = db.Column(db.Integer, db.ForeignKey("wts_trackrec.key"), index=True, primary_key=True) type_key = db.Column(db.Integer, db.ForeignKey("cv_wts_type.key"), index=True, primary_key=True)
class StatusHistory(db.Model): __tablename__ = "wts_status_history" key = db.Column(db.Integer, primary_key=True) tr_key = db.Column(db.Integer, db.ForeignKey("wts_trackrec.key"), index=True) status_key = db.Column(db.Integer, db.ForeignKey("cv_wts_status.key"), index=True) user_key = db.Column(db.Integer, db.ForeignKey("cv_user.key"), index=True) set_date = db.Column(db.DateTime())
class TrackRec(db.Model): __tablename__ = "wts_trackrec" key = db.Column(db.Integer, primary_key=True) priority_key = db.Column(db.Integer, db.ForeignKey("cv_wts_priority.key")) size_key = db.Column(db.Integer, db.ForeignKey("cv_wts_size.key"), index=True) status_key = db.Column(db.Integer, db.ForeignKey("cv_wts_status.key"), index=True) status_user_key = db.Column(db.Integer, db.ForeignKey("cv_user.key"), index=True) status_set_date = db.Column(db.DateTime()) locked_user_key = db.Column(db.Integer, db.ForeignKey("cv_user.key"), index=True) locked_date = db.Column(db.DateTime()) title = db.Column(db.String()) has_directory = db.Column(db.Boolean) attention_by = db.Column(db.DateTime()) creation_date = db.Column(db.DateTime(), default=db.func.now()) modification_date = db.Column(db.DateTime(), default=db.func.now()) description = db.Column(db.String()) progress_notes = db.Column(db.String()) priority = db.relationship("Priority", uselist=False, backref="trs") size = db.relationship("Size", uselist=False, backref="trs") status = db.relationship("Status", uselist=False, backref="trs") areas = db.relationship("Area", secondary=TRAreaAssoc.__table__, backref="trs") types = db.relationship("Type", secondary=TRTypeAssoc.__table__, backref="trs") assigned_users = db.relationship("User", secondary=TRAssignedUserAssoc.__table__) requested_by = db.relationship("User", secondary=TRRequestedUserAssoc.__table__) statusChanges = db.relationship("StatusHistory") child_trs = db.relationship( "TrackRec", secondary=TrackRecChildAssoc.__table__, primaryjoin="TrackRec.key==TrackRecChildAssoc.tr_key", secondaryjoin="TrackRec.key==TrackRecChildAssoc.child_tr_key", backref=db.backref("parent", uselist=False))
class ProbeNoteChunk(db.Model, MGIModel): __tablename__ = "prb_notes" _probe_key = db.Column(db.Integer, db.ForeignKey("prb_probe._probe_key"), primary_key=True) note = db.Column(db.String()) sequencenum = db.Column(db.Integer, primary_key=True)
class MarkerDetailClipNoteChunk(db.Model, MGIModel): __tablename__ = "mrk_notes" _marker_key = db.Column(db.Integer, db.ForeignKey("mrk_marker._marker_key"), primary_key=True) note = db.Column(db.String()) sequencenum = db.Column(db.Integer, primary_key=True)
class MarkerLocationCache(db.Model, MGIModel): __tablename__ = "mrk_location_cache" _cache_key = db.Column(db.Integer, primary_key=True) _marker_key = db.Column(db.Integer, db.ForeignKey("mrk_marker._marker_key")) _organism_key = db.Column(db.Integer()) chromosome = db.Column(db.String()) cytogeneticoffset = db.Column(db.String()) cmoffset = db.Column(db.Float()) genomicchromosome = db.Column(db.String()) startcoordinate = db.Column(db.Float()) endcoordinate = db.Column(db.Float()) strand = db.Column(db.String()) mapunits = db.Column(db.String()) provider = db.Column(db.String()) version = db.Column(db.String()) @property def providerString(self): if not self.provider: return "" return "From %s annotation of %s" % (self.provider, self.version) def __repr__(self): if not self.startcoordinate or not self.endcoordinate: return "Chr%s" % (self.chromosome) return "Chr%s:%d-%d bp, %s strand" % (self.chromosome, self.startcoordinate, self.endcoordinate, self.strand)
class ReportLabel(db.Model): __tablename__ = "pwi_report_label" __bind_key__ = "mgd" id = db.Column(db.Integer, primary_key=True) report_id = db.Column(db.Integer, db.ForeignKey("pwi_report.id"), index=True) label = db.Column(db.String(), index=True) def __repr__(self): return self.label
def mgi_fk(fkString): fkString = "mgd." + fkString fk = db.ForeignKey(fkString) return fk
class ADStructure(db.Model, MGIModel): __tablename__ = "gxd_structure" _structure_key = db.Column(db.Integer, primary_key=True) _structurename_key = db.Column( db.Integer, mgi_fk("gxd_structurename._structurename_key")) _parent_key = db.Column(db.Integer, db.ForeignKey(_structure_key)) _stage_key = db.Column(db.Integer) printname = db.Column(db.String()) structurenote = db.Column(db.Integer) # constants _mgitype_key = 38 # column properties mgiid = db.column_property( db.select([Accession.accid]).where( db.and_(Accession._mgitype_key == _mgitype_key, Accession.prefixpart == 'MGI:', Accession.preferred == 1, Accession._logicaldb_key == 1, Accession._object_key == _structure_key))) # relationships mgiid_object = db.relationship( "Accession", primaryjoin="and_(Accession._object_key==ADStructure._structure_key," "Accession.prefixpart=='MGI:'," "Accession.preferred==1," "Accession._logicaldb_key==1," "Accession._mgitype_key==%d)" % _mgitype_key, foreign_keys="Accession._object_key", uselist=False) secondaryids = db.relationship( "Accession", primaryjoin="and_(Accession._object_key==ADStructure._structure_key," "Accession._logicaldb_key!=1," "Accession._mgitype_key==%d)" % _mgitype_key, foreign_keys="Accession._object_key", order_by="Accession.accid") # all names, including synonyms names = db.relationship( "ADStructureName", primaryjoin= "ADStructureName._structure_key==ADStructure._structure_key", foreign_keys="[ADStructureName._structure_key]") # results # backref in Result class # only synonyms synonyms = db.relationship( "ADStructureName", primaryjoin= "and_(ADStructureName._structure_key==ADStructure._structure_key," "ADStructureName._structurename_key!=ADStructure._structurename_key)", foreign_keys= "[ADStructureName._structure_key,ADStructureName._structurename_key]", order_by="ADStructureName.structure") children = db.relationship("ADStructure", backref=db.backref("parent", remote_side=_structure_key)) # parent # backref defined above @property def stage(self): return self._stage_key @property def emapsterm(self): term_object = None if self.mgiid_object and self.mgiid_object.emapsids: term_object = self.mgiid_object.emapsids[0].vocterm return term_object # for vocterm compatibility @property def primaryid(self): return self.mgiid @property def term(self): return self.printname @property def display(self): return "TS%s: %s" % (self.stage, self.printname) def __repr__(self): return self.display
class Category(CVMixin, db.Model): __tablename__ = "cv_wts_category" email = db.Column(db.String()) area_key = db.Column(db.Integer, db.ForeignKey("cv_wts_area.key")) type_key = db.Column(db.Integer, db.ForeignKey("cv_wts_type.key")) status_key = db.Column(db.Integer, db.ForeignKey("cv_wts_status.key"))