Merge commit 'alpha/update_2_12_for_2_11_2_series_merge^2' into HEAD
[jalview.git] / src / jalview / ws / dbsources / Uniprot.java
index b9fe52f..0775870 100644 (file)
@@ -21,7 +21,6 @@
 package jalview.ws.dbsources;
 
 import java.util.Locale;
-
 import jalview.bin.Cache;
 import jalview.datamodel.Alignment;
 import jalview.datamodel.AlignmentI;
@@ -71,6 +70,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
@@ -104,7 +104,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;
   }
 
   /*
@@ -154,18 +159,14 @@ public class Uniprot extends DbSourceProxyImpl
       // use/backoff logic to retry when the server tells us to go away
       if (urlconn.getResponseCode() == 200)
       {
-        InputStream istr = urlconn.getInputStream();
-        List<Entry> entries = getUniprotEntries(istr);
-        if (entries != null)
+        List<SequenceI> seqs = new ArrayList<>();
+        for (Entry entry : entries)
         {
-          List<SequenceI> seqs = new ArrayList<>();
-          for (Entry entry : entries)
-          {
-            seqs.add(uniprotEntryToSequence(entry));
-          }
-          al = new Alignment(seqs.toArray(new SequenceI[seqs.size()]));
+          seqs.add(uniprotEntryToSequence(entry));
         }
+        al = new Alignment(seqs.toArray(new SequenceI[seqs.size()]));
       }
+
       stopQuery();
       return al;