JAL-4102 update 2.12 from 2.11.2.6 patch release - JAL-3416 JAL-2353 JAL-4104 JAL...
[jalview.git] / src / jalview / ws / dbsources / Uniprot.java
index c9db7f2..7c8e4ef 100644 (file)
@@ -48,6 +48,7 @@ import jalview.datamodel.Sequence;
 import jalview.datamodel.SequenceFeature;
 import jalview.datamodel.SequenceI;
 import jalview.schemes.ResidueProperties;
+import jalview.util.Platform;
 import jalview.util.StringUtils;
 import jalview.ws.seqfetcher.DbSourceProxyImpl;
 import jalview.xml.binding.uniprot.DbReferenceType;
@@ -70,6 +71,7 @@ public class Uniprot extends DbSourceProxyImpl
   private static final String DEFAULT_UNIPROT_DOMAIN = "https://www.uniprot.org";
 
   private static final String BAR_DELIMITER = "|";
+  private static Regex ACCESSION_REGEX;
 
   /**
    * Constructor
@@ -103,7 +105,12 @@ public class Uniprot extends DbSourceProxyImpl
   @Override
   public Regex getAccessionValidator()
   {
-    return new Regex("([A-Z]+[0-9]+[A-Z0-9]+|[A-Z0-9]+_[A-Z0-9]+)");
+    if (ACCESSION_REGEX == null)
+    {
+      ACCESSION_REGEX = Platform
+              .newRegex("([A-Z]+[0-9]+[A-Z0-9]+|[A-Z0-9]+_[A-Z0-9]+)");
+    }
+    return ACCESSION_REGEX;
   }
 
   /*
@@ -164,6 +171,7 @@ public class Uniprot extends DbSourceProxyImpl
           al = new Alignment(seqs.toArray(new SequenceI[seqs.size()]));
         }
       }
+
       stopQuery();
       return al;
 
@@ -249,6 +257,7 @@ public class Uniprot extends DbSourceProxyImpl
           dbRefs.add(dbr);
         }
       }
+      // from 2.11.2.6 - probably see a conflict here
       if (type != null
               && type.toLowerCase(Locale.ROOT).startsWith("ensembl"))
       {