Clover icon

jalviewX

  1. Project Clover database Wed Oct 31 2018 15:13:58 GMT
  2. Package jalview.ws.jws2

File SequenceAnnotationWSClient.java

 

Coverage histogram

../../../img/srcFileCovDistChart3.png
47% of files have more coverage

Code metrics

24
60
9
1
256
180
24
0.4
6.67
9
2.67

Classes

Class Line # Actions
SequenceAnnotationWSClient 44 60 24 66
0.2903225729%
 

Contributing tests

This file is covered by 99 tests. .

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;
22   
23    import jalview.api.AlignCalcWorkerI;
24    import jalview.gui.AlignFrame;
25    import jalview.gui.Desktop;
26    import jalview.gui.JvSwingUtils;
27    import jalview.util.MessageManager;
28    import jalview.ws.jws2.dm.AAConSettings;
29    import jalview.ws.jws2.jabaws2.Jws2Instance;
30    import jalview.ws.params.WsParamSetI;
31    import jalview.ws.uimodel.AlignAnalysisUIText;
32   
33    import java.awt.event.ActionEvent;
34    import java.awt.event.ActionListener;
35    import java.util.List;
36   
37    import javax.swing.JMenu;
38    import javax.swing.JMenuItem;
39   
40    /**
41    * @author jprocter
42    *
43    */
 
