Jalview-JS/JAL-3253-applet also comments relating to JAL-3268
[jalview.git] / src / jalview / ext / ensembl / EnsemblGene.java
index 7648536..63a6a6c 100644 (file)
@@ -34,6 +34,7 @@ import jalview.io.gff.SequenceOntologyI;
 import jalview.schemes.FeatureColour;
 import jalview.schemes.FeatureSettingsAdapter;
 import jalview.util.MapList;
+import jalview.util.Platform;
 
 import java.awt.Color;
 import java.io.UnsupportedEncodingException;
@@ -55,7 +56,7 @@ public class EnsemblGene extends EnsemblSeqProxy
    * accepts anything as we will attempt lookup of gene or 
    * transcript id or gene name
    */
-  private static final Regex ACCESSION_REGEX = new Regex(".*");
+  private static Regex ACCESSION_REGEX;
 
   private static final EnsemblFeatureType[] FEATURES_TO_FETCH = {
       EnsemblFeatureType.gene, EnsemblFeatureType.transcript,
@@ -138,7 +139,6 @@ public class EnsemblGene extends EnsemblSeqProxy
      * convert to a non-duplicated list of gene identifiers
      */
     List<String> geneIds = getGeneIds(query);
-
     AlignmentI al = null;
     for (String geneId : geneIds)
     {
@@ -155,9 +155,7 @@ public class EnsemblGene extends EnsemblSeqProxy
       {
         // ensure id has 'correct' case for the Ensembl identifier
         geneId = geneAlignment.getSequenceAt(0).getName();
-
         findGeneLoci(geneAlignment.getSequenceAt(0), geneId);
-
         getTranscripts(geneAlignment, geneId);
       }
       if (al == null)
@@ -539,10 +537,11 @@ public class EnsemblGene extends EnsemblSeqProxy
   @Override
   public String getTestQuery()
   {
-    return "ENSG00000157764"; // BRAF, 5 transcripts, reverse strand
+    return Platform.isJS() ? "ENSG00000123569" : "ENSG00000157764";
+    // ENSG00000123569 // H2BFWT histone, 2 transcripts, reverse strand
+    // ENSG00000157764 // BRAF, 5 transcripts, reverse strand
     // ENSG00000090266 // NDUFB2, 15 transcripts, forward strand
     // ENSG00000101812 // H2BFM histone, 3 transcripts, forward strand
-    // ENSG00000123569 // H2BFWT histone, 2 transcripts, reverse strand
   }
 
   /**
@@ -578,7 +577,7 @@ public class EnsemblGene extends EnsemblSeqProxy
   @Override
   protected boolean retainFeature(SequenceFeature sf, String accessionId)
   {
-    SequenceOntologyI so = SequenceOntologyFactory.getInstance();
+    SequenceOntologyI so = SequenceOntologyFactory.getSequenceOntology();
     String type = sf.getType();
     if (so.isA(type, SequenceOntologyI.GENE))
     {
@@ -607,6 +606,10 @@ public class EnsemblGene extends EnsemblSeqProxy
   @Override
   public Regex getAccessionValidator()
   {
+    if (ACCESSION_REGEX == null)
+    {
+      ACCESSION_REGEX = Platform.newRegex(".*", null);
+    }
     return ACCESSION_REGEX;
   }
 
@@ -625,7 +628,7 @@ public class EnsemblGene extends EnsemblSeqProxy
   {
     return new FeatureSettingsAdapter()
     {
-      SequenceOntologyI so = SequenceOntologyFactory.getInstance();
+      SequenceOntologyI so = SequenceOntologyFactory.getSequenceOntology();
 
       @Override
       public boolean isFeatureDisplayed(String type)