class IsoJobMember(JobMember): relation = "%s/iso_job" % RELATION_BASE_URL isos = collection_attribute(IIso, 'isos') number_stock_racks = terminal_attribute(int, 'number_stock_racks') stock_racks = collection_attribute(IStockRack, 'iso_job_stock_racks') preparation_plates = collection_attribute(IPlate, 'preparation_plates') status = terminal_attribute(str, 'status')
class ExperimentDesignMember(Member): relation = "%s/experiment-design" % RELATION_BASE_URL title = terminal_attribute(str, 'slug') rack_shape = member_attribute(IRackShape, 'rack_shape') experiment_design_racks = collection_attribute(IExperimentDesignRack, 'experiment_design_racks') experiments = collection_attribute(IExperiment, 'experiments') experiment_metadata = member_attribute(IExperimentMetadata, 'experiment_metadata')
class MoleculeDesignPoolMember(MoleculeDesignSetMember): """ """ relation = "%s/molecule-design-pool" % RELATION_BASE_URL molecule_type = member_attribute(IMoleculeType, 'molecule_type') # stock_samples = collection_attribute(IStockSample, 'stock_samples') # member_hash = terminal_attribute(str, 'member_hash') number_designs = terminal_attribute(int, 'number_designs') genes = collection_attribute(IGene, 'genes') supplier_molecule_designs = \ collection_attribute(ISupplierMoleculeDesign, 'supplier_molecule_designs')
class MoleculeDesignMember(Member): relation = "%s/molecule-design" % RELATION_BASE_URL @property def title(self): return str(self.id) molecule_type = member_attribute(IMoleculeType, 'molecule_type') chemical_structures = collection_attribute(IChemicalStructure, 'chemical_structures') genes = collection_attribute(IGene, 'genes', cardinality=CARDINALITIES.MANYTOMANY) supplier_molecule_designs = \ collection_attribute(ISupplierMoleculeDesign, 'supplier_molecule_designs')
class MoleculeTypeMember(Member): relation = "%s/molecule-type" % RELATION_BASE_URL title = attribute_alias('name') name = terminal_attribute(str, 'name') description = terminal_attribute(str, 'description') thaw_time = terminal_attribute(float, 'thaw_time') modifications = collection_attribute(IChemicalStructure, 'modifications')
class ExperimentDesignRackMember(Member): relation = "%s/experiment-design-rack" % RELATION_BASE_URL title = attribute_alias('label') label = terminal_attribute(str, 'label') rack_shape = member_attribute(IRackShape, 'rack_layout.shape') rack_layout = member_attribute(IRackLayout, 'rack_layout') tags = collection_attribute(ITag, 'tags')
class GeneMember(Member): relation = "%s/gene" % RELATION_BASE_URL title = attribute_alias('locus_name') accession = terminal_attribute(str, 'accession') locus_name = terminal_attribute(str, 'locus_name') # nice_name = terminal_attribute('nice_name') species = member_attribute(ISpecies, 'species') molecule_designs = \ collection_attribute(IMoleculeDesign, 'molecule_designs', cardinality=CARDINALITIES.MANYTOMANY) molecule_design_pools = \ collection_attribute(IMoleculeDesignPool, 'molecule_design_pools', cardinality=CARDINALITIES.MANYTOMANY)
class SiteMember(Member): relation = 'http://plantscribe.org/relations/site' title = attribute_alias('name') name = terminal_attribute(str, 'name') incidences = collection_attribute(IIncidence, backref='site', is_nested=True) project = member_attribute(IProject, 'project')
class MoleculeMember(Member): relation = "%s/molecule" % RELATION_BASE_URL molecule_design = member_attribute(IMoleculeDesign, 'molecule_design') molecule_design_id = terminal_attribute(int, 'molecule_design.id') supplier = member_attribute(IOrganization, 'supplier') product_id = terminal_attribute(str, 'supplier_molecule_design.product_id') insert_date = terminal_attribute(datetime, 'insert_date') samples = collection_attribute(ISample, 'samples')
class ProjectMember(Member): relation = "%s/project" % RELATION_BASE_URL title = attribute_alias('label') label = terminal_attribute(str, 'label') creation_date = terminal_attribute(datetime, 'creation_date') leader = member_attribute(IUser, 'leader') customer = member_attribute(IOrganization, 'customer') subprojects = collection_attribute(ISubproject, 'subprojects')
class ChemicalStructureMember(Member): relation = "%s/chemical-structure" % RELATION_BASE_URL molecule_designs = collection_attribute(IMoleculeDesign, 'molecule_designs') structure_type = member_attribute(IChemicalStructureType, 'structure_type') representation = terminal_attribute(str, 'representation') structure_type_id = terminal_attribute(str, 'structure_type_id') title = attribute_alias('representation')
class UserMember(Member): relation = "%s/user" % RELATION_BASE_URL title = attribute_alias('username') label = attribute_alias('username') username = terminal_attribute(str, 'username') user_preferenceses = collection_attribute(IUserPreferences, 'user_preferenceses') directory_user_id = terminal_attribute(str, 'directory_user_id')
class SampleMember(Member): relation = "%s/sample" % RELATION_BASE_URL volume = terminal_attribute(float, 'volume') container = member_attribute(IContainer, 'container') sample_molecules = collection_attribute(ISampleMolecule, 'sample_molecules') molecule_design_pool_id = terminal_attribute(int, 'molecule_design_pool_id')
class MoleculeDesignPoolSetMember(Member): """ """ relation = "%s/molecule-design-pool-set" % RELATION_BASE_URL molecule_type = member_attribute(IMoleculeType, 'molecule_type') molecule_design_pools = collection_attribute(IMoleculeDesignPool, 'molecule_design_pools')
class TubeTransferWorklistMember(Member): relation = '%s/tube-transfer-worklists' % RELATION_BASE_URL user = member_attribute(IUser, 'user') tube_transfers = collection_attribute(ITubeTransfer, 'tube_transfers') @property def title(self): entity = self.get_entity() return str(entity.id)
class LabIsoMember(IsoMember): relation = "%s/lab-iso" % RELATION_BASE_URL iso_request = member_attribute(ILabIsoRequest, 'iso_request') library_plates = collection_attribute(ILibraryPlate, 'library_plates', backref='lab_iso') requested_library_plates = terminal_attribute(str, 'requested_library_plates')
class PlateMember(RackMember): relation = "%s/plate" % RELATION_BASE_URL containers = collection_attribute(IWell, 'containers', backref='rack') def __getitem__(self, name): if name == 'wells': result = self.containers else: result = RackMember.__getitem__(self, name) return result
class DeviceTypeMember(Member): relation = "%s/device-type" % RELATION_BASE_URL title = attribute_alias('label') name = terminal_attribute(str, 'name') label = terminal_attribute(str, 'label') devices = collection_attribute(IDevice, 'devices', backref='type') def update(self, member): super(DeviceTypeMember, self).update(member) self.get_entity().name = member.get_entity().name self.label = member.label
class ContainerMember(Member): relation = "%s/container" % RELATION_BASE_URL specs = member_attribute(IContainerSpecs, 'specs') sample_volume = terminal_attribute(float, 'sample.volume') sample_molecules = collection_attribute(ISampleMolecule, 'sample.sample_molecules', backref='sample.container') status = member_attribute(IItemStatus, 'status') sample_molecule_design_pool_id = \ terminal_attribute(str, 'sample.molecule_design_pool_id')
class IsoRequestMember(Member): relation = "%s/iso-request" % RELATION_BASE_URL iso_type = terminal_attribute(str, 'iso_type') label = terminal_attribute(str, 'label') owner = terminal_attribute(str, 'owner') expected_number_isos = terminal_attribute(int, 'expected_number_isos') number_aliquots = terminal_attribute(int, 'number_aliquots') iso_jobs = collection_attribute(IIsoJob, 'iso_jobs') @property def title(self): return 'Base ISO Request'
class MyEntityChildMember(Member): relation = 'http://test.org/myentity-child' # Member. parent = member_attribute(IMyEntity, 'parent', backref='children') # Collection accessed as entity attribute and represented as # "parent equal to parent member" (backreferencing) specification. children = collection_attribute(IMyEntityGrandchild, entity_attr='children', backref='parent') # String terminal. text = terminal_attribute(str, 'text') # String terminal with different name in entity. text_rc = terminal_attribute(str, 'text_ent')
class TubeRackMember(RackMember): relation = "%s/tube-rack" % RELATION_BASE_URL containers = collection_attribute(ITube, 'tube_locations.container', backref='rack') def __getitem__(self, name): if name == 'tubes': result = self.containers elif name == 'shape': result = self.specs.shape else: result = RackMember.__getitem__(self, name) return result
class IsoMember(Member): relation = "%s/iso" % RELATION_BASE_URL title = attribute_alias('label') iso_type = terminal_attribute(str, 'label') label = terminal_attribute(str, 'label') status = terminal_attribute(str, 'status') rack_layout = member_attribute(IRackLayout, 'rack_layout') iso_job = member_attribute(IIsoJob, 'iso_job') number_stock_racks = terminal_attribute(int, 'number_stock_racks') molecule_design_pool_set = member_attribute(IMoleculeDesignPoolSet, 'molecule_design_pool_set') optimizer_excluded_racks = terminal_attribute(str, 'optimizer_excluded_racks') optimizer_requested_tubes = terminal_attribute( str, 'optimizer_requested_tubes') preparation_plates = collection_attribute(IPlate, 'preparation_plates') aliquot_plates = collection_attribute(IPlate, 'aliquot_plates') stock_racks = collection_attribute(IStockRack, 'stock_racks') def update(self, data): if IDataElement.providedBy(data): # pylint: disable=E1101 raise SyntaxError('Should not get here.') else: Member.update(self, data)
class MoleculeDesignLibraryMember(Member): relation = "%s/molecule-design-library" % RELATION_BASE_URL molecule_design_pool_set = member_attribute(IMoleculeDesignPoolSet, 'molecule_design_pool_set') label = terminal_attribute(str, 'label') final_volume = terminal_attribute(float, 'final_volume') final_concentration = terminal_attribute(float, 'final_concentration') number_layouts = terminal_attribute(int, 'number_layouts') rack_layout = member_attribute(IRackLayout, 'rack_layout') library_plates = collection_attribute(ILibraryPlate, 'library_plates') creation_iso_request = member_attribute(IIsoRequest, 'creation_iso_request') @property def title(self): return self.label
class ExperimentMember(Member): relation = '%s/experiment' % RELATION_BASE_URL title = attribute_alias('label') label = terminal_attribute(str, 'label') source_rack = member_attribute(IRack, 'source_rack') experiment_design = member_attribute(IExperimentDesign, 'experiment_design') experiment_racks = collection_attribute(IExperimentRack, 'experiment_racks') experiment_job = member_attribute(IExperimentJob, 'job') experiment_metadata_type = \ member_attribute(IExperimentMetadataType, 'experiment_design.experiment_metadata.experiment_metadata_type') def get_writer(self): return get_writer(self.get_entity())
class StockInfoMember(Member): relation = "%s/stock-info" % RELATION_BASE_URL title = attribute_alias('id') id = terminal_attribute(str, 'id') # stock info IDs are *strings*. # FIXME: This should be called molecule_design_pool_id in the entity molecule_design_pool_id = terminal_attribute(int, 'molecule_design_set_id') total_tubes = terminal_attribute(int, 'total_tubes') total_volume = terminal_attribute(float, 'total_volume') maximum_volume = terminal_attribute(float, 'maximum_volume') minimum_volume = terminal_attribute(float, 'minimum_volume') concentration = terminal_attribute(float, 'concentration') molecule_type = member_attribute(IMoleculeType, 'molecule_type') molecule_design_pool = member_attribute(IMoleculeDesignPool, 'molecule_design_pool') genes = collection_attribute(IGene, 'genes', cardinality=CARDINALITIES.MANYTOMANY)
class MoleculeDesignSetMember(Member): """ """ relation = "%s/molecule-design-set" % RELATION_BASE_URL @property def title(self): return str(self.id) molecule_designs = collection_attribute(IMoleculeDesign, 'molecule_designs') set_type = terminal_attribute(str, 'set_type') def update(self, data): if IEntity.providedBy(data): # pylint: disable=E1101 self.get_entity().molecule_designs = data.molecule_designs else: Member.update(self, data)
class MyEntityMember(Member): relation = 'http://test.org/myentity' # Member. parent = member_attribute(IMyEntityParent, 'parent') # Nested member (i.e., URL built relative to parent). nested_parent = member_attribute(IMyEntityParent, 'parent', is_nested=True) # Collection. children = collection_attribute(IMyEntityChild, 'children') # String terminal. text = terminal_attribute(str, 'text') # String terminal with different name in entity. text_rc = terminal_attribute(str, 'text_ent') # Number terminal. number = terminal_attribute(int, 'number') # Date time terminal. date_time = terminal_attribute(datetime.datetime, 'date_time') # Nested attribute. parent_text = terminal_attribute(str, 'parent.text_ent')
class MyEntityMember(Member): relation = 'http://test.org/myentity' # Member. parent = member_attribute(IMyEntityParent, 'parent', cardinality=CARDINALITIES.ONETOONE, backref='child') # Collection. children = collection_attribute(IMyEntityChild, 'children', backref='parent') # String terminal. text = terminal_attribute(str, 'text') # String terminal with different name in entity. text_rc = terminal_attribute(str, 'text_ent') # Number terminal. number = terminal_attribute(int, 'number') # Date time terminal. date_time = terminal_attribute(datetime.datetime, 'date_time') # Dotted attribute. parent_text = terminal_attribute(str, 'parent.text_ent')
class RackLayoutMember(Member): relation = '%s/rack-layout' % RELATION_BASE_URL @property def title(self): return str(self.id) shape = member_attribute(IRackShape, 'shape') tagged_rack_position_sets = \ collection_attribute(ITaggedRackPositionSet, 'tagged_rack_position_sets') # @property # def rack(self): # tags = [] # for tp in self.tagged_rack_position_sets: # tags.append(tp) # return tags def __getitem__(self, name): if name == 'tagged-rack-position-sets': return self.tagged_rack_position_sets else: raise KeyError(name)
def test_invalid_descriptors(self): with self.assert_raises(ValueError) as cm: collection_attribute(IMyEntity) exc_msg = 'may be None, but not both.' self.assert_true(cm.exception.message.endswith(exc_msg))