+ public static List<AnnotatedSequence> readJRonn(final File result)\r
+ throws IOException, UnknownFileFormatException {\r
+ InputStream input = new FileInputStream(result);\r
+ List<AnnotatedSequence> sequences = readJRonn(input);\r
+ input.close();\r
+ return sequences;\r
+ }\r
+\r
+ /**\r
+ * Reader for JRonn horizontal file format\r
+ * \r
+ * >Foobar\r
+ * \r
+ * M G D T T A G\r
+ * \r
+ * 0.48 0.42 0.42 0.48 0.52 0.53 0.54\r
+ * \r
+ * All values are tab delimited\r
+ * \r
+ * @param inStream\r
+ * @return\r
+ * @throws IOException\r
+ * @throws UnknownFileFormatException\r
+ */\r
+ public static List<AnnotatedSequence> readJRonn(final InputStream inStream)\r
+ throws IOException, UnknownFileFormatException {\r
+ final List<AnnotatedSequence> seqs = new ArrayList<AnnotatedSequence>();\r
+\r
+ final BufferedReader infasta = new BufferedReader(\r
+ new InputStreamReader(inStream, "UTF8"), 16000);\r
+\r
+ String line;\r
+ String sname = "";\r
+ do {\r
+ line = infasta.readLine();\r
+ if (line == null || line.isEmpty()) {\r
+ // skip empty lines\r
+ continue;\r
+ }\r
+ if (line.startsWith(">")) {\r
+ // read name\r
+ sname = line.trim().substring(1);\r
+ // read sequence line\r
+ line = infasta.readLine();\r
+ final String sequence = line.replace("\t", "");\r
+ // read annotation line\r
+ line = infasta.readLine();\r
+ String[] annotValues = line.split("\t");\r
+ float[] annotation = convertToNumber(annotValues);\r
+ if (annotation.length != sequence.length()) {\r
+ throw new UnknownFileFormatException(\r
+ "File does not look like Jronn horizontally formatted output file!\n"\r
+ + JRONN_WRONG_FORMAT_MESSAGE);\r
+ }\r
+ seqs.add(new AnnotatedSequence(sname, sequence, annotation));\r
+ }\r
+ } while (line != null);\r
+\r
+ infasta.close();\r
+ return seqs;\r
+ }\r
+\r
+ private static float[] convertToNumber(String[] annotValues)\r
+ throws UnknownFileFormatException {\r
+ float[] annotation = new float[annotValues.length];\r
+ try {\r
+ for (int i = 0; i < annotation.length; i++) {\r
+ annotation[i] = Float.parseFloat(annotValues[i]);\r
+ }\r
+ } catch (NumberFormatException e) {\r
+ throw new UnknownFileFormatException(JRONN_WRONG_FORMAT_MESSAGE, e\r
+ .getCause());\r
+ }\r
+ return annotation;\r
+ }\r
+\r
+ private static final String JRONN_WRONG_FORMAT_MESSAGE = "Jronn file must be in the following format:\n"\r
+ + ">sequence_name\n "\r
+ + "M V S\n"\r
+ + "0.43 0.22 0.65\n"\r
+ + "Where first line is the sequence name,\n"\r
+ + "second line is the tab delimited sequence,\n"\r
+ + "third line contains tab delimited disorder prediction values.\n"\r
+ + "No lines are allowed between these three. Additionally, the number of "\r
+ + "sequence residues must be equal to the number of the disorder values.";\r
+\r