Cargo Data

AntWiki: The Ants --- Online

Cargo is used to store and query data contained within AntWiki pages. Data is added to pages by including specially formatted templates on individual pages. These templates not only display data on the page, but also add it to a database table. Each template uses a single table, with a column for each template parameter. There are a few exceptions to this; see Cargo Documentation for a full discussion of the details.

See Cargo Tables for a list of Cargo-managed data.

How It Works

Cargo is similar to the extension Dynamic Page List [DPL] (which is used extensively throughout AntWiki) in that sets of pages meeting user-defined conditions can be retrieved and displayed. For example, this DPL code:

|category=Bamboo Specialist

gives the same result as this Cargo code:

|fields= _pageName=Taxon
|where=Item HOLDS "Bamboo Specialist"
|order by = _pageName

While these simple queries are essentially the same, Cargo offers extended functionality that supports much more sophisticated queries, as well as allowing complex data to be stored without relying on page categories alone. This extends and greatly simplifies data storage and retrieval.


As an example, here is how AntWiki stores and manages karyotype data using the Karyotype template.

The standard karyotype template has two sections added beyond what is needed to display data on the page, one to create the database table and one to add data to the table.

Code to create the table with the fields Haploid, Diploid, Karyotype, Locality, Source, Notes:

{{#cargo_declare: _table = Karyotype
|Haploid = List (;) of Integer
|Diploid = List (;) of Integer
|Karyotype = String
|Locality = String
|Source = String
|Notes = String

Code to store the data:

{{#cargo_store: _table = Karyotype
|Haploid = {{{haploid|}}}
|Diploid = {{{diploid|}}}
|Karyotype = {{{karyotype|}}}
|Locality = {{{locality|}}}
|Source = {{{source|}}}
|Notes = {{{notes|}}}

When adding the template to a page, each of the included parameters (those that are non-blank) will be displayed on the page as well as stored in the table named “Karyotype”. The table can be viewed in its entirety or queries of the data can be included on individual pages.

Displaying Queried Data on Individual Pages

This query (when added to a page):

{{#cargo_query: tables = Karyotype
|fields = _pageName = Taxon, Haploid, Diploid, Karyotype, Locality, Source, Notes
|format = table

will display this table (this is live data but only the top 10 rows are included here):

Taxon Haploid Diploid Karyotype Locality Source Notes
Acanthomyrmex 22 Malaysia Goni et al., 1982
Acanthomyrmex 24 Sarawak Tjan et al., 1986
Acanthomyrmex 11 Malaysia Goni et al., 1982
Acanthomyrmex 11 22 Malaysia Imai et al., 1983
Acromyrmex ambiguus 38 14M + 12SM + 8ST + 4A Brazil de Castro et al., 2020
Acromyrmex ambiguus 38 2M+6SM+16ST+14A Uruguay Goñi et al., 1984
Acromyrmex ameliae 36 10M +16SM + 8ST + 2A Brazil Barros et al., 2021; Cardoso et al. 2018; de Castro et al., 2020; Micolino et al., 2021
Acromyrmex aspersus 38 8M+10SM+16ST+4A Brazil Teixeira et al., 2017
Acromyrmex balzani 38 12M+10SM+14ST+2A Brazil Barros et al., 2016
Acromyrmex balzani 38 12M+10SM+14ST+2A French Guiana Aguiar et al., 2020


To include only data for the genus ‘’Aphaenogaster’’, this query:

{{#cargo_query: tables = Karyotype
|fields =_pageName=Taxon, Haploid, Diploid, Karyotype, Locality, Source, Notes
|where = _pageName like "Aphaenogaster%"
|format = table

will return (only the first 10 rows shown):

Taxon Haploid Diploid Karyotype Locality Source Notes
Aphaenogaster 30 Malaysia Goni et al., 1982
Aphaenogaster depilis 34 Tunisia Hauschteck-Jungen & Jungen, 1983
Aphaenogaster famelica 17 34 Japan Imai & Yosida, 1964; Imai, 1966; Imai, 1969; Imai, 1971
Aphaenogaster fulva 36 USA Crozier, 1977
Aphaenogaster gibbosa 11 16 17 34 4M+2SM+4ST+6T; 6M+4SM+8ST+16T Switzerland Hauschteck-Jungen & Jungen, 1983; Lorite et al., 2000; Palomeque et al., 1993b this karyotype is reported as fusion of two telocentric chromosomes
Aphaenogaster iberica 17 34 6M+4SM+8ST+16T Spain Palomeque et al., 1993a; Palomeque et al., 1993b; Lorite et al., 2000 ocurrence of supernumery chromosome segment
Aphaenogaster japonica 22 Japan Imai, 1969
Aphaenogaster lamellidens 38 USA Crozier, 1977; Taber & Cokendolpher, 1988
Aphaenogaster longiceps 45 46 Australia Imai et al., 1977 a metacentric pair is single and two telocentric corresponds the arms
Aphaenogaster miamiana 36 USA Crozier, 1977


Complex Data Queries

The database used by Cargo is a relational database. This means that separate tables within the database can be joined together to return a single, combined result set containing data from both tables. As an example, AntWiki holds data on both karyotypes and worker morphology. By combining these two tables, information on the (say) diploid karyotype number can be compared to (say) the antennal segment number for any given taxon.

In this query, the tables WorkerMorphology and Karyotype are joined on the field _pageName (which occurs in both tables) and three fields are returned: taxon name (from either table), diploid number (from Karyotype) and antennal segment count (from WorkerMorphology):

{{#cargo_query: tables = WorkerMorphology, Karyotype
|join on = WorkerMorphology._pageName = Karyotype._pageName
|fields = WorkerMorphology._pageName = Taxon, Karyotype.Diploid = Diploid, WorkerMorphology.AntennalSegmentCount = AntennalCount
|where = Karyotype.Diploid__full IS NOT NULL
|group by = WorkerMorphology._pageName
|order by = WorkerMorphology._pageName

with the result (first 10 rows only):

Taxon Diploid AntennalCount
Acanthomyrmex 22 12
Acropyga 30 32 7 8 9 10 11
Aenictus 30 8 9 10
Amblyopone 44
Anochetus 24 12
Anonychomyrma 16 12
Aphaenogaster 30 12
Apterostigma 20 24 32 11
Bothroponera 48
Brachymyrmex 18 9


Using this technique, complex questions can be answered by combining data from across AntWiki.

Real-World Examples

A few of the AntWiki pages that use Cargo data include: