Clover icon

Coverage Report

  1. Project Clover database Fri Dec 6 2024 13:47:14 GMT
  2. Package jalview.ws.jws2.dm

File AAConSettings.java

 

Coverage histogram

../../../../img/srcFileCovDistChart0.png
60% of files have more coverage

Code metrics

20
37
8
1
153
109
21
0.57
4.62
8
2.62

Classes

Class Line # Actions
AAConSettings 43 37 21
0.00%
 

Contributing tests

No tests hitting this source file were found.

Source view

1    /*
2    * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
3    * Copyright (C) $$Year-Rel$$ The Jalview Authors
4    *
5    * This file is part of Jalview.
6    *
7    * Jalview is free software: you can redistribute it and/or
8    * modify it under the terms of the GNU General Public License
9    * as published by the Free Software Foundation, either version 3
10    * of the License, or (at your option) any later version.
11    *
12    * Jalview is distributed in the hope that it will be useful, but
13    * WITHOUT ANY WARRANTY; without even the implied warranty
14    * of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15    * PURPOSE. See the GNU General Public License for more details.
16    *
17    * You should have received a copy of the GNU General Public License
18    * along with Jalview. If not, see <http://www.gnu.org/licenses/>.
19    * The Jalview Authors are detailed in the 'AUTHORS' file.
20    */
21    package jalview.ws.jws2.dm;
22   
23    import jalview.util.MessageManager;
24    import jalview.ws.jws2.JabaParamStore;
25    import jalview.ws.jws2.JabaPreset;
26    import jalview.ws.jws2.ParameterUtils;
27    import jalview.ws.jws2.jabaws2.Jws2Instance;
28    import jalview.ws.params.ArgumentI;
29    import jalview.ws.params.WsParamSetI;
30   
31    import java.util.ArrayList;
32    import java.util.List;
33   
34    import compbio.metadata.Argument;
35    import compbio.metadata.Option;
36   
37    /**
38    * preferences for running AACon service
39    *
40    * @author jprocter TODO: refactor to a generic 'last job and service run'
41    * container ?
42    */
 
43    public class AAConSettings extends jalview.ws.params.AutoCalcSetting
44    {
45    Jws2Instance service;
46   
 
47  0 toggle public AAConSettings(boolean autoUpdate, Jws2Instance service,
48    WsParamSetI preset, List<ArgumentI> jobArgset)
49    {
50  0 super(preset, jobArgset, autoUpdate);
51  0 this.service = service;
52    }
53   
 
54  0 toggle public Jws2Instance getService()
55    {
56  0 return service;
57    }
58   
 
59  0 toggle public void setService(Jws2Instance service)
60    {
61  0 this.service = service;
62  0 if (preset != null)
63    {
64    // migrate preset to new service
65  0 for (String url : preset.getApplicableUrls())
66    {
67  0 if (url.equals(service.getUri()))
68    {
69  0 return;
70    }
71    }
72  0 WsParamSetI pr = service.getParamStore().getPreset(preset.getName());
73  0 if (pr instanceof JabaPreset && preset instanceof JabaPreset)
74    {
75    // easy - Presets are identical (we assume)
76  0 preset = pr;
77  0 return;
78    }
79  0 List<ArgumentI> oldargs = new ArrayList<ArgumentI>(),
80    newargs = new ArrayList<ArgumentI>();
81  0 oldargs.addAll(preset.getArguments());
82    // need to compare parameters
83  0 for (ArgumentI newparg : pr.getArguments())
84    {
85  0 if (!oldargs.remove(newparg))
86    {
87  0 newargs.add(newparg);
88    }
89    }
90  0 if (oldargs.size() == 0 && newargs.size() == 0)
91    {
92    // exact match.
93  0 preset = pr;
94  0 return;
95    }
96    // Try even harder to migrate arguments.
97  0 throw new Error(MessageManager
98    .getString("error.parameter_migration_not_implemented_yet"));
99    }
100    }
101   
 
102  0 toggle public List<Argument> getJobArgset()
103    {
104  0 return jobArgset == null ? null
105    : JabaParamStore.getJabafromJwsArgs(jobArgset);
106    }
107   
 
108  0 toggle public void setJobArgset(List<Argument> jobArgset)
109    {
110    // TODO: test if parameters valid for service
111  0 this.jobArgset = jobArgset == null ? null
112    : JabaParamStore.getJwsArgsfromJaba(jobArgset);
113    }
114   
 
115  0 toggle public String getWsParamFile()
116    {
117  0 List<Option> opts = null;
118  0 if (jobArgset != null)
119    {
120  0 opts = JabaParamStore.getJabafromJwsArgs(jobArgset);
121    }
122    else
123    {
124  0 if (preset != null)
125    {
126  0 opts = JabaParamStore.getJabafromJwsArgs(preset.getArguments());
127    }
128    }
129  0 if (opts == null || opts.size() == 0)
130    {
131  0 return "";
132    }
133  0 StringBuffer pset = new StringBuffer();
134  0 for (String ps : ParameterUtils.writeParameterSet(opts, " "))
135    {
136  0 pset.append(ps);
137  0 pset.append("\n");
138    }
139  0 return pset.toString();
140    }
141   
 
142  0 toggle @Override
143    public String getServiceURI()
144    {
145  0 return service.getServiceTypeURI();
146    }
147   
 
148  0 toggle @Override
149    public String[] getServiceURLs()
150    {
151  0 return new String[] { service.getUri() };
152    }
153    }