Example #1
0
 def dehydrate(self, bundle):
     _filter = ( 
         lambda field_information: 
             ( not bundle.obj.is_restricted 
                 or field_information.is_unrestricted ) )
     bundle.data = get_detail_bundle(bundle.obj, ['smallmolecule',''], _filter=_filter)
     
     smbs = SmallMoleculeBatch.objects.filter(smallmolecule=bundle.obj)
     bundle.data['batches'] = []
     for smb in smbs:
         bundle.data['batches'].append(
             get_detail_bundle(smb, ['smallmoleculebatch',''], _filter=_filter))
     return bundle
Example #2
0
    def dehydrate(self, bundle):
        def _filter(field_information):
            return (not bundle.obj.is_restricted 
                    or field_information.is_unrestricted )

        bundle.data = get_detail_bundle(bundle.obj, ['cell',''], _filter=_filter)

        batches = ( CellBatch.objects.filter(reagent=bundle.obj)
            .exclude(batch_id=0) )
        bundle.data['batches'] = []
        for batch in batches:
            bundle.data['batches'].append(
                get_detail_bundle(batch, ['cellbatch',''], _filter=_filter))
        return bundle
Example #3
0
    def dehydrate(self, bundle):
        
        def _filter(field_information):
            return (not bundle.obj.is_restricted 
                    or field_information.is_unrestricted )

        bundle.data = get_detail_bundle(bundle.obj, ['smallmolecule',''], _filter=_filter)

        smbs = ( SmallMoleculeBatch.objects.filter(reagent=bundle.obj)
            .exclude(batch_id=0) )
        bundle.data['batches'] = []
        for smb in smbs:
            bundle.data['batches'].append(
                get_detail_bundle(smb, ['smallmoleculebatch',''], _filter=_filter))
        return bundle
Example #4
0
    def dehydrate(self, bundle):
        _facility_id =str(bundle.data['facility_id'])
        dataset_id = bundle.data['id']
        
        datasetDataColumns = DataSetDataResource.get_datasetdata_camel_case_columns(dataset_id)
        bundle.data = get_detail_bundle(
            bundle.obj, ['dataset',''],
            _override_filter=lambda x: x.show_in_detail or x.field=='bioassay' )
        saf_uri = self.absolute_uri.replace('dataset','datasetdata')
        saf_uri = saf_uri.replace('json','csv');

        datacolumns = list( DataColumn.objects.all().filter(dataset_id=dataset_id) )
        # TODO: drive the columns to show here from fieldinformation inputs
        dc_fieldinformation = FieldInformation.objects.all().filter(table='datacolumn', show_in_detail=True)
        dc_field_names = [fi.get_camel_case_dwg_name() for fi in dc_fieldinformation]
        datapoints = [ dict(zip(dc_field_names, [ getattr(x,fi.field) for fi in dc_fieldinformation ] )) for x in datacolumns ]

        # Custom fields for SAF: TODO: generate the names here from the fieldinformation
        bundle.data['datapointFile'] = {'uri': saf_uri,
                                       'noCols':len(datasetDataColumns),
                                       'cols':datasetDataColumns,
                                       'noDatapoints': len(datapoints),
                                       'datapoints': datapoints
                                       }
        
        bundle.data['safVersion'] = '0.1'  # TODO: drive this from data
        bundle.data['screeningFacility'] = 'HMS' #TODO: drive this from data
        return bundle
Example #5
0
    def dehydrate(self, bundle):
        def _filter(field_information):
            return (not bundle.obj.is_restricted 
                    or field_information.is_unrestricted )

        bundle.data = get_detail_bundle(
            bundle.obj, ['primarycell',''], _filter=_filter,
            extra_properties=self._meta.extra_properties)
        
        batches = ( 
            PrimaryCellBatch.objects.filter(reagent=bundle.obj)
                .exclude(batch_id=0).order_by('batch_id') )
        bundle.data['batches'] = []
        for batch in batches:
            bundle.data['batches'].append(
                get_detail_bundle(
                    batch, ['primarycellbatch',''], _filter=_filter))
        return bundle
Example #6
0
 def dehydrate(self, bundle):
     # TODO: the following call executes the query *just* to get the column names
     _facility_id =str(bundle.data['facility_id'])
     visibleColumns = get_visible_columns(views.DataSetManager(bundle.obj).get_table())
     bundle.data = get_detail_bundle(bundle.obj, ['dataset',''])
     # TODO: this is a kludge to deal with issue #103 db: api: URI for datasetdata is incorrect
     bundle.data['endpointFile'] = {'uri':'http://lincs.hms.harvard.edu/db/api/v1/datasetdata/'+ _facility_id + "/?format=csv",
                                    'noCols':len(visibleColumns),
                                    'cols':visibleColumns.values()
                                    }
     return bundle
