Class DensityMapResult

java.lang.Object
org.biojava.nbio.structure.io.density.DensityMapResult

public class DensityMapResult extends Object
A density map that was successfully obtained, together with everything a caller needs to know in order to use it.

Which source answered matters to the caller and is therefore part of the result: the file might be a full CCP4 grid, a downsampled volume slice, or — if non-renderable formats were allowed — a set of structure factors that must be Fourier-transformed before anything can be drawn. See isRenderable().

Every field is persisted to a .meta sidecar beside the cached file, so a result can be reconstructed later without contacting any server. That is what lets the cache serve LocalPDBDirectory.FetchBehavior.LOCAL_ONLY requests fully offline.

Since:
7.3.0
Author:
Amr ALHOSSARY
  • Field Details

    • META_EXT

      public static final String META_EXT
      Extension of the metadata sidecar written beside every cached map.
      See Also:
  • Constructor Details

    • DensityMapResult

      public DensityMapResult(File file, DensityMapSource source, DensityFileFormat format, DensityMapKind kind, PdbId pdbId, String emdbId, String sourceUrl, boolean fromCache, Double recommendedContourLevel, Double sigma)
      Parameters:
      file - the cached map file
      source - which service supplied it
      format - the file format
      kind - what the values mean; never DensityMapKind.AUTO
      pdbId - the PDB entry, may be null
      emdbId - the EMDB entry, may be null
      sourceUrl - the URL it came from
      fromCache - whether it was already on disk rather than freshly downloaded
      recommendedContourLevel - the author-recommended contour level in absolute map units, or null if unknown
      sigma - the RMS deviation of the map, or null if unknown
  • Method Details

    • getFile

      public File getFile()
      Returns:
      the cached map file
    • getSource

      public DensityMapSource getSource()
      Returns:
      which service supplied the map
    • getFormat

      public DensityFileFormat getFormat()
      Returns:
      the file format
    • getKind

      public DensityMapKind getKind()
      Returns:
      what the map values mean; never DensityMapKind.AUTO
    • getPdbId

      public PdbId getPdbId()
      Returns:
      the PDB entry, or null
    • getEmdbId

      public String getEmdbId()
      Returns:
      the EMDB entry, or null
    • getSourceUrl

      public String getSourceUrl()
      Returns:
      the URL the map was fetched from
    • isFromCache

      public boolean isFromCache()
      Returns:
      true if the file was already cached rather than downloaded now
    • isRenderable

      public boolean isRenderable()
      Whether a viewer can contour this file as it stands.
      Returns:
      false for map coefficients, which need a Fourier transform first
      See Also:
    • getRecommendedContourLevel

      public Double getRecommendedContourLevel()
      The contour level recommended by the depositors, in absolute map units. Normally only available for EMDB maps, where it is the conventional way to contour rather than a multiple of sigma.
      Returns:
      the level, or null if unknown
    • getSigma

      public Double getSigma()
      Returns:
      the RMS deviation of the map values, or null if unknown
    • getContourInSigma

      public Double getContourInSigma()
      The recommended contour expressed in multiples of sigma, for viewers that prefer to work that way.
      Returns:
      the level divided by sigma, or null if either is unknown or sigma is zero
    • getFileSizeBytes

      public long getFileSizeBytes()
      Returns:
      the size of the cached file in bytes, or 0 if it is missing
    • metaFileFor

      public static File metaFileFor(File mapFile)
      The metadata sidecar file for a cached map.
      Parameters:
      mapFile - the cached map
      Returns:
      the sidecar path, which need not exist
    • writeMeta

      public void writeMeta()
      Writes this result's metadata beside the cached file, so that it can be reconstructed later without any network access.
    • readMeta

      public static DensityMapResult readMeta(File mapFile)
      Reconstructs a result from a cached file and its metadata sidecar.
      Parameters:
      mapFile - the cached map
      Returns:
      the reconstructed result, or null if the sidecar is missing or unusable
    • toString

      public String toString()
      Overrides:
      toString in class Object