Class BaseFileInfo

java.lang.Object
net.sf.basedb.util.importer.spotdata.BaseFileInfo

public class BaseFileInfo
extends Object
Collects information about a BASEfile as it gets parsed by a BaseFileImporter. Information in one section is often needed when parsing other sections or after the parsing has been completed.
Version:
2.14
Author:
Nicklas
Last modified
$Date: 2011-08-11 11:09:06 +0200 (to, 11 aug 2011) $
  • Field Details

    • file

      private final FileWrapper file
    • assaysHaveParentAssaysMapping

      private boolean assaysHaveParentAssaysMapping
    • childAssays

      private Map<Integer,​BaseFileInfo.ChildBioAssay> childAssays
    • parentHasNullReporter

      private boolean parentHasNullReporter
    • parentHasZeroReporter

      private boolean parentHasZeroReporter
    • parentReporterPositions

      private Map<Integer,​Integer> parentReporterPositions
    • parentChildColumnMapping

      private Map<Short,​List<Short>> parentChildColumnMapping
    • spotSectionInfo

      private Map<Integer,​BaseFileInfo.SpotSectionInfo> spotSectionInfo
    • extraFloats

      private Map<String,​ExtraValueType> extraFloats
    • childHasDifferentReporterPositionMapping

      private boolean childHasDifferentReporterPositionMapping
    • childReporterPositions

      private Map<Integer,​Integer> childReporterPositions
  • Constructor Details

    • BaseFileInfo

      public BaseFileInfo​(FileWrapper file)
      The source file which should be a BASEfile.
      Since:
      2.16
  • Method Details

    • getName

      public String getName()
      Get the name of the file.
    • getCharacterSet

      public String getCharacterSet()
      Get the character set used by the file, or null if not known.
    • getSize

      public long getSize()
      Get the file size.
    • setAssaysHaveParentAssaysMapping

      public void setAssaysHaveParentAssaysMapping​(boolean haveMapping)
      Set a flag that indicates if the BASEfile includes a mapping from child to parent assays.
    • getAssaysHaveParentAssaysMapping

      public boolean getAssaysHaveParentAssaysMapping()
      A flag that indicates if the BASEfile includes a mapping from child to parent assays.
    • addChildAssay

      public boolean addChildAssay​(BaseFileInfo.ChildBioAssay child)
      Add information about a child assay.
      Parameters:
      child - Information about the child assay
      Returns:
      TRUE if the child was added, FALSE if a child with the same ID already exists
    • getChildAssays

      public Collection<BaseFileInfo.ChildBioAssay> getChildAssays()
      Get information about all child bioassays referenced in the file.
    • getChildAssay

      public BaseFileInfo.ChildBioAssay getChildAssay​(int id)
      Get the child bioassay with the given id (from the BASEfile).
      Parameters:
      id - The ID in the BASEfile
      Returns:
      A ChildBioAssay or null
    • checkBioAssay

      public void checkBioAssay​(DbControl dc, int id, int line)
      Checks that the bioassay with the given id exists in the database. If not, an exception is thrown.
      Parameters:
      dc - The DbControl to use
      id - The id of the bioassay
      line - The current line
      Throws:
      ItemNotFoundException - If the bioassay doesn't exists in the database
    • setParentHasNullReporter

      public void setParentHasNullReporter​(boolean parentHasNullReporter)
      Set a flag indicating that at least one position in the parent bioassay set has a null reporter.
      Parameters:
      parentHasNullReporter - TRUE if there is a position with a null reporter, FALSE otherwise
      See Also:
      loadParentReporterPositions(DbControl, BioAssaySet)
    • getParentHasNullReporter

      public boolean getParentHasNullReporter()
      A flag that indicates if at least one position in the parent bioassay set has a null reporter or not. We need to know this because some BASE 1 plug-ins convert a null reporter to 0 and in most cases it is safe to convert it back, but only if the parent had a null reporter but not a '0' reporter to begin with.
      See Also:
      getParentHasZeroReporter()
    • setParentHasZeroReporter

      public void setParentHasZeroReporter​(boolean parentHasZeroReporter)
      Set a flag indicating that at least one position in the parent bioassay set has a reporter with ID=0.
    • getParentHasZeroReporter

      public boolean getParentHasZeroReporter()
      A flag that indicates if at least one position in the parent bioassay set has a reporter with ID=0.
      See Also:
      getParentHasNullReporter()
    • loadParentReporterPositions

      public void loadParentReporterPositions​(DbControl dc, BioAssaySet parent)
      Load position/reporter mapping from the parent bioassay set. This will also set the getParentHasNullReporter()/getParentHasZeroReporter() flags.
      Parameters:
      dc - A DbControl to use
      parent - The parent bioassay set
    • setChildHasDifferentReporterPositionMapping

      public void setChildHasDifferentReporterPositionMapping​(boolean flag)
      Set a flag that indicates if the child data has a different position/reporter mapping than the parent bioassay set.
      See Also:
      addChildReporter(Integer, Integer)
    • getChildHasDifferentReporterPositionMapping

      public boolean getChildHasDifferentReporterPositionMapping()
      A flag that indicates if the child data has a different position/reporter mapping than the parent bioassay set.
    • addChildReporter

      public Integer addChildReporter​(Integer position, Integer reporterId)
      Add a child position/reporter mapping from the parsed BASEfile. The added mapping will be checked against the parent position/reporter mapping and the getChildHasDifferentReporterPositionMapping() flag is set if the mapping has changed.

      If a mapping for the given position already exists, a check is made if the mapping is identical or different. If the mapping is different the reporter id of the already existing mapping is returned. It is up to the called to take any appropriate action in this case (usually; throw an exception). If the mapping doesn't exist or if the mapping is identical the 'reporterId' value is returned. Thus, it is easy to check for success by simply comparing:

                      
      if (reporterId != addChildReporter(position, reporterId))
      {
         // ... throw exception
      }
      
      Parameters:
      position - The position value
      reporterId - The ID of the reporter
      Returns:
      The reporterId (same instance) if the mapping is new or if an identical mapping already exists. The reporer ID of an existing mapping if it is different.
    • getChildReporterPositions

      public Map<Integer,​Integer> getChildReporterPositions()
      Get a map with all added child position/reporter mappings. The key is the position value and the value is the reporter id.
    • mapParentChildColumns

      public void mapParentChildColumns​(short parentColumn, short childColumn)
      Maps a parent data cube column to a child cube column. Note! A parent may map to multiple childs, and a child may have multiple parents.
      Parameters:
      parentColumn - The parent data cube column
      childColumn - The child data cube column
    • getChildColumns

      public List<Short> getChildColumns​(short parentColumn)
      Get all child columns that have been mapped to the specified parent column.
      Returns:
      A list or null if no mapping exists
    • addSpotSectionInfo

      public void addSpotSectionInfo​(int spotSection, BaseFileInfo.SpotSectionInfo info)
      Adds information about a 'spot' section.
      Parameters:
      spotSection - The ordinal number of the spot section as it appears in the BASEfile, starting with 1
      info - The information
    • getSpotSectionInfo

      public BaseFileInfo.SpotSectionInfo getSpotSectionInfo​(int spotSection)
      Get information about a spot section.
      Parameters:
      spotSection - The ordinal number of the spot section as it appears in the BASEfile, starting with 1
    • addExtraFloat

      public ExtraValueType addExtraFloat​(DbControl dc, String extraFloatId)
      Add information about an extra float value that appears in the BASEfile. This method will check if the an ExtraValueType with the given external id exists. If not, a new float-type extra value type is created.
      Parameters:
      dc - A DbControl object to use for database access
      extraFloatId - The external id of an extra value type
    • getExtraFloat

      public ExtraValueType getExtraFloat​(String extraFloatId)
      Get the extra value type that has the given external id. The extra float must have been added with addExtraFloat(DbControl, String) before.
      Parameters:
      extraFloatId - The external id of an extra value type
      Returns:
      The extra value type, or null