import jalview.datamodel.Alignment;
import jalview.datamodel.AlignmentAnnotation;
import jalview.datamodel.AlignmentI;
-import jalview.datamodel.Annotation;
import jalview.datamodel.HiddenMarkovModel;
import jalview.datamodel.SequenceI;
import jalview.gui.AlignFrame;
+import jalview.gui.Desktop;
import jalview.gui.JvOptionPane;
import jalview.io.DataSourceType;
import jalview.io.FileParse;
SequenceI[] seqs;
+ private String databaseName;
+
/**
* Constructor for the HMMSearchThread
*
return;
}
- SequenceI hmmSeq = hmm.getConsensusSequence();// af.getSelectedHMMSequence();
+ SequenceI hmmSeq = hmm.getConsensusSequence();
long msgId = System.currentTimeMillis();
af.setProgressBar(MessageManager.getString("status.running_hmmsearch"),
msgId);
String domEvalueCutoff = null;
String seqScoreCutoff = null;
String domScoreCutoff = null;
+ databaseName = "Alignment";
if (params != null)
{
else if (MessageManager.getString(AUTO_ALIGN_SEQS_KEY)
.equals(name))
{
- realign = true; // TODO: not used
+ realign = true;
}
else if (MessageManager.getString(USE_ACCESSIONS_KEY)
.equals(name))
if (!MessageManager.getString(THIS_ALIGNMENT_KEY)
.equals(dbPath))
{
+ int pos = dbPath.lastIndexOf(File.separator);
+ databaseName = dbPath.substring(pos + 1);
databaseFile = new File(dbPath);
}
}
/**
* Imports the data from the temporary file to which the output of hmmsearch
- * is directed.
+ * was directed. The results are optionally realigned using hmmalign.
*
* @param hmmSeq
*/
hmmAndSeqs[0] = hmmSeq;
System.arraycopy(seqs, 0, hmmAndSeqs, 1, seqCount);
- /*
- * and align the search results to the HMM profile
- */
- AlignmentI al = new Alignment(hmmAndSeqs);
- AlignFrame frame = new AlignFrame(al, 1, 1);
- List<ArgumentI> alignArgs = new ArrayList<>();
- String defSeq = hmmSeq.getName();
- List<String> options = Collections.singletonList(defSeq);
- Option option = new Option(MessageManager.getString("label.use_hmm"),
- "", true, defSeq, defSeq, options, null);
- alignArgs.add(option);
- if (trim)
+ if (realign)
+ {
+ realignResults(hmmAndSeqs);
+ }
+ else
{
- alignArgs.add(new BooleanOption(
- MessageManager.getString(TRIM_TERMINI_KEY),
- MessageManager.getString("label.trim_termini_desc"), true,
- true, true, null));
+ AlignmentI al = new Alignment(hmmAndSeqs);
+ AlignFrame alignFrame = new AlignFrame(al, AlignFrame.DEFAULT_WIDTH,
+ AlignFrame.DEFAULT_HEIGHT);
+ String ttl = "hmmSearch of " + databaseName + " using "
+ + hmmSeq.getName();
+ Desktop.addInternalFrame(alignFrame, ttl, AlignFrame.DEFAULT_WIDTH,
+ AlignFrame.DEFAULT_HEIGHT);
}
- HmmerCommand hmmalign = new HMMAlign(frame, alignArgs);
- hmmalign.run();
- frame = null;
+
hmmTemp.delete();
inputAlignmentTemp.delete();
searchOutputFile.delete();
}
}
+ /**
+ * Realigns the given sequences using hmmalign, to the HMM profile sequence
+ * which is the first in the array, and opens the results in a new frame
+ *
+ * @param hmmAndSeqs
+ */
+ protected void realignResults(SequenceI[] hmmAndSeqs)
+ {
+ /*
+ * and align the search results to the HMM profile
+ */
+ AlignmentI al = new Alignment(hmmAndSeqs);
+ AlignFrame frame = new AlignFrame(al, 1, 1);
+ List<ArgumentI> alignArgs = new ArrayList<>();
+ String alignTo = hmmAndSeqs[0].getName();
+ List<String> options = Collections.singletonList(alignTo);
+ Option option = new Option(MessageManager.getString("label.use_hmm"),
+ "", true, alignTo, alignTo, options, null);
+ alignArgs.add(option);
+ if (trim)
+ {
+ alignArgs.add(new BooleanOption(
+ MessageManager.getString(TRIM_TERMINI_KEY),
+ MessageManager.getString("label.trim_termini_desc"), true,
+ true, true, null));
+ }
+ HmmerCommand hmmalign = new HMMAlign(frame, alignArgs);
+ hmmalign.run();
+ }
+
+ /**
+ * Reads in the scores table output by hmmsearch and adds annotation to
+ * sequences for E-value and bit score
+ *
+ * @param inputTableTemp
+ * @throws IOException
+ */
void readTable(File inputTableTemp) throws IOException
{
BufferedReader br = new BufferedReader(new FileReader(inputTableTemp));
Scanner scanner = new Scanner(line);
String str = scanner.next(); // full sequence eValue score
- float eValue = Float.parseFloat(str);
- int seqLength = seqs[index].getLength();
- Annotation[] annots = new Annotation[seqLength];
- for (int j = 0; j < seqLength; j++)
- {
- annots[j] = new Annotation(eValue);
- }
+ // float eValue = Float.parseFloat(str);
+ // int seqLength = seqs[index].getLength();
+ // Annotation[] annots = new Annotation[seqLength];
+ // for (int j = 0; j < seqLength; j++)
+ // {
+ // annots[j] = new Annotation(eValue);
+ // }
AlignmentAnnotation annot = new AlignmentAnnotation("E-value",
- "Score", annots);
- annot.setScore(Double.parseDouble(str));
+ "Score", null);
+ annot.setCalcId(HMMSEARCH);
+ double eValue = Double.parseDouble(str);
+ annot.setScore(eValue);
annot.setSequenceRef(seqs[index]);
seqs[index].addAlignmentAnnotation(annot);