--- /dev/null
+/*\r
+ * Copyright (c) 2011 Peter Troshin JAva Bioinformatics Analysis Web Services\r
+ * (JABAWS) @version: 2.0 This library is free software; you can redistribute it\r
+ * and/or modify it under the terms of the Apache License version 2 as published\r
+ * by the Apache Software Foundation This library is distributed in the hope\r
+ * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied\r
+ * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
+ * Apache License for more details. A copy of the license is in\r
+ * apache_license.txt. It is also available here:\r
+ * @see: http://www.apache.org/licenses/LICENSE-2.0.txt Any republication or\r
+ * derived work distributed in source code form must include this copyright and\r
+ * license notice.\r
+ */\r
+\r
+package compbio.runner.disorder;\r
+\r
+import java.io.File;\r
+import java.io.FileNotFoundException;\r
+import java.io.IOException;\r
+import java.util.Map;\r
+import java.util.Set;\r
+import java.util.TreeMap;\r
+import java.util.TreeSet;\r
+\r
+import org.apache.log4j.Logger;\r
+\r
+import compbio.data.sequence.Score;\r
+import compbio.data.sequence.ScoreManager;\r
+import compbio.data.sequence.SequenceUtil;\r
+import compbio.data.sequence.UnknownFileFormatException;\r
+import compbio.engine.client.SkeletalExecutable;\r
+import compbio.metadata.ResultNotAvailableException;\r
+\r
+/**\r
+ * iupred sequenceFile <short long glob >\r
+ * \r
+ * Maximum sequence length is 40000 chars. Single string length max is a 1000\r
+ * chars!\r
+ * \r
+ */\r
+public class IUPred extends SkeletalExecutable<IUPred> {\r
+\r
+ private static Logger log = Logger.getLogger(IUPred.class);\r
+ private static final String GLOB_SUFFIX = ".glob";\r
+ private static final String SHORT_SUFFIX = ".short";\r
+ private static final String LONG_SUFFIX = ".long";\r
+\r
+ @Override\r
+ @SuppressWarnings("unchecked")\r
+ public ScoreManager getResults(String workDirectory)\r
+ throws ResultNotAvailableException {\r
+\r
+ ScoreManager results = null;\r
+ try {\r
+\r
+ Map<String, Score> globScores = SequenceUtil.readIUPred(new File(\r
+ workDirectory, getOutput() + GLOB_SUFFIX));\r
+ Map<String, Score> shortScores = SequenceUtil.readIUPred(new File(\r
+ workDirectory, getOutput() + SHORT_SUFFIX));\r
+ Map<String, Score> longScores = SequenceUtil.readIUPred(new File(\r
+ workDirectory, getOutput() + LONG_SUFFIX));\r
+ Map<String, Set<Score>> combined = new TreeMap<String, Set<Score>>();\r
+ for (String key : globScores.keySet()) {\r
+ Set<Score> all = new TreeSet<Score>();\r
+ Score globsc = globScores.get(key);\r
+ assert globsc != null;\r
+ Score shortsc = shortScores.get(key);\r
+ assert shortsc != null;\r
+ all.add(shortsc);\r
+ Score longsc = longScores.get(key);\r
+ assert longsc != null;\r
+ all.add(longsc);\r
+ combined.put(key, all);\r
+ }\r
+ results = ScoreManager.newInstance(combined);\r
+\r
+ } catch (FileNotFoundException e) {\r
+ log.error(e.getMessage(), e.getCause());\r
+ throw new ResultNotAvailableException(e);\r
+ } catch (IOException e) {\r
+ log.error(e.getMessage(), e.getCause());\r
+ throw new ResultNotAvailableException(e);\r
+ } catch (UnknownFileFormatException e) {\r
+ log.error(e.getMessage(), e.getCause());\r
+ throw new ResultNotAvailableException(e);\r
+ } catch (NullPointerException e) {\r
+ log.error(e.getMessage(), e.getCause());\r
+ throw new ResultNotAvailableException(e);\r
+ }\r
+ return results;\r
+ }\r
+\r
+ @Override\r
+ public IUPred setInput(String inFile) {\r
+ super.setInput(inFile);\r
+ cbuilder.setFirst(inFile);\r
+ return this;\r
+ }\r
+\r
+ @SuppressWarnings("unchecked")\r
+ @Override\r
+ public Class<IUPred> getType() {\r
+ return (Class<IUPred>) this.getClass();\r
+ }\r
+\r
+}\r