JAL-2629 manual curation of HMMs via reference annotation functional
authorTZVanaalten <TZVanaalten@LS30916.ad.lifesci.dundee.ac.uk>
Fri, 1 Sep 2017 14:18:09 +0000 (15:18 +0100)
committerTZVanaalten <TZVanaalten@LS30916.ad.lifesci.dundee.ac.uk>
Fri, 1 Sep 2017 14:18:09 +0000 (15:18 +0100)
src/jalview/hmmer/HMMAlignThread.java
src/jalview/hmmer/HMMBuildThread.java
src/jalview/hmmer/HMMERCommands.java
src/jalview/hmmer/HMMSearchThread.java
src/jalview/io/StockholmFile.java
src/jalview/viewmodel/AlignmentViewport.java

index 532271b..5eec1c4 100644 (file)
@@ -125,7 +125,7 @@ public class HMMAlignThread implements Runnable
         try
         {
           cmds.exportData(seqs, outTemp.getAbsoluteFile(), hmm,
-                  hmmTemp.getAbsoluteFile());
+                hmmTemp.getAbsoluteFile(), null);
         } catch (IOException e1)
         {
           e1.printStackTrace();
index f940fbb..2fdc97b 100644 (file)
@@ -234,7 +234,16 @@ public class HMMBuildThread implements Runnable
           }
 
           cmds.uniquifySequences(newArr);
-          cmds.exportData(newArr, stoTemp, null, null);
+
+        if (forGroup)
+        {
+          cmds.exportData(newArr, stoTemp, null, null, group);
+        }
+        else
+        {
+          cmds.exportData(newArr, stoTemp, null, null, alignment);
+        }
+
           jalview.analysis.SeqsetUtils.deuniquify(cmds.hash, array);
 
       } catch (FileNotFoundException e)
@@ -330,8 +339,11 @@ public class HMMBuildThread implements Runnable
     {
         if (af != null)
         {
+        if (af.getTitle().length() < 15)
+        {
           name = af.getTitle();
         }
+        }
         if (name == null || "".equals(name))
         {
           name = "Alignment";
@@ -362,7 +374,8 @@ public class HMMBuildThread implements Runnable
    */
   private void importData() throws IOException, InterruptedException
   {
-      HMMFile file = new HMMFile(new FileParse(hmmTemp.getAbsolutePath(),
+    HMMFile file = new HMMFile(
+            new FileParse(hmmTemp.getAbsolutePath(),
               DataSourceType.FILE));
     SequenceI[] seqs = file.getSeqsAsArray();
     SequenceI seq = seqs[0];
index ba4c57b..4c1748b 100644 (file)
@@ -1,7 +1,9 @@
 package jalview.hmmer;
 
 import jalview.datamodel.Alignment;
+import jalview.datamodel.AlignmentAnnotation;
 import jalview.datamodel.AlignmentI;
+import jalview.datamodel.AnnotatedCollectionI;
 import jalview.datamodel.HiddenMarkovModel;
 import jalview.datamodel.SequenceI;
 import jalview.gui.AlignFrame;
@@ -128,12 +130,24 @@ public class HMMERCommands
    * @throws IOException
    */
   public void exportData(SequenceI[] seqs,
-          File stoLocation, HiddenMarkovModel hmm, File hmmLocation)
+          File stoLocation, HiddenMarkovModel hmm, File hmmLocation,
+          AnnotatedCollectionI al)
           throws IOException
   {
     if (seqs != null)
     {
-      StockholmFile file = new StockholmFile(new Alignment(seqs));
+      AlignmentI newAl = new Alignment(seqs);
+      if (stoLocation != null)
+      {
+        for (AlignmentAnnotation annot : al.getAlignmentAnnotation())
+        {
+          if (annot.label.contains("Reference") || "RF".equals(annot.label))
+          {
+            newAl.addAnnotation(annot);
+          }
+        }
+      }
+      StockholmFile file = new StockholmFile(newAl);
       String output = file.print(seqs, false);
       PrintWriter writer = new PrintWriter(stoLocation);
       writer.println(output);
index 4012cfe..8adeb22 100644 (file)
@@ -118,7 +118,7 @@ public class HMMSearchThread implements Runnable
     }
     try
     {
-      cmds.exportData(null, null, hmm, hmmTemp.getAbsoluteFile());
+      cmds.exportData(null, null, hmm, hmmTemp.getAbsoluteFile(), null);
     } catch (IOException e1)
     {
       e1.printStackTrace();
index 3644ff9..efd45eb 100644 (file)
@@ -1069,6 +1069,10 @@ public class StockholmFile extends AlignFile
           {
             label = aa.label;
           }
+          else if ("RF".equals(key))
+          {
+            label = key;
+          }
           else
           {
             label = key + "_cons";
index c2c2c5d..9b4e1fe 100644 (file)
@@ -3146,7 +3146,7 @@ public abstract class AlignmentViewport
     AlignmentAnnotation[] annots = this.alignment.getAlignmentAnnotation();
     for (AlignmentAnnotation annot : annots)
     {
-      if ("RF".equals(annot.getCalcId()))
+      if ("RF".equals(annot.label) || annot.label.contains("Reference"))
       {
         return true;
       }