Browse Source

Tag value unit test added

Risharde Ramnath 4 years ago
parent
commit
085cf9eabd

+ 4 - 0
tests/tripal_chado/data/gff_tagvalue_unescaped_character.gff

@@ -0,0 +1,4 @@
+##gff-version 3
+Contig0	FRAEX38873_v2	gene	16315	44054	.	+	.	ID=FRAEX38873_v2_000000010;TEST=T,EST;Name=FRAEX38873_v2_000000010;biotype=protein_coding
+Contig0	FRAEX38873_v2	mRNA	16315	44054	.	+	.	ID=FRAEX38873_v2_000000010.1;Parent=FRAEX38873_v2_000000010;Name=FRAEX38873_v2_000000010.1;biotype=protein_coding;AED=0.05
+Contig0	FRAEX38873_v2	polypeptide	16315	44054	.	+	.	ID=FRAEX38873_v2_000000010.1.3_test_protein;Parent=FRAEX38873_v2_000000010.1

+ 44 - 3
tests/tripal_chado/loaders/GFF3ImporterTest.php

@@ -52,9 +52,9 @@ class GFF3ImporterTest extends TripalTestCase {
   }
 
   /**
-   * Run the GFF loader on gff_unescaped_ids.gff for testing.
+   * Run the GFF loader on gff_tag_unescaped_character.gff for testing.
    *
-   * This tests whether the GFF loader adds IDs that contain whitespaces. 
+   * This tests whether the GFF loader adds IDs that contain a comma. 
    * The GFF loader should allow it
    */  
   public function testGFFImporterUnescapedTagWithComma() {
@@ -92,9 +92,50 @@ class GFF3ImporterTest extends TripalTestCase {
     }
 
     $this->assertEquals($hasException, true);
-
   }
 
+  /**
+   * Run the GFF loader on gff_tagvalue_unescaped_character.gff for testing.
+   *
+   * This tests whether the GFF loader adds IDs that contain a comma. 
+   * The GFF loader should allow it
+   */  
+  public function testGFFImporterUnescapedTagValueWithComma() {
+    $gff_file = ['file_local' => __DIR__ . '/../data/gff_tagvalue_unescaped_character.gff'];
+    $analysis = factory('chado.analysis')->create();
+    $organism = factory('chado.organism')->create();
+    $run_args = [
+      'analysis_id' => $analysis->analysis_id,
+      'organism_id' => $organism->organism_id,
+      'use_transaction' => 1,
+      'add_only' => 0,
+      'update' => 1,
+      'create_organism' => 0,
+      'create_target' => 0,
+      // regexps for mRNA and protein.
+      're_mrna' => NULL,
+      're_protein' => NULL,
+      // optional
+      'target_organism_id' => NULL,
+      'target_type' => NULL,
+      'start_line' => NULL,
+      'landmark_type' => NULL,
+      'alt_id_attr' => NULL,
+    ];
+
+  
+    $this->loadLandmarks($analysis, $organism);
+    // This should throw an error based on the tag name having the comma
+    $hasException = false;
+    try {
+      $this->runGFFLoader($run_args, $gff_file);
+    }
+    catch (\Exception $ex) {
+      $hasException = true;
+    }
+
+    $this->assertEquals($hasException, true);
+  }
 
   /**
    * Run the GFF loader on gff_seqid_invalid_character.gff for testing.