CGView.js
Examples Tutorials Docs API JSON
  • Index
  • Tutorials

  • Basic Map
  • Sequence Map
  • JSON Map
  • CGViewBuilder
  • Map Controls
  • Details

  • JSON Files
  • Meta & Qualifiers
  • Map Scales
# Metadata and Qualifiers In CGView, **Qualifiers** and **Metadata** serve distinct purposes for annotating features: - **Qualifiers**: Hold additional data about a feature as defined by the [GenBank Feature Table](https://www.insdc.org/submitting-standards/feature-table/#7.3). They provide standardized descriptors for features, ensuring consistency and interoperability. - **Metadata**: Store user-defined key-value pairs that are not covered by standard qualifiers. This allows for the inclusion of custom information relevant to specific applications or analyses. ## What is Metadata? In CGView, all components that subclass `CGObject` (not just features) can store **metadata** — user-defined key:value pairs — in a property called `meta`. This allows developers to attach extra information to objects such as features, without modifying the core structure. ## Why Use Metadata? - Provides a safe place to store extra values used by your app or plugin code. - Values in `meta` are preserved when exporting to JSON using `.toJSON()`. - Metadata is **not interpreted or modified by CGView**, making it ideal for storing custom annotations. ## Example Use Case Say you want to add a `category` to a `feature`. You might try: ```js // Wrong way to add a category feature.category = "bad"; ``` However, `category` is not a recognized core property of `feature`, so it will **not be included** when exporting the map to CGView JSON (via toJSON()). Instead, use meta: ```js // Correct way to add a category feature.meta = { category: 'good' }; ``` Then you can access the `category` like this: ```js feature.meta.category // => 'good' ``` - This way, the category is preserved in the exported JSON. - Any custom key-value pairs added to `meta` will remain intact when saving and loading data. ## Limitations - The `meta` property is not currently supported when using `viewer.updateFeatures`. ## Feature Example ```json { "features": [ { "name": "rnl", // -- "type": "rRNA", // | "contig": "CP021212", // | "start": 56, // | "stop": 2806, // |- Core Properties "strand": 1, // | "source": "sequence-features", // | "legend": "rRNA", // | "visible": false, // -- "qualifiers": { // -- "gene": "rnl", // | "locus_tag": "ReamoMr68", // |- Qualifiers (e.g. GenBank) "db_xref": "GeneID:801132" // | }, // -- "meta": { // -- "category": "good", // |- Metadata (user-defined) } // -- }, ] } ```