Merge branch 'develop' into bug/JAL-2255_seq-fetcher-broken-on-linux
[jalview.git] / src / jalview / ws / jws1 / JPredThread.java
index 8299e3c..e685d00 100644 (file)
@@ -21,6 +21,7 @@
 package jalview.ws.jws1;
 
 import jalview.analysis.AlignSeq;
+import jalview.analysis.SeqsetUtils;
 import jalview.bin.Cache;
 import jalview.datamodel.Alignment;
 import jalview.datamodel.AlignmentAnnotation;
@@ -31,7 +32,13 @@ import jalview.datamodel.SequenceI;
 import jalview.gui.AlignFrame;
 import jalview.gui.Desktop;
 import jalview.gui.WebserviceInfo;
+import jalview.io.DataSourceType;
+import jalview.io.FileFormatI;
 import jalview.io.FormatAdapter;
+import jalview.io.IdentifyFile;
+import jalview.io.JPredFile;
+import jalview.io.JnetAnnotationMaker;
+import jalview.io.PileUpfile;
 import jalview.util.Comparison;
 import jalview.util.MessageManager;
 import jalview.ws.AWsJob;
@@ -71,6 +78,7 @@ class JPredThread extends JWS1Thread implements WSClientI
      * @return true if getResultSet will return a valid alignment and prediction
      *         result.
      */
+    @Override
     public boolean hasResults()
     {
       if (subjobComplete && result != null && result.isFinished()
@@ -82,6 +90,7 @@ class JPredThread extends JWS1Thread implements WSClientI
       return false;
     }
 
+    @Override
     public boolean hasValidInput()
     {
       if (sequence != null)
@@ -110,23 +119,23 @@ class JPredThread extends JWS1Thread implements WSClientI
 
       JpredResult result = (JpredResult) this.result;
 
-      jalview.bin.Cache.log.debug("Parsing output from JNet job.");
+      Cache.log.debug("Parsing output from JNet job.");
       // JPredFile prediction = new JPredFile("C:/JalviewX/files/jpred.txt",
       // "File");
-      jalview.io.JPredFile prediction = new jalview.io.JPredFile(
-              result.getPredfile(), "Paste");
+      JPredFile prediction = new JPredFile(
+              result.getPredfile(), DataSourceType.PASTE);
       SequenceI[] preds = prediction.getSeqsAsArray();
-      jalview.bin.Cache.log.debug("Got prediction profile.");
+      Cache.log.debug("Got prediction profile.");
 
       if ((this.msa != null) && (result.getAligfile() != null))
       {
-        jalview.bin.Cache.log.debug("Getting associated alignment.");
+        Cache.log.debug("Getting associated alignment.");
         // we ignore the returned alignment if we only predicted on a single
         // sequence
-        String format = new jalview.io.IdentifyFile().identify(
-                result.getAligfile(), "Paste");
+        FileFormatI format = new IdentifyFile().identify(
+                result.getAligfile(), DataSourceType.PASTE);
 
-        if (jalview.io.FormatAdapter.isValidFormat(format))
+        if (format != null)
         {
           SequenceI sqs[];
           if (predMap != null)
@@ -140,14 +149,14 @@ class JPredThread extends JWS1Thread implements WSClientI
           else
           {
             al = new FormatAdapter().readFile(result.getAligfile(),
-                    "Paste", format);
+                    DataSourceType.PASTE, format);
             sqs = new SequenceI[al.getHeight()];
 
             for (int i = 0, j = al.getHeight(); i < j; i++)
             {
               sqs[i] = al.getSequenceAt(i);
             }
-            if (!jalview.analysis.SeqsetUtils.deuniquify(SequenceInfo, sqs))
+            if (!SeqsetUtils.deuniquify(SequenceInfo, sqs))
             {
               throw (new Exception(
                       MessageManager
@@ -164,15 +173,15 @@ class JPredThread extends JWS1Thread implements WSClientI
           {
             al.setDataset(null);
           }
-          jalview.io.JnetAnnotationMaker.add_annotation(prediction, al,
+          JnetAnnotationMaker.add_annotation(prediction, al,
                   FirstSeq, false, predMap);
 
         }
         else
         {
           throw (new Exception(MessageManager.formatMessage(
-                  "exception.unknown_format_for_file", new String[] {
-                      format, result.getAligfile() })));
+                  "exception.unknown_format_for_file", new String[] { "",
+                      result.getAligfile() })));
         }
       }
       else
@@ -355,8 +364,8 @@ class JPredThread extends JWS1Thread implements WSClientI
         if (msf.length > 1)
         {
           msa = new vamsas.objects.simple.Msfalignment();
-          jalview.io.PileUpfile pileup = new jalview.io.PileUpfile();
-          msa.setMsf(pileup.print(msf));
+          PileUpfile pileup = new PileUpfile();
+          msa.setMsf(pileup.print(msf, true));
         }
       }
     }
@@ -420,6 +429,7 @@ class JPredThread extends JWS1Thread implements WSClientI
     }
   }
 
+  @Override
   public void StartJob(AWsJob j)
   {
     if (!(j instanceof JPredJob))
@@ -502,6 +512,7 @@ class JPredThread extends JWS1Thread implements WSClientI
     }
   }
 
+  @Override
   public void parseResult()
   {
     int results = 0; // number of result sets received
@@ -529,6 +540,7 @@ class JPredThread extends JWS1Thread implements WSClientI
       wsInfo.showResultsNewFrame
               .addActionListener(new java.awt.event.ActionListener()
               {
+                @Override
                 public void actionPerformed(java.awt.event.ActionEvent evt)
                 {
                   displayResults(true);
@@ -537,6 +549,7 @@ class JPredThread extends JWS1Thread implements WSClientI
       wsInfo.mergeResults
               .addActionListener(new java.awt.event.ActionListener()
               {
+                @Override
                 public void actionPerformed(java.awt.event.ActionEvent evt)
                 {
                   displayResults(false);
@@ -652,21 +665,25 @@ class JPredThread extends JWS1Thread implements WSClientI
     }
   }
 
+  @Override
   public void pollJob(AWsJob job) throws Exception
   {
     ((JPredJob) job).result = server.getresult(job.getJobId());
   }
 
+  @Override
   public boolean isCancellable()
   {
     return false;
   }
 
+  @Override
   public void cancelJob()
   {
     throw new Error(MessageManager.getString("error.implementation_error"));
   }
 
+  @Override
   public boolean canMergeResults()
   {
     return false;