Class UrlTemplates

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

public class UrlTemplates extends Object
Expands the named placeholders used in the configurable density-server URL templates.

The recognised placeholders are:

{pdbid}
the PDB identifier as given
{pdbid_lc}
the PDB identifier in lower case
{pdbid_uc}
the PDB identifier in upper case
{mid}
the two-character divided-archive directory, e.g. cb for 1cbs
{extid}
the extended identifier in lower case, the spelling the archive itself uses, e.g. pdb_00001cbs for 1cbs
{emdb_id}
the EMDB identifier, e.g. EMD-0262
{emdb_num}
the EMDB number alone, e.g. 0262
{detail}
the density-server detail level
A placeholder with no supplied value is left in place rather than replaced by an empty string, so that a misconfigured template produces an obviously wrong URL instead of a subtly wrong one.

{mid} and {extid} exist for mirrors rather than for the default URLs. The services BioJava fetches from resolve an entry by name alone, but a site pointing this code at its own copy of the archive has to spell out a directory path — and so does any mirror that publishes one, such as EBI. Both the present divided layout and the per-entry layout that replaces it in July 2027 are directory paths, and between them the two placeholders express either without a code change:

 {mid}/{pdbid_lc}/{pdbid_lc}_validation_2fo-fc_map_coef.cif.gz
 entries/{mid}/{extid}/validation_reports/{extid}_validation_2fo-fc_map_coef.cif.gz
 

This is deliberately separate from the template mechanism in DownloadChemCompProvider, which resolves a single chemical-component identifier with optional substring indices. The two solve different problems: here several distinct values are substituted by name.

Since:
7.3.0
Author:
Amr ALHOSSARY
  • Method Details

    • expand

      public static String expand(String template, Map<String,String> values)
      Expands a template against a set of named values.
      Parameters:
      template - the template string
      values - the values, keyed by placeholder name without the braces
      Returns:
      the expanded string
    • values

      public static Map<String,String> values(String pdbId, String emdbId, int detail)
      Builds the standard value map for an entry.
      Parameters:
      pdbId - the PDB identifier, may be null
      emdbId - the EMDB identifier in any accepted form, may be null
      detail - the density-server detail level, or a negative value to omit it
      Returns:
      a map suitable for expand(String, Map)