X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fhmmer%2FJackHMMER.java;h=12c049216655da4ed9b36bc24d15c216433cfc28;hb=72404f561ccd190eab1990874f017bbe94bf9e10;hp=1815ac4be729fc6a750e27d882389588eb5db4ca;hpb=ed581b841fe9361bfe80bb006df190a29df264fb;p=jalview.git diff --git a/src/jalview/hmmer/JackHMMER.java b/src/jalview/hmmer/JackHMMER.java index 1815ac4..12c0492 100644 --- a/src/jalview/hmmer/JackHMMER.java +++ b/src/jalview/hmmer/JackHMMER.java @@ -2,7 +2,6 @@ package jalview.hmmer; import jalview.bin.Cache; import jalview.datamodel.Alignment; -import jalview.datamodel.AlignmentAnnotation; import jalview.datamodel.AlignmentI; import jalview.datamodel.SequenceI; import jalview.gui.AlignFrame; @@ -21,23 +20,13 @@ import java.io.FileReader; import java.io.IOException; import java.util.ArrayList; import java.util.List; -import java.util.Scanner; import javax.swing.JOptionPane; -public class JackHMMER extends HmmerCommand +public class JackHMMER extends Search { - static final String JACKHMMER = "jackhmmer"; - boolean realign = false; - - boolean trim = false; - - int seqsToReturn = Integer.MAX_VALUE; - - SequenceI[] seqs; - - private String databaseName; + SequenceI seq = null; /** * Constructor for the JackhmmerThread @@ -58,7 +47,7 @@ public class JackHMMER extends HmmerCommand @Override public void run() { - SequenceI seq = getSequence(); + seq = getSequence(); if (seq == null) { // shouldn't happen if we got this far @@ -72,13 +61,14 @@ public class JackHMMER extends HmmerCommand try { - File seqFile = FileUtils.createTempFile("seq", ".fa"); + File seqFile = FileUtils.createTempFile("seq", ".sto"); File hitsAlignmentFile = FileUtils.createTempFile("hitAlignment", ".sto"); File searchOutputFile = FileUtils.createTempFile("searchOutput", ".txt"); - exportSequence(seq, seqFile.getAbsoluteFile()); + exportStockholm(new SequenceI[] { seq }, seqFile.getAbsoluteFile(), + null); boolean ran = runCommand(searchOutputFile, hitsAlignmentFile, seqFile); @@ -130,131 +120,6 @@ public class JackHMMER extends HmmerCommand } /** - * Appends command line arguments to the given list, to specify input and output - * files for the search, and any additional options that may have been passed - * from the parameters dialog - * - * @param args - * @param searchOutputFile - * @param hitsAlignmentFile - * @param seqFile - * @throws IOException - */ - protected void buildArguments(List args, File searchOutputFile, - File hitsAlignmentFile, File seqFile) throws IOException - { - args.add("-o"); - args.add(getFilePath(searchOutputFile, true)); - args.add("-A"); - args.add(getFilePath(hitsAlignmentFile, true)); - - boolean dbFound = false; - String dbPath = ""; - File databaseFile = null; - - boolean useEvalueCutoff = false; - boolean useScoreCutoff = false; - String seqEvalueCutoff = null; - String domEvalueCutoff = null; - String seqScoreCutoff = null; - String domScoreCutoff = null; - databaseName = "Alignment"; - boolean searchAlignment = false; - - if (params != null) - { - for (ArgumentI arg : params) - { - String name = arg.getName(); - - if (MessageManager.getString("action.search").equals(name)) - { - searchAlignment = arg.getValue().equals( - MessageManager.getString(JackHMMER.THIS_ALIGNMENT_KEY)); - } - else if (MessageManager.getString(DATABASE_KEY).equals(name)) - { - dbPath = arg.getValue(); - int pos = dbPath.lastIndexOf(File.separator); - databaseName = dbPath.substring(pos + 1); - databaseFile = new File(dbPath); - } - else if (MessageManager.getString(REPORTING_CUTOFF_KEY) - .equals(name)) - { - if (CUTOFF_EVALUE.equals(arg.getValue())) - { - useEvalueCutoff = true; - } - else if (CUTOFF_SCORE.equals(arg.getValue())) - { - useScoreCutoff = true; - } - } - else if (MessageManager.getString(SEQ_EVALUE_KEY).equals(name)) - { - seqEvalueCutoff = arg.getValue(); - } - else if (MessageManager.getString(SEQ_SCORE_KEY).equals(name)) - { - seqScoreCutoff = arg.getValue(); - } - else if (MessageManager.getString(DOM_EVALUE_KEY).equals(name)) - { - domEvalueCutoff = arg.getValue(); - } - else if (MessageManager.getString(DOM_SCORE_KEY).equals(name)) - { - domScoreCutoff = arg.getValue(); - } - else if (MessageManager.getString(DATABASE_KEY).equals(name)) - { - dbFound = true; - dbPath = arg.getValue(); - if (!MessageManager.getString(THIS_ALIGNMENT_KEY).equals(dbPath)) - { - int pos = dbPath.lastIndexOf(File.separator); - databaseName = dbPath.substring(pos + 1); - databaseFile = new File(dbPath); - } - } - } - } - - if (useEvalueCutoff) - { - args.add("-E"); - args.add(seqEvalueCutoff); - args.add("--domE"); - args.add(domEvalueCutoff); - } - else if (useScoreCutoff) - { - args.add("-T"); - args.add(seqScoreCutoff); - args.add("--domT"); - args.add(domScoreCutoff); - } - - // if (!dbFound || MessageManager.getString(THIS_ALIGNMENT_KEY) - // .equals(dbPath)) - if (searchAlignment) - { - /* - * no external database specified for search, so - * export current alignment as 'database' to search - */ - databaseFile = FileUtils.createTempFile("database", ".fa"); - AlignmentI al = af.getViewport().getAlignment(); - deleteHmmSequences(al); - exportFasta(al, databaseFile); - } - - args.add(getFilePath(seqFile, true)); - args.add(getFilePath(databaseFile, true)); - } - - /** * Imports the data from the temporary file to which the output of jackhmmer was * directed. */ @@ -275,9 +140,17 @@ public class JackHMMER extends HmmerCommand inputAlignmentTemp.getAbsolutePath(), DataSourceType.FILE)); seqs = file.getSeqsAsArray(); - readTable(searchOutputFile); + readDomainTable(searchOutputFile, true); + + if (searchAlignment) + { + recoverSequences(sequencesHash, seqs); + } + + + + int seqCount = seqs.length; - int seqCount = Math.min(seqs.length, seqsToReturn); AlignmentI al = new Alignment(seqs); @@ -300,76 +173,6 @@ public class JackHMMER extends HmmerCommand } } - /** - * Reads in the scores table output by jackhmmer and adds annotation to - * sequences for E-value and bit score - * - * @param inputTableTemp - * @throws IOException - */ - void readTable(File inputTableTemp) throws IOException - { - BufferedReader br = new BufferedReader(new FileReader(inputTableTemp)); - String line = ""; - while (!line.startsWith("Query:")) - { - line = br.readLine(); - } - while (!line.contains("-------")) - { - line = br.readLine(); - } - line = br.readLine(); - - int index = 0; - while (!" ------ inclusion threshold ------".equals(line) - && !"".equals(line)) - { - SequenceI seq = seqs[index]; - - Scanner scanner = new Scanner(line); - String evalue = scanner.next(); - evalue = scanner.next(); - String score = scanner.next(); - addScoreAnnotations(evalue, score, seq); - scanner.close(); - line = br.readLine(); - index++; - } - - br.close(); - } - - protected void addScoreAnnotations(String eValue, String bitScore, - SequenceI seq) - { - String label = "Search Scores"; - String description = "Full sequence bit score and E-Value"; - - try - { - AlignmentAnnotation annot = new AlignmentAnnotation(label, - description, null); - - annot.label = label; - annot.description = description; - - annot.setCalcId(JACKHMMER); - - double dEValue = Double.parseDouble(eValue); - annot.setEValue(dEValue); - - double dBitScore = Double.parseDouble(bitScore); - annot.setEValue(dBitScore); - - annot.setSequenceRef(seq); - seq.addAlignmentAnnotation(annot); - } catch (NumberFormatException e) - { - System.err.println("Error parsing " + label + " from " + eValue - + " & " + bitScore); - } - }