JAL-2629 formatting only
authorgmungoc <g.m.carstairs@dundee.ac.uk>
Mon, 19 Feb 2018 10:19:19 +0000 (10:19 +0000)
committergmungoc <g.m.carstairs@dundee.ac.uk>
Mon, 19 Feb 2018 10:19:19 +0000 (10:19 +0000)
src/jalview/hmmer/HMMAlignThread.java
src/jalview/hmmer/HMMBuildThread.java
src/jalview/hmmer/HMMERCommands.java
src/jalview/hmmer/HMMERParamStore.java
src/jalview/hmmer/HMMSearchThread.java

index 5eec1c4..168e3f9 100644 (file)
@@ -107,53 +107,52 @@ public class HMMAlignThread implements Runnable
     af.setProgressBar(MessageManager.getString("status.running_hmmalign"),
             barID);
     cmds.HMMERFOLDER = Cache.getProperty(Preferences.HMMER_PATH);
-      prepareAlignment();
-      SequenceI[][] subAlignments = msa.getVisibleContigs('-');
-      allOrders = new ArrayList<>();
-      allResults = new SequenceI[subAlignments.length][];
-      int job = 0;
-      for (SequenceI[] seqs : subAlignments)
+    prepareAlignment();
+    SequenceI[][] subAlignments = msa.getVisibleContigs('-');
+    allOrders = new ArrayList<>();
+    allResults = new SequenceI[subAlignments.length][];
+    int job = 0;
+    for (SequenceI[] seqs : subAlignments)
+    {
+      cmds.uniquifySequences(seqs);
+      try
       {
-        cmds.uniquifySequences(seqs);
-        try
-        {
-          createTemporaryFiles();
-        } catch (IOException e2)
-        {
-          e2.printStackTrace();
-        }
-        try
-        {
-          cmds.exportData(seqs, outTemp.getAbsoluteFile(), hmm,
+        createTemporaryFiles();
+      } catch (IOException e2)
+      {
+        e2.printStackTrace();
+      }
+      try
+      {
+        cmds.exportData(seqs, outTemp.getAbsoluteFile(), hmm,
                 hmmTemp.getAbsoluteFile(), null);
-        } catch (IOException e1)
-        {
-          e1.printStackTrace();
-        }
-        try
-        {
-          boolean ran = runCommand();
-          if (!ran)
-          {
-            JvOptionPane.showInternalMessageDialog(af,
-                    MessageManager.getString("warn.hmmalign_failed"));
-            return;
-          }
-        } catch (IOException | InterruptedException e)
-        {
-          e.printStackTrace();
-        }
-        try
-        {
-          importData(job);
-        } catch (IOException | InterruptedException e)
+      } catch (IOException e1)
+      {
+        e1.printStackTrace();
+      }
+      try
+      {
+        boolean ran = runCommand();
+        if (!ran)
         {
-          // TODO Auto-generated catch block
-          e.printStackTrace();
+          JvOptionPane.showInternalMessageDialog(af,
+                  MessageManager.getString("warn.hmmalign_failed"));
+          return;
         }
-        job++;
+      } catch (IOException | InterruptedException e)
+      {
+        e.printStackTrace();
       }
-
+      try
+      {
+        importData(job);
+      } catch (IOException | InterruptedException e)
+      {
+        // TODO Auto-generated catch block
+        e.printStackTrace();
+      }
+      job++;
+    }
 
     displayResults(newFrame);
 
@@ -270,8 +269,7 @@ public class HMMAlignThread implements Runnable
   {
     AlignmentOrder[] arrOrders = allOrders
             .toArray(new AlignmentOrder[allOrders.size()]);
-    Object[] newview = msa.getUpdatedView(allResults,
-            arrOrders, '-');
+    Object[] newview = msa.getUpdatedView(allResults, arrOrders, '-');
     SequenceI[] alignment = (SequenceI[]) newview[0];
     HiddenColumns hidden = (HiddenColumns) newview[1];
     Alignment al = new Alignment(alignment);
@@ -430,6 +428,4 @@ public class HMMAlignThread implements Runnable
     }
 
   }
