import java.io.FileReader;
import java.io.IOException;
import java.util.ArrayList;
+import java.util.Hashtable;
import java.util.List;
import java.util.Scanner;
private String databaseName;
+ boolean searchAlignment = true;
+
+ Hashtable sequencesHash;
+
/**
* Constructor for the JackhmmerThread
*
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);
String seqScoreCutoff = null;
String domScoreCutoff = null;
databaseName = "Alignment";
- boolean searchAlignment = false;
if (params != null)
{
{
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)
+ if (MessageManager.getString(REPORTING_CUTOFF_KEY)
.equals(name))
{
- if (CUTOFF_EVALUE.equals(arg.getValue()))
+ if (MessageManager.getString(CUTOFF_EVALUE)
+ .equals(arg.getValue()))
{
useEvalueCutoff = true;
}
- else if (CUTOFF_SCORE.equals(arg.getValue()))
+ else if (MessageManager.getString(CUTOFF_SCORE)
+ .equals(arg.getValue()))
{
useScoreCutoff = true;
}
databaseName = dbPath.substring(pos + 1);
databaseFile = new File(dbPath);
}
+ searchAlignment = false;
}
}
}
* no external database specified for search, so
* export current alignment as 'database' to search
*/
- databaseFile = FileUtils.createTempFile("database", ".fa");
+ databaseFile = FileUtils.createTempFile("database", ".sto");
AlignmentI al = af.getViewport().getAlignment();
- exportFasta(al.getSequencesArray(), databaseFile);
+ AlignmentI copy = new Alignment(al);
+
+ deleteHmmSequences(copy);
+
+ sequencesHash = stashSequences(copy.getSequencesArray());
+
+ exportStockholm(copy.getSequencesArray(), databaseFile, null);
}
args.add(getFilePath(seqFile, true));
inputAlignmentTemp.getAbsolutePath(), DataSourceType.FILE));
seqs = file.getSeqsAsArray();
+ if (searchAlignment)
+ {
+ recoverSequences(sequencesHash, seqs);
+ }
+
readTable(searchOutputFile);
int seqCount = Math.min(seqs.length, seqsToReturn);
&& !"".equals(line))
{
SequenceI seq = seqs[index];
- AlignmentAnnotation pp = null;
- if (seq.getAlignmentAnnotations("", "Posterior Probability")
- .size() != 0)
- {
- pp = seq.getAlignmentAnnotations("", "Posterior Probability")
- .get(0);
- }
+
Scanner scanner = new Scanner(line);
- String str = scanner.next();
- str = scanner.next();
- addScoreAnnotation(str, seq, "jackhmmer E-value",
- "Full sequence E-value", pp);
- str = scanner.next();
- addScoreAnnotation(str, seq, "jackhmmer Score",
- "Full sequence bit score", pp);
- seq.removeAlignmentAnnotation(pp);
+ String evalue = scanner.next();
+ evalue = scanner.next();
+ String score = scanner.next();
+ addScoreAnnotations(evalue, score, seq);
scanner.close();
line = br.readLine();
index++;
br.close();
}
- /**
- * A helper method that adds one score-only (non-positional) annotation to a
- * sequence
- *
- * @param value
- * @param seq
- * @param label
- * @param description
- */
- protected void addScoreAnnotation(String value, SequenceI seq,
- String label, String description)
+ protected void addScoreAnnotations(String eValue, String bitScore,
+ SequenceI seq)
{
- addScoreAnnotation(value, seq, label, description, null);
- }
+ String label = "Search Scores";
+ String description = "Full sequence bit score and E-Value";
- /**
- * A helper method that adds one score-only (non-positional) annotation to a
- * sequence
- *
- * @param value
- * @param seq
- * @param label
- * @param description
- * @param pp
- * existing posterior probability annotation - values
- * copied to new annotation row
- */
- protected void addScoreAnnotation(String value, SequenceI seq,
- String label, String description, AlignmentAnnotation pp)
- {
try
{
- AlignmentAnnotation annot = null;
- if (pp == null)
- {
- annot = new AlignmentAnnotation(label, description, null);
- }
- else
- {
- annot = new AlignmentAnnotation(pp);
- annot.label = label;
- annot.description = description;
- }
+ AlignmentAnnotation annot = new AlignmentAnnotation(label,
+ description, null);
+
+ annot.label = label;
+ annot.description = description;
+
annot.setCalcId(JACKHMMER);
- double eValue = Double.parseDouble(value);
- annot.setScore(eValue);
+
+ double dEValue = Double.parseDouble(eValue);
+ annot.setEValue(dEValue);
+
+ double dBitScore = Double.parseDouble(bitScore);
+ annot.setBitScore(dBitScore);
+
annot.setSequenceRef(seq);
seq.addAlignmentAnnotation(annot);
+
} catch (NumberFormatException e)
{
- System.err.println("Error parsing " + label + " from " + value);
+ System.err.println("Error parsing " + label + " from " + eValue
+ + " & " + bitScore);
}
}
+
+
}