package jalview.hmmer;
import jalview.bin.Cache;
+import jalview.datamodel.Alignment;
import jalview.datamodel.AlignmentI;
-import jalview.datamodel.AlignmentOrder;
import jalview.datamodel.HiddenMarkovModel;
import jalview.datamodel.SequenceI;
import jalview.gui.AlignFrame;
+import jalview.gui.Desktop;
import jalview.gui.Preferences;
import jalview.io.DataSourceType;
import jalview.io.FileFormat;
import jalview.io.FileLoader;
import jalview.util.MessageManager;
+import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.HashMap;
public class HMMAlignThread implements Runnable
{
+ HMMERCommands cmds = new HMMERCommands();
AlignFrame af;
barID = System.currentTimeMillis();
af.setProgressBar(MessageManager.getString("status.running_hmmbuild"),
barID);
- HMMERCommands.HMMERFOLDER = Cache.getProperty(Preferences.HMMER_PATH);
+ cmds.HMMERFOLDER = Cache.getProperty(Preferences.HMMER_PATH);
+ try
+ {
+ cmds.HMMBUFFER = File.createTempFile("hmm", ".hmm").getAbsolutePath()
+ + cmds.SPACE;
+ cmds.ALIGNMENTBUFFER = File.createTempFile("output", ".sto")
+ .getAbsolutePath() + cmds.SPACE;
+ cmds.ALIGNMENTINPUT = File.createTempFile("input", ".sto")
+ .getAbsolutePath() + cmds.SPACE;
+ cmds.OUTPUTALIGNMENT = "-o " + cmds.ALIGNMENTINPUT + cmds.SPACE;
+ } catch (IOException e1)
+ {
+ // TODO Auto-generated catch block
+ e1.printStackTrace();
+ }
+
try
{
try
{
hmmSeqs = alignment.getHMMConsensusSequences(true);
- HMMERCommands.exportData(alignment, true, true, hmm);
+ cmds.exportData(alignment, true, true, hmm);
} catch (FileNotFoundException e)
{
// TODO Auto-generated catch block
private void runCommand() throws IOException, InterruptedException
{
- String command = HMMERCommands.HMMERFOLDER + HMMERCommands.HMMALIGN;
+ String command = cmds.HMMERFOLDER + cmds.HMMALIGN;
if (!hmm.getFileHeader().contains("HMMER3/f"))
{
- command += HMMERCommands.ALLCOL;
+ command += cmds.ALLCOL;
}
- command += HMMERCommands.TRIM + HMMERCommands.OUTPUTALIGNMENT
- + HMMERCommands.JALVIEWDIRECTORY + HMMERCommands.HMMBUFFER
- + HMMERCommands.JALVIEWDIRECTORY
- + HMMERCommands.ALIGNMENTBUFFER;
- HMMERCommands.runCommand(command);
+ command += cmds.TRIM + cmds.OUTPUTALIGNMENT + cmds.HMMBUFFER
+ + cmds.ALIGNMENTBUFFER;
+ cmds.runCommand(command);
}
private void importData() throws IOException, InterruptedException
if (newFrame)
{
FileLoader loader = new FileLoader();
- AlignmentOrder order = new AlignmentOrder(alignment);
- AlignFrame newAFrame = loader.LoadFileWaitTillLoaded(
- HMMERCommands.ALIGNMENTINPUT, DataSourceType.FILE);
+ AlignFrame aFrame = new AlignFrame(new Alignment(new SequenceI[1]),
+ AlignFrame.DEFAULT_WIDTH, AlignFrame.DEFAULT_HEIGHT);
+ Desktop.addInternalFrame(aFrame, aFrame.getTitle(),
+ AlignFrame.DEFAULT_WIDTH, AlignFrame.DEFAULT_HEIGHT);
+ aFrame.setTitle(
+ af.getName() + "Aligned to " + hmm.getName() + "'s HMM");
+ af.getViewport().setAlignment(null);
+
+ aFrame.loadJalviewDataFile(cmds.ALIGNMENTINPUT,
+ DataSourceType.FILE, FileFormat.Stockholm, null);
+
+
+
Map<Integer, SequenceI> copy = new HashMap<>(
hmmSeqs);
- addSeqs(newAFrame, copy);
- SequenceI seq = newAFrame.getViewport().getAlignment()
+ addSeqs(aFrame, copy);
+ SequenceI seq = aFrame.getViewport().getAlignment()
.getSequenceAt(0);
- hmm.mapToReferenceAnnotation(newAFrame, seq);
+ seq.getHMM().mapToReferenceAnnotation(aFrame, seq);
addSeqs(af, hmmSeqs);
}
else
{
af.getViewport().getAlignment().getSequences().clear();
af.setIsRecurring(true);
- af.loadJalviewDataFile(HMMERCommands.ALIGNMENTBUFFER,
+ af.loadJalviewDataFile(cmds.ALIGNMENTBUFFER,
DataSourceType.FILE, FileFormat.Stockholm, null);
af.setIsRecurring(false);
addSeqs(af, hmmSeqs);
{
SequenceI seq = entry.getValue();
Integer pos = entry.getKey();
- HMMERCommands.addHMMConsensusSequence(alignFrame, seq, pos);
+ cmds.addHMMConsensusSequence(alignFrame, seq, pos);
}
}
import jalview.io.FileFormat;
import jalview.util.MessageManager;
+import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.Map;
public class HMMBuildThread implements Runnable
{
-
+ HMMERCommands cmds = new HMMERCommands();
AlignFrame af;
AlignmentI alignment;
barID = System.currentTimeMillis();
af.setProgressBar(MessageManager.getString("status.running_hmmbuild"),
barID);
- HMMERCommands.HMMERFOLDER = Cache.getProperty(Preferences.HMMER_PATH);
+ cmds.HMMERFOLDER = Cache.getProperty(Preferences.HMMER_PATH);
+ try
+ {
+ cmds.HMMBUFFER = File.createTempFile("hmm", ".hmm").getAbsolutePath()
+ + cmds.SPACE;
+ cmds.ALIGNMENTBUFFER = File.createTempFile("output", ".sto")
+ .getAbsolutePath() + cmds.SPACE;
+ } catch (IOException e1)
+ {
+ e1.printStackTrace();
+ }
try
{
try
{
hmmSeqs = alignment.getHMMConsensusSequences(true);
- HMMERCommands.exportData(alignment, true, false,
+ cmds.exportData(alignment, true, false,
new HiddenMarkovModel());
} catch (FileNotFoundException e)
{
private void runCommand() throws IOException, InterruptedException
{
- final String command = HMMERCommands.HMMERFOLDER
- + HMMERCommands.HMMBUILD + HMMERCommands.NAME
- + af.getName() + HMMERCommands.SPACE
- + HMMERCommands.JALVIEWDIRECTORY + HMMERCommands.HMMBUFFER
- + HMMERCommands.JALVIEWDIRECTORY + HMMERCommands.ALIGNMENTBUFFER;
- HMMERCommands.runCommand(command);
+ final String command = cmds.HMMERFOLDER + cmds.HMMBUILD + cmds.NAME
+ + af.getName() + cmds.SPACE + cmds.HMMBUFFER
+ + cmds.ALIGNMENTBUFFER;
+ cmds.runCommand(command);
}
private void importData() throws IOException, InterruptedException
{
- af.loadJalviewDataFile(HMMERCommands.HMMBUFFER, DataSourceType.FILE,
+ af.loadJalviewDataFile(cmds.HMMBUFFER, DataSourceType.FILE,
FileFormat.HMMER3, null);
for (Map.Entry<Integer, SequenceI> entry : hmmSeqs.entrySet())
{
SequenceI seq = entry.getValue();
Integer pos = entry.getKey();
- HMMERCommands.addHMMConsensusSequence(af, seq, pos);
+ cmds.addHMMConsensusSequence(af, seq, pos);
}
af.alignPanel.alignmentChanged();
}
public class HMMERCommands
{
// Path of hmmer binaries directory
- static String HMMERFOLDER = "/Documents/";
+ String HMMERFOLDER = "/Documents/";
- static final String JALVIEWDIRECTORY = System.getProperty("user.dir")
+ public String JALVIEWDIRECTORY = System.getProperty("user.dir")
+ "/";
- static String HMMALIGN = "/hmmalign ";
+ public String HMMALIGN = "/hmmalign ";
- static String HMMBUILD = "/hmmbuild ";
+ public String HMMBUILD = "/hmmbuild ";
- static String HMMSEARCH = "/hmmsearch ";
+ public String HMMSEARCH = "/hmmsearch ";
- static final String HMMBUFFER = "src/jalview/hmmer/hmm_buffer.hmm ";
+ public String HMMBUFFER;
- static final String ALIGNMENTBUFFER = "src/jalview/hmmer/alignment_buffer.sto ";
+ public String ALIGNMENTBUFFER;
- static final String ALIGNMENTINPUT = "src/jalview/hmmer/alignment_input.sto ";
+ public String ALIGNMENTINPUT;
- static final String OUTPUTALIGNMENT = "-o " + JALVIEWDIRECTORY
- + ALIGNMENTINPUT;
+ public String OUTPUTALIGNMENT;
- static final String NAME = "-n ";
+ public String NAME = "-n ";
- static final String SPACE = " ";
+ public String SPACE = " ";
- static final String ALLCOL = "--allcol ";
+ public String ALLCOL = "--allcol ";
- static final String TRIM = "--trim ";
+ public String TRIM = "--trim ";
/**
* @throws IOException
* @throws InterruptedException
*/
- public static void runCommand(String command)
+ public void runCommand(String command)
throws IOException, InterruptedException
{
final Process p = Runtime.getRuntime().exec(command);
* @param alignment
* @throws IOException
*/
- public static void exportData(AlignmentI alignment,
+ public void exportData(AlignmentI alignment,
boolean exportAlignment, boolean exportHMM, HiddenMarkovModel hmm)
throws IOException
{
}
}
- public static void addHMMConsensusSequence(AlignFrame af, SequenceI seq,
+ public void addHMMConsensusSequence(AlignFrame af, SequenceI seq,
Integer position)
{
seq.getHMM().initHMMSequence(af, position);