-  }
-
-
+}
index 346bcbd..2262bae 100644 (file)
@@ -1,6 +1,5 @@
 package jalview.hmmer;
 
-
 import jalview.bin.Cache;
 import jalview.datamodel.AlignmentI;
 import jalview.datamodel.HiddenMarkovModel;
@@ -28,15 +27,18 @@ import javax.swing.JOptionPane;
 public class HMMBuildThread implements Runnable
 {
   HMMERCommands cmds = new HMMERCommands();
+
   AlignFrame af;
 
   AlignViewport viewport;
 
   boolean multiJob = false;
+
   AlignmentI alignment;
+
   SequenceGroup group;
-  List<ArgumentI> params;
 
+  List<ArgumentI> params;
 
   boolean forGroup = false;
 
@@ -45,7 +47,7 @@ public class HMMBuildThread implements Runnable
   File stoTemp = null;
 
   long barID;
-  
+
   /**
    * This is used for validation purposes. Do not use!
    * 
@@ -73,8 +75,8 @@ public class HMMBuildThread implements Runnable
     barID = System.currentTimeMillis();
     if (af != null)
     {
-    af.setProgressBar(MessageManager.getString("status.running_hmmbuild"),
-            barID);
+      af.setProgressBar(MessageManager.getString("status.running_hmmbuild"),
+              barID);
     }
     cmds.HMMERFOLDER = Cache.getProperty(Preferences.HMMER_PATH);
 
@@ -163,7 +165,6 @@ public class HMMBuildThread implements Runnable
       }
     }
 
-
     if (af != null)
     {
       af.setProgressBar(MessageManager.getString("status.running_hmmbuild"),
@@ -174,20 +175,20 @@ public class HMMBuildThread implements Runnable
   private void runHMMBuild()
   {
     if (alignment == null && group == null)
-      {
-        JOptionPane.showMessageDialog(af,
+    {
+      JOptionPane.showMessageDialog(af,
               MessageManager.getString("warn.no_sequence_data"));
-      }
-      try
-      {
-        hmmTemp = File.createTempFile("hmm", ".hmm");
-        hmmTemp.deleteOnExit();
-        stoTemp = File.createTempFile("output", ".sto");
-        stoTemp.deleteOnExit();
-      } catch (IOException e1)
-      {
-        e1.printStackTrace();
-      }
+    }
+    try
+    {
+      hmmTemp = File.createTempFile("hmm", ".hmm");
+      hmmTemp.deleteOnExit();
+      stoTemp = File.createTempFile("output", ".sto");
+      stoTemp.deleteOnExit();
+    } catch (IOException e1)
+    {
+      e1.printStackTrace();
+    }
 
     try
     {
@@ -214,26 +215,26 @@ public class HMMBuildThread implements Runnable
           array = alignment.getSequencesArray();
         }
 
-          cmds.setHmmSeqs(seqs);
+        cmds.setHmmSeqs(seqs);
 
         if (array.length < 1)
-          {
+        {
           if (af != null)
           {
             JOptionPane.showMessageDialog(af,
                     MessageManager.getString("warn.no_sequence_data"));
           }
           return;
-          }
-          SequenceI[] newArr = new SequenceI[array.length];
-          int index = 0;
-          for (SequenceI seq : array)
-          {
-            newArr[index] = new Sequence(seq);
-            index++;
-          }
+        }
+        SequenceI[] newArr = new SequenceI[array.length];
+        int index = 0;
+        for (SequenceI seq : array)
+        {
+          newArr[index] = new Sequence(seq);
+          index++;
+        }
 
-          cmds.uniquifySequences(newArr);
+        cmds.uniquifySequences(newArr);
 
         if (forGroup)
         {
@@ -244,7 +245,7 @@ public class HMMBuildThread implements Runnable
           cmds.exportData(newArr, stoTemp, null, null, alignment);
         }
 
-          jalview.analysis.SeqsetUtils.deuniquify(cmds.hash, array);
+        jalview.analysis.SeqsetUtils.deuniquify(cmds.hash, array);
 
       } catch (FileNotFoundException e)
       {
@@ -254,11 +255,11 @@ public class HMMBuildThread implements Runnable
       }
       try
       {
-          boolean ran = runCommand();
-          if (!ran)
-          {
-            return;
-          }
+        boolean ran = runCommand();
+        if (!ran)
+        {
+          return;
+        }
       } catch (IOException | InterruptedException e)
       {
         // TODO Auto-generated catch block
@@ -273,14 +274,12 @@ public class HMMBuildThread implements Runnable
         // TODO Auto-generated catch block
         e.printStackTrace();
       }
-      } catch (Exception e)
-      {
-        e.printStackTrace();
+    } catch (Exception e)
+    {
+      e.printStackTrace();
     }
   }
 
-  
-
   /**
    * Executes the hmmbuild command in the command line.
    * 
@@ -333,20 +332,19 @@ public class HMMBuildThread implements Runnable
       name = group.getName() + "_HMM";
     }
 
-
     if (name == null || "".equals(name))
     {
-        if (af != null)
-        {
+      if (af != null)
+      {
         if (af.getTitle().length() < 15)
         {
           name = af.getTitle();
         }
-        }
-        if (name == null || "".equals(name))
-        {
-          name = "Alignment";
-        }
+      }
+      if (name == null || "".equals(name))
+      {
+        name = "Alignment";
+      }
 
     }
 
@@ -360,11 +358,11 @@ public class HMMBuildThread implements Runnable
       command += cmds.FORCEDNA;
     }
 
-    command += hmmTemp.getAbsolutePath()
-            + cmds.SPACE + stoTemp.getAbsolutePath() + cmds.SPACE;
+    command += hmmTemp.getAbsolutePath() + cmds.SPACE
+            + stoTemp.getAbsolutePath() + cmds.SPACE;
     return cmds.runCommand(command);
   }
-  
+
   /**
    * Imports the .hmm file produced by hmmbuild.
    * 
@@ -374,8 +372,7 @@ public class HMMBuildThread implements Runnable
   private void importData() throws IOException, InterruptedException
   {
     HMMFile file = new HMMFile(
-            new FileParse(hmmTemp.getAbsolutePath(),
-              DataSourceType.FILE));
+            new FileParse(hmmTemp.getAbsolutePath(), DataSourceType.FILE));
     SequenceI[] seqs = file.getSeqsAsArray();
     SequenceI seq = seqs[0];
     seq.createDatasetSequence();
@@ -411,7 +408,7 @@ public class HMMBuildThread implements Runnable
     hmmTemp.delete();
     stoTemp.delete();
   }
-  
+
   /**
    * Runs hmmbuild, and waits for the results to be imported before continuing
    */
index ea795dd..854f0c5 100644 (file)
@@ -31,8 +31,7 @@ public class HMMERCommands
   // Path of hmmer binaries directory
   String HMMERFOLDER = "/Documents/";
 
-  public String JALVIEWDIRECTORY = System.getProperty("user.dir")
-          + "/";
+  public String JALVIEWDIRECTORY = System.getProperty("user.dir") + "/";
 
   public final String HMMALIGN = "/hmmalign ";
 
@@ -91,31 +90,31 @@ public class HMMERCommands
   {
     try
     {
-    final Process p = Runtime.getRuntime().exec(command);
+      final Process p = Runtime.getRuntime().exec(command);
 
-    new Thread(new Runnable()
-    {
-      @Override
-      public void run()
+      new Thread(new Runnable()
       {
-        BufferedReader input = new BufferedReader(
-                new InputStreamReader(p.getInputStream()));
-        String line = null;
-
-        try
+        @Override
+        public void run()
         {
-          while ((line = input.readLine()) != null)
+          BufferedReader input = new BufferedReader(
+                  new InputStreamReader(p.getInputStream()));
+          String line = null;
+
+          try
+          {
+            while ((line = input.readLine()) != null)
+            {
+              System.out.println(line);
+            }
+          } catch (IOException e)
           {
-            System.out.println(line);
+            e.printStackTrace();
           }
-        } catch (IOException e)
-        {
-          e.printStackTrace();
         }
-      }
-    }).start();
+      }).start();
 
-    p.waitFor();
+      p.waitFor();
     } catch (Exception e)
     {
       e.printStackTrace();
@@ -130,9 +129,8 @@ public class HMMERCommands
    * @param alignment
    * @throws IOException
    */
-  public void exportData(SequenceI[] seqs,
-          File stoLocation, HiddenMarkovModel hmm, File hmmLocation,
-          AnnotatedCollectionI al)
+  public void exportData(SequenceI[] seqs, File stoLocation,
+          HiddenMarkovModel hmm, File hmmLocation, AnnotatedCollectionI al)
           throws IOException
   {
     if (seqs != null)
index 11cde90..c23fe02 100644 (file)
@@ -1,6 +1,5 @@
 package jalview.hmmer;
 
-
 import jalview.bin.Cache;
 import jalview.gui.Preferences;
 import jalview.util.MessageManager;
@@ -19,7 +18,6 @@ import java.util.Collection;
 import java.util.List;
 import java.util.Scanner;
 
-
 public class HMMERParamStore implements ParamDatastoreI
 {
 
@@ -117,8 +115,8 @@ public class HMMERParamStore implements ParamDatastoreI
             false, true, null));
     args.add(new LogarithmicParameter(
             MessageManager.getString("label.seq_e_value"),
-            MessageManager.getString("label.seq_e_value_desc"), false,
-            -3d, -37.92977945, 1d, 10d));
+            MessageManager.getString("label.seq_e_value_desc"), false, -3d,
+            -37.92977945, 1d, 10d));
     /*
     args.add(new DoubleParameter(
             MessageManager.getString("label.seq_score"),
@@ -127,8 +125,8 @@ public class HMMERParamStore implements ParamDatastoreI
        */
     args.add(new LogarithmicParameter(
             MessageManager.getString("label.dom_e_value_desc"),
-            MessageManager.getString("label.dom_e_value_desc"), false,
-            -3d, -37.92977945, 1d, 10d));
+            MessageManager.getString("label.dom_e_value_desc"), false, -3d,
+            -37.92977945, 1d, 10d));
     /*
     args.add(new DoubleParameter(
             MessageManager.getString("label.dom_score"),
@@ -138,7 +136,6 @@ public class HMMERParamStore implements ParamDatastoreI
             */
   }
 
-
   private void getHMMAlignParams(List<ArgumentI> args)
   {
     args.add(new BooleanOption(
index 8adeb22..d5baedf 100644 (file)
@@ -63,11 +63,8 @@ public class HMMSearchThread implements Runnable
 
   File databaseFile = null;
 
-
-
   SequenceI[] seqs;
 
-
   /**
    * Constructor for the HMMSearchThread. If create new frame is set to true, a
    * new frame will be created.
@@ -360,7 +357,7 @@ public class HMMSearchThread implements Runnable
             && !"".equals(line))
     {
       Scanner scanner = new Scanner(line);
-    
+
       String str = scanner.next();
       Annotation[] annots = new Annotation[seqs[index].getLength()];
       for (Annotation an : annots)
@@ -372,14 +369,13 @@ public class HMMSearchThread implements Runnable
       annot.setScore(Double.parseDouble(str));
       annot.setSequenceRef(seqs[index]);
       seqs[index].addAlignmentAnnotation(annot);
-    
+
       scanner.close();
       line = br.readLine();
       index++;
     }
-    
+
     br.close();
   }
 
-
 }