class SourceChannel(NamedModel, db.Model): __tablename__ = 'sourcechannel' volume_id = db.Column(db.Integer, db.ForeignKey('volume.id')) source_url = db.Column(db.String(250), nullable=False) default_channel = db.Column(db.Boolean, nullable=False, default=False) type = db.Column(db.String(32), default='image') __mapper_args__ = { 'polymorphic_on': 'type', 'polymorphic_identity': '' }
class Link(NamedModel, db.Model): __tablename__ = 'link' type = db.Column(db.String(32)) link = db.Column(db.String(10000)) __mapper_args__ = { 'polymorphic_on': 'type', 'polymorphic_identity': 'link' } def get_link_html(self): return '<a href="{}">{}</a>'.format(self.link, self.name)
class Rating(TimestampMixin, db.Model): __tablename__ = "rating" type = db.Column(db.String(32)) object_id = db.Column( db.Integer, db.ForeignKey('bioobject.id'), nullable=False, ) rating_source_id = db.Column( db.Integer, db.ForeignKey('ratingsource.id'), nullable=False, ) classificationtype_id = db.Column(db.Integer, db.ForeignKey('classificationtype.id'), nullable=False) confidence = db.Column(db.Float) classificationtype = db.relationship('ClassificationType') rating_source = db.relationship('RatingSource') object = db.relationship('BioObject') bool_rating = db.Column(db.Boolean) tert_rating = db.Column(db.Integer) def get_rating(self): '''generic function, need to implement for class''' pass __mapper_args__ = { 'polymorphic_identity': 'rating', 'polymorphic_on': 'type', }
class RatingSource(NamedModel, db.Model): __tablename__ = "ratingsource" type = db.Column(db.String(32)) __mapper_args__ = { 'polymorphic_identity': 'ratingsource', 'polymorphic_on': 'type', }
class Synapse(BioObject): __tablename__ = None # Add table name to be None __mapper_args__ = {'polymorphic_identity': 'synapse'} oid = db.Column(db.String(50)) areas = db.Column( Geometry(geometry_type="MULTIPOLYGONZ", management=True, use_typmod=False, srid=SYNAPSE_SRID, dimension=3))
class BioObject(db.Model): __tablename__ = "bioobject" # Add table name to be None __mapper_args__ = { 'polymorphic_identity': 'bioobject', 'polymorphic_on': 'type', } object_collection_id = db.Column(db.Integer, db.ForeignKey('bioobjectcollection.id')) collection = db.relationship(BioObjectCollection) type = db.Column(db.String(32))
class BioObjectCollection(NamedModel, db.Model): __tablename__ = 'bioobjectcollection' volume_id = db.Column(db.Integer, db.ForeignKey('volume.id')) volume = db.relationship('Volume') link_id = db.Column(db.Integer, db.ForeignKey('link.id')) link = db.relationship('Link') objects = db.relationship('BioObject') type = db.Column(db.String(32)) __mapper_args__ = { 'polymorphic_on': 'type', 'polymorphic_identity': 'employee' }
class NamedModel(object): name = db.Column(db.String(100), nullable=False) def __repr__(self): return "{}({})".format(self.name, self.id)
class SynapseCollection(BioObjectCollection): __tablename__ = None # Add table name to be None __mapper_args__ = {'polymorphic_identity': 'synapsecollection'} synapse_collection_type = db.Column(db.String(100))
class ImageChannel(SourceChannel): __tablename__ = None default_color = db.Column(db.String(1)) __mapper_args__ = { 'polymorphic_identity': 'image' }
class DataSet(NamedModel, db.Model): render_project = db.Column(db.String(50)) render_owner = db.Column(db.String(50)) volumes = db.relationship('Volume', backref='data_set')
class ClassificationType(NamedModel, db.Model): __tablename__ = "classificationtype" rating_type = db.Column(db.String(40))
class MachineLearningSource(RatingSource): algorithm = db.Column(db.String(100)) __tablename__ = None __mapper_args__ = { 'polymorphic_identity': 'machinelearning', }