From: gmungoc Date: Tue, 15 May 2018 11:19:02 +0000 (+0100) Subject: JAL-2719 parse bit score annotation from search results X-Git-Url: http://source.jalview.org/gitweb/?p=jalview.git;a=commitdiff_plain;h=9a0adf8857c4e0f1a4f1191f4a511434e2432d8a JAL-2719 parse bit score annotation from search results --- diff --git a/src/jalview/hmmer/HMMSearch.java b/src/jalview/hmmer/HMMSearch.java index 21a3b20..4c5bfb3 100644 --- a/src/jalview/hmmer/HMMSearch.java +++ b/src/jalview/hmmer/HMMSearch.java @@ -398,24 +398,14 @@ public class HMMSearch extends HmmerCommand while (!" ------ inclusion threshold ------".equals(line) && !"".equals(line)) { + SequenceI seq = seqs[index]; Scanner scanner = new Scanner(line); - - String str = scanner.next(); // full sequence eValue score - // float eValue = Float.parseFloat(str); - // int seqLength = seqs[index].getLength(); - // Annotation[] annots = new Annotation[seqLength]; - // for (int j = 0; j < seqLength; j++) - // { - // annots[j] = new Annotation(eValue); - // } - AlignmentAnnotation annot = new AlignmentAnnotation("E-value", - "Score", null); - annot.setCalcId(HMMSEARCH); - double eValue = Double.parseDouble(str); - annot.setScore(eValue); - annot.setSequenceRef(seqs[index]); - seqs[index].addAlignmentAnnotation(annot); - + String str = scanner.next(); + addScoreAnnotation(str, seq, "hmmsearch E-value", + "Full sequence E-value"); + str = scanner.next(); + addScoreAnnotation(str, seq, "hmmsearch Score", + "Full sequence bit score"); scanner.close(); line = br.readLine(); index++; @@ -424,4 +414,31 @@ public class HMMSearch extends HmmerCommand 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) + { + try + { + AlignmentAnnotation annot = new AlignmentAnnotation(label, + description, null); + annot.setCalcId(HMMSEARCH); + double eValue = Double.parseDouble(value); + annot.setScore(eValue); + annot.setSequenceRef(seq); + seq.addAlignmentAnnotation(annot); + } catch (NumberFormatException e) + { + System.err.println("Error parsing " + label + " from " + value); + } + } + }