2 * Copyright (c) 2011 Peter Troshin JAva Bioinformatics Analysis Web Services
\r
3 * (JABAWS) @version: 2.0 This library is free software; you can redistribute it
\r
4 * and/or modify it under the terms of the Apache License version 2 as published
\r
5 * by the Apache Software Foundation This library is distributed in the hope
\r
6 * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied
\r
7 * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
\r
8 * Apache License for more details. A copy of the license is in
\r
9 * apache_license.txt. It is also available here:
\r
10 * @see: http://www.apache.org/licenses/LICENSE-2.0.txt Any republication or
\r
11 * derived work distributed in source code form must include this copyright and
\r
15 package compbio.runner.disorder;
\r
17 import java.io.File;
\r
18 import java.io.FileNotFoundException;
\r
19 import java.io.IOException;
\r
20 import java.util.Map;
\r
21 import java.util.Set;
\r
22 import java.util.TreeMap;
\r
23 import java.util.TreeSet;
\r
25 import org.apache.log4j.Logger;
\r
27 import compbio.data.sequence.Score;
\r
28 import compbio.data.sequence.ScoreManager;
\r
29 import compbio.data.sequence.SequenceUtil;
\r
30 import compbio.data.sequence.UnknownFileFormatException;
\r
31 import compbio.engine.client.SkeletalExecutable;
\r
32 import compbio.metadata.ResultNotAvailableException;
\r
35 * iupred sequenceFile <short long glob >
\r
37 * Maximum sequence length is 40000 chars. Single string length max is a 1000
\r
41 public class IUPred extends SkeletalExecutable<IUPred> {
\r
43 private static Logger log = Logger.getLogger(IUPred.class);
\r
44 private static final String GLOB_SUFFIX = ".glob";
\r
45 private static final String SHORT_SUFFIX = ".short";
\r
46 private static final String LONG_SUFFIX = ".long";
\r
49 @SuppressWarnings("unchecked")
\r
50 public ScoreManager getResults(String workDirectory)
\r
51 throws ResultNotAvailableException {
\r
53 ScoreManager results = null;
\r
56 Map<String, Score> globScores = SequenceUtil.readIUPred(new File(
\r
57 workDirectory, getOutput() + GLOB_SUFFIX));
\r
58 Map<String, Score> shortScores = SequenceUtil.readIUPred(new File(
\r
59 workDirectory, getOutput() + SHORT_SUFFIX));
\r
60 Map<String, Score> longScores = SequenceUtil.readIUPred(new File(
\r
61 workDirectory, getOutput() + LONG_SUFFIX));
\r
62 Map<String, Set<Score>> combined = new TreeMap<String, Set<Score>>();
\r
63 for (String key : globScores.keySet()) {
\r
64 Set<Score> all = new TreeSet<Score>();
\r
65 Score globsc = globScores.get(key);
\r
66 assert globsc != null;
\r
67 Score shortsc = shortScores.get(key);
\r
68 assert shortsc != null;
\r
70 Score longsc = longScores.get(key);
\r
71 assert longsc != null;
\r
73 combined.put(key, all);
\r
75 results = ScoreManager.newInstance(combined);
\r
77 } catch (FileNotFoundException e) {
\r
78 log.error(e.getMessage(), e.getCause());
\r
79 throw new ResultNotAvailableException(e);
\r
80 } catch (IOException e) {
\r
81 log.error(e.getMessage(), e.getCause());
\r
82 throw new ResultNotAvailableException(e);
\r
83 } catch (UnknownFileFormatException e) {
\r
84 log.error(e.getMessage(), e.getCause());
\r
85 throw new ResultNotAvailableException(e);
\r
86 } catch (NullPointerException e) {
\r
87 log.error(e.getMessage(), e.getCause());
\r
88 throw new ResultNotAvailableException(e);
\r
94 public IUPred setInput(String inFile) {
\r
95 super.setInput(inFile);
\r
96 cbuilder.setFirst(inFile);
\r
100 @SuppressWarnings("unchecked")
\r
102 public Class<IUPred> getType() {
\r
103 return (Class<IUPred>) this.getClass();
\r