+ /**\r
+ * \r
+ > Foobar_dundeefriends\r
+ * \r
+ * # COILS 34-41, 50-58, 83-91, 118-127, 160-169, 191-220, 243-252, 287-343\r
+ * \r
+ * # REM465 355-368\r
+ * \r
+ * # HOTLOOPS 190-204\r
+ * \r
+ * # RESIDUE COILS REM465 HOTLOOPS\r
+ * \r
+ * M 0.86010 0.88512 0.37094\r
+ * \r
+ * T 0.79983 0.85864 0.44331\r
+ * \r
+ * >Next Sequence name\r
+ * \r
+ * \r
+ * @param input\r
+ * @return\r
+ * @throws IOException\r
+ * @throws UnknownFileFormatException\r
+ */\r
+ public static HashMap<String, Set<Score>> readGlobPlot(\r
+ final InputStream input) throws IOException,\r
+ UnknownFileFormatException {\r
+ Scanner scan = new Scanner(input);\r
+ scan.useDelimiter(">");\r
+ if (!scan.hasNext()) {\r
+ throw new UnknownFileFormatException(\r
+ "In GlobPlot score format each sequence score is expected "\r
+ + "to start from the line: >Sequence name "\r
+ + " No such line was found!");\r
+ }\r
+\r
+ HashMap<String, Set<Score>> results = new HashMap<String, Set<Score>>();\r
+ int seqCounter = 0;\r
+ while (scan.hasNext()) {\r
+ seqCounter++;\r
+ String singleSeq = scan.next();\r
+ Scanner scansingle = new Scanner(singleSeq);\r
+ if (!scansingle.hasNextLine()) {\r
+ throw new RuntimeException(\r
+ "The input looks like an incomplete GlobPlot file - cannot parse!");\r
+ }\r
+\r
+ StringBuffer seqbuffer = new StringBuffer();\r
+ ArrayList<Float> dydxScore = new ArrayList<Float>();\r
+ ArrayList<Float> rawScore = new ArrayList<Float>();\r
+ ArrayList<Float> smoothedScore = new ArrayList<Float>();\r
+\r
+ String sequenceName = scansingle.nextLine().trim();\r
+ TreeSet<Range> domsR = parseRanges(GlobProtResult.GlobDoms,\r
+ scansingle.nextLine());\r
+ TreeSet<Range> disorderR = parseRanges(GlobProtResult.Disorder,\r
+ scansingle.nextLine());\r
+\r
+ String title = scansingle.nextLine();\r
+ assert title.startsWith("# RESIDUE DYDX") : ">Sequence_name must follow column title: # RESIDUE DYDX RAW SMOOTHED!";\r
+\r
+ while (scansingle.hasNext()) {\r
+ seqbuffer.append(scansingle.next());\r
+ dydxScore.add(scansingle.nextFloat());\r
+ rawScore.add(scansingle.nextFloat());\r
+ smoothedScore.add(scansingle.nextFloat());\r
+ }\r
+ /*\r
+ * Also possible FastaSequence fs = new FastaSequence(sequenceName,\r
+ * seqbuffer.toString());\r
+ */\r
+ Set<Score> scores = new TreeSet<Score>();\r
+ scores.add(new Score(GlobProtResult.Disorder, disorderR));\r
+ scores.add(new Score(GlobProtResult.GlobDoms, domsR));\r
+ scores.add(new Score(GlobProtResult.Dydx, dydxScore));\r
+ scores.add(new Score(GlobProtResult.RawScore, rawScore));\r
+ scores.add(new Score(GlobProtResult.SmoothedScore, smoothedScore));\r
+ results.put(sequenceName, scores);\r
+\r
+ scansingle.close();\r
+ }\r
+ scan.close();\r