3 import java.util.HashMap;
7 import javax.servlet.http.HttpServletRequest;
8 import javax.servlet.http.HttpServletResponse;
10 import jalview.api.AlignmentViewPanel;
11 import jalview.bin.Cache;
12 import jalview.datamodel.AlignmentI;
13 import jalview.datamodel.SequenceI;
14 import jalview.gui.AlignFrame;
15 import jalview.gui.Desktop;
16 import jalview.structure.StructureSelectionManager;
18 public class HighlightSequenceEndpoint extends AbstractEndpoint
20 public HighlightSequenceEndpoint(API api)
22 super(api, path, name, parameters, description);
25 protected static final String path = "highlightsequence";
27 private static final String name = "Highlight sequence positions";
29 private static final String parameters = "<sequence names>,<ranges>";
31 private static final String description = "Highlight the specified sequences at the specified position";
33 public void processEndpoint(HttpServletRequest request,
34 HttpServletResponse response)
36 if (!checkParameters(request, response, 2))
40 String[] parameters = getEndpointPathParameters(request);
42 String posString = parameters[1];
46 pos = Integer.parseInt(posString);
47 } catch (NumberFormatException e)
49 returnError(request, response,
50 "Could not parse postition integer " + posString);
53 String sequenceNames = parameters[0];
54 String fromIdString = request.getParameter("fromId");
56 Map<SequenceI, StructureSelectionManager> ssmMap = new HashMap<>();
57 AlignFrame[] alignFrames;
58 if (fromIdString != null)
60 AlignFrame af = AlignFrame.getAlignFrameFromRestId(fromIdString);
63 returnError(request, response,
64 "fromId value '" + fromIdString + "' results not found");
67 alignFrames = new AlignFrame[] { af };
71 alignFrames = Desktop.getAlignFrames();
73 if (alignFrames == null)
75 for (int i = 0; i < alignFrames.length; i++)
77 AlignFrame af = alignFrames[i];
78 List<AlignmentViewPanel> aps = (List<AlignmentViewPanel>) af
80 for (AlignmentViewPanel ap : aps)
82 StructureSelectionManager ssm = ap.getStructureSelectionManager();
83 // ap.getAlignViewport().getSequenceSetId()
84 AlignmentI al = ap.getAlignment();
85 List<SequenceI> seqs = (List<SequenceI>) al.getSequences();
86 for (SequenceI seq : seqs)
88 Cache.info("REMOVEME sequence name=" + seq.getName());
89 if (sequenceNames.equals(seq.getName()))
91 Cache.info("REMOVEME MATCHED " + seq.getName());
98 for (SequenceI seq : ssmMap.keySet())
100 StructureSelectionManager ssm = ssmMap.get(seq);
103 Cache.info("REMOVEME skipping sequence " + seq.getName());
106 Cache.info("REMOVEME Attempting to highlight sequence "
107 + seq.getName() + " at postition " + pos);
108 ssm.mouseOverSequence(seq, pos, -1, null);