*/
jalview.io.packed.JalviewDataset jds;
+ /**
+ * informative name for results
+ */
+ public String viewTitle;
+
protected void constructJob()
{
service.setInvolvesFlags();
-
// record all aspects of alignment view so we can merge back or recreate
// later
undoredo = av.getUndoRedoHash();
*/
boolean selExists = (av.getSelectionGroup() != null)
&& (av.getSelectionGroup().getSize() > 1);
- // TODO: revise to full focus+context+dataset input data staging model
+ // TODO: JAL-715: refactor to alignViewport methods and revise to full focus+context+dataset input data staging model
if (selExists)
{
if (service.partitiondata)
av.hasHiddenColumns(),
true,
true);
+ viewTitle = "selected "+(av.hasHiddenColumns() ? "visible" : "") + " region of "+af.getTitle();
}
else
{
false,
true);
}
- // TODO: verify that some kind of partition can be constructed from input
+ viewTitle = "select and unselected "+(av.hasHiddenColumns() ? "visible" : "") + " regions from "+af.getTitle();
}
else
{
av.hasHiddenColumns(),
true,
true);
+ viewTitle = "selected "+(av.hasHiddenColumns() ? "visible" : "") + " region of "+af.getTitle();
}
} else {
// standard alignment view without selection present
av.hasHiddenColumns(),
false,
true);
+ viewTitle = ""+(av.hasHiddenColumns() ? "visible region of " : "") + af.getTitle();
}
RestJobThread jobsthread = new RestJobThread(this);
{
// TODO: try to tell the user why the job couldn't be started.
JOptionPane.showMessageDialog(Desktop.desktop,
- "Unable to start web service analysis",
- "Internal Jalview Error", JOptionPane.WARNING_MESSAGE);
+ (jobsthread.hasWarnings() ? jobsthread.getWarnings() : "The Job couldn't be started. Please check your input, and the Jalview console for any warning messages."),
+ "Unable to start web service analysis", JOptionPane.WARNING_MESSAGE);
}
}
public static RestClient makeShmmrRestClient()
{
- String action = "Analyse", description = "Sequence Harmony and Multi-Relief (UNSTABLE!)", name = "Sequence Harmony";
+ String action = "Analysis", description = "Sequence Harmony and Multi-Relief (UNSTABLE!)", name = "Sequence Harmony";
Hashtable<String, InputType> iparams = new Hashtable<String, InputType>();
jalview.ws.rest.params.JobConstant toolp;
//toolp = new jalview.ws.rest.JobConstant("tool","jalview");
//aliinput.writeAsFile=true;
iparams.put(aliinput.token, aliinput);
jalview.ws.rest.params.SeqGroupIndexVector sgroups = new jalview.ws.rest.params.SeqGroupIndexVector();
- sgroups.minsize=2;
+ sgroups.setMinsize(2);
+ sgroups.min=2;// need at least two group defined to make a partition
iparams.put("groups", sgroups);
sgroups.token = "groups";
sgroups.sep = " ";
// TODO: move validation of input data to SeqGroupIndexVector
if ((prm.getValue() instanceof SeqGroupIndexVector)
&& (_input.getGroups() != null && _input.getGroups()
- .size() > 0))
+ .size() >= prm.getValue().min))
{
alinp.add(prm.getValue());
+ } else {
+ statMessage=("Not enough groups defined on the alignment - need at least "+prm.getValue().min);
}
}
}
{
String postUrl = rj.getPostUrl();
doHttpReq(Stage.SUBMIT, rj, postUrl);
+ wsInfo.invalidate();
}
/**
{
System.err.println("Debug RestJob: Posting Job");
doPost((RestJob) job);
- } catch (Exception ex)
+ }
+ catch (NoValidInputDataException erex)
+ {
+ job.setSubjobComplete(true);
+ job.setSubmitted(true);
+ ((RestJob)job).statMessage="<br>It looks like there was a problem with the data sent to the service :<br>"+erex.getMessage()+"\n";
+ ((RestJob)job).error=true;
+
+ }
+ catch (Exception ex)
{
job.setSubjobComplete(true);
job.setAllowedServerExceptions(-1);
*/
if (true)
{
- wsInfo.setViewResultsImmediatly(false);
+ // preserver current jalview behaviour
+ wsInfo.setViewResultsImmediatly(true);
}
else
{
else
{
// tell the user nothing was returned.
+ wsInfo.setStatus(wsInfo.STATE_STOPPED_ERROR);
+ wsInfo.setFinishedNoResults();
}
}
AlignmentI destal;
ColumnSelection destcs;
String alTitle = restClient.service.details.Action + " using "
- + restClient.service.details.Name + " on "
- + " whatever you clicked on." + "(set " + als + ")";
+ + restClient.service.details.Name + " on "+restClient.viewTitle;
switch (action)
{
case newAlignment:
* i++) { af.addSortByOrderMenuItem( WebServiceName + ((String)
* names.get(i)) + " Ordering", (AlignmentOrder) alorders.get(i)); } } }
*/
+ // TODO: modify this and previous alignment's title if many alignments have been returned.
Desktop.addInternalFrame(destaf, alTitle, AlignFrame.DEFAULT_WIDTH,
AlignFrame.DEFAULT_HEIGHT);
break;
case newView:
-
+ // TODO: determine title for view
break;
case currentView:
break;
*/
public boolean isValid()
{
+ ArrayList<String> _warnings=new ArrayList<String>();
+ boolean validt=true;
if (jobs != null)
{
for (RestJob rj : (RestJob[]) jobs)
{
// invalid input for this job
System.err.println("Job " + rj.getJobnum()
- + " has invalid input.");
- return false;
+ + " has invalid input. ( "+rj.getStatus()+")");
+ if (rj.hasStatus() && !_warnings.contains(rj.getStatus()))
+ {
+ _warnings.add(rj.getStatus());
+ }
+ validt=false;
+ }
+ }
+ }
+ if (!validt)
+ {
+ warnings = "";
+ for (String st : _warnings) {
+ if (warnings.length()>0) { warnings+="\n";
}
+ warnings += st;
+
}
- return true;
}
+ return validt;
+ }
+
+ protected String warnings;
+ public boolean hasWarnings()
+ {
// TODO Auto-generated method stub
- return false;
+ return warnings!=null && warnings.length()>0;
+ }
+
+ /**
+ * get any informative messages about why the job thread couldn't start.
+ * @return
+ */
+ public String getWarnings()
+ {
+ return isValid() ? "Job can be started. No warnings." : hasWarnings() ? warnings : "";
}
}
// assume that alignment is properly ordered so groups form consecutive
// blocks
ArrayList<int[]> gl = new ArrayList<int[]>();
+ int p=0;
for (SequenceGroup sg : (Vector<SequenceGroup>) al.getGroups())
{
if (sg.getSize()<minsize)
int[] se = null;
for (SequenceI sq : sg.getSequencesInOrder(al))
{
- int p = al.findIndex(sq);
+ p = al.findIndex(sq);
if (se == null)
{
se = new int[]
gl.add(se);
}
}
+ // are there any more sequences ungrouped that should be added as a single remaining group ? - these might be at the start or the end
+ if (gl.size()>0)
+ {
+ int[] tail=gl.get(0);
+ if (tail[0]>0) {
+ if (1+tail[0]>minsize)
+ {
+ gl.add(0,new int[] { 0,tail[0]-1});
+ } else {
+ // lets be intelligent here - if the remaining sequences aren't enough to make a final group, then don't make one.
+ // throw new NoValidInputDataException("Group from remaining ungrouped sequences in input contains less than "+minsize+" sequences.");
+ }
+ } else {
+ tail=gl.get(gl.size()-1);
+ if (1+tail[1]<al.getHeight())
+ {
+ if (al.getHeight()-(1+tail[1])>minsize) {
+ gl.add(new int[] { tail[1]+1, al.getHeight()-1});
+ } else {
+ // lets be intelligent here - if the remaining sequences aren't enough to make a final group, then don't make one.
+ // throw new NoValidInputDataException("Group from remaining ungrouped sequences in input contains less than "+minsize+" sequences.");
+ }
+ }
+ }
+ } else {
+ gl.add(new int[] { 0, al.getHeight()-1});
+ }
+ if (min>=0 && gl.size()<min)
+ {
+ throw new NoValidInputDataException("Not enough sequence groups for input. Need at least "+min+" groups (including ungrouped regions).");
+ }
+ if (max>0 && gl.size()>max)
+ {
+ throw new NoValidInputDataException("Too many sequence groups for input. Need at most "+max+" groups (including ungrouped regions).");
+ }
int[][] vals = gl.toArray(new int[gl.size()][]);
int[] srt = new int[gl.size()];
for (int i = 0; i < vals.length; i++)
return new StringBody(idvector.toString());
}
+ /**
+ * set minimum number of sequences allowed in a partition. Default is 1 sequence.
+ * @param i (number greater than 1)
+ */
+ public void setMinsize(int i)
+ {
+ if (minsize>=1)
+ {
+ minsize=i;
+ } else {
+ minsize=1;
+ }
+ }
}
\ No newline at end of file