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 SpeciesMember(Member): relation = 'http://plantscribe.org/relations/species' title = attribute_alias('species_name') species_name = terminal_attribute(str, 'species_name') genus_name = terminal_attribute(str, 'genus_name') cultivar = terminal_attribute(str, 'cultivar') author = terminal_attribute(str, 'author')
class RackSpecsMember(Member): relation = "%s/rack-specs" % RELATION_BASE_URL title = attribute_alias('label') label = terminal_attribute(str, 'label') shape = member_attribute(IRackShape, 'shape') manufacturer = member_attribute(IOrganization, 'manufacturer') has_tubes = terminal_attribute(bool, 'has_tubes')
class BarcodePrintJobMember(Member): relation = "%s/barcode" % RELATION_BASE_URL title = attribute_alias('labels') barcodes = terminal_attribute(str, 'barcodes') labels = terminal_attribute(str, 'labels') printer = terminal_attribute(str, 'printer') type = terminal_attribute(str, 'type')
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 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 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 MyEntityParentMember(Member): relation = 'http://test.org/myentity-parent' # String terminal. text = terminal_attribute(str, 'text') # String terminal with different name in entity. text_rc = terminal_attribute(str, 'text_ent') # text_alias = attribute_alias('text')
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 ContainerSpecsMember(Member): relation = "%s/container-specs" % RELATION_BASE_URL title = attribute_alias('label') label = terminal_attribute(str, 'label') description = terminal_attribute(str, 'description') max_volume = terminal_attribute(float, 'max_volume') dead_volume = terminal_attribute(float, 'dead_volume') manufacturer = member_attribute(IOrganization, 'manufacturer')
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 SpeciesMember(Member): relation = "%s/species" % RELATION_BASE_URL title = attribute_alias('common_name') genus_name = terminal_attribute(str, 'genus_name') species_name = terminal_attribute(str, 'species_name') common_name = terminal_attribute(str, 'common_name') acronym = terminal_attribute(str, 'acronym') ncbi_tax_id = terminal_attribute(int, 'ncbi_tax_id')
class RackShapeMember(Member): relation = "%s/rack-shape" % RELATION_BASE_URL id = terminal_attribute(str, 'id') # rack shape IDs are *strings*. name = terminal_attribute(str, 'name') label = terminal_attribute(str, 'label') number_rows = terminal_attribute(int, 'number_rows') number_columns = terminal_attribute(int, 'number_columns') title = attribute_alias('label')
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 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 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 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 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 ChemicalStructureTypeMember(Member): relation = "%s/chemical-structure-type" % RELATION_BASE_URL name = terminal_attribute(str, 'name') label = terminal_attribute(str, 'label') molecule_types = collection_attribute(IMoleculeType, 'molecule_types') title = attribute_alias('label')
class LocationTypeMember(Member): relation = "%s/location-type" % RELATION_BASE_URL title = attribute_alias('name') name = terminal_attribute(str, 'name')
class ExperimentMetadataTypeMember(Member): relation = '%s/experiment-metadata-type' % RELATION_BASE_URL title = attribute_alias('display_name') display_name = terminal_attribute(str, 'display_name')
class ExperimentMetadataMember(Member): relation = '%s/experiment-metadata' % RELATION_BASE_URL label = terminal_attribute(str, 'label') title = attribute_alias('label') ticket_number = terminal_attribute(int, 'ticket_number') subproject = member_attribute(ISubproject, 'subproject') number_replicates = terminal_attribute(int, 'number_replicates') molecule_design_pool_set = member_attribute(IMoleculeDesignPoolSet, 'molecule_design_pool_set') experiment_design = member_attribute(IExperimentDesign, 'experiment_design') iso_request = member_attribute(ILabIsoRequest, 'lab_iso_request') creation_date = terminal_attribute(datetime, 'creation_date') experiment_metadata_type = member_attribute(IExperimentMetadataType, 'experiment_metadata_type') def __getitem__(self, name): if name == 'tags': tags_dict = {} design_racks = self.__get_design_racks() for rack in design_racks: for tp in rack.rack_layout.tagged_rack_position_sets: for tag in tp.tags: tags_dict[tag.get_entity().slug] = tag tag_coll = get_root_collection(ITag) tag_coll.filter = cntd(id=[tag.id for tag in tags_dict.values()]) result = tag_coll elif name == 'experiment-design-racks': result = self.__get_design_racks() else: result = Member.__getitem__(self, name) return result @classmethod def create_from_entity(cls, entity): if entity.ticket_number is None: # Create a new ticket and attach the ticket number. user = get_current_user() ticket_creator = \ IsoRequestTicketCreator(requester=user, experiment_metadata=entity) entity.ticket_number = \ cls.__run_trac_tool(ticket_creator, 'Could not update the ticket: %s.') return cls(entity) def update(self, data): if IDataElement.providedBy(data): # pylint: disable=E1101 # FIXME: This really should be a PATCH operation. prx = DataElementAttributeProxy(data) self_entity = self.get_entity() changed_num_reps = prx.number_replicates != self.number_replicates emt_id = prx.experiment_metadata_type.get('id') changed_em_type = emt_id != self.experiment_metadata_type.id if changed_em_type or changed_num_reps: if changed_num_reps: self_entity.number_replicates = prx.number_replicates if changed_em_type: self_entity.experiment_metadata_type = \ get_experiment_metadata_type(emt_id) if not self_entity.experiment_design is None: # invalidate data to force a fresh upload of the XLS file self_entity.experiment_design.experiment_design_racks = [] self_entity.experiment_design.worklist_series = None if not self_entity.lab_iso_request is None: shape = self_entity.lab_iso_request.rack_layout.shape new_layout = RackLayout(shape=shape) self_entity.lab_iso_request.rack_layout = new_layout self_entity.lab_iso_request.owner = '' changed_sp = self_entity.subproject.id != prx.subproject.get('id') if changed_sp: new_sp = \ url_to_resource(prx.subproject.get('href')).get_entity() self_entity.subproject = new_sp self_entity.label = prx.label # Perform appropriate Trac updates. if not self_entity.lab_iso_request is None: if self.iso_request.owner == STOCKMANAGEMENT_USER: ticket_activator = IsoRequestTicketActivator( experiment_metadata=self_entity) self.__run_trac_tool(ticket_activator, 'Could not update the ticket: %s.') else: if changed_em_type or changed_num_reps: trac_updater = IsoRequestTicketDescriptionRemover( experiment_metadata=self_entity, changed_num_replicates=changed_num_reps, changed_em_type=changed_em_type) else: url = 'http://thelma/public//LOUICe.html#' \ + self.path iso_url = 'http://thelma/public//LOUICe.html#' \ + self.iso_request.path trac_updater = IsoRequestTicketDescriptionUpdater( experiment_metadata=self_entity, experiment_metadata_link=url, iso_request_link=iso_url) self.__run_trac_tool(trac_updater, 'Could not update the ticket: %s.') else: Member.update(self, data) @classmethod def __run_trac_tool(cls, tool, error_msg_text): tool.run() if not tool.transaction_completed(): exc_msg = str(tool.get_messages(logging_level=logging.ERROR)) raise HTTPBadRequest(error_msg_text % exc_msg).exception return tool.return_value def __get_design_racks(self): if self.experiment_design is not None: design_racks = self.experiment_design.experiment_design_racks else: # order only type design_racks = [] return design_racks
class CustomerMember(Member): relation = 'http://plantscribe.org/relations/customer' title = attribute_alias('last_name') first_name = terminal_attribute(str, 'first_name') last_name = terminal_attribute(str, 'last_name') projects = collection_attribute(IProject, backref='customer')
class OrganizationMember(Member): relation = "%s/organization" % RELATION_BASE_URL title = attribute_alias('name') name = terminal_attribute(str, 'name')
class ItemStatusMember(Member): id = terminal_attribute(str, 'id') # IDs are strings for item status relation = "%s/item-status" % RELATION_BASE_URL title = attribute_alias('name') name = terminal_attribute(str, 'name') description = terminal_attribute(str, 'description')
class RackPositionMember(Member): relation = "%s/rack-position" % RELATION_BASE_URL label = terminal_attribute(str, 'label') row_index = terminal_attribute(int, 'row_index') column_index = terminal_attribute(int, 'column_index') title = attribute_alias('label')
class ProjectMember(Member): relation = 'http://plantscribe.org/relations/project' title = attribute_alias('name') name = terminal_attribute(str, 'name') customer = member_attribute(ICustomer, 'customer') sites = collection_attribute(ISite, backref='project', is_nested=True)
class UserPreferencesMember(Member): relation = "%s/user-preferences" % RELATION_BASE_URL title = attribute_alias('app_name') label = attribute_alias('app_name') app_name = terminal_attribute(str, 'app_name') preferences = terminal_attribute(str, 'preferences')