コード例 #1
0
def create_mapper(rack_specs_tbl):
    "Mapper factory."
    rs = rack_specs_tbl
    polymorphic_select = select([
        rs,
        (case([(rs.c.has_movable_subitems,
                literal(RACK_SPECS_TYPES.TUBE_RACK_SPECS))],
              else_=literal(
                  RACK_SPECS_TYPES.PLATE_SPECS))).label('rackspecs_type')
    ], ).alias('rackspecs')
    m = mapper(
        RackSpecs,
        polymorphic_select,
        id_attribute='rack_specs_id',
        slug_expression=lambda cls: as_slug_expression(cls.name),
        properties=dict(
            manufacturer=relationship(Organization),
            shape=relationship(RackShape,
                               uselist=False,
                               back_populates='specs'),
            rack_specs_type=column_property(
                polymorphic_select.c.rackspecs_type),
        ),
        polymorphic_on=polymorphic_select.c.rackspecs_type,
        polymorphic_identity=RACK_SPECS_TYPES.RACK_SPECS,
    )
    RackSpecs.has_tubes = synonym('has_movable_subitems')
    return m
コード例 #2
0
ファイル: rackspecs.py プロジェクト: helixyte/TheLMA
def create_mapper(rack_specs_tbl):
    "Mapper factory."
    rs = rack_specs_tbl
    polymorphic_select = select([
        rs,
        (case([(rs.c.has_movable_subitems,
                literal(RACK_SPECS_TYPES.TUBE_RACK_SPECS))],
              else_=literal(RACK_SPECS_TYPES.PLATE_SPECS))).label(
                                                            'rackspecs_type')
        ],
        ).alias('rackspecs')
    m = mapper(RackSpecs, polymorphic_select,
            id_attribute='rack_specs_id',
            slug_expression=lambda cls: as_slug_expression(cls.name),
            properties=dict(
                manufacturer=relationship(Organization),
                shape=relationship(RackShape, uselist=False,
                                   back_populates='specs'),
                rack_specs_type=
                        column_property(polymorphic_select.c.rackspecs_type),
                ),
            polymorphic_on=polymorphic_select.c.rackspecs_type,
            polymorphic_identity=RACK_SPECS_TYPES.RACK_SPECS,
            )
    RackSpecs.has_tubes = synonym('has_movable_subitems')
    return m
コード例 #3
0
ファイル: rackshape.py プロジェクト: helixyte/TheLMA
def create_mapper(rack_shape_tbl):
    "Mapper factory."
    m = mapper(RackShape, rack_shape_tbl,
        id_attribute='rack_shape_name',
        slug_expression=lambda cls: as_slug_expression(cls.rack_shape_name),
        properties=dict(
            specs=relationship(RackSpecs, back_populates='shape'),
            ),
        )
    RackShape.name = synonym('rack_shape_name')
    return m
コード例 #4
0
def create_mapper(rack_shape_tbl):
    "Mapper factory."
    m = mapper(
        RackShape,
        rack_shape_tbl,
        id_attribute='rack_shape_name',
        slug_expression=lambda cls: as_slug_expression(cls.rack_shape_name),
        properties=dict(specs=relationship(RackSpecs,
                                           back_populates='shape'), ),
    )
    RackShape.name = synonym('rack_shape_name')
    return m
コード例 #5
0
ファイル: gene.py プロジェクト: papagr/TheLMA
def create_mapper(refseq_gene_tbl, molecule_design_gene_tbl,
                  molecule_design_set_gene_tbl,
                  molecule_design_tbl,
                  molecule_design_pool_tbl):
    "Mapper factory."
    rsg = refseq_gene_tbl
    mdg = molecule_design_gene_tbl
    mdsg = molecule_design_set_gene_tbl
    md = molecule_design_tbl
    mdp = molecule_design_pool_tbl
    m = mapper(Gene, rsg,
        id_attribute='gene_id',
        slug_expression=lambda cls: as_slug_expression(cls.accession),
        properties=dict(
            accession=column_property(
                rsg.c.accession,
                comparator_factory=CaseInsensitiveComparator
                ),
            locus_name=column_property(
                rsg.c.locus_name,
                comparator_factory=CaseInsensitiveComparator
                ),
            molecule_designs=
                relationship(
                    MoleculeDesign, viewonly=True,
                    secondary=mdg,
                    primaryjoin=(mdg.c.gene_id == rsg.c.gene_id),
                    secondaryjoin=(md.c.molecule_design_id ==
                                            mdg.c.molecule_design_id),
                    foreign_keys=(mdg.c.molecule_design_id,
                                  mdg.c.gene_id),
                    back_populates='genes',
                    ),
            molecule_design_pools=
                relationship(
                    MoleculeDesignPool, viewonly=True,
                    secondary=mdsg,
                    primaryjoin=(mdsg.c.gene_id == rsg.c.gene_id),
                    secondaryjoin=(mdsg.c.molecule_design_set_id ==
                                            mdp.c.molecule_design_set_id),
                    foreign_keys=(mdsg.c.molecule_design_set_id,
                                  mdsg.c.gene_id),
                    ),
            species=relationship(Species, uselist=False,
                                 back_populates='genes',
#                                 lazy='joined'
                                 ),
            ),
        )
    Gene.name = synonym('locus_name')
    return m