44    public class SequenceAnnotationWSClient extends Jws2Client
45    {
46    /**
47    * initialise a client so its attachWSMenuEntry method can be called.
48    */
 
49  2804 toggle public SequenceAnnotationWSClient()
50    {
51    // TODO Auto-generated constructor stub
52    }
53   
 
54  0 toggle public SequenceAnnotationWSClient(final Jws2Instance sh,
55    AlignFrame alignFrame, WsParamSetI preset, boolean editParams)
56    {
57  0 super(alignFrame, preset, null);
58  0 initSequenceAnnotationWSClient(sh, alignFrame, preset, editParams);
59    }
60   
61    // dan think. Do I need to change this method to run RNAalifold through the
62    // GUI
63   
 
64  0 toggle public void initSequenceAnnotationWSClient(final Jws2Instance sh,
65    AlignFrame alignFrame, WsParamSetI preset, boolean editParams)
66    {
67    // dan changed! dan test. comment out if conditional
68    // if (alignFrame.getViewport().getAlignment().isNucleotide())
69    // {
70    // JvOptionPane.showMessageDialog(Desktop.desktop, sh.serviceType
71    // + " can only be used\nfor amino acid alignments.",
72    // "Wrong type of sequences!", JvOptionPane.WARNING_MESSAGE);
73    // return;
74    //
75    // }
76  0 AlignAnalysisUIText aaui = sh.getAlignAnalysisUI();
77  0 if (aaui != null)
78    {
79  0 Class clientClass = aaui.getClient();
80   
81    // Build an AACon style client - take alignment, return annotation for
82    // columns
83   
84  0 List<AlignCalcWorkerI> clnts = alignFrame.getViewport()
85    .getCalcManager().getRegisteredWorkersOfClass(clientClass);
86  0 AbstractJabaCalcWorker worker;
87  0 if (clnts == null || clnts.size() == 0)
88    {
89  0 if (!processParams(sh, editParams))
90    {
91  0 return;
92    }
93  0 try
94    {
95  0 worker = (AbstractJabaCalcWorker) (clientClass
96    .getConstructor(new Class[]
97    { Jws2Instance.class, AlignFrame.class, WsParamSetI.class,
98    List.class })
99    .newInstance(new Object[]
100    { sh, alignFrame, this.preset, paramset }));
101    } catch (Exception x)
102    {
103  0 x.printStackTrace();
104  0 throw new Error(
105    MessageManager.getString("error.implementation_error"),
106    x);
107    }
108  0 alignFrame.getViewport().getCalcManager().registerWorker(worker);
109  0 alignFrame.getViewport().getCalcManager().startWorker(worker);
110   
111    }
112    else
113    {
114  0 worker = (AbstractJabaCalcWorker) clnts.get(0);
115  0 if (editParams)
116    {
117  0 paramset = worker.getArguments();
118  0 preset = worker.getPreset();
119    }
120   
121  0 if (!processParams(sh, editParams, true))
122    {
123  0 return;
124    }
125    // reinstate worker if it was blacklisted (might have happened due to
126    // invalid parameters)
127  0 alignFrame.getViewport().getCalcManager().enableWorker(worker);
128  0 worker.updateParameters(this.preset, paramset);
129    }
130    }
131  0 if (sh.action.toLowerCase().contains("disorder"))
132    {
133    // build IUPred style client. take sequences, returns annotation per
134    // sequence.
135  0 if (!processParams(sh, editParams))
136    {
137  0 return;
138    }
139   
140  0 alignFrame.getViewport().getCalcManager().startWorker(
141    new AADisorderClient(sh, alignFrame, preset, paramset));
142    }
143    }
144   
 
145  0 toggle public SequenceAnnotationWSClient(AAConSettings fave,
146    AlignFrame alignFrame, boolean b)
147    {
148  0 super(alignFrame, fave.getPreset(), fave.getJobArgset());
149  0 initSequenceAnnotationWSClient(fave.getService(), alignFrame,
150    fave.getPreset(), b);
151    }
152   
153    /*
154    * (non-Javadoc)
155    *
156    * @see jalview.ws.jws2.Jws2Client#attachWSMenuEntry(javax.swing.JMenu,
157    * jalview.ws.jws2.jabaws2.Jws2Instance, jalview.gui.AlignFrame)
158    */
 
159  2804 toggle public void attachWSMenuEntry(JMenu wsmenu, final Jws2Instance service,
160    final AlignFrame alignFrame)
161    {
162  2796 if (registerAAConWSInstance(wsmenu, service, alignFrame))
163    {
164    // Alignment dependent analysis calculation WS gui
165  932 return;
166    }
167  1864 boolean hasparams = service.hasParameters();
168    // Assume name ends in WS
169  1864 String calcName = service.serviceType.substring(0,
170    service.serviceType.length() - 2);
171   
172  1864 JMenuItem annotservice = new JMenuItem(MessageManager.formatMessage(
173    "label.calcname_with_default_settings", new String[]
174    { calcName }));
175  1864 annotservice.addActionListener(new ActionListener()
176    {
177   
 
178  0 toggle @Override
179    public void actionPerformed(ActionEvent e)
180    {
181  0 new SequenceAnnotationWSClient(service, alignFrame, null, false);
182    }
183    });
184  1864 wsmenu.add(annotservice);
185  1864 if (hasparams)
186    {
187    // only add these menu options if the service has user-modifiable
188    // arguments
189  466 annotservice = new JMenuItem(
190    MessageManager.getString("label.edit_settings_and_run"));
191  466 annotservice.setToolTipText(MessageManager.getString(
192    "label.view_and_change_parameters_before_running_calculation"));
193   
194  466 annotservice.addActionListener(new ActionListener()
195    {
 
196  0 toggle public void actionPerformed(ActionEvent e)
197    {
198  0 new SequenceAnnotationWSClient(service, alignFrame, null, true);
199    }
200    });
201  466 wsmenu.add(annotservice);
202  466 List<WsParamSetI> presets = service.getParamStore().getPresets();
203  466 if (presets != null && presets.size() > 0)
204    {
205  0 JMenu presetlist = new JMenu(MessageManager
206    .formatMessage("label.run_with_preset", new String[]
207    { calcName }));
208   
209  0 for (final WsParamSetI preset : presets)
210    {
211  0 final JMenuItem methodR = new JMenuItem(preset.getName());
212  0 methodR.setToolTipText(JvSwingUtils.wrapTooltip(true, "<strong>"
213  0 + (preset.isModifiable()
214    ? MessageManager.getString("label.user_preset")
215    : MessageManager
216    .getString("label.service_preset"))
217    + "</strong><br/>" + preset.getDescription()));
218  0 methodR.addActionListener(new ActionListener()
219    {
 
220  0 toggle public void actionPerformed(ActionEvent e)
221    {
222  0 new SequenceAnnotationWSClient(service, alignFrame, preset,
223    false);
224    }
225   
226    });
227  0 presetlist.add(methodR);
228    }
229  0 wsmenu.add(presetlist);
230    }
231   
232    }
233    else
234    {
235  1398 annotservice = new JMenuItem(
236    MessageManager.getString("label.view_documentation"));
237  1398 if (service.docUrl != null)
238    {
239  1398 annotservice.addActionListener(new ActionListener()
240    {
241   
 
242  0 toggle @Override
243    public void actionPerformed(ActionEvent arg0)
244    {
245  0 Desktop.instance.showUrl(service.docUrl);
246    }
247    });
248  1398 annotservice.setToolTipText(
249    JvSwingUtils.wrapTooltip(true, MessageManager.formatMessage(
250    "label.view_service_doc_url", new String[]
251    { service.docUrl, service.docUrl })));
252  1398 wsmenu.add(annotservice);
253    }
254    }
255    }
256    }