Clover icon

Coverage Report

  1. Project Clover database Mon Sep 2 2024 17:57:51 BST
  2. Package jalview.ws.jws2

File SequenceAnnotationWSClient.java

 

Coverage histogram

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

Code metrics

24
60
9
1
258
181
24
0.4
6.67
9
2.67

Classes

Class Line # Actions
SequenceAnnotationWSClient 46 60 24
0.2903225729%
 

Contributing tests

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