{
JMenu submenu = new JMenu("Slivka");
+ String[] services = { "clustalo", "clustalw", "probcons", "muscle", "mafft", "tcoffee" };
+ String[] names = { "ClustalO", "ClustalW2", "Probcons", "Muscle", "Mafft", "TCoffe" };
+
+ for (int i = 0; i < services.length; i++)
{
- // clustalo menu entry
- JMenuItem noParamMenuItem = new JMenuItem("ClustalO with defaults");
- SlivkaWSInstance clustalo;
try
{
- clustalo = new SlivkaWSInstance(client, client.getService("clustalo"));
- } catch (IOException e)
- {
- throw new IOError(e);
- }
- noParamMenuItem.addActionListener((ActionEvent e) -> {
- AlignmentView msa = alignFrame.gatherSequencesForAlignment();
- if (msa != null)
- {
- new MsaWSClient(
- clustalo, alignFrame.getTitle(), msa, false, true, alignFrame.getViewport().getAlignment().getDataset(),
- alignFrame
- );
- }
- });
- submenu.add(noParamMenuItem);
-
- JMenuItem parametrisedMenuItem = new JMenuItem("ClustalO with custom parameters");
- parametrisedMenuItem.addActionListener((ActionEvent evt) -> {
- AlignmentView msa = alignFrame.gatherSequencesForAlignment();
- if (msa != null)
- {
- try
- {
- SlivkaParamSet paramSet = new SlivkaParamSet(clustalo.getService());
- new MsaWSClient(
- clustalo, paramSet, null, true, alignFrame.getTitle(), msa, false, true,
- alignFrame.getViewport().getAlignment().getDataset(), alignFrame
- );
- } catch (IOException e)
+ SlivkaWSInstance instance = new SlivkaWSInstance(client,
+ client.getService(services[i]));
+
+ JMenuItem defaultMenuItem = new JMenuItem(
+ String.format("%s with defaults", names[i]));
+ defaultMenuItem.addActionListener((ActionEvent e) -> {
+ AlignmentView msa = alignFrame.gatherSequencesForAlignment();
+ if (msa != null)
{
- e.printStackTrace();
+ new MsaWSClient(instance, alignFrame.getTitle(), msa, false, true,
+ alignFrame.getViewport().getAlignment().getDataset(),
+ alignFrame);
}
- }
- });
- submenu.add(parametrisedMenuItem);
- }
+ });
+ submenu.add(defaultMenuItem);
- {
- // clustalw2 menu entry
- JMenuItem noParamMenuItem = new JMenuItem("ClustalW2 with defaults");
- SlivkaWSInstance clustalo;
- try
- {
- clustalo = new SlivkaWSInstance(client, client.getService("clustalw"));
+ JMenuItem customMenuItem = new JMenuItem(
+ String.format("%s with custom parameters", names[i]));
+ customMenuItem.addActionListener((ActionEvent e) -> {
+ AlignmentView msa = alignFrame.gatherSequencesForAlignment();
+ if (msa != null)
+ {
+ try
+ {
+ SlivkaParamSet paramSet = new SlivkaParamSet(
+ instance.getService());
+ new MsaWSClient(instance, paramSet, null, true,
+ alignFrame.getTitle(), msa, false, true,
+ alignFrame.getViewport().getAlignment().getDataset(),
+ alignFrame);
+ } catch (IOException e1)
+ {
+ throw new IOError(e1);
+ }
+
+ }
+ });
+ submenu.add(customMenuItem);
} catch (IOException e)
{
- throw new IOError(e);
+ // TODO Auto-generated catch block
+ e.printStackTrace();
}
- noParamMenuItem.addActionListener((ActionEvent e) -> {
- AlignmentView msa = alignFrame.gatherSequencesForAlignment();
- if (msa != null)
- {
- new MsaWSClient(
- clustalo, alignFrame.getTitle(), msa, false, true, alignFrame.getViewport().getAlignment().getDataset(),
- alignFrame
- );
- }
- });
- submenu.add(noParamMenuItem);
-
- JMenuItem parametrisedMenuItem = new JMenuItem("ClustalW2 with custom parameters");
- parametrisedMenuItem.addActionListener((ActionEvent evt) -> {
- AlignmentView msa = alignFrame.gatherSequencesForAlignment();
- if (msa != null)
- {
- try
- {
- SlivkaParamSet paramSet = new SlivkaParamSet(clustalo.getService());
- new MsaWSClient(
- clustalo, paramSet, null, true, alignFrame.getTitle(), msa, false, true,
- alignFrame.getViewport().getAlignment().getDataset(), alignFrame
- );
- } catch (IOException e)
- {
- e.printStackTrace();
- }
- }
- });
- submenu.add(parametrisedMenuItem);
}
wsmenu.add(submenu);