import jalview.analysis.AnnotationSorter.SequenceAnnotationOrder;
import jalview.bin.Cache;
+import jalview.datamodel.Alignment;
+import jalview.datamodel.AlignmentI;
+import jalview.datamodel.HiddenMarkovModel;
+import jalview.datamodel.Sequence;
+import jalview.datamodel.SequenceI;
import jalview.gui.Help.HelpId;
import jalview.gui.StructureViewer.ViewerType;
+import jalview.hmmer.HMMBuildThread;
import jalview.io.FileFormatI;
import jalview.io.JalviewFileChooser;
import jalview.io.JalviewFileView;
import java.awt.event.ActionListener;
import java.awt.event.MouseEvent;
import java.io.File;
-import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
{
frame.updateHMMERStatus(hmmerStatus);
}
- if (hmmerStatus)
- {
- // String ver = getHMMERVersion();
- Cache.setProperty("HMMER_VERSION", "3.1b2");
- }
trimTermini.setSelected(Cache.getDefault("TRIM_TERMINI", false));
}
return false;
}
- if (!canExecute(folder + "/hmmbuild"))
+ AlignmentI alignment = new Alignment(
+ new SequenceI[]
+ { new Sequence("test", "WLWL", 0, 3) });
+ if (canExecute(folder + "/hmmbuild"))
{
- message += MessageManager.getString("label.hmmbuild_not_found")
- + "\n";
- missing++;
+ validateHMMBuild(alignment);
}
+ else
+ {
+ message += MessageManager.getString("label.hmmbuild_not_found")
+ + "\n";
+ missing++;
+ }
- if (!canExecute(folder + "/hmmalign"))
+ if (canExecute(folder + "/hmmalign"))
{
- message += MessageManager.getString("label.hmmalign_not_found")
- + "\n";
- missing++;
+
}
+ else
+ {
+ message += MessageManager.getString("label.hmmalign_not_found")
+ + "\n";
+ missing++;
+ }
- if (!canExecute(folder + "/hmmsearch"))
+ if (canExecute(folder + "/hmmsearch"))
{
- message += MessageManager.getString("label.hmmsearch_not_found")
- + "\n";
- missing++;
+
}
+ else
+ {
+ message += MessageManager.getString("label.hmmsearch_not_found")
+ + "\n";
+ missing++;
+ }
}
if (missing > 0)
}
/**
- * Gets the current version of hmmer
+ * Runs hmmbuild to check if it is working. While doing this it parses the
+ * version of HMMER.
*
+ * @param frame
* @return
*/
- private String getHMMERVersion()
+ public boolean validateHMMBuild(AlignmentI alignment)
{
- File file = new File(hmmerPath.getText() + "/release-notes");
- Scanner scanner = null;
- try
+ HMMBuildThread hmmbuild = new HMMBuildThread(alignment);
+ hmmbuild.hmmbuildWaitTillComplete();
+ SequenceI hmmSeq = alignment.getSequenceAt(1);
+ HiddenMarkovModel hmm;
+ if (hmmSeq.isHMMConsensusSequence() && hmmSeq.getHMM() != null)
{
- scanner = new Scanner(file);
- } catch (IOException e)
+ hmm = hmmSeq.getHMM();
+
+ if (hmm.getNumberOfSymbols() < 1)
+ {
+ return false;
+ }
+ }
+ else
{
- e.printStackTrace();
- return null;
+ return false;
}
- scanner.next();
- String res = scanner.next();
- scanner.close();
- return res;
+
+ String header = hmm.getFileHeader();
+ if (header == null)
+ {
+ return false;
+ }
+ else
+ {
+ Scanner scanner = new Scanner(header);
+ scanner.next();
+ String string = scanner.next();
+ String version = string.substring(1);
+ Cache.setProperty("HMMER_VERSION", version);
+ scanner.close();
+
+ }
+ return true;
}
+
private boolean validateHMMERPath()
{
return validateHMMERPath(true);
package jalview.hmmer;
+
import jalview.bin.Cache;
import jalview.datamodel.AlignmentI;
import jalview.datamodel.Sequence;
import jalview.datamodel.SequenceGroup;
import jalview.datamodel.SequenceI;
import jalview.gui.AlignFrame;
+import jalview.gui.AlignViewport;
import jalview.gui.JvOptionPane;
import jalview.gui.Preferences;
import jalview.io.DataSourceType;
import jalview.io.FileFormat;
import jalview.io.FileLoader;
+import jalview.io.FileParse;
+import jalview.io.HMMFile;
import jalview.util.MessageManager;
import java.io.File;
{
HMMERCommands cmds = new HMMERCommands();
AlignFrame af;
+
+ AlignViewport viewport;
AlignmentI alignment;
SequenceGroup group;
+
boolean forGroup = false;
- boolean canRun = true;
File hmmTemp = null;
long barID;
+ /**
+ * This is used for validation purposes. Do not use!
+ *
+ * @param viewport
+ */
+ public HMMBuildThread(AlignmentI alignment)
+ {
+ this.alignment = alignment;
+ forGroup = false;
+ }
+
public HMMBuildThread(AlignFrame af)
{
this.af = af;
public void run()
{
barID = System.currentTimeMillis();
+ if (af != null)
+ {
af.setProgressBar(MessageManager.getString("status.running_hmmbuild"),
barID);
+ }
cmds.HMMERFOLDER = Cache.getProperty(Preferences.HMMER_PATH);
if (alignment == null && group == null)
{
}
if (array.length < 1)
{
- JOptionPane.showMessageDialog(af,
+ if (af != null)
+ {
+ JOptionPane.showMessageDialog(af,
MessageManager.getString("warn.no_sequence_data"));
+ }
return;
}
SequenceI[] newArr = new SequenceI[array.length];
boolean ran = runCommand();
if (!ran)
{
- JvOptionPane.showInternalMessageDialog(af,
+ if (af != null)
+ {
+ JvOptionPane.showInternalMessageDialog(af,
MessageManager.getString("warn.hmmbuild_failed"));
+ }
return;
}
} catch (IOException | InterruptedException e)
e.printStackTrace();
} finally
{
- af.setProgressBar(MessageManager.getString("status.running_hmmbuild"),
+ if (af != null)
+ {
+ af.setProgressBar(
+ MessageManager.getString("status.running_hmmbuild"),
barID);
+ }
}
}
}
else
{
- String name = af.getName();
+ String name = null;
+ if (af != null)
+ {
+ name = af.getName();
+ }
if (name == null)
{
name = "Alignment";
private void importData() throws IOException, InterruptedException
{
- cmds.addHMMConsensusSequences(af);
- FileLoader loader = new FileLoader();
- loader.LoadFileOntoAlignmentWaitTillLoaded(af.getViewport(),
- hmmTemp.getAbsolutePath(), DataSourceType.FILE,
- FileFormat.HMMER3);
+ if (af != null)
+ {
+ cmds.addHMMConsensusSequences(af);
+
+ FileLoader loader = new FileLoader();
+ loader.LoadFileOntoAlignmentWaitTillLoaded(viewport,
+ hmmTemp.getAbsolutePath(), DataSourceType.FILE,
+ FileFormat.HMMER3);
+ }
+ else
+ {
+ HMMFile file = new HMMFile(new FileParse(hmmTemp.getAbsolutePath(),
+ DataSourceType.FILE));
+ alignment.addSequence(file.getSeqsAsArray()[0]);
+ }
hmmTemp.delete();
stoTemp.delete();
}
- public boolean canRun()
+ public void hmmbuildWaitTillComplete()
{
- return canRun;
+ Thread loader = new Thread(this);
+ loader.start();
+
+ while (loader.isAlive())
+ {
+ try
+ {
+ Thread.sleep(500);
+ } catch (Exception ex)
+ {
+ }
+ }
}
-
-
-
}
/**
- * Adds capability to read in and write out HMMER3 files. Currently only supports HMMER3/f.
+ * Adds capability to read in and write out HMMER3 files. .
*
*
* @author TZVanaalten
*/
void parseAnnotations(Scanner scanner, int index)
{
- if (hmm.mapIsActive())
+ if (hmm.mapIsActive() && scanner.hasNext())
{
int column;
column = scanner.nextInt();
* @param numberOfElements
* The number of elements in the list to be filled.
* @return filled list Returns the list of doubles.
+ * @throws IOException
*/
static List<Double> fillList(Scanner input,
- int numberOfElements)
+ int numberOfElements) throws IOException
{
List<Double> list = new ArrayList<>();
for (int i = 0; i < numberOfElements; i++)
list.add(prob);
}
}
+ if (list.size() < numberOfElements)
+ {
+ throw new IOException("Incomplete data");
+ }
return list;
}
}
@Test
- public void testFillList()
+ public void testFillList() throws IOException
{
Scanner scanner1 = new Scanner("1.3 2.4 5.3 3.9 9.8 4.7 4.3 2.3 6.9");
ArrayList<Double> filledArray = new ArrayList<>();