custom_data_loader.rst 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501
  1. Creating Custom Data Loaders
  2. ==============================
  3. .. note::
  4. This guide is also available as a `video on youtube. <https://www.youtube.com/watch?v=5y8rDtDQEg0>`_
  5. The ``TripalImporter`` class can be extended to create your own data loader. This class provides many conveniences to simplify loader construction. For example, it simplifies and unifies input form development, automatically handles files upload by the user, provides job submission, logging and progress updates. Using the TripalImporter to create your loader also makes it easy to share your loader with other Tripal users!
  6. To document how to create a new importer, we will describe use of the ``TripalImporter`` class within the context of a new simple importer called the ``ExampleImporter``. This importer will read in a comma-separated file containing genomic features and their properties ( a fictional "Test Format" file). The loader will split each line into feature and property values, and then insert each property into the ``featureprop`` table of Chado using a controlled vocabulary term (supplied by the user) as the ``type_id`` for the property.
  7. .. note::
  8. Prior to starting your data loader you should plan how the data will be imported into Chado. Chado is a flexible database schema and it may be challenging at times to decide in to which tables data should be placed. It is recommended to reach out to the Chado community to solicit advice. Doing so will allow you to share your loader will other Tripal users more easily!
  9. Create a Custom Module
  10. ----------------------
  11. To create your own importer, you first need to have a custom extension module in which the loader will be provided. If you do not know how to create a module, see the section titled **Creating a Custom Module** for further direction. Providing your new importer within a custom module will allow you to more easily share your loader with other Tripal users. Any site that downloads and enables your extension module will be able to use your data loader. For this document we will describe creation of a new importer in a module named ``tripal_example_importer``.
  12. Create the Class File
  13. ---------------------
  14. To define a new class that extends ``TripalImporter``, you should create a new class file with a ``.inc`` extension within your custom module in the directory: ``includes/TripalImporter/``. If this is your first importer, then you will need to create this directory. For the example described here, we will create a new ``TripalImporter`` class named ``ExampleImporter``. Therefore, we must name the file the same as the class (with the .inc extension) and place the file here: ``tripal_example_importer/includes/TripalImporter/ExampleImporter.inc``. Initially, our new class is empty:
  15. .. code-block:: php
  16. class ExampleImporter extends TripalImporter {
  17. }
  18. There is no need to include the importer via a ``require_once`` statement in your module file. Placing it in the ``/includes/TripalImporter/`` directory of your module is all you need for Tripal to find it. Tripal will automatically place a link for your importer at ``admin -> Tripal -> Data Loaders``.
  19. .. note::
  20. If after creation of your importer file, Tripal does not show a link for it in the Data Loaders page, check that you have named your class file correctly and it is in the path described above. Sometimes a clear cache is necessary (``drush cc all``).
  21. Static Variables
  22. -----------------
  23. The next step in creation of your importer is setting the static member variables. Open the ``TripalImporter`` class file that comes with Tripal and found here ``tripal/includes/TripalImporter.inc``. Copy the ``public static`` member variables at the top of the class into your own class. For your importer, override any of the ``public static`` variables that need to be different from the default.
  24. .. note::
  25. For the sake of simplicity in this document, many of the default settings are not changed, and therefore, not all are included.
  26. Our ``ExampleImporter`` class now appears as follows:
  27. .. code-block:: php
  28. /**
  29. * @see TripalImporter
  30. */
  31. class ExampleImporter extends TripalImporter {
  32. /**
  33. * The name of this loader. This name will be presented to the site
  34. * user.
  35. */
  36. public static $name = 'Example TST File Importer';
  37. /**
  38. * The machine name for this loader. This name will be used to construct
  39. * the URL for the loader.
  40. */
  41. public static $machine_name = 'tripal_tst_loader';
  42. /**
  43. * A brief description for this loader. This description will be
  44. * presented to the site user.
  45. */
  46. public static $description = 'Loads TST files';
  47. /**
  48. * An array containing the extensions of allowed file types.
  49. */
  50. public static $file_types = ['txt', 'tst', 'csv'];
  51. /**
  52. * Provides information to the user about the file upload. Typically this
  53. * may include a description of the file types allowed.
  54. */
  55. public static $upload_description = 'TST is a fictional format. Its a 2-column, CSV file. The columns should be of the form featurename, and text';
  56. /**
  57. * Indicates the methods that the file uploader will support.
  58. */
  59. public static $methods = [
  60. // Allow the user to upload a file to the server.
  61. 'file_upload' => TRUE,
  62. // Allow the user to provide the path on the Tripal server for the file.
  63. 'file_local' => TRUE,
  64. // Allow the user to provide a remote URL for the file.
  65. 'file_remote' => TRUE,
  66. ];
  67. }
  68. .. warning::
  69. The variables that are ``private static`` **should not** be copied and should not be changed. Only copy and change the ``public static`` member variables.
  70. Now that we've given our importer a name and description, it will show up at ``/admin/tripal/loaders``:
  71. .. image:: ./custom_data_loader.0.png
  72. Form Components
  73. -----------------
  74. By default, the ``TripalImporter`` class will provide the necessary upload widgets to allow a user to upload files for import. The static variables we set in the previous step dictate how that uploader appears to the user. However, for this example, our importer needs additional information from the user before data can be loaded. We need to provide additional form widgets.
  75. Typically, to create forms, Drupal provides form hooks: ``form``, ``form_validate``, ``form_submit``. The **TripalImporter** wraps these for us as class functions named ``form``, ``formValidate`` and ``formSubmit``. We can override these class functions to provide additional widgets to the form.
  76. .. note::
  77. Typically we only need to implement the ``form`` and ``formValidate`` functions. The ``formSubmit`` does not need to be modified.
  78. .. note::
  79. If you are not familiar with form creation in Drupal you may want to find a Drupal reference book that provides step-by-step instructions. Additionally, you can explore the `API documentation for form construction for Drupal 7 <https://api.drupal.org/api/drupal/developer%21topics%21forms_api_reference.html/7.x>`_. Here, this example expects you are comfortable with form construction in Drupal.
  80. The form function
  81. ^^^^^^^^^^^^^^^^^
  82. To provide custom widgets for our importer we need to implement the ``form`` function. However, let's review the current form provided by the TripalImporter for us already. Using the static variables settings specified above the form automatically provides a **File Upload** field set, and an **Analysis** selector. The **File Upload** area lets users choose to upload a file, provide a **Server path** to a file already on the web server or a **Remote path** for files located via a downloadable link on the web. The **Analysis** selector is important because it allows the user to specify an analysis that describes how the data file was created.
  83. .. image:: ./custom_data_loader.1.oob_file_interface.png
  84. .. image:: ./custom_data_loader.2.oob_analysis_select.png
  85. For our example TST file importer these upload options are sufficient. However, for our data import we want the user provide a CV term. We want our importer to read the file, split it into feature and values, and insert properties into the ``featureprop`` table of Chado using the the CV term as the ``type_id`` for the table.
  86. To add a widget that allows the user to provide a CV term, we must implement the ``form`` function and include code using Drupal's Form API that will add the widget.
  87. .. code-block:: php
  88. :name: ExampleImporter::form
  89. public function form($form, &$form_state) {
  90. // For our example loader let's assume that there is a small list of
  91. // vocabulary terms that are appropriate as properties for the genomics
  92. // features. Therefore, we will provide an array of sequence ontology terms
  93. // the user can select from.
  94. $terms = [
  95. ['id' => 'SO:0000235'],
  96. ['id' => 'SO:0000238'],
  97. ['id' => 'SO:0000248']
  98. ];
  99. // Construct the options for the select drop down.
  100. $options = [];
  101. // Iterate through the terms array and get the term id and name using
  102. // appropriate Tripal API functions.
  103. foreach ($terms as $term){
  104. $term_object = chado_get_cvterm($term);
  105. $id = $term_object->cvterm_id;
  106. $options[$id] = $term_object->name;
  107. }
  108. // Provide the Drupal Form API array for a select box.
  109. $form['pick_cvterm'] = [
  110. '#title' => 'CVterm',
  111. '#description' => 'Please pick a CVterm. The loaded TST file will associate the values with this term as a feature property.',
  112. '#type' => 'select',
  113. '#default_value' => '0',
  114. '#options' => $options,
  115. '#empty_option' => '--please select an option--'
  116. ];
  117. // The form function must always return our form array.
  118. return $form;
  119. }
  120. Our form now has a select box!
  121. .. image:: ./custom_data_loader.3.cvterm_select.png
  122. Using AJAX in forms
  123. """""""""""""""""""
  124. .. note::
  125. This section is not yet available. For now, check out the Drupal AJAX guide https://api.drupal.org/api/drupal/includes%21ajax.inc/group/ajax/7.x
  126. The formValidate function
  127. ^^^^^^^^^^^^^^^^^^^^^^^^^
  128. The ``formValidate`` function is responsible for verifying that the user supplied values from the form submission are valid. To warn the user of inappropriate values, the Drupal API function, ``form_set_error()`` is used. It provides an error message, highlights in red the widget containing the bad value, and prevents the form from being submitted--allowing the user to make corrections. In our example code, we will check that the user selected a CV term from the ``pick_cvterm`` widget.
  129. .. code-block:: php
  130. public function formValidate($form, &$form_state) {
  131. // Always call the TripalImporter (i.e. parent) formValidate as it provides
  132. // some important feature needed to make the form work properly.
  133. parent::formValidate($form, $form_state);
  134. // Get the chosen CV term form the form state and if there is no value
  135. // set warn the user.
  136. $chosen_cvterm = $form_state['values']['pick_cvterm'];
  137. if ($chosen_cvterm == 0) {
  138. form_set_error('pick_cvterm', 'Please choose a CVterm.');
  139. }
  140. }
  141. The implementation above looks for the ``pick_cvterm`` element of the ``$form_state`` and ensures the user selected something. This is a simple example. An implementation for a more complex loader with a variety of widgets will require more validation checks.
  142. .. note::
  143. If our importer followed best practices, it would not need a validator at all. The cvterm select box in the form could be defined as below. Note the ``'#required' => True`` line: this would handle the validation for us. For this tutorial, however, we implement the validation ourselves to demonstrate the function.
  144. .. code-block:: php
  145. // Provide the Drupal Form API array for a select box.
  146. $form['pick_cvterm'] = [
  147. '#title' => 'CVterm',
  148. '#description' => 'Please pick a CVterm. The loaded TST file will associate the values with this term as a feature property.',
  149. '#type' => 'select',
  150. '#default_value' => '0',
  151. '#options' => $options,
  152. '#empty_option' => '--please select an option--'
  153. '#required' => True
  154. ];
  155. When an importer form is submitted and passes all validation checks, a job is automatically added to the **Tripal Job** system. The ``TripalImporter`` parent class does this for us! The **Tripal Job** system is meant to allow long-running jobs to execute behind-the-scenes on a regular time schedule. As jobs are added they are executed in order. Therefore, if a user submits a job using the importer's form then the **Tripal Job** system will automatically run the job the next time it is scheduled to run or it can be launched manually by the site administrator.
  156. Importer Execution
  157. ------------------
  158. The ``form`` and ``formValidate`` functions allow our Importer to receive an input file and additional values needed for import of the data. To execute loading a file the ``TripalImporter`` provides several additional overridable functions: ``run``, ``preRun`` and ``postRun``. When the importer is executed, the ``preRun`` function is called first. It allows the importer to perform setup prior to full execution. The ``run`` function is where the full execution occurs and the ``postRun`` function is used to perform "cleanup" prior to completion. For our ``ExampleImporter`` class we only need to implement the ``run`` function. We have no need to perform any setup or cleanup outside of the typical run.
  159. The run function
  160. ^^^^^^^^^^^^^^^^
  161. The ``run`` function is called automatically when Tripal runs the importer. For our ``ExampleImporter``, the run function should collect the values provided by the user, read and parse the input file and load the data into Chado. The first step, is to retrieve the user provided values and file details. The inline comments in the code below provide instructions for retrieving these details.
  162. .. code-block:: php
  163. /**
  164. * @see TripalImporter::run()
  165. */
  166. public function run() {
  167. // All values provided by the user in the Importer's form widgets are
  168. // made available to us here by the Class' arguments member variable.
  169. $arguments = $this->arguments['run_args'];
  170. // The path to the uploaded file is always made available using the
  171. // 'files' argument. The importer can support multiple files, therefore
  172. // this is an array of files, where each has a 'file_path' key specifying
  173. // where the file is located on the server.
  174. $file_path = $this->arguments['files'][0]['file_path'];
  175. // The analysis that the data being imported is associated with is always
  176. // provided as an argument.
  177. $analysis_id = $arguments['analysis_id'];
  178. // Any of the widgets on our form are also available as an argument.
  179. $cvterm_id = $arguments['pick_cvterm'];
  180. // Now that we have our file path, analysis_id and CV term we can load
  181. // the file. We'll do so by creating a new function in our class
  182. // called "loadMyFile" and pass these arguments to it.
  183. $this->loadMyFile($analysis_id, $file_path, $cvterm_id);
  184. }
  185. .. note::
  186. We do not need to validate in the ``run`` function that all of the necessary values in the arguments array are valid. Remember, this was done by the ``formValidate`` function when the user submitted the form. Therefore, we can trust that all of the necessary values we need for the import are correct. That is of course provided our ``formValidate`` function sufficiently checks the user input.
  187. Importing the File
  188. ^^^^^^^^^^^^^^^^^^
  189. To keep the ``run`` function small, we will implement a new function named ``loadMyFile`` that will perform parsing and import of the file into Chado. As seen in the code above, the ``loadMyFile`` function is called in the ``run`` function.
  190. Initially, lets get a feel for how the importer will work. Lets just print out the values provided to our importer:
  191. .. code-block:: php
  192. public function loadMyFile($analysis_id, $file_path, $cvterm){
  193. var_dump(["this is running!", $analysis_id, $file_path, $cvterm]);
  194. }
  195. To test our importer navigate to ``admin > Tripal > Data Importers`` and click the link for our TFT importer. Fill out the form and press submit. If there are no validation errors, we'll receive notice that our job was submitted and given a command to execute the job manually. For example:
  196. ..
  197. drush trp-run-jobs --username=admin --root=/var/www/html
  198. If we execute our importer we should see the following output:
  199. .. code-block:: bash
  200. Calling: tripal_run_importer(146)
  201. Running 'Example TST File Importer' importer
  202. NOTE: Loading of file is performed using a database transaction.
  203. If it fails or is terminated prematurely then all insertions and
  204. updates are rolled back and will not be found in the database
  205. array(4) {
  206. [0]=>
  207. string(16) "This is running!"
  208. [1]=>
  209. string(3) "147"
  210. [2]=>
  211. string(3) "695"
  212. [3]=>
  213. string(72) "/Users/chet/UTK/tripal/sites/default/files/tripal/users/1/expression.tsv"
  214. }
  215. Done.
  216. Remapping Chado Controlled vocabularies to Tripal Terms...
  217. As you can see, running the job executes our run script, and we have all the variables we need to load the data. All we need to do now is write the code!
  218. To import data into Chado we will use the Tripal API. After splitting each line of the input file into a genomic feature and its property, we will use the ``chado_select_record`` to match the feature's name with a record in the ``feature`` table of Chado, and the ``chado_insert_property`` to add the property value.
  219. .. code-block:: php
  220. public function loadMyFile($analysis_id, $file_path, $cvterm_id){
  221. // We want to provide a progress report to the end-user so that they:
  222. // 1) Recognize that the loader is not hung if running a large file, but is
  223. // executing
  224. // 2) Provides some indicatation for how long the file will take to load.
  225. //
  226. // Here we'll get the size of the file and tell the TripalImporter how
  227. // many "items" we have to process (in this case bytes of the file).
  228. $filesize = filesize($file_path);
  229. $this->setTotalItems($filesize);
  230. $this->setItemsHandled(0);
  231. // Loop through each line of file. We use the fgets function so as not
  232. // to load the entire file into memory but rather to iterate over each
  233. // line separately.
  234. $bytes_read = 0;
  235. while ($line = fgets($file_path)) {
  236. // Calculate how many bytes we have read from the file and let the
  237. // importer know how many have been processed so it can provide a
  238. // progress indicator.
  239. $bytes_read += drupal_strlen($line);
  240. $this->setItemsHandled($bytes_read);
  241. // Remove any trailing white-space from the line.
  242. $line = trim($line);
  243. // Split line on a comma into an array. The feature name appears in the
  244. // first "column" of data and the property in the second.
  245. $cols = explode(",", $line);
  246. $feature_name = $cols[0];
  247. $this_value = $cols[1];
  248. // Our file has a header with the name 'Feature name' expected as the
  249. // title for the first column. If we see this ignore it.
  250. if ($feature_name == 'Feature name'){
  251. continue;
  252. }
  253. // Using the name of the feature from the file, see if we can find a
  254. // record in the feature table of Chado that matches. Note: in reality
  255. // the feature table of Chado has a unique contraint on the uniquename,
  256. // organism_id and type_id columns of the feature table. So, to ensure
  257. // we find a single record ideally we should include the organism_id and
  258. // type_id in our filter and that would require more widgets on our form!
  259. // For simplicity, we will just search on the uniquename and hope we
  260. // find unique features.
  261. $match = ['uniquename' => $feature_name];
  262. $results = chado_select_record('feature', ['feature_id'], $match);
  263. // The chado_select_record function always returns an array of matches. If
  264. // we found no matches then this feature doesn't exist and we'll skip
  265. // this line of the file. But, log this issue so the user knows about it.
  266. if (count($results) == 0) {
  267. $this->logMessage('The feature, !feature, does not exist in the database',
  268. ['!feature' => $feature_name], TRIPAL_WARNING);
  269. continue;
  270. }
  271. // If we failed to find a unique feature then we should warn the user
  272. // but keep on going.
  273. if (count($results) == 0) {
  274. $this->logMessage('The feature, !feature, exists multiple times. ' .
  275. 'Cannot add a property', ['!feature' => $feature_name], TRIPAL_WARNING);
  276. continue;
  277. }
  278. // If we've made it this far then we have a feature and we can do the
  279. // insert.
  280. $feature = $results[0];
  281. $record = [
  282. 'table' => 'feature',
  283. 'id' => $feature->feature_id
  284. ];
  285. $property = [
  286. 'type_id' => $cvterm_id,
  287. 'value' => $this_value,
  288. ];
  289. $options = ['update_if_present' => TRUE];
  290. chado_insert_property($record, $property, $options);
  291. }
  292. }
  293. Logging and Progress
  294. --------------------
  295. During execution of our importer it is often useful to inform the user of progress, status and issues encountered. There are several functions to assist with this. These include the ``logMessage``, ``setTotalItems`` and ``setItemsHandled`` functions. All three of these functions were used in the sample code above of the ``loadMyFile`` function. Here, we provide a bit more detail.
  296. The logMessage function
  297. ^^^^^^^^^^^^^^^^^^^^^^^
  298. The ``logMessage`` function is meant to allow the importer to provide status messages to the user while the importer is running. The function takes three arguments:
  299. 1) a message string.
  300. 2) an array of substitution values.
  301. 3) a message status.
  302. The message string contains the message for the user. You will notice that no variables are included in the string but rather tokens are used as placeholders for variables. This is a security feature provided by Drupal. Consider these lines from the code above:
  303. .. code-block:: php
  304. $this->logMessage('The feature, !feature, does not exist in the database',
  305. ['!feature' => $feature_name], TRIPAL_WARNING);
  306. Notice that ``!feature`` is used in the message string as a placeholder for the feature name. The mapping of ``!feature`` to the actually feature name is provided in the array provided as the second argument. The third argument supports several message types including ``TRIPAL_NOTICE``, ``TRIPAL_WARNING`` and ``TRIPAL_ERROR``. The message status indicates a severity level for the message. By default if no message type is provided the message is of type ``TRIPAL_NOTICE``.
  307. Any time the ``logMessage`` function is used the message is stored in the job log, and a site admin can review these logs by clicking on the job in the ``admin > Tripal > Tripal Jobs`` page.
  308. .. note::
  309. You should avoid using ``print`` or ``print_r`` statements in a loader to provide messages to the end-user while loading the file. Always use the ``logMessage`` function to ensure all messages are sent to the job's log.
  310. The setTotalItems and setItemsHandled functions
  311. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  312. The ``TripalImporter`` class is capable of providing progress updates to the end-user while the importer job is running. This is useful as it gives the end-user a sense for how long the job will take. As shown in the sample code above for the ``loadMyFile`` function, The first step is to tell the ``TripalImporter`` how many items need processing. An **item** is an arbitrary term indicating some measure of countable "units" that will be processed by our importer.
  313. In the code above we consider a byte as an item, and when all bytes from a file are read we are done loading that file. Therefore the ``setTotalItems`` function is used to tell the importer how many bytes we need to process. As we read each line, we count the number of bytes read and provide that number to the ``setItemsHandled`` function. The ``TripalImporter`` class will automatically calculate progress and print a message to the end-user indicating the percent complete, and some additional details such as the total amount of memory consumed during the loading.
  314. .. note::
  315. All importers are different and the "item" need not be the number of bytes in the file. However, if you want to provide progress reports you must identify an "item" and the total number of items there are for processing.
  316. Testing Importers
  317. ------------------
  318. Unit Testing is a critically important component of any software project. You should always strive to write tests for your software. Tripal provides unit testing using the ``phpunit`` testing framework. The Tripal Test Suite provides a strategy for adding tests for your new Importer. It will automatically set up and bootstrap Drupal and Tripal for your testing environment, as well as provide database transactions for your tests, and factories to quickly generate data. We will use the Tripal Test Suite to provide unit testing for our ``ExampelImporter``.
  319. .. note::
  320. Before continuing, please install and configure Tripal Test Suite.
  321. For instructions on how to install, configure, and run Tripal Test Suite, `please see the Tripal Test Suite documentation. <https://tripaltestsuite.readthedocs.io/en/latest/>`_
  322. Example file
  323. ^^^^^^^^^^^^
  324. When developing tests, consider including a small example file as this is good practice both to ensure that your loader works as intended, and for new developers to easily see the expected file format. For our ``ExampleImporter``, we'll include the following sample file and store it in this directory of our module: ``tests/data/example.txt``.
  325. .. csv-table:: Example input file
  326. :header: "Feature name", "CVterm value"
  327. "test_gene_1", "blue"
  328. "test_gene_2", "red"
  329. Loading the Importer
  330. ^^^^^^^^^^^^^^^^^^^^
  331. Testing your loader requires a few setup steps. First, TripalImporters are not explicitly loaded in your module (note that we never use ``include_once()`` or ``require_once`` in the ``.module`` file). Normally Tripal finds the importer automatically, but for unit testing we must include it to our test class explicitly. Second, we must initialize an instance of our importer class. Afterwards we can perform any tests to ensure our loader executed properly. The following function provides an example for setup of the loader for testing:
  332. .. code-block:: php
  333. private function run_loader(){
  334. // Load our importer into scope.
  335. module_load_include('inc', 'tripal_example_importer', 'includes/TripalImporter/ExampleImporter');
  336. // Create an array of arguments we'll use for testing our importer.
  337. $run_args = [
  338. 'analysis_id' => $some_analysis_id,
  339. 'cvterm' => $some_cvterm_id
  340. ];
  341. $file = ['file_local' => __DIR__ . '/../data/exampleFile.txt'];
  342. // Create a new instance of our importer.
  343. $importer = new \ExampleImporter();
  344. $importer->create($run_args, $file);
  345. // Before we run our loader we must let the TripalImporter prepare the
  346. // files for us.
  347. $importer->prepareFiles();
  348. $importer->run();
  349. }
  350. .. note::
  351. We highly recommend you make use of database transactions in your tests, especially when running loaders. Simply add ``use DBTransaction;`` at the start of your test class. Please see the `Tripal Test Suite documentation for more information <https://tripaltestsuite.readthedocs.io/en/latest/>`_.