af.setProgressBar(MessageManager.getString("status.running_hmmalign"),
barID);
cmds.HMMERFOLDER = Cache.getProperty(Preferences.HMMER_PATH);
- prepareAlignment();
- SequenceI[][] subAlignments = msa.getVisibleContigs('-');
- allOrders = new ArrayList<>();
- allResults = new SequenceI[subAlignments.length][];
- int job = 0;
- for (SequenceI[] seqs : subAlignments)
+ prepareAlignment();
+ SequenceI[][] subAlignments = msa.getVisibleContigs('-');
+ allOrders = new ArrayList<>();
+ allResults = new SequenceI[subAlignments.length][];
+ int job = 0;
+ for (SequenceI[] seqs : subAlignments)
+ {
+ cmds.uniquifySequences(seqs);
+ try
{
- cmds.uniquifySequences(seqs);
- try
- {
- createTemporaryFiles();
- } catch (IOException e2)
- {
- e2.printStackTrace();
- }
- try
- {
- cmds.exportData(seqs, outTemp.getAbsoluteFile(), hmm,
+ createTemporaryFiles();
+ } catch (IOException e2)
+ {
+ e2.printStackTrace();
+ }
+ try
+ {
+ cmds.exportData(seqs, outTemp.getAbsoluteFile(), hmm,
hmmTemp.getAbsoluteFile(), null);
- } catch (IOException e1)
- {
- e1.printStackTrace();
- }
- try
- {
- boolean ran = runCommand();
- if (!ran)
- {
- JvOptionPane.showInternalMessageDialog(af,
- MessageManager.getString("warn.hmmalign_failed"));
- return;
- }
- } catch (IOException | InterruptedException e)
- {
- e.printStackTrace();
- }
- try
- {
- importData(job);
- } catch (IOException | InterruptedException e)
+ } catch (IOException e1)
+ {
+ e1.printStackTrace();
+ }
+ try
+ {
+ boolean ran = runCommand();
+ if (!ran)
{
- // TODO Auto-generated catch block
- e.printStackTrace();
+ JvOptionPane.showInternalMessageDialog(af,
+ MessageManager.getString("warn.hmmalign_failed"));
+ return;
}
- job++;
+ } catch (IOException | InterruptedException e)
+ {
+ e.printStackTrace();
}
-
+ try
+ {
+ importData(job);
+ } catch (IOException | InterruptedException e)
+ {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ job++;
+ }
displayResults(newFrame);
{
AlignmentOrder[] arrOrders = allOrders
.toArray(new AlignmentOrder[allOrders.size()]);
- Object[] newview = msa.getUpdatedView(allResults,
- arrOrders, '-');
+ Object[] newview = msa.getUpdatedView(allResults, arrOrders, '-');
SequenceI[] alignment = (SequenceI[]) newview[0];
HiddenColumns hidden = (HiddenColumns) newview[1];
Alignment al = new Alignment(alignment);
}
}
- }
-
-
+}
package jalview.hmmer;
-
import jalview.bin.Cache;
import jalview.datamodel.AlignmentI;
import jalview.datamodel.HiddenMarkovModel;
public class HMMBuildThread implements Runnable
{
HMMERCommands cmds = new HMMERCommands();
+
AlignFrame af;
AlignViewport viewport;
boolean multiJob = false;
+
AlignmentI alignment;
+
SequenceGroup group;
- List<ArgumentI> params;
+ List<ArgumentI> params;
boolean forGroup = false;
File stoTemp = null;
long barID;
-
+
/**
* This is used for validation purposes. Do not use!
*
barID = System.currentTimeMillis();
if (af != null)
{
- af.setProgressBar(MessageManager.getString("status.running_hmmbuild"),
- barID);
+ af.setProgressBar(MessageManager.getString("status.running_hmmbuild"),
+ barID);
}
cmds.HMMERFOLDER = Cache.getProperty(Preferences.HMMER_PATH);
}
}
-
if (af != null)
{
af.setProgressBar(MessageManager.getString("status.running_hmmbuild"),
private void runHMMBuild()
{
if (alignment == null && group == null)
- {
- JOptionPane.showMessageDialog(af,
+ {
+ JOptionPane.showMessageDialog(af,
MessageManager.getString("warn.no_sequence_data"));
- }
- try
- {
- hmmTemp = File.createTempFile("hmm", ".hmm");
- hmmTemp.deleteOnExit();
- stoTemp = File.createTempFile("output", ".sto");
- stoTemp.deleteOnExit();
- } catch (IOException e1)
- {
- e1.printStackTrace();
- }
+ }
+ try
+ {
+ hmmTemp = File.createTempFile("hmm", ".hmm");
+ hmmTemp.deleteOnExit();
+ stoTemp = File.createTempFile("output", ".sto");
+ stoTemp.deleteOnExit();
+ } catch (IOException e1)
+ {
+ e1.printStackTrace();
+ }
try
{
array = alignment.getSequencesArray();
}
- cmds.setHmmSeqs(seqs);
+ cmds.setHmmSeqs(seqs);
if (array.length < 1)
- {
+ {
if (af != null)
{
JOptionPane.showMessageDialog(af,
MessageManager.getString("warn.no_sequence_data"));
}
return;
- }
- SequenceI[] newArr = new SequenceI[array.length];
- int index = 0;
- for (SequenceI seq : array)
- {
- newArr[index] = new Sequence(seq);
- index++;
- }
+ }
+ SequenceI[] newArr = new SequenceI[array.length];
+ int index = 0;
+ for (SequenceI seq : array)
+ {
+ newArr[index] = new Sequence(seq);
+ index++;
+ }
- cmds.uniquifySequences(newArr);
+ cmds.uniquifySequences(newArr);
if (forGroup)
{
cmds.exportData(newArr, stoTemp, null, null, alignment);
}
- jalview.analysis.SeqsetUtils.deuniquify(cmds.hash, array);
+ jalview.analysis.SeqsetUtils.deuniquify(cmds.hash, array);
} catch (FileNotFoundException e)
{
}
try
{
- boolean ran = runCommand();
- if (!ran)
- {
- return;
- }
+ boolean ran = runCommand();
+ if (!ran)
+ {
+ return;
+ }
} catch (IOException | InterruptedException e)
{
// TODO Auto-generated catch block
// TODO Auto-generated catch block
e.printStackTrace();
}
- } catch (Exception e)
- {
- e.printStackTrace();
+ } catch (Exception e)
+ {
+ e.printStackTrace();
}
}
-
-
/**
* Executes the hmmbuild command in the command line.
*
name = group.getName() + "_HMM";
}
-
if (name == null || "".equals(name))
{
- if (af != null)
- {
+ if (af != null)
+ {
if (af.getTitle().length() < 15)
{
name = af.getTitle();
}
- }
- if (name == null || "".equals(name))
- {
- name = "Alignment";
- }
+ }
+ if (name == null || "".equals(name))
+ {
+ name = "Alignment";
+ }
}
command += cmds.FORCEDNA;
}
- command += hmmTemp.getAbsolutePath()
- + cmds.SPACE + stoTemp.getAbsolutePath() + cmds.SPACE;
+ command += hmmTemp.getAbsolutePath() + cmds.SPACE
+ + stoTemp.getAbsolutePath() + cmds.SPACE;
return cmds.runCommand(command);
}
-
+
/**
* Imports the .hmm file produced by hmmbuild.
*
private void importData() throws IOException, InterruptedException
{
HMMFile file = new HMMFile(
- new FileParse(hmmTemp.getAbsolutePath(),
- DataSourceType.FILE));
+ new FileParse(hmmTemp.getAbsolutePath(), DataSourceType.FILE));
SequenceI[] seqs = file.getSeqsAsArray();
SequenceI seq = seqs[0];
seq.createDatasetSequence();
hmmTemp.delete();
stoTemp.delete();
}
-
+
/**
* Runs hmmbuild, and waits for the results to be imported before continuing
*/
// Path of hmmer binaries directory
String HMMERFOLDER = "/Documents/";
- public String JALVIEWDIRECTORY = System.getProperty("user.dir")
- + "/";
+ public String JALVIEWDIRECTORY = System.getProperty("user.dir") + "/";
public final String HMMALIGN = "/hmmalign ";
{
try
{
- final Process p = Runtime.getRuntime().exec(command);
+ final Process p = Runtime.getRuntime().exec(command);
- new Thread(new Runnable()
- {
- @Override
- public void run()
+ new Thread(new Runnable()
{
- BufferedReader input = new BufferedReader(
- new InputStreamReader(p.getInputStream()));
- String line = null;
-
- try
+ @Override
+ public void run()
{
- while ((line = input.readLine()) != null)
+ BufferedReader input = new BufferedReader(
+ new InputStreamReader(p.getInputStream()));
+ String line = null;
+
+ try
+ {
+ while ((line = input.readLine()) != null)
+ {
+ System.out.println(line);
+ }
+ } catch (IOException e)
{
- System.out.println(line);
+ e.printStackTrace();
}
- } catch (IOException e)
- {
- e.printStackTrace();
}
- }
- }).start();
+ }).start();
- p.waitFor();
+ p.waitFor();
} catch (Exception e)
{
e.printStackTrace();
* @param alignment
* @throws IOException
*/
- public void exportData(SequenceI[] seqs,
- File stoLocation, HiddenMarkovModel hmm, File hmmLocation,
- AnnotatedCollectionI al)
+ public void exportData(SequenceI[] seqs, File stoLocation,
+ HiddenMarkovModel hmm, File hmmLocation, AnnotatedCollectionI al)
throws IOException
{
if (seqs != null)
package jalview.hmmer;
-
import jalview.bin.Cache;
import jalview.gui.Preferences;
import jalview.util.MessageManager;
import java.util.List;
import java.util.Scanner;
-
public class HMMERParamStore implements ParamDatastoreI
{
false, true, null));
args.add(new LogarithmicParameter(
MessageManager.getString("label.seq_e_value"),
- MessageManager.getString("label.seq_e_value_desc"), false,
- -3d, -37.92977945, 1d, 10d));
+ MessageManager.getString("label.seq_e_value_desc"), false, -3d,
+ -37.92977945, 1d, 10d));
/*
args.add(new DoubleParameter(
MessageManager.getString("label.seq_score"),
*/
args.add(new LogarithmicParameter(
MessageManager.getString("label.dom_e_value_desc"),
- MessageManager.getString("label.dom_e_value_desc"), false,
- -3d, -37.92977945, 1d, 10d));
+ MessageManager.getString("label.dom_e_value_desc"), false, -3d,
+ -37.92977945, 1d, 10d));
/*
args.add(new DoubleParameter(
MessageManager.getString("label.dom_score"),
*/
}
-
private void getHMMAlignParams(List<ArgumentI> args)
{
args.add(new BooleanOption(
File databaseFile = null;
-
-
SequenceI[] seqs;
-
/**
* Constructor for the HMMSearchThread. If create new frame is set to true, a
* new frame will be created.
&& !"".equals(line))
{
Scanner scanner = new Scanner(line);
-
+
String str = scanner.next();
Annotation[] annots = new Annotation[seqs[index].getLength()];
for (Annotation an : annots)
annot.setScore(Double.parseDouble(str));
annot.setSequenceRef(seqs[index]);
seqs[index].addAlignmentAnnotation(annot);
-
+
scanner.close();
line = br.readLine();
index++;
}
-
+
br.close();
}
-
}