Class RawDataBatcher

  • All Implemented Interfaces:
    AutoCloseable, AccessControlled, Batcher

    public class RawDataBatcher
    extends BasicBatcher<RawData>
    Batcher class for raw data. A single instance can be used for raw data belonging to a single RawBioAssay. If the raw bioassay is connected to an array design with features the raw data is verified against the features before it is inserted as follows:
    • Find the feature located at the same coordinates as given by the row, column and block or row, column, metaGridX and metaGridY. A block number of zero signals that meta coordinates should be used. All other values use block coordinates.
    • If a feature isn't found, an ItemNotFoundException is thrown
    • If you have specified to verify the external reporter id by using the insert(RawData, String, String) method the external reporter id of the feature is checked against the supplied reporter id. If they don't match an InvalidDataException is thrown.
    • Finally, the position and reporter is copied from the feature to the raw data. Note that any reporter you have set on the raw data yourself is overwritten and never used.

    Note that if the raw bioassay isn't connected to an array design no checks are made and none of the above apply. The major difference is that you must alsways set a reporter youself in this case. We recommend that you use the insert(RawData) method if no array design is connected, and the insert(RawData, String, String) method otherwise.

    Version:
    2.0
    Author:
    Nicklas
    Last modified
    $Date: 2017-05-22 14:35:27 +0200 (må, 22 maj 2017) $
    • Field Detail

      • logSql

        private static final org.slf4j.Logger logSql
        Log all SQL statements.
      • debugSqlEnabled

        private static final boolean debugSqlEnabled
        So we don't always have to call logSql.debug()
      • rawBioAssay

        private final RawBioAssay rawBioAssay
        The raw bioassay this batcher adds raw data to.
      • rawBioAssayData

        private final RawBioAssayData rawBioAssayData
        Just a copy of the data object for the raw bioassay.
      • rawDataType

        private final RawDataType rawDataType
        The type of raw data to batch.
      • arrayDesign

        private final ArrayDesignData arrayDesign
        The array design the raw bioassay is connected to, if any.
      • caseInsensitive

        private final boolean caseInsensitive
        If case should be ignored when comparing strings (external ID)
      • currentPosition

        private int currentPosition
        Keeps track of the position number unless the raw bioassay is connected to an array design with features.
      • bytes

        private long bytes
        The number of bytes the spot data is occupying on disk. This value is calculated by the validate method for each spot and added to the raw bioassay by the close method.
      • findReporter

        private org.hibernate.query.Query<ReporterData> findReporter
        A query to find reporters by the external id.
      • usedFeatures

        private Set<Object> usedFeatures
        Keep track of the used features to make sure that no more than raw data spot references the same feature.
      • useNullIfReporterNotFound

        private boolean useNullIfReporterNotFound
        If we should use the null reporter if a reporter isn't found.
      • numReportersNotFound

        private int numReportersNotFound
        The number of reporters that was not found.
      • skipInsertIfMissingFeature

        private boolean skipInsertIfMissingFeature
        If inserts that can't find a matching feature should be skipped or generate an error.
      • numSkippedMissingFeature

        private int numSkippedMissingFeature
        The number of skipped inserts due to missing feature
      • acceptInsertIfNullReporterOnFeature

        private boolean acceptInsertIfNullReporterOnFeature
        If we should always accept inserts when the feature has a NULL reporter.
      • numAcceptedWithNullReporterOnFeature

        private int numAcceptedWithNullReporterOnFeature
        The number of accepted inserts were the feature had a NULL reporter
    • Method Detail

      • getType

        public Item getType()
        Description copied from class: BasicBatcher
        Get the type of item supported by the batcher. The returned value is one of the values defined in the Item enumeration.
        Specified by:
        getType in class BasicBatcher<RawData>
        Returns:
        A value indicating the type of item
        See Also:
        Item
      • delete

        public void delete​(int id)
                    throws BaseException
        Always throws a PermissionDeniedException, since raw data cannot be modifed once it has been created, except if all spots are deleted at the same time.
        Overrides:
        delete in class BasicBatcher<RawData>
        Parameters:
        id - Id of the object to be deleted
        Throws:
        PermissionDeniedException - If the logged in user doesn't have delete permission
        BaseException - If there is another error
        See Also:
        deleteAll()
      • initPermissions

        void initPermissions​(int granted,
                             int denied)
                      throws BaseException
        Grant read permission if the logged in user has read permission to the raw bioassay. Grant write, delete and create permission if the logged in user has write permission to the raw bioassay.
        Overrides:
        initPermissions in class BasicBatcher<RawData>
        Parameters:
        granted - Permissions that have been granted by the subclass
        denied - Permissions that have been denied by the subclass
        Throws:
        BaseException - If the permissions couldn't be initialised
      • useNullIfReporterNotFound

        public void useNullIfReporterNotFound​(boolean useNull)
        Specify if the insert method should use a null reporter if a reporter with the given external ID isn't found. This setting only affects raw bioassays that are not connected to an array design.
        Parameters:
        useNull - TRUE if the insert should use a null reporter (default), FALSE otherwise
        See Also:
        skipInsertIfMissingFeature(boolean)
      • skipInsertIfMissingFeature

        public void skipInsertIfMissingFeature​(boolean skip)
        Specify if the insert method should skip the insert if a feature for the spot can't be found. This setting only affects raw bioassays that are connected to an array design.
        Parameters:
        skip - TRUE if the insert should be skipped, FALSE to throw an ItemNotFoundException (default)
        Since:
        2.7
        See Also:
        useNullIfReporterNotFound(boolean)
      • getNumSkippedMissingFeature

        public int getNumSkippedMissingFeature()
        Get the number of skipped inserts because of a missing feature.
        Since:
        2.7
        See Also:
        skipInsertIfMissingFeature(boolean)
      • acceptInsertIfNullReporterOnFeature

        public void acceptInsertIfNullReporterOnFeature​(boolean accept)
        Specify if inserts always should be accepted if there is a matching feature that has a NULL reporter. This settings only affects raw bioassays that are connected to an array design.

        NOTE! The inserted data will also reference the NULL reporter.

        Parameters:
        accept - TRUE to always accept the insert, FALSE to throw an ItemNotFoundException if the insert doesn't specify a NULL reporter (default)
        Since:
        2.7
      • getNumAcceptedWithNullReporterOnFeature

        public int getNumAcceptedWithNullReporterOnFeature()
        Get the number of accepted inserts because of features with a NULL reporter.
        Since:
        2.7
        See Also:
        acceptInsertIfNullReporterOnFeature(boolean)
      • getRawBioAssay

        public RawBioAssay getRawBioAssay()
        Get the raw bioassay this batcher is used for.
      • insert

        public void insert​(RawData data,
                           String externalReporterId,
                           String externalFeatureId)
        Insert a raw data spot and verify the external id of the reporter. The external id is only verified if it is not null and the raw bioassay is connected to an array design with features. The external id is verified to match the external id of the reporter attached to feature of the spot's position. If the raw bioassay isn't connected to an array design, the batcher will automatically try to load the reporter with the given external ID. If you use this method you don't have the set the reporter with the RawData.setReporter(ReporterData) method.

        The externalFeatureId is only needed if the FeatureIdentificationMethod.FEATURE_ID identification method is used. The other methods will use properties on the RawData object (postion or the coordinates) to find the feature. Feature identification is of course needed when the raw bioassay is connected to an array design but is also used when there is no array design to validate that duplicate spots are not inserted.

        Parameters:
        data - The raw data to insert
        externalReporterId - The external id of the reporter expected to be found at the feature of this spot, or null to use the reporter attached to the feature
        externalFeatureId - The feature ID of the feature if the FeatureIdentificationMethod.FEATURE_ID identification method is used
        Throws:
        BaseException - If the insertion failed
        Since:
        2.6
      • preloadFeatures

        private void preloadFeatures()