getViewport().updateInformation(alignPanel);
isAnnotation = true;
- getViewport().alignmentChanged(alignPanel);
}
else if (FileFormat.Jnet.equals(format))
Map<Integer, SequenceI> hmmSeqs;
+ File hmmTemp = null;
+
+ File outTemp = null;
+
+ File inputTemp = null;
+
public HMMAlignThread(AlignFrame af, boolean createNewFrame)
{
this.af = af;
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;
+ hmmTemp = File.createTempFile("hmm", ".hmm");
+ hmmTemp.deleteOnExit();
+ outTemp = File.createTempFile("output", ".sto");
+ outTemp.deleteOnExit();
+ inputTemp = File.createTempFile("input", ".sto");
+ inputTemp.deleteOnExit();
} catch (IOException e1)
{
// TODO Auto-generated catch block
try
{
hmmSeqs = alignment.getHMMConsensusSequences(true);
- cmds.exportData(alignment, true, true, hmm);
+ cmds.exportData(alignment, outTemp.getAbsoluteFile(), hmm,
+ hmmTemp.getAbsoluteFile());
} catch (FileNotFoundException e)
{
// TODO Auto-generated catch block
{
command += cmds.ALLCOL;
}
- command += cmds.TRIM + cmds.OUTPUTALIGNMENT + cmds.HMMBUFFER
- + cmds.ALIGNMENTBUFFER;
+ command += cmds.TRIM + " -o" + inputTemp.getAbsolutePath() + cmds.SPACE
+ + hmmTemp.getAbsolutePath() + cmds.SPACE
+ + outTemp.getAbsolutePath();
cmds.runCommand(command);
}
af.getName() + "Aligned to " + hmm.getName() + "'s HMM");
af.getViewport().setAlignment(null);
- aFrame.loadJalviewDataFile(cmds.ALIGNMENTINPUT,
+ aFrame.loadJalviewDataFile(inputTemp.getAbsolutePath(),
DataSourceType.FILE, FileFormat.Stockholm, null);
{
af.getViewport().getAlignment().getSequences().clear();
af.setIsRecurring(true);
- af.loadJalviewDataFile(cmds.ALIGNMENTBUFFER,
+ af.loadJalviewDataFile(inputTemp.getAbsolutePath(),
DataSourceType.FILE, FileFormat.Stockholm, null);
af.setIsRecurring(false);
addSeqs(af, hmmSeqs);
}
+ hmmTemp.delete();
+ outTemp.delete();
+ inputTemp.delete();
}
private void addSeqs(AlignFrame alignFrame, Map<Integer, SequenceI> map)
import jalview.bin.Cache;
import jalview.datamodel.AlignmentI;
-import jalview.datamodel.HiddenMarkovModel;
import jalview.datamodel.SequenceI;
import jalview.gui.AlignFrame;
import jalview.gui.Preferences;
AlignFrame af;
AlignmentI alignment;
+ File hmmTemp = null;
+
+ File stoTemp = null;
+
long barID;
Map<Integer, SequenceI> hmmSeqs;
public void run()
{
barID = System.currentTimeMillis();
+ System.out.println(System.getProperty("java.io.tmpdir"));
af.setProgressBar(MessageManager.getString("status.running_hmmbuild"),
barID);
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;
+ hmmTemp = File.createTempFile("hmm", ".hmm");
+ hmmTemp.deleteOnExit();
+ stoTemp = File.createTempFile("output", ".sto");
+ stoTemp.deleteOnExit();
} catch (IOException e1)
{
e1.printStackTrace();
try
{
hmmSeqs = alignment.getHMMConsensusSequences(true);
- cmds.exportData(alignment, true, false,
- new HiddenMarkovModel());
+ cmds.exportData(alignment, stoTemp, null, null);
} catch (FileNotFoundException e)
{
// TODO Auto-generated catch block
}
try
{
+
importData();
} catch (IOException | InterruptedException e)
{
private void runCommand() throws IOException, InterruptedException
{
final String command = cmds.HMMERFOLDER + cmds.HMMBUILD + cmds.NAME
- + af.getName() + cmds.SPACE + cmds.HMMBUFFER
- + cmds.ALIGNMENTBUFFER;
+ + af.getName() + cmds.SPACE + hmmTemp.getAbsolutePath()
+ + cmds.SPACE + stoTemp.getAbsolutePath() + cmds.SPACE;
cmds.runCommand(command);
}
private void importData() throws IOException, InterruptedException
{
- af.loadJalviewDataFile(cmds.HMMBUFFER, DataSourceType.FILE,
+ af.loadJalviewDataFile(hmmTemp.getAbsolutePath(), DataSourceType.FILE,
FileFormat.HMMER3, null);
for (Map.Entry<Integer, SequenceI> entry : hmmSeqs.entrySet())
{
cmds.addHMMConsensusSequence(af, seq, pos);
}
af.alignPanel.alignmentChanged();
+ hmmTemp.delete();
+ stoTemp.delete();
}
import jalview.io.StockholmFile;
import java.io.BufferedReader;
+import java.io.File;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
* @throws IOException
*/
public void exportData(AlignmentI alignment,
- boolean exportAlignment, boolean exportHMM, HiddenMarkovModel hmm)
+ File stoLocation, HiddenMarkovModel hmm, File hmmLocation)
throws IOException
{
- if (exportAlignment)
+ if (alignment != null)
{
if (!alignment.isAligned())
{
StockholmFile file = new StockholmFile(new Alignment(array));
file.setSeqs(array);
String output = file.print();
- PrintWriter writer = new PrintWriter(ALIGNMENTBUFFER);
+ PrintWriter writer = new PrintWriter(stoLocation);
writer.println(output);
writer.close();
}
- if (exportHMM)
+ if (hmm != null)
{
HMMFile file = new HMMFile(hmm);
- file.exportFile(HMMBUFFER);
+ file.exportFile(hmmLocation);
}
}
import jalview.datamodel.SequenceI;
import java.io.BufferedReader;
+import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.PrintWriter;
private final String EMPTY = "";
- //This is a line that needs to be added to each HMMER£ file. It is purely for readability.
+ //This is a line that needs to be added to each HMMER� file. It is purely for readability.
private static final String TRANSITIONTYPELINE = "m->m m->i m->d i->m i->i d->m d->d";
/**
}
/**
+ * Writes a HMM to a file/
+ *
+ * @param exportLocation
+ * Filename, URL or Pasted String to write to.
+ * @throws FileNotFoundException
+ * @throws UnsupportedEncodingException
+ *
+ **/
+
+ public void exportFile(File exportLocation) throws IOException
+ {
+ PrintWriter writer = new PrintWriter(exportLocation);
+ appendFileProperties(writer);
+ appendModel(writer);
+ writer.println("//");
+
+ writer.close();
+
+ }
+
+ /**
* Returns a string to be added to the StringBuilder containing the entire
* output String.
*