JAL-3336 add better method of determining where data table begins
[jalview.git] / src / jalview / hmmer / HMMSearch.java
index 409ef80..57786e5 100644 (file)
@@ -181,9 +181,9 @@ public class HMMSearch extends HmmerCommand
           File hitsAlignmentFile, File hmmFile) throws IOException
   {
     args.add("-o");
-    args.add(getFilePath(searchOutputFile));
+    args.add(getFilePath(searchOutputFile, true));
     args.add("-A");
-    args.add(getFilePath(hitsAlignmentFile));
+    args.add(getFilePath(hitsAlignmentFile, true));
 
     boolean dbFound = false;
     String dbPath = "";
@@ -314,8 +314,8 @@ public class HMMSearch extends HmmerCommand
       exportStockholm(copy.getSequencesArray(), databaseFile, null);
     }
 
-    args.add(getFilePath(hmmFile));
-    args.add(getFilePath(databaseFile));
+    args.add(getFilePath(hmmFile, true));
+    args.add(getFilePath(databaseFile, true));
   }
 
   /**
@@ -365,7 +365,31 @@ public class HMMSearch extends HmmerCommand
       hmmSeq = hmmSeq.deriveSequence(); // otherwise all bad things happen
       hmmAndSeqs[0] = hmmSeq;
       System.arraycopy(seqs, 0, hmmAndSeqs, 1, seqCount);
-
+      if (modelpos != null)
+      {
+        // TODO need - get ungapped sequence method
+        hmmSeq.setSequence(
+                hmmSeq.getDatasetSequence().getSequenceAsString());
+        Annotation[] refpos = modelpos.annotations;
+        // insert gaps to match with refseq positions
+        int gc = 0, lcol = 0;
+        for (int c = 0; c < refpos.length; c++)
+        {
+          if (refpos[c] != null && ("x".equals(refpos[c].displayCharacter)))
+          {
+            if (gc > 0)
+            {
+              hmmSeq.insertCharAt(lcol + 1, gc, '-');
+            }
+            gc = 0;
+            lcol = c;
+          }
+          else
+          {
+            gc++;
+          }
+        }
+      }
       if (realign)
       {
         realignResults(hmmAndSeqs);
@@ -446,10 +470,11 @@ public class HMMSearch extends HmmerCommand
     {
       line = br.readLine();
     }
-    for (int i = 0; i < 5; i++)
+    while (!line.contains("-------"))
     {
       line = br.readLine();
     }
+    line = br.readLine();
 
     int index = 0;
     while (!"  ------ inclusion threshold ------".equals(line)