|
@@ -1,6 +1,6 @@
|
|
|
|
|
|
Bulk Loader
|
|
|
-===============
|
|
|
+===========
|
|
|
|
|
|
The bulk loader is a tool that Tripal provides for loading of data contained in tab delimited files. Tripal supports loading of files in standard formats (e.g. ``FASTA``, ``GFF``, ``OBO``), but Chado can support a variety of different biological data types and there are often no community standard file formats for loading these data. For example, there is no file format for importing genotype and phenotype data. Those data can be stored in the feature, stock and natural diversity tables of Chado. The Bulk Loader was introduced in Tripal v1.1 and provides a web interface for building custom data loader. In short, the site developer creates the bulk loader "template". This template can then be used and re-used for any tab delimited file that follows the format described by the template. Additionally, bulk loading templates can be exported allowing Tripal sites to share loaders with one another. Loading templates that have been shared are available on the Tripal website here: http://tripal.info/extensions/bulk-loader-templates.
|
|
|
|
|
@@ -12,7 +12,7 @@ The following commands can be executed to install the Tripal Bulk Loader using D
|
|
|
drush pm-enable tripal_bulk_loader
|
|
|
|
|
|
Plan How to Store Data
|
|
|
-~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
|
+----------------------
|
|
|
|
|
|
To demonstrate use of the Bulk Loader, a brief example that imports a list of organisms and associates them with their NCBI taxonomy IDs will be performed. The input tab-delimited file will contains the list of all *Fragaria* (strawberry) species in NCBI at the time of the writing of this document.
|
|
|
|
|
@@ -37,8 +37,10 @@ This file has three columns: NCBI taxonomy ID, genus and species:
|
|
|
|
|
|
To use the bulk loader you must be familiar with the Chado database schema and have an idea for where data should be stored. It is best practice to consult the GMOD website or consult the Chado community (via the `gmod-schema mailing list <https://lists.sourceforge.net/lists/listinfo/gmod-schema>`_) when deciding how to store data. For this example, we want to add the species to Chado, and we want to associate the NCBI taxonomy ID with these organisms. The first step, therefore, is to decide where in Chado these data should go. In Chado, organisms are stored in the **organism** table. This table has the following fields:
|
|
|
|
|
|
-.. csv-table:: Chado organism table
|
|
|
- :header: "Name", "Type", "Description"
|
|
|
+`chado.organism Table Schema`
|
|
|
+
|
|
|
+.. csv-table::
|
|
|
+ :header: "Name", "Type", "Description"
|
|
|
|
|
|
"organism_id", "serial", "PRIMARY KEY"
|
|
|
"abbreviation", "character varying(255)",
|
|
@@ -53,8 +55,9 @@ We can therefore store the second and third columns of the tab-delimited input f
|
|
|
In order to store a database external reference (such as for the NCBI Taxonomy ID) we need to use the following tables: **db**, **dbxref**, and **organism_dbxref**. The **db** table will house the entry for the NCBI Taxonomy; the **dbxref** table will house the entry for the taxonomy ID; and the **organism_dbxref** table will link the taxonomy ID stored in the **dbxref** table with the organism housed in the **organism** table. For reference, the fields of these tables are as follows:
|
|
|
|
|
|
|
|
|
+`chado.db Table Schema`
|
|
|
|
|
|
-.. csv-table:: chado.db structure
|
|
|
+.. csv-table::
|
|
|
:header: "Name", "Type", "Description"
|
|
|
|
|
|
"db_id", "serial", "PRIMARY KEY"
|
|
@@ -64,7 +67,9 @@ In order to store a database external reference (such as for the NCBI Taxonomy I
|
|
|
"url", "character varying(255)"
|
|
|
|
|
|
|
|
|
-.. csv-table:: chado.dbxref structure
|
|
|
+`chado.dbxref Table Schema`
|
|
|
+
|
|
|
+.. csv-table::
|
|
|
:header: "Name", "Type", "Description"
|
|
|
|
|
|
"dbxref_id", "serial", "PRIMARY KEY"
|
|
@@ -74,7 +79,9 @@ In order to store a database external reference (such as for the NCBI Taxonomy I
|
|
|
"description", "text"
|
|
|
|
|
|
|
|
|
-.. csv-table:: chado.organism_dbxref structure
|
|
|
+`chado.organism_dbxref Table Schema`
|
|
|
+
|
|
|
+.. csv-table::
|
|
|
:header: "Name", "Type", "Description"
|
|
|
|
|
|
"organism_dbxref_id", "serial", "PRIMARY KEY"
|
|
@@ -85,13 +92,12 @@ In order to store a database external reference (such as for the NCBI Taxonomy I
|
|
|
For our bulk loader template, we will therefore need to insert values into the **organism**, **db**, **dbxref** and **organism_dbxref** tables. In our input file we have the genus and species and taxonomy ID so we can import these with a bulk loader template. However, we do not have information that will go into the db table (e.g. "NCBI Taxonomy"). This is not a problem as the bulk loader can use existing data to help with import. We simply need to use the "NCBI Taxonomy" database that is currently in the Chado instance of Tripal v3.
|
|
|
|
|
|
Creating a New Bulk Loader Template
|
|
|
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
|
+-----------------------------------
|
|
|
|
|
|
Now that we know where all of the data in the input file will go and we have the necessary dependencies in the database (i.e. the NCBI Taxonomy database), we can create a new bulk loader template. Navigate to ``Tripal → Data Loaders → Chado Bulk Loader``, click the **Templates** tab in the top right corner, and finally click the link **Add Template**. The following page appears:
|
|
|
|
|
|
.. image:: ./bulk_loader.1.png
|
|
|
|
|
|
-
|
|
|
We need to first provide a name for our template. Try to name templates in a way that are meaningful for others. Currently only site administrators can load files using the bulk loader. But, future versions of Tripal will provide functionality to allow other privileged users the ability to use the bulk loader templates. Thus, it is important to name the templates so that others can easily identify the purpose of the template. For this example, enter the name **NCBI Taxonomy Importer (taxid, genus, species)**. The following page appears:
|
|
|
|
|
|
.. image:: ./bulk_loader.2.png
|
|
@@ -129,7 +135,6 @@ Next, we need to add the **species** field to the record. Click the **Add Field*
|
|
|
* Chado Field/Column: species
|
|
|
* Column: 3
|
|
|
|
|
|
-
|
|
|
We now have two fields for our organism record:
|
|
|
|
|
|
.. image:: ./bulk_loader.5.png
|
|
@@ -151,7 +156,6 @@ To this point, we have built the loader such that it can load two of the three c
|
|
|
* Constant Value: NCBITaxon
|
|
|
* Check "Ensure the value is in the table"
|
|
|
|
|
|
-
|
|
|
Here we use a field type of **Constant** rather than **Data**. This is because we are providing the value to be used in the record rather than using a value from the input file. The value we are providing is "NCBI Taxonomy" which is the name of the database we added previously. The goal is to match the name "NCBI Taxonomy" with an entry in the **db** table. Click the **Save Changes** button.
|
|
|
|
|
|
We now see a second record on the **Edit Template** page. However, the mode for this record is insert. We do not want to insert this value into the table, we want to select it because we need the corresponding **db_id** for the **dbxref** record. To change this, click the Edit link to the left of the **NCBI Taxonomy DB** record. Here we want to select only the option **SELECT ONCE**. We choose this option because the database entry that will be returned by the record will apply for the entire input file. Therefore, we only need to select it one time. Otherwise, the select statement would execute for each row in the input file causing excess queries. Finally, click **Save Record**. The **NCBI Taxonomy DB** record now has a mode of **select once**. When we created the record, we selected the option to 'SELECT ONCE'. This means that the bulk loader will perform the action one time for that record for the entire import process. Because the field is a constant the bulk loader need not execute that record for every row it imports from our input file. We simply need to select the record once and the record then becomes available for use through the entire import process.
|
|
@@ -174,11 +178,8 @@ Now that we have a record that selects the **db_id** we can now create the **dbx
|
|
|
|
|
|
Click the Save Changes button. The Edit Template page appears.
|
|
|
|
|
|
-
|
|
|
.. image:: ./bulk_loader.6.png
|
|
|
|
|
|
-
|
|
|
-
|
|
|
Again, we need to edit the record to make the loader more fault tolerant. Click the Edit link to the left of the Taxonomy ID record. Select the following:
|
|
|
|
|
|
* Insert
|
|
@@ -196,7 +197,6 @@ To complete this record, we need to add the accession field. Click the Add field
|
|
|
|
|
|
At this state, we should have three records: Organism, NCBI Taxonomy DB, and Taxonomy ID. We can now add the final record that will insert a record into the **organism_dbxref** table. Create this new record with the following details:
|
|
|
|
|
|
-
|
|
|
* For the record:
|
|
|
* Record: New Record
|
|
|
* Unique Record Name: Taxonomy/Organism Linker
|
|
@@ -227,18 +227,16 @@ Create the second field:
|
|
|
|
|
|
We are now done! We have created a bulk loader template that reads in a file with three columns containing an NCBI taxonomy ID, a genus and species. The loader places the genus and species in the **organism** table, adds the NCBI Taxonomy ID to the **dbxref** table, links it to the NCBI Taxonomy entry in the db table, and then adds an entry to the **organism_dbxref** table that links the organism to the NCBI taxonomy Id. The following screen shots show how the template should appear:
|
|
|
|
|
|
-
|
|
|
.. image:: ./bulk_loader.7.png
|
|
|
|
|
|
-
|
|
|
To save the template, click the **Save Template** link at the bottom of the page.
|
|
|
|
|
|
Creating a Bulk Loader Job (importing a file)
|
|
|
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
|
+---------------------------------------------
|
|
|
|
|
|
Now that we have created a bulk loader template we can use it to import a file. We will import the **Fragaria**.txt file downloaded previously. To import a file using a bulk loader template, click the **Add Content** link in the administrative menu and click the **Bulk Loading Job**. A bulk loading job is required each time we want to load a file. Below is a screen shot of the page used for creating a bulk loading job.
|
|
|
|
|
|
-
|
|
|
+.. image:: ./bulk_loader.8.png
|
|
|
|
|
|
Provide the following values:
|
|
|
|
|
@@ -250,15 +248,11 @@ Provide the following values:
|
|
|
|
|
|
Click **Save**. The page then appears as follows:
|
|
|
|
|
|
-
|
|
|
-.. image:: ./bulk_loader.8.png
|
|
|
-
|
|
|
+.. image:: ./bulk_loader.9.png
|
|
|
|
|
|
You can see details about constants that are used by the template and the where the fields from the input file will be stored by clicking the **Data Fields** tab in the table of contents on the left sidebar.
|
|
|
|
|
|
-
|
|
|
-.. image:: ./bulk_loader.9.png
|
|
|
-
|
|
|
+.. image:: ./bulk_loader.10.png
|
|
|
|
|
|
Now that we have created a job, we can submit it for execution by clicking the **Submit Job** button. This adds a job to the Tripal Jobs systems and we can launc the job as we have previously in this tutorial:
|
|
|
|
|
@@ -296,32 +290,26 @@ After execution of the job you should see similar output to the terminal window:
|
|
|
|
|
|
Our *Fragaira* species should now be loaded, and we return to the Tripal site to see them. Click on the **Organisms** link in the **Search Data** menu. In the search form that appears, type "Fragaria" in the **Genus** text box and click the **Filter** button. We should see the list of newly added *Fragaria* species.
|
|
|
|
|
|
-.. image:: ./bulk_loader.10.png
|
|
|
-
|
|
|
-
|
|
|
-Before the organisms will have Tripal pages, the Chado records need to be **Published**. You can publish them by navigating to ``admin -> Tripal Content -> Publish Tripal Content``. Select the **organism** table from the dropdown and run the job.
|
|
|
-
|
|
|
+.. image:: ./bulk_loader.11.png
|
|
|
|
|
|
+Before the organisms will have Tripal pages, the Chado records need to be **Published**. You can publish them by navigating to **Tripal Content -> Publish Tripal Content**. Select the **organism** table from the dropdown and run the job.
|
|
|
|
|
|
.. note::
|
|
|
|
|
|
- In Tripal 2, records were synced by naviating to ``Tripal → Chado Modules → Organisms``.
|
|
|
-
|
|
|
-
|
|
|
+ In Tripal 2, records were synced by naviating to **Tripal → Chado Modules → Organisms**.
|
|
|
|
|
|
Once complete, return to the search form, find a *Fragaria* species that has been published and view its page. You should see a Cross References link in the left table of contents. If you click that link you should see the NCBI Taxonomy ID with a link to the page:
|
|
|
|
|
|
-.. image:: ./bulk_loader.11.png
|
|
|
+.. image:: ./bulk_loader.12.png
|
|
|
|
|
|
|
|
|
Sharing Your Templates with Others
|
|
|
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
|
+----------------------------------
|
|
|
|
|
|
-Now that our template for loading organisms with NCBI Taxonomy IDs is completed we can share our template loader with anyone else that has a Tripal-based site. To do this we simply export the template in text format, place it in a text file or directly in an email and send to a collaborator for import into their site. To do this, navigate to ``Tripal → Chado Data Loaders → Buik Loader`` and click the **Tempalate** tab at the top. Here we find a table of all the tempaltes we have created. We should see our template named **NCBI Taxonomy Importer** (taxid, genus, species). In the far right colum is a link to export that template. Licking that link will redirect you to a page where the template is provided in a serialized PHP array.
|
|
|
-
|
|
|
-.. image:: ./bulk_loader.12.png
|
|
|
+Now that our template for loading organisms with NCBI Taxonomy IDs is completed we can share our template loader with anyone else that has a Tripal-based site. To do this we simply export the template in text format, place it in a text file or directly in an email and send to a collaborator for import into their site. To do this, navigate to **Tripal → Chado Data Loaders → Buik Loader** and click the **Tempalate** tab at the top. Here we find a table of all the tempaltes we have created. We should see our template named **NCBI Taxonomy Importer** (taxid, genus, species). In the far right colum is a link to export that template. Licking that link will redirect you to a page where the template is provided in a serialized PHP array.
|
|
|
|
|
|
+.. image:: ./bulk_loader.13.png
|
|
|
|
|
|
-Simply cut-and-paste all of the text in the **Export** field and send it to a collaborator.
|
|
|
+Cut-and-paste all of the text in the **Export** field and send it to a collaborator.
|
|
|
|
|
|
-To import a template that may have been created by someone else, navigate to ``Tripal → Chado Data Loaders → Buik Loader`` and click the **Tempalate** tab. A link titled Import Template appears above the table of existing importers. The page that appears when that link is clicked will allow you to import any template shared with you.
|
|
|
+To import a template that may have been created by someone else, navigate to **Tripal → Chado Data Loaders → Buik Loader** and click the **Tempalate** tab. A link titled Import Template appears above the table of existing importers. The page that appears when that link is clicked will allow you to import any template shared with you.
|