From 501d5434f5e6a535d6ffcdced863d15aa84d2b61 Mon Sep 17 00:00:00 2001 From: Charles Ofoegbu Date: Wed, 19 Nov 2014 16:53:36 +0000 Subject: [PATCH] JAL-1583 MSA webservice validation --- src/jalview/ws/jws2/MsaWSClient.java | 44 ++++++++++++++++++++++------------ 1 file changed, 29 insertions(+), 15 deletions(-) diff --git a/src/jalview/ws/jws2/MsaWSClient.java b/src/jalview/ws/jws2/MsaWSClient.java index 76a1c56..d9452a3 100644 --- a/src/jalview/ws/jws2/MsaWSClient.java +++ b/src/jalview/ws/jws2/MsaWSClient.java @@ -21,7 +21,6 @@ package jalview.ws.jws2; import jalview.datamodel.Alignment; -import jalview.datamodel.AlignmentI; import jalview.datamodel.AlignmentView; import jalview.datamodel.SequenceI; import jalview.gui.AlignFrame; @@ -129,8 +128,10 @@ public class MsaWSClient extends Jws2Client return; } + startMsaWSClient(altitle, msa, submitGaps, preserveOrder, seqdataset); + } public MsaWSClient() @@ -175,24 +176,23 @@ public class MsaWSClient extends Jws2Client WsURL, wsInfo, alignFrame, WebServiceName, jobtitle, msa, submitGaps, preserveOrder, seqdataset); wsInfo.setthisService(msathread); - if (isValidAlignment(alignFrame.getCurrentView().getAlignment())) - { msathread.start(); - } + } - private boolean isValidAlignment(AlignmentI seqdataset) + private boolean isValidAlignment(AlignmentView av) { - String header = wsInfo.getInfoText() - + "\nValidating submited Alignment..."; - wsInfo.setInfoText(header); int validSeqCount = 0; - List seqs = seqdataset.getSequences(); + List seqs = av.getVisibleAlignment('c').getSequences(); // .getSequences(); if (seqs.size() < 2) { - wsInfo.setInfoText(header - + "\nA minimum of two sequences is required to perform this operation"); + JOptionPane + .showMessageDialog( + alignFrame, + "A minimum of two sequences is required to perform this operation", + "Invalid selection", JOptionPane.INFORMATION_MESSAGE); + return false; } @@ -206,14 +206,16 @@ public class MsaWSClient extends Jws2Client } if (validSeqCount > 1) { - wsInfo.setInfoText(header - + "\nAlignment sequences was successfully validated"); return true; } } - wsInfo.setInfoText(header - + "\nA minimum of two sequences with at least one non-gap character in each sequence is required to perform this operation"); + JOptionPane + .showMessageDialog( + alignFrame, + "A minimum of two sequences with at least one non-gap character \nin each sequence is required to perform this operation", + "Invalid selection", JOptionPane.INFORMATION_MESSAGE); + return false; } @@ -300,9 +302,13 @@ public class MsaWSClient extends Jws2Client public void actionPerformed(ActionEvent e) { AlignmentView msa = alignFrame.gatherSequencesForAlignment(); + + if (isValidAlignment(msa)) + { new MsaWSClient(service, alignFrame.getTitle(), msa, withGaps, true, alignFrame.getViewport().getAlignment() .getDataset(), alignFrame); + } } }); @@ -321,9 +327,13 @@ public class MsaWSClient extends Jws2Client public void actionPerformed(ActionEvent e) { AlignmentView msa = alignFrame.gatherSequencesForAlignment(); + + if (isValidAlignment(msa)) + { new MsaWSClient(service, null, null, true, alignFrame .getTitle(), msa, withGaps, true, alignFrame .getViewport().getAlignment().getDataset(), alignFrame); + } } }); @@ -374,9 +384,13 @@ public class MsaWSClient extends Jws2Client { AlignmentView msa = alignFrame .gatherSequencesForAlignment(); + + if (isValidAlignment(msa)) + { new MsaWSClient(service, preset, alignFrame.getTitle(), msa, false, true, alignFrame.getViewport() .getAlignment().getDataset(), alignFrame); + } } -- 1.7.10.2