From b7c744e08b3b2c3ff98f6c1183dae80cb3f86a86 Mon Sep 17 00:00:00 2001 From: TZVanaalten Date: Thu, 24 Aug 2017 14:12:45 +0100 Subject: [PATCH] JAL-2629 hmmsearch now works for different databases --- resources/lang/Messages.properties | 1 + src/jalview/hmmer/HMMERParamStore.java | 6 ++++-- src/jalview/hmmer/HMMSearchThread.java | 32 ++++++++++++++++++++++++++++---- 3 files changed, 33 insertions(+), 6 deletions(-) diff --git a/resources/lang/Messages.properties b/resources/lang/Messages.properties index a7623f7..38e29ed 100644 --- a/resources/lang/Messages.properties +++ b/resources/lang/Messages.properties @@ -1362,6 +1362,7 @@ label.dom_e_value_desc = The E-value cutoff for returned domains. label.dom_score_desc = The score threshold for returned domains. label.not_enough_sequences = There are not enough sequences to run {0} label.add_database = Add Database +label.this_alignment = This alignment warn.file_not_exists = File does not exist warn.invalid_format = This is not a valid database file format. The current supported formats are Fasta, Stockholm and Pfam. label.database_for_hmmsearch = The database hmmsearch will search through. \ No newline at end of file diff --git a/src/jalview/hmmer/HMMERParamStore.java b/src/jalview/hmmer/HMMERParamStore.java index 3dad581..4791626 100644 --- a/src/jalview/hmmer/HMMERParamStore.java +++ b/src/jalview/hmmer/HMMERParamStore.java @@ -60,7 +60,7 @@ public class HMMERParamStore implements ParamDatastoreI if (names != null && !names.isEmpty()) { Collection databases = new ArrayList<>(); - databases.add("This Alignment"); + databases.add(MessageManager.getString("label.this_alignment")); Scanner nameScanner = new Scanner(names); if (nameScanner.hasNext()) @@ -82,7 +82,9 @@ public class HMMERParamStore implements ParamDatastoreI nameScanner.close(); args.add(new Option(MessageManager.getString("label.database"), MessageManager.getString("label.database_for_hmmsearch"), - true, "This Alignment", "This Alignment", databases, null)); + true, MessageManager.getString("label.this_alignment"), + MessageManager.getString("label.this_alignment"), databases, + null)); } args.add(new BooleanOption( MessageManager.getString("label.auto_align_seqs"), diff --git a/src/jalview/hmmer/HMMSearchThread.java b/src/jalview/hmmer/HMMSearchThread.java index c723d2f..b67ef6f 100644 --- a/src/jalview/hmmer/HMMSearchThread.java +++ b/src/jalview/hmmer/HMMSearchThread.java @@ -19,6 +19,7 @@ import jalview.ws.params.simple.BooleanOption; import java.io.File; import java.io.IOException; +import java.io.PrintWriter; import java.util.ArrayList; import java.util.List; @@ -158,7 +159,6 @@ public class HMMSearchThread implements Runnable inputAlignmentTemp.deleteOnExit(); inputTableTemp = File.createTempFile("buffer", ".sto"); inputTableTemp.deleteOnExit(); - databaseFile = new File("D:/Thomas/uniref50.fasta"); } /** @@ -170,6 +170,8 @@ public class HMMSearchThread implements Runnable */ private boolean runCommand() throws IOException, InterruptedException { + Boolean dbFound = false; + String dbPath = ""; File file = new File(cmds.HMMERFOLDER + "/hmmsearch"); if (!file.canExecute()) { @@ -222,13 +224,36 @@ public class HMMSearchThread implements Runnable break; case "Trim Non-Matching Termini": trim = true; - + break; + case "Database": + dbFound = true; + dbPath = arg.getValue(); + if (!MessageManager.getString("label.this_alignment") + .equals(dbPath)) + { + databaseFile = new File(dbPath); + } } - } } + if (dbFound == false || MessageManager.getString("label.this_alignment") + .equals(dbPath)) + { + AlignmentI alignment = af.getViewport().getAlignment(); + AlignmentI copy = new Alignment(alignment); + copy.getHMMConsensusSequences(true); + StockholmFile stoFile = new StockholmFile(copy); + stoFile.setSeqs(copy.getSequencesArray()); + String alignmentString = stoFile.print(); + databaseFile = File.createTempFile("database", ".sto"); + databaseFile.deleteOnExit(); + PrintWriter writer = new PrintWriter(databaseFile); + writer.print(alignmentString); + writer.close(); + } + command += hmmTemp.getAbsolutePath() + cmds.SPACE + databaseFile.getAbsolutePath(); return cmds.runCommand(command); @@ -279,7 +304,6 @@ public class HMMSearchThread implements Runnable AlignmentI alignment = new Alignment(hmmAndSeqs); AlignFrame frame = new AlignFrame(alignment, 1, 1); frame.setSelectedHMMSequence(hmmSeq); - frame.getViewport().initInformation(); List alignArgs = new ArrayList<>(); if (trim) { -- 1.7.10.2