Example #7
0
 def dehydrate(self, bundle):
     # TODO: the following call executes the query *just* to get the column names
     _facility_id =str(bundle.data['facility_id'])
     visibleColumns = get_visible_columns(views.DataSetManager(bundle.obj).get_table())
     bundle.data = get_detail_bundle(bundle.obj, ['dataset',''])
     saf_uri = self.absolute_uri.replace('dataset','datasetdata')
     saf_uri = saf_uri.replace('json','csv');
     bundle.data['datapointFile'] = {'uri': saf_uri,
                                    'noCols':len(visibleColumns),
                                    'cols':visibleColumns.values()
                                    }
     return bundle
Example #8
0
    def dehydrate(self, bundle):
        
        dataset_id = bundle.data['id']

        bundle.data = get_detail_bundle(
            bundle.obj, ['dataset',''],
            _override_filter=lambda x: x.show_in_detail or x.field=='bioassay')
        
        if bundle.obj.datarecord_set.exists():
            datapointFileSchema = DataSetDataResource2.generate_schema(dataset_id)
            _uri = self.get_resource_uri(bundle)
            saf_uri = _uri.replace('dataset','datasetdata')
            saf_uri = saf_uri + '?format=csv'
            datapointFileSchema['uri'] = bundle.request.build_absolute_uri(saf_uri)
            bundle.data['datapointFile'] = datapointFileSchema
            bundle.data['safVersion'] = '0.1'  
        
        if bundle.obj.dataset_data_url:
            bundle.data['data_url'] = bundle.obj.dataset_data_url
        
        bundle.data['screeningFacility'] = 'HMS' 

        bundle.data['reagents_studied'] = {
            'antibodies': [
                x.facility_batch for x in 
                    bundle.obj.antibodies.all().order_by(
                        'reagent__facility_id', 'batch_id')],
            'cells': [
                x.facility_batch for x in 
                    bundle.obj.cells.all().order_by(
                        'reagent__facility_id', 'batch_id')],
            'other_reagents': [
                x.facility_batch for x in 
                    bundle.obj.other_reagents.all().order_by(
                        'reagent__facility_id', 'batch_id')],
            'primary_cells': [
                x.facility_batch for x in 
                    bundle.obj.primary_cells.all().order_by(
                        'reagent__facility_id', 'batch_id')],
            'proteins': [
                x.facility_batch for x in 
                    bundle.obj.proteins.all().order_by(
                        'reagent__facility_id', 'batch_id')],
            'small_molecules': [
                x.facility_salt_batch for x in 
                    bundle.obj.small_molecules.all().order_by(
                        'reagent__facility_id', 'reagent__salt_id', 'batch_id')]
        }
        
        
        return bundle
Example #9
0
    def dehydrate(self, bundle):
        
        dataset_id = bundle.data['id']

        bundle.data = get_detail_bundle(
            bundle.obj, ['dataset',''],
            _override_filter=lambda x: x.show_in_detail or x.field=='bioassay')
        
        datapointFileSchema = DataSetDataResource2.generate_schema(dataset_id)
        _uri = self.get_resource_uri(bundle)
        saf_uri = _uri.replace('dataset','datasetdata')
        saf_uri = saf_uri + '?format=csv'
        datapointFileSchema['uri'] = bundle.request.build_absolute_uri(saf_uri)
        
        bundle.data['datapointFile'] = datapointFileSchema
        bundle.data['safVersion'] = '0.1'  
        bundle.data['screeningFacility'] = 'HMS' 
        return bundle
Example #10
0
 def dehydrate(self, bundle):
     bundle.data = get_detail_bundle(bundle.obj, ['library',''])
     return bundle
Example #11
0
 def dehydrate(self, bundle):
     bundle.data = get_detail_bundle(bundle.obj, ['library',''])
     return bundle
Example #12
0
 def dehydrate(self, bundle):
     bundle.data = get_detail_bundle(bundle.obj, ['protein',''])
     return bundle
Example #13
0
 def dehydrate(self, bundle):
     bundle.data = get_detail_bundle(bundle.obj, ['otherreagent',''])
     return bundle
Example #14
0
 def dehydrate(self, bundle):
     bundle.data = get_detail_bundle(bundle.obj, ['antibody',''])
     return bundle
Example #15
0
 def dehydrate(self, bundle):
     bundle.data = get_detail_bundle(bundle.obj, ['smallmolecule',''])
     return bundle