Przeglądaj źródła

Start adding tests for chado_get_feature_sequences().

Lacey Sanderson 5 lat temu
rodzic
commit
78a22be0ff
2 zmienionych plików z 137 dodań i 27 usunięć
  1. 28 27
      composer.lock
  2. 109 0
      tests/tripal_chado/api/TripalChadoFeatureAPITest.php

+ 28 - 27
composer.lock

@@ -113,27 +113,28 @@
         },
         {
             "name": "guzzlehttp/guzzle",
-            "version": "6.3.3",
+            "version": "6.4.1",
             "source": {
                 "type": "git",
                 "url": "https://github.com/guzzle/guzzle.git",
-                "reference": "407b0cb880ace85c9b63c5f9551db498cb2d50ba"
+                "reference": "0895c932405407fd3a7368b6910c09a24d26db11"
             },
             "dist": {
                 "type": "zip",
-                "url": "https://api.github.com/repos/guzzle/guzzle/zipball/407b0cb880ace85c9b63c5f9551db498cb2d50ba",
-                "reference": "407b0cb880ace85c9b63c5f9551db498cb2d50ba",
+                "url": "https://api.github.com/repos/guzzle/guzzle/zipball/0895c932405407fd3a7368b6910c09a24d26db11",
+                "reference": "0895c932405407fd3a7368b6910c09a24d26db11",
                 "shasum": ""
             },
             "require": {
+                "ext-json": "*",
                 "guzzlehttp/promises": "^1.0",
-                "guzzlehttp/psr7": "^1.4",
+                "guzzlehttp/psr7": "^1.6.1",
                 "php": ">=5.5"
             },
             "require-dev": {
                 "ext-curl": "*",
                 "phpunit/phpunit": "^4.8.35 || ^5.7 || ^6.4 || ^7.0",
-                "psr/log": "^1.0"
+                "psr/log": "^1.1"
             },
             "suggest": {
                 "psr/log": "Required for using the Log middleware"
@@ -145,12 +146,12 @@
                 }
             },
             "autoload": {
-                "files": [
-                    "src/functions_include.php"
-                ],
                 "psr-4": {
                     "GuzzleHttp\\": "src/"
-                }
+                },
+                "files": [
+                    "src/functions_include.php"
+                ]
             },
             "notification-url": "https://packagist.org/downloads/",
             "license": [
@@ -174,7 +175,7 @@
                 "rest",
                 "web service"
             ],
-            "time": "2018-04-22T15:46:56+00:00"
+            "time": "2019-10-23T15:58:00+00:00"
         },
         {
             "name": "guzzlehttp/promises",
@@ -600,22 +601,22 @@
         },
         {
             "name": "phpspec/prophecy",
-            "version": "1.8.1",
+            "version": "1.9.0",
             "source": {
                 "type": "git",
                 "url": "https://github.com/phpspec/prophecy.git",
-                "reference": "1927e75f4ed19131ec9bcc3b002e07fb1173ee76"
+                "reference": "f6811d96d97bdf400077a0cc100ae56aa32b9203"
             },
             "dist": {
                 "type": "zip",
-                "url": "https://api.github.com/repos/phpspec/prophecy/zipball/1927e75f4ed19131ec9bcc3b002e07fb1173ee76",
-                "reference": "1927e75f4ed19131ec9bcc3b002e07fb1173ee76",
+                "url": "https://api.github.com/repos/phpspec/prophecy/zipball/f6811d96d97bdf400077a0cc100ae56aa32b9203",
+                "reference": "f6811d96d97bdf400077a0cc100ae56aa32b9203",
                 "shasum": ""
             },
             "require": {
                 "doctrine/instantiator": "^1.0.2",
                 "php": "^5.3|^7.0",
-                "phpdocumentor/reflection-docblock": "^2.0|^3.0.2|^4.0",
+                "phpdocumentor/reflection-docblock": "^2.0|^3.0.2|^4.0|^5.0",
                 "sebastian/comparator": "^1.1|^2.0|^3.0",
                 "sebastian/recursion-context": "^1.0|^2.0|^3.0"
             },
@@ -659,7 +660,7 @@
                 "spy",
                 "stub"
             ],
-            "time": "2019-06-13T12:50:23+00:00"
+            "time": "2019-10-03T11:07:50+00:00"
         },
         {
             "name": "phpunit/php-code-coverage",
@@ -1799,16 +1800,16 @@
         },
         {
             "name": "symfony/console",
-            "version": "v4.3.4",
+            "version": "v4.3.7",
             "source": {
                 "type": "git",
                 "url": "https://github.com/symfony/console.git",
-                "reference": "de63799239b3881b8a08f8481b22348f77ed7b36"
+                "reference": "d2e39dbddae68560fa6be0c576da6ad4e945b90d"
             },
             "dist": {
                 "type": "zip",
-                "url": "https://api.github.com/repos/symfony/console/zipball/de63799239b3881b8a08f8481b22348f77ed7b36",
-                "reference": "de63799239b3881b8a08f8481b22348f77ed7b36",
+                "url": "https://api.github.com/repos/symfony/console/zipball/d2e39dbddae68560fa6be0c576da6ad4e945b90d",
+                "reference": "d2e39dbddae68560fa6be0c576da6ad4e945b90d",
                 "shasum": ""
             },
             "require": {
@@ -1870,7 +1871,7 @@
             ],
             "description": "Symfony Console Component",
             "homepage": "https://symfony.com",
-            "time": "2019-08-26T08:26:39+00:00"
+            "time": "2019-11-05T15:00:49+00:00"
         },
         {
             "name": "symfony/polyfill-ctype",
@@ -2049,16 +2050,16 @@
         },
         {
             "name": "symfony/service-contracts",
-            "version": "v1.1.6",
+            "version": "v1.1.8",
             "source": {
                 "type": "git",
                 "url": "https://github.com/symfony/service-contracts.git",
-                "reference": "ea7263d6b6d5f798b56a45a5b8d686725f2719a3"
+                "reference": "ffc7f5692092df31515df2a5ecf3b7302b3ddacf"
             },
             "dist": {
                 "type": "zip",
-                "url": "https://api.github.com/repos/symfony/service-contracts/zipball/ea7263d6b6d5f798b56a45a5b8d686725f2719a3",
-                "reference": "ea7263d6b6d5f798b56a45a5b8d686725f2719a3",
+                "url": "https://api.github.com/repos/symfony/service-contracts/zipball/ffc7f5692092df31515df2a5ecf3b7302b3ddacf",
+                "reference": "ffc7f5692092df31515df2a5ecf3b7302b3ddacf",
                 "shasum": ""
             },
             "require": {
@@ -2103,7 +2104,7 @@
                 "interoperability",
                 "standards"
             ],
-            "time": "2019-08-20T14:44:19+00:00"
+            "time": "2019-10-14T12:27:06+00:00"
         },
         {
             "name": "theseer/tokenizer",

+ 109 - 0
tests/tripal_chado/api/TripalChadoFeatureAPITest.php

@@ -0,0 +1,109 @@
+<?php
+namespace Tests\tripal_chado\api;
+
+use StatonLab\TripalTestSuite\DBTransaction;
+use StatonLab\TripalTestSuite\TripalTestCase;
+
+class TripalChadoFeatureAPITest extends TripalTestCase {
+  // Uncomment to auto start and rollback db transactions per test method.
+  use DBTransaction;
+
+  /**
+   * Tests chado_get_feature_sequences().
+   *
+   * @group tripal_chado_api
+   * @group feature-module
+   */
+  public function testChadoGetFeatureSeqs() {
+
+    // Preparation... Create the features.
+    $base_seq = 'GGG' . str_repeat('A', 25) . str_repeat('G', 10) . str_repeat('C', 50) . 'GGG';
+    $base_feature = factory('chado.feature')->create([
+      'residues' => $base_seq,
+    ]);
+    // Create two derived features matching the region of AAA's.
+    $mRNA_feature = factory('chado.feature')->create([
+      'residues' => '',
+    ]);
+    chado_insert_record('featureloc', [
+      'feature_id' => $mRNA_feature->feature_id,
+      'srcfeature_id' => $base_feature->feature_id,
+      'fmin' => 3,
+      'fmax' => (3 + 25),
+      'strand' => 1,
+      'rank' => 0,
+    ]);
+    chado_insert_record('featureloc', [
+      'feature_id' => $mRNA_feature->feature_id,
+      'srcfeature_id' => $base_feature->feature_id,
+      'fmin' => (3 + 25 + 10),
+      'fmax' => (3 + 25 + 10 + 50),
+      'strand' => 1,
+      'rank' => 1,
+    ]);
+
+    // Make sure we can retrieve the correct sequence for the base feature.
+    $returned_seq_results = chado_get_feature_sequences([
+      'feature_id' => $base_feature->feature_id
+    ], ['is_html' => FALSE, 'width' => 100]);
+
+    $this->assertCount(1, $returned_seq_results, "There should only be the base sequence returned.");
+
+    $returned_seq = $returned_seq_results[0]['residues'];
+    $this->assertEquals($base_seq, $returned_seq, "The returned sequence did not match the base sequence we created the feature with.");
+
+    // Now check we can get the derived sequence based using the mRNA.
+    $returned_seq_results = chado_get_feature_sequences([
+      'feature_id' => $mRNA_feature->feature_id
+    ], ['is_html' => FALSE, 'width' => 100, 'derive_from_parent' => 1]);
+    $this->assertCount(2, $returned_seq_results, 'We added two locations therefore we should have two returned sequences.');
+    $this->assertEquals(
+      str_repeat('A', 25),
+      $returned_seq_results[0]['residues'],
+      'The first region located on the base was not returned correctly.'
+    );
+    $this->assertEquals(
+      str_repeat('C', 50),
+      $returned_seq_results[1]['residues'],
+      'The second region located on the base was not returned correctly.'
+    );
+
+    // Now change our featurelocs to be on the negative strand.
+    // Note: fmin/fmax do not change because they are always the leftmost not
+    // necessarily the start or 5' end.
+    chado_delete_record('featureloc',
+      ['srcfeature_id' => $base_feature->feature_id]);
+    chado_insert_record('featureloc', [
+      'feature_id' => $mRNA_feature->feature_id,
+      'srcfeature_id' => $base_feature->feature_id,
+      'fmin' => 3,
+      'fmax' => (3 + 25),
+      'strand' => -1,
+      'rank' => 0,
+    ]);
+    chado_insert_record('featureloc', [
+      'feature_id' => $mRNA_feature->feature_id,
+      'srcfeature_id' => $base_feature->feature_id,
+      'fmin' => (3 + 25 + 10),
+      'fmax' => (3 + 25 + 10 + 50),
+      'strand' => -1,
+      'rank' => 1,
+    ]);
+
+    // Now check we can get the derived sequence based using the negative mRNA.
+    $returned_seq_results = chado_get_feature_sequences([
+      'feature_id' => $mRNA_feature->feature_id
+    ], ['is_html' => FALSE, 'width' => 100, 'derive_from_parent' => 1]);
+    $this->assertCount(2, $returned_seq_results, 'We added two locations therefore we should have two returned sequences.');
+    $this->assertEquals(
+      str_repeat('G', 50),
+      $returned_seq_results[0]['residues'],
+      'The first region located on the base was not returned correctly.'
+    );
+    $this->assertEquals(
+      str_repeat('T', 25),
+      $returned_seq_results[1]['residues'],
+      'The second region located on the base was not returned correctly.'
+    );
+  }
+}