def _getDataSetsForExperiment(self):
        """
        Return a list of datasets belonging to the experiment and optionally
        to the sample. If the sample ID is empty, only the experiment is used
        in the search criteria.
        If none are found, return [].

        """

        # Set search criteria to retrieve all datasets for the experiment.
        # If the sample code is set, we also filter by it.
        searchCriteria = SearchCriteria()
        searchCriteria.addMatchClause(MatchClause.createAttributeMatch(MatchClauseAttribute.TYPE, "MICROSCOPY_IMG_CONTAINER"))
        expCriteria = SearchCriteria()
        expCriteria.addMatchClause(MatchClause.createAttributeMatch(MatchClauseAttribute.PERM_ID, self._experiment.permId))
        searchCriteria.addSubCriteria(SearchSubCriteria.createExperimentCriteria(expCriteria))
        if self._sample is not None:
            self._logger.info("Filter by sample " + self._sampleId)
            sampleCriteria = SearchCriteria()
            sampleCriteria.addMatchClause(MatchClause.createAttributeMatch(MatchClauseAttribute.PERM_ID, self._sample.permId))
            searchCriteria.addSubCriteria(SearchSubCriteria.createSampleCriteria(sampleCriteria))

        dataSets = searchService.searchForDataSets(searchCriteria)

        if len(dataSets) == 0:
            dataSets = []
            self._message = "Could not retrieve datasets for experiment " \
            "with id " + self._experimentId
            if self._sampleId != "":
                self._message = self._message + " and sample with id " + \
                self._sampleId
            self._logger.error(self._message)

        # Return
        return dataSets
コード例 #2
0
def _getDataSetsForSample(sampleIdentifier, dataSetType):
    """Return the dataSet of given type for specified sample."""

    # Set search criteria to retrieve the dataSet associated with the sample
    searchCriteria = SearchCriteria()
    searchCriteria.addMatchClause(
        MatchClause.createAttributeMatch(
            MatchClauseAttribute.TYPE,
            dataSetType)
        )

    sampleCriteria = SearchCriteria()
    sampleCriteria.addMatchClause(
        MatchClause.createAttributeMatch(
            MatchClauseAttribute.CODE,
            sampleIdentifier)
        )

    searchCriteria.addSubCriteria(
        SearchSubCriteria.createSampleCriteria(
            sampleCriteria)
        )
    dataSetList = searchService.searchForDataSets(searchCriteria)

    if len(dataSetList) != 1:
        []

    # Return the dataSet
    return dataSetList
コード例 #3
0
    def _getDataSetForTube(self, tubeCode=None):
        """
        Get the datasets belonging to the tube with specified tube code.
        If none is found, return [].

        If no tubeCode is given, it is assumed that the tube is the passed
        entity with code self._entityCode.
        """

        if tubeCode is None:
            tubeCode = self._entityCode

        # Set search criteria to retrieve the dataset contained in the tube
        searchCriteria = SearchCriteria()
        tubeCriteria = SearchCriteria()
        tubeCriteria.addMatchClause(MatchClause.createAttributeMatch(MatchClauseAttribute.CODE, tubeCode))
        searchCriteria.addSubCriteria(SearchSubCriteria.createSampleCriteria(tubeCriteria))
        dataSets = searchService.searchForDataSets(searchCriteria)

        if len(dataSets) == 0:
            self._message = "Could not retrieve datasets for tube " \
            "with code " + tubeCode + "."
            self._logger.error(self._message)

        # Return
        return dataSets
コード例 #4
0
    def _getDataSetForWell(self, wellId=None):
        """
        Get the datasets belonging to the well with specified code. If none
        are found, return [].

        If no wellId is given, it is assumed that the well is the passed
        entity with code self._entityId.
        """

        if wellId is None:
            wellId = self._entityId

        # Set search criteria to retrieve the dataset contained in the well
        searchCriteria = SearchCriteria()
        wellCriteria = SearchCriteria()
        wellCriteria.addMatchClause(
            MatchClause.createAttributeMatch(MatchClauseAttribute.CODE,
                                             wellId))
        searchCriteria.addSubCriteria(
            SearchSubCriteria.createSampleCriteria(wellCriteria))
        dataSets = searchService.searchForDataSets(searchCriteria)

        if len(dataSets) == 0:
            self._message = "Could not retrieve datasets for well " \
            "with code " + wellId + "."
            self._logger.error(self._message)

        # Return
        return dataSets
コード例 #5
0
    def _getDataSetForTube(self, tubeCode):
        """
        Get the datasets belonging to the tube with specified tube code.
        If none is found, return [].
        """

        if _DEBUG:
            self._logger.info("Searching for tube with code " + tubeCode)

        # Set search criteria to retrieve the dataset contained in the tube
        searchCriteria = SearchCriteria()
        tubeCriteria = SearchCriteria()
        tubeCriteria.addMatchClause(
            MatchClause.createAttributeMatch(MatchClauseAttribute.CODE,
                                             tubeCode))
        searchCriteria.addSubCriteria(
            SearchSubCriteria.createSampleCriteria(tubeCriteria))
        dataSets = searchService.searchForDataSets(searchCriteria)

        if _DEBUG:
            self._logger.info("Retrieved " + str(len(dataSets)) + \
                              " datasets for tube with code " + tubeCode)

        if len(dataSets) == 0:
            self._message = "Could not retrieve datasets for tube " \
            "with code " + tubeCode + "."
            self._logger.error(self._message)

        # Return
        return dataSets
    def _getDataSetsForExperiment(self):
        """
        Return a list of datasets belonging to the experiment and optionally
        to the sample. If the sample ID is empty, only the experiment is used
        in the search criteria.
        If none are found, return [].

        """

        # Set search criteria to retrieve all datasets of type MICROSCOPY_IMG_CONTAINER
        # for the experiment. If the sample code is set, we also filter by it.
        searchCriteria = SearchCriteria()
        searchCriteria.addMatchClause(MatchClause.createAttributeMatch(MatchClauseAttribute.TYPE, "MICROSCOPY_IMG_CONTAINER"))
        expCriteria = SearchCriteria()
        expCriteria.addMatchClause(MatchClause.createAttributeMatch(MatchClauseAttribute.PERM_ID, self._experiment.permId))
        searchCriteria.addSubCriteria(SearchSubCriteria.createExperimentCriteria(expCriteria))
        if self._sample is not None:
            self._logger.info("Filter by sample " + self._sampleId)
            sampleCriteria = SearchCriteria()
            sampleCriteria.addMatchClause(MatchClause.createAttributeMatch(MatchClauseAttribute.PERM_ID, self._sample.permId))
            searchCriteria.addSubCriteria(SearchSubCriteria.createSampleCriteria(sampleCriteria))

        dataSets = searchService.searchForDataSets(searchCriteria)

        if len(dataSets) == 0:
            dataSets = []
            self._message = "Could not retrieve datasets for experiment " \
            "with id " + self._experimentId
            if self._sampleId != "":
                self._message = self._message + " and sample with id " + \
                self._sampleId
            self._logger.error(self._message)

        # Return
        return dataSets
コード例 #7
0
    def _getDataSetForWell(self, wellCode=None):
        """
        Get the datasets belonging to the well with specified code. If none
        are found, return [].

        If no wellCode is given, it is assumed that the well is the passed
        entity with code self._entityCode.
        """

        if wellCode is None:
            wellCode = self._entityCode

        # Set search criteria to retrieve the dataset contained in the well
        searchCriteria = SearchCriteria()
        wellCriteria = SearchCriteria()
        wellCriteria.addMatchClause(MatchClause.createAttributeMatch(MatchClauseAttribute.CODE, wellCode))
        searchCriteria.addSubCriteria(SearchSubCriteria.createSampleCriteria(wellCriteria))
        dataSets = searchService.searchForDataSets(searchCriteria)

        if len(dataSets) == 0:
            self._message = "Could not retrieve datasets for well " \
            "with code " + wellCode + "."

        # Return
        return dataSets
コード例 #8
0
def _getDataSetsForSample(sampleIdentifier, dataSetType):
    """Return the dataSet of given type for specified sample."""

    # Set search criteria to retrieve the dataSet associated with the sample
    searchCriteria = SearchCriteria()
    searchCriteria.addMatchClause(
        MatchClause.createAttributeMatch(MatchClauseAttribute.TYPE,
                                         dataSetType))

    sampleCriteria = SearchCriteria()
    sampleCriteria.addMatchClause(
        MatchClause.createAttributeMatch(MatchClauseAttribute.CODE,
                                         sampleIdentifier))

    searchCriteria.addSubCriteria(
        SearchSubCriteria.createSampleCriteria(sampleCriteria))
    dataSetList = searchService.searchForDataSets(searchCriteria)

    if len(dataSetList) != 1:
        []

    # Return the dataSet
    return dataSetList
    def _getAccessoryDataSetsForExperiment(self):
        """
        Return a list of datasets belonging to the experiment and optionally
        to the sample. If the sample ID is empty, only the experiment is used
        in the search criteria.
        If none are found, return [].

        """

        # Set search criteria to retrieve all datasets of type for the experiment.
        # If the sample code is set, we also filter by it.
        searchCriteria = SearchCriteria()
        searchCriteria.addMatchClause(MatchClause.createAttributeMatch(MatchClauseAttribute.TYPE, "MICROSCOPY_ACCESSORY_FILE"))
        expCriteria = SearchCriteria()
        expCriteria.addMatchClause(MatchClause.createAttributeMatch(MatchClauseAttribute.PERM_ID, self._experiment.permId))
        searchCriteria.addSubCriteria(SearchSubCriteria.createExperimentCriteria(expCriteria))
        if self._sample is not None:
            self._logger.info("Filter by sample " + self._sampleId)
            sampleCriteria = SearchCriteria()
            sampleCriteria.addMatchClause(MatchClause.createAttributeMatch(MatchClauseAttribute.PERM_ID, self._sample.permId))
            searchCriteria.addSubCriteria(SearchSubCriteria.createSampleCriteria(sampleCriteria))

        accessoryDataSets = searchService.searchForDataSets(searchCriteria)

        # Append the accessory datasets
        if len(accessoryDataSets) != 0:
            self._message = "Found " + str(len(accessoryDataSets)) + \
                            " accessory datasets for experiment " \
                            "with id " + self._experimentId
            if self._sampleId != "":
                self._message = self._message + " and sample with id " + \
                self._sampleId
            self._logger.info(self._message)

        # Return
        return accessoryDataSets
コード例 #10
0
    def _getDataSets(self, expSampleType, expSamplePermId, sampleType, samplePermId,
                     requestedDatasetType="MICROSCOPY_IMG_CONTAINER"):
        """
        Return a list of datasets of requested type belonging to the MICROSCOPY_EXPERIMENT sample 
        and a specific sample of type MICROSCOPY_SAMPLE_TYPE.
        If none are found, return [].
        """

        # Only two types of experiment are allowed
        assert requestedDatasetType == "MICROSCOPY_IMG_CONTAINER" or requestedDatasetType == "MICROSCOPY_ACCESSORY_FILE", \
            "Input argument 'requestedDatasetType' must be one of MICROSCOPY_IMG_CONTAINER or MICROSCOPY_ACCESSORY_FILE."

        self._logger.info("_getDataSetsForMicroscopySampleType() called " +
                          "with requested data type " + requestedDatasetType)

        if _DEBUG:
            self._logger.info("* Requested dataset type: " + requestedDatasetType)
            self._logger.info("* Requested experiment sample type: " + expSampleType)
            self._logger.info("* Requested experiment sample permId: " + expSamplePermId)
            self._logger.info("* Requested sample type: " + sampleType)
            self._logger.info("* Requested sample permId: " + samplePermId)

        # Dataset criteria
        datasetSearchCriteria = SearchCriteria()
        datasetSearchCriteria.addMatchClause(
            MatchClause.createAttributeMatch(
                MatchClauseAttribute.TYPE,
                requestedDatasetType)
            )

        # Add search criteria for sample of type MICROSCOPY_EXPERIMENT with specified CODE
        sampleExpCriteria = SearchCriteria()
        sampleExpCriteria.addMatchClause(
            MatchClause.createAttributeMatch(
                MatchClauseAttribute.TYPE,
                expSampleType))
        sampleExpCriteria.addMatchClause(
            MatchClause.createAttributeMatch(
                MatchClauseAttribute.PERM_ID,
                expSamplePermId)
            )

        # Add search criteria for sample of type MICROSCOPY_SAMPLE_TYPE with specified CODE
        sampleCriteria = SearchCriteria()
        sampleCriteria.addMatchClause(
            MatchClause.createAttributeMatch(
                MatchClauseAttribute.TYPE,
                sampleType)
            )
        sampleCriteria.addMatchClause(
             MatchClause.createAttributeMatch(
                MatchClauseAttribute.PERM_ID,
                samplePermId)
             )
        sampleCriteria.addSubCriteria(
            SearchSubCriteria.createSampleParentCriteria(
                sampleExpCriteria)
            )

        # Add search for a parent sample of type MICROSCOPY_SAMPLE_TYPE as subcriterion
        datasetSearchCriteria.addSubCriteria(
            SearchSubCriteria.createSampleCriteria(sampleCriteria)
            )

        # Retrieve the datasets
        dataSets = searchService.searchForDataSets(datasetSearchCriteria)

        # Inform
        self._logger.info("Retrieved " + str(len(dataSets)) +
                          " dataSets of type " + requestedDatasetType + ".")

        # Return
        return dataSets
    def _getDataSets(self, expSampleType, expSamplePermId, sampleType, samplePermId,
                     requestedDatasetType="MICROSCOPY_IMG_CONTAINER"):
        """
        Return a list of datasets of requested type belonging to the MICROSCOPY_EXPERIMENT sample 
        and a specific sample of type MICROSCOPY_SAMPLE_TYPE.
        If none are found, return [].
        """

        # Only two types of experiment are allowed
        assert requestedDatasetType == "MICROSCOPY_IMG_CONTAINER" or requestedDatasetType == "MICROSCOPY_ACCESSORY_FILE", \
            "Input argument 'requestedDatasetType' must be one of MICROSCOPY_IMG_CONTAINER or MICROSCOPY_ACCESSORY_FILE."

        self._logger.info("_getDataSetsForMicroscopySampleType() called " +
                          "with requested data type " + requestedDatasetType)

        if _DEBUG:
            self._logger.info("* Requested dataset type: " + requestedDatasetType)
            self._logger.info("* Requested experiment sample type: " + expSampleType)
            self._logger.info("* Requested experiment sample permId: " + expSamplePermId)
            self._logger.info("* Requested sample type: " + sampleType)
            self._logger.info("* Requested sample permId: " + samplePermId)

        # Dataset criteria
        datasetSearchCriteria = SearchCriteria()
        datasetSearchCriteria.addMatchClause(
            MatchClause.createAttributeMatch(
                MatchClauseAttribute.TYPE,
                requestedDatasetType)
            )

        # Add search criteria for sample of type MICROSCOPY_EXPERIMENT with specified CODE
        sampleExpCriteria = SearchCriteria()
        sampleExpCriteria.addMatchClause(
            MatchClause.createAttributeMatch(
                MatchClauseAttribute.TYPE,
                expSampleType))
        sampleExpCriteria.addMatchClause(
            MatchClause.createAttributeMatch(
                MatchClauseAttribute.PERM_ID,
                expSamplePermId)
            )

        # Add search criteria for sample of type MICROSCOPY_SAMPLE_TYPE with specified CODE
        sampleCriteria = SearchCriteria()
        sampleCriteria.addMatchClause(
            MatchClause.createAttributeMatch(
                MatchClauseAttribute.TYPE,
                sampleType)
            )
        sampleCriteria.addMatchClause(
             MatchClause.createAttributeMatch(
                MatchClauseAttribute.PERM_ID,
                samplePermId)
             )
        sampleCriteria.addSubCriteria(
            SearchSubCriteria.createSampleParentCriteria(
                sampleExpCriteria)
            )

        # Add search for a parent sample of type MICROSCOPY_SAMPLE_TYPE as subcriterion
        datasetSearchCriteria.addSubCriteria(
            SearchSubCriteria.createSampleCriteria(sampleCriteria)
            )

        # Retrieve the datasets
        dataSets = searchService.searchForDataSets(datasetSearchCriteria)

        # Inform
        self._logger.info("Retrieved " + str(len(dataSets)) +
                          " dataSets of type " + requestedDatasetType + ".")

        # Return
        return dataSets