2 * Jalview - A Sequence Alignment Editor and Viewer (Version 2.5)
3 * Copyright (C) 2010 J Procter, AM Waterhouse, G Barton, M Clamp, S Searle
5 * This file is part of Jalview.
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 of the License, or (at your option) any later version.
11 * Jalview is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty
13 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR
14 * PURPOSE. See the GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License along with Jalview. If not, see <http://www.gnu.org/licenses/>.
20 import jalview.api.SequenceStructureBinding;
21 import jalview.appletgui.AlignFrame;
22 import jalview.appletgui.AppletJmol;
23 import jalview.appletgui.EmbmenuFrame;
24 import jalview.appletgui.FeatureSettings;
25 import jalview.datamodel.Alignment;
26 import jalview.datamodel.PDBEntry;
27 import jalview.datamodel.Sequence;
28 import jalview.datamodel.SequenceI;
29 import jalview.io.AnnotationFile;
30 import jalview.io.AppletFormatAdapter;
31 import jalview.io.FileParse;
32 import jalview.io.IdentifyFile;
33 import jalview.io.JnetAnnotationMaker;
35 import java.applet.Applet;
36 import java.awt.Button;
37 import java.awt.Color;
38 import java.awt.Component;
40 import java.awt.Frame;
41 import java.awt.Graphics;
42 import java.awt.event.ActionEvent;
43 import java.awt.event.WindowAdapter;
44 import java.awt.event.WindowEvent;
45 import java.io.BufferedReader;
46 import java.io.InputStreamReader;
47 import java.lang.reflect.Method;
48 import java.util.Enumeration;
49 import java.util.StringTokenizer;
50 import java.util.Vector;
53 * Jalview Applet. Runs in Java 1.18 runtime
58 public class JalviewLite extends Applet
61 // /////////////////////////////////////////
62 // The following public methods maybe called
63 // externally, eg via javascript in HTML page
65 * @return String list of selected sequence IDs, each terminated by "¬"
68 public String getSelectedSequences()
70 return getSelectedSequencesFrom(getDefaultTargetFrame());
75 * separator string or null for default
76 * @return String list of selected sequence IDs, each terminated by sep or
79 public String getSelectedSequences(String sep)
81 return getSelectedSequencesFrom(getDefaultTargetFrame(), sep);
86 * alignframe containing selection
87 * @return String list of selected sequence IDs, each terminated by "¬"
90 public String getSelectedSequencesFrom(AlignFrame alf)
92 return getSelectedSequencesFrom(alf, "¬");
96 * get list of selected sequence IDs separated by given separator
99 * window containing selection
101 * separator string to use - default is "¬"
102 * @return String list of selected sequence IDs, each terminated by the given
105 public String getSelectedSequencesFrom(AlignFrame alf, String sep)
107 StringBuffer result = new StringBuffer("");
108 if (sep == null || sep.length() == 0)
112 if (alf.viewport.getSelectionGroup() != null)
114 SequenceI[] seqs = alf.viewport.getSelectionGroup()
115 .getSequencesInOrder(alf.viewport.getAlignment());
117 for (int i = 0; i < seqs.length; i++)
119 result.append(seqs[i].getName());
124 return result.toString();
128 * get sequences selected in current alignFrame and return their alignment in
129 * format 'format' either with or without suffix
132 * - where selection is
134 * - format of alignment file
136 * - "true" to append /start-end string to each sequence ID
137 * @return selected sequences as flat file or empty string if there was no
140 public String getSelectedSequencesAsAlignment(String format, String suffix)
142 return getSelectedSequencesAsAlignmentFrom(currentAlignFrame, format,
147 * get sequences selected in alf and return their alignment in format 'format'
148 * either with or without suffix
151 * - where selection is
153 * - format of alignment file
155 * - "true" to append /start-end string to each sequence ID
156 * @return selected sequences as flat file or empty string if there was no
159 public String getSelectedSequencesAsAlignmentFrom(AlignFrame alf,
160 String format, String suffix)
164 boolean seqlimits = suffix.equalsIgnoreCase("true");
165 if (alf.viewport.getSelectionGroup() != null)
167 String reply = new AppletFormatAdapter().formatSequences(format,
168 new Alignment(alf.viewport.getSelectionAsNewSequence()),
172 } catch (Exception ex)
174 ex.printStackTrace();
175 return "Error retrieving alignment in " + format + " format. ";
180 public String getAlignment(String format)
182 return getAlignmentFrom(getDefaultTargetFrame(), format, "true");
185 public String getAlignmentFrom(AlignFrame alf, String format)
187 return getAlignmentFrom(alf, format, "true");
190 public String getAlignment(String format, String suffix)
192 return getAlignmentFrom(getDefaultTargetFrame(), format, suffix);
195 public String getAlignmentFrom(AlignFrame alf, String format,
200 boolean seqlimits = suffix.equalsIgnoreCase("true");
202 String reply = new AppletFormatAdapter().formatSequences(format,
203 alf.viewport.getAlignment(), seqlimits);
205 } catch (Exception ex)
207 ex.printStackTrace();
208 return "Error retrieving alignment in " + format + " format. ";
212 public void loadAnnotation(String annotation)
214 loadAnnotationFrom(getDefaultTargetFrame(), annotation);
217 public void loadAnnotationFrom(AlignFrame alf, String annotation)
219 if (new AnnotationFile().readAnnotationFile(alf.getAlignViewport()
220 .getAlignment(), annotation, AppletFormatAdapter.PASTE))
222 alf.alignPanel.fontChanged();
223 alf.alignPanel.setScrollValues(0, 0);
227 alf.parseFeaturesFile(annotation, AppletFormatAdapter.PASTE);
231 public String getFeatures(String format)
233 return getFeaturesFrom(getDefaultTargetFrame(), format);
236 public String getFeaturesFrom(AlignFrame alf, String format)
238 return alf.outputFeatures(false, format);
241 public String getAnnotation()
243 return getAnnotationFrom(getDefaultTargetFrame());
246 public String getAnnotationFrom(AlignFrame alf)
248 return alf.outputAnnotations(false);
251 public AlignFrame newView()
253 return newViewFrom(getDefaultTargetFrame());
256 public AlignFrame newView(String name)
258 return newViewFrom(getDefaultTargetFrame(), name);
261 public AlignFrame newViewFrom(AlignFrame alf)
263 return alf.newView(null);
266 public AlignFrame newViewFrom(AlignFrame alf, String name)
268 return alf.newView(name);
274 * alignment file as a string
277 * @return null or new alignment frame
279 public AlignFrame loadAlignment(String text, String title)
283 String format = new IdentifyFile().Identify(text,
284 AppletFormatAdapter.PASTE);
287 al = new AppletFormatAdapter().readFile(text,
288 AppletFormatAdapter.PASTE, format);
289 if (al.getHeight() > 0)
291 return new AlignFrame(al, this, title, false);
293 } catch (java.io.IOException ex)
295 ex.printStackTrace();
300 // //////////////////////////////////////////////
301 // //////////////////////////////////////////////
303 public static int lastFrameX = 200;
305 public static int lastFrameY = 200;
307 boolean fileFound = true;
309 String file = "No file";
311 Button launcher = new Button("Start Jalview");
314 * The currentAlignFrame is static, it will change if and when the user
315 * selects a new window. Note that it will *never* point back to the embedded
316 * AlignFrame if the applet is started as embedded on the page and then
317 * afterwards a new view is created.
319 public static AlignFrame currentAlignFrame = null;
322 * This is the first frame to be displayed, and does not change. API calls
323 * will default to this instance if currentAlignFrame is null.
325 AlignFrame initialAlignFrame = null;
327 boolean embedded = false;
329 private boolean checkForJmol = true;
331 private boolean checkedForJmol = false; // ensure we don't check for jmol
333 // every time the app is re-inited
335 public boolean jmolAvailable = false;
337 private boolean alignPdbStructures=false;
339 public static boolean debug = false;
341 static String builddate = null, version = null;
343 private static void initBuildDetails()
345 if (builddate == null)
347 builddate = "unknown";
349 java.net.URL url = JalviewLite.class
350 .getResource("/.build_properties");
355 BufferedReader reader = new BufferedReader(new InputStreamReader(
358 while ((line = reader.readLine()) != null)
360 if (line.indexOf("VERSION") > -1)
362 version = line.substring(line.indexOf("=") + 1);
364 if (line.indexOf("BUILD_DATE") > -1)
366 builddate = line.substring(line.indexOf("=") + 1);
369 } catch (Exception ex)
371 ex.printStackTrace();
377 public static String getBuildDate()
383 public static String getVersion()
390 * init method for Jalview Applet
396 * turn on extra applet debugging
398 String dbg = getParameter("debug");
401 debug = dbg.toLowerCase().equals("true");
406 System.err.println("JalviewLite Version " + getVersion());
407 System.err.println("Build Date : " + getBuildDate());
411 * if true disable the check for jmol
413 String chkforJmol = getParameter("nojmol");
414 if (chkforJmol != null)
416 checkForJmol = !chkforJmol.equals("true");
419 * get the separator parameter if present
421 String sep = getParameter("separator");
424 if (sep.length() > 0)
429 System.err.println("Separator set to '" + separator + "'");
435 "Invalid separator parameter - must be non-zero length");
441 String param = getParameter("RGB");
447 r = Integer.parseInt(param.substring(0, 2), 16);
448 g = Integer.parseInt(param.substring(2, 4), 16);
449 b = Integer.parseInt(param.substring(4, 6), 16);
450 } catch (Exception ex)
458 param = getParameter("label");
461 launcher.setLabel(param);
464 this.setBackground(new Color(r, g, b));
466 file = getParameter("file");
470 // Maybe the sequences are added as parameters
471 StringBuffer data = new StringBuffer("PASTE");
473 while ((file = getParameter("sequence" + i)) != null)
475 data.append(file.toString() + "\n");
478 if (data.length() > 5)
480 file = data.toString();
484 final JalviewLite applet = this;
485 if (getParameter("embedded") != null
486 && getParameter("embedded").equalsIgnoreCase("true"))
488 // Launch as embedded applet in page
490 LoadingThread loader = new LoadingThread(file, applet);
493 else if (file != null)
495 if (getParameter("showbutton") == null
496 || !getParameter("showbutton").equalsIgnoreCase("false"))
498 // Add the JalviewLite 'Button' to the page
500 launcher.addActionListener(new java.awt.event.ActionListener()
502 public void actionPerformed(ActionEvent e)
504 LoadingThread loader = new LoadingThread(file, applet);
511 // Open jalviewLite immediately.
512 LoadingThread loader = new LoadingThread(file, applet);
518 // jalview initialisation with no alignment. loadAlignment() method can
519 // still be called to open new alignments.
526 * Initialises and displays a new java.awt.Frame
529 * java.awt.Frame to be displayed
535 * height of new frame
537 public static void addFrame(final Frame frame, String title, int width,
540 frame.setLocation(lastFrameX, lastFrameY);
543 frame.setSize(width, height);
544 frame.setTitle(title);
545 frame.addWindowListener(new WindowAdapter()
547 public void windowClosing(WindowEvent e)
549 if (frame instanceof AlignFrame)
551 ((AlignFrame) frame).closeMenuItem_actionPerformed();
553 if (currentAlignFrame == frame)
555 currentAlignFrame = null;
559 if (frame instanceof EmbmenuFrame)
561 ((EmbmenuFrame) frame).destroyMenus();
563 frame.setMenuBar(null);
567 public void windowActivated(WindowEvent e)
569 if (frame instanceof AlignFrame)
571 currentAlignFrame = (AlignFrame) frame;
574 System.err.println("Activated window " + frame);
578 super.windowActivated(e);
581 * Probably not necessary to do this - see TODO above. (non-Javadoc)
584 * java.awt.event.WindowAdapter#windowDeactivated(java.awt.event.WindowEvent
587 * public void windowDeactivated(WindowEvent e) { if (currentAlignFrame ==
588 * frame) { currentAlignFrame = null; if (debug) {
589 * System.err.println("Deactivated window "+frame); } }
590 * super.windowDeactivated(e); }
593 frame.setVisible(true);
597 * This paints the background surrounding the "Launch Jalview button" <br>
599 * If file given in parameter not found, displays error message
604 public void paint(Graphics g)
608 g.setColor(new Color(200, 200, 200));
609 g.setColor(Color.cyan);
610 g.fillRect(0, 0, getSize().width, getSize().height);
611 g.setColor(Color.red);
612 g.drawString("Jalview can't open file", 5, 15);
613 g.drawString("\"" + file + "\"", 5, 30);
617 g.setColor(Color.black);
618 g.setFont(new Font("Arial", Font.BOLD, 24));
619 g.drawString("Jalview Applet", 50, this.getSize().height / 2 - 30);
620 g.drawString("Loading Data...", 50, this.getSize().height / 2);
624 class LoadJmolThread extends Thread
626 private boolean running = false;
630 if (running || checkedForJmol)
639 if (!System.getProperty("java.version").startsWith("1.1"))
641 Class.forName("org.jmol.adapter.smarter.SmarterJmolAdapter");
642 jmolAvailable = true;
647 .println("Jmol not available - Using MCview for structures");
649 } catch (java.lang.ClassNotFoundException ex)
655 jmolAvailable = false;
659 .println("Skipping Jmol check. Will use MCView (probably)");
662 checkedForJmol = true;
666 public boolean notFinished()
668 return running || !checkedForJmol;
672 class LoadingThread extends Thread
675 * State variable: File source
680 * State variable: protocol for access to file source
685 * State variable: format of file source
693 private void dbgMsg(String msg)
697 System.err.println(msg);
702 * update the protocol state variable for accessing the datasource located
706 * @return possibly updated datasource string
708 public String setProtocolState(String file)
710 if (file.startsWith("PASTE"))
712 file = file.substring(5);
713 protocol = AppletFormatAdapter.PASTE;
715 else if (inArchive(file))
717 protocol = AppletFormatAdapter.CLASSLOADER;
721 file = addProtocol(file);
722 protocol = AppletFormatAdapter.URL;
724 dbgMsg("Protocol identified as '" + protocol + "'");
728 public LoadingThread(String _file, JalviewLite _applet)
736 LoadJmolThread jmolchecker = new LoadJmolThread();
738 while (jmolchecker.notFinished())
740 // wait around until the Jmol check is complete.
744 } catch (Exception e)
752 private void startLoading()
754 AlignFrame newAlignFrame;
755 dbgMsg("Loading thread started with:\n>>file\n" + _file + ">>endfile");
756 file = setProtocolState(_file);
758 format = new jalview.io.IdentifyFile().Identify(file, protocol);
759 dbgMsg("File identified as '" + format + "'");
760 dbgMsg("Loading started.");
764 al = new AppletFormatAdapter().readFile(file, protocol, format);
765 } catch (java.io.IOException ex)
767 dbgMsg("File load exception.");
768 ex.printStackTrace();
773 FileParse fp = new FileParse(file, protocol);
775 dbgMsg(">>>Dumping contents of '" + file + "' " + "("
777 while ((ln = fp.nextLine()) != null)
781 dbgMsg(">>>Dump finished.");
782 } catch (Exception e)
785 .println("Exception when trying to dump the content of the file parameter.");
790 if ((al != null) && (al.getHeight() > 0))
792 dbgMsg("Successfully loaded file.");
793 newAlignFrame = new AlignFrame(al, applet, file, embedded);
794 if (initialAlignFrame == null)
796 initialAlignFrame = newAlignFrame;
799 currentAlignFrame = newAlignFrame;
801 if (protocol == jalview.io.AppletFormatAdapter.PASTE)
803 newAlignFrame.setTitle("Sequences from " + getDocumentBase());
806 newAlignFrame.statusBar.setText("Successfully loaded file " + file);
808 String treeFile = applet.getParameter("tree");
809 if (treeFile == null)
811 treeFile = applet.getParameter("treeFile");
814 if (treeFile != null)
818 treeFile = setProtocolState(treeFile);
820 * if (inArchive(treeFile)) { protocol =
821 * AppletFormatAdapter.CLASSLOADER; } else { protocol =
822 * AppletFormatAdapter.URL; treeFile = addProtocol(treeFile); }
824 jalview.io.NewickFile fin = new jalview.io.NewickFile(treeFile,
829 if (fin.getTree() != null)
831 newAlignFrame.loadTree(fin, treeFile);
832 dbgMsg("Successfuly imported tree.");
836 dbgMsg("Tree parameter did not resolve to a valid tree.");
838 } catch (Exception ex)
840 ex.printStackTrace();
844 String param = getParameter("features");
847 param = setProtocolState(param);
849 newAlignFrame.parseFeaturesFile(param, protocol);
852 param = getParameter("showFeatureSettings");
853 if (param != null && param.equalsIgnoreCase("true"))
855 newAlignFrame.viewport.showSequenceFeatures(true);
856 new FeatureSettings(newAlignFrame.alignPanel);
859 param = getParameter("annotations");
862 param = setProtocolState(param);
864 if (new AnnotationFile().readAnnotationFile(
865 newAlignFrame.viewport.getAlignment(), param, protocol))
867 newAlignFrame.alignPanel.fontChanged();
868 newAlignFrame.alignPanel.setScrollValues(0, 0);
873 .println("Annotations were not added from annotation file '"
879 param = getParameter("jnetfile");
884 param = setProtocolState(param);
885 jalview.io.JPredFile predictions = new jalview.io.JPredFile(
887 JnetAnnotationMaker.add_annotation(predictions,
888 newAlignFrame.viewport.getAlignment(), 0, false); // false==do
896 newAlignFrame.alignPanel.fontChanged();
897 newAlignFrame.alignPanel.setScrollValues(0, 0);
898 } catch (Exception ex)
900 ex.printStackTrace();
904 * <param name="alignpdbfiles" value="false/true"/>
905 * Undocumented for 2.6 - related to JAL-434
907 applet.setAlignPdbStructures(getDefaultParameter("alignpdbfiles",false));
909 * <param name="PDBfile" value="1gaq.txt PDB|1GAQ|1GAQ|A PDB|1GAQ|1GAQ|B
912 * <param name="PDBfile2" value="1gaq.txt A=SEQA B=SEQB C=SEQB">
914 * <param name="PDBfile3" value="1q0o Q45135_9MICO">
917 int pdbFileCount = 0;
918 // Accumulate pdbs here if they are heading for the same view (if alignPdbStructures is true)
919 Vector pdbs=new Vector();
922 if (pdbFileCount > 0)
923 param = getParameter("PDBFILE" + pdbFileCount);
925 param = getParameter("PDBFILE");
929 PDBEntry pdb = new PDBEntry();
932 SequenceI[] seqs = null;
933 String[] chains = null;
935 StringTokenizer st = new StringTokenizer(param, " ");
937 if (st.countTokens() < 2)
939 String sequence = applet.getParameter("PDBSEQ");
940 if (sequence != null)
941 seqs = new SequenceI[]
942 { (Sequence) newAlignFrame.getAlignViewport()
943 .getAlignment().findName(sequence) };
948 param = st.nextToken();
949 Vector tmp = new Vector();
950 Vector tmp2 = new Vector();
952 while (st.hasMoreTokens())
954 seqstring = st.nextToken();
955 StringTokenizer st2 = new StringTokenizer(seqstring, "=");
956 if (st2.countTokens() > 1)
959 tmp2.addElement(st2.nextToken());
960 seqstring = st2.nextToken();
962 tmp.addElement((Sequence) newAlignFrame.getAlignViewport()
963 .getAlignment().findName(seqstring));
966 seqs = new SequenceI[tmp.size()];
968 if (tmp2.size() == tmp.size())
970 chains = new String[tmp2.size()];
971 tmp2.copyInto(chains);
974 param = setProtocolState(param);
976 if (// !jmolAvailable
978 protocol == AppletFormatAdapter.CLASSLOADER)
980 // TODO: verify this Re:
981 // https://mantis.lifesci.dundee.ac.uk/view.php?id=36605
982 // This exception preserves the current behaviour where, even if
983 // the local pdb file was identified in the class loader
984 protocol = AppletFormatAdapter.URL; // this is probably NOT
986 param = addProtocol(param); //
993 for (int i = 0; i < seqs.length; i++)
997 ((Sequence) seqs[i]).addPDBId(pdb);
1001 if (JalviewLite.debug)
1003 // this may not really be a problem but we give a warning
1006 .println("Warning: Possible input parsing error: Null sequence for attachment of PDB (sequence "
1012 if (!alignPdbStructures) {
1013 newAlignFrame.newStructureView(applet, pdb, seqs, chains,
1016 pdbs.addElement(new Object[] { pdb, seqs, chains, new String(protocol)});
1022 } while (pdbFileCount < 10);
1025 SequenceI[][] seqs = new SequenceI[pdbs.size()][];
1026 PDBEntry[] pdb = new PDBEntry[pdbs.size()];
1027 String[][] chains = new String[pdbs.size()][];
1028 String[] protocols = new String[pdbs.size()];
1029 for (int pdbsi=0,pdbsiSize=pdbs.size(); pdbsi<pdbsiSize;pdbsi++)
1031 Object[] o = (Object[]) pdbs.elementAt(pdbsi);
1032 pdb[pdbsi] = (PDBEntry) o[0];
1033 seqs[pdbsi] = (SequenceI[]) o[1];
1034 chains[pdbsi] = (String[]) o[2];
1035 protocols[pdbsi] = (String) o[3];
1037 newAlignFrame.alignedStructureView(applet, pdb, seqs, chains, protocols);
1040 // ///////////////////////////
1041 // modify display of features
1043 // hide specific groups
1044 param = getParameter("hidefeaturegroups");
1047 applet.setFeatureGroupStateOn(newAlignFrame, param, false);
1049 // show specific groups
1050 param = getParameter("showfeaturegroups");
1053 applet.setFeatureGroupStateOn(newAlignFrame, param, true);
1065 * Discovers whether the given file is in the Applet Archive
1071 boolean inArchive(String file)
1073 // This might throw a security exception in certain browsers
1074 // Netscape Communicator for instance.
1077 boolean rtn = (getClass().getResourceAsStream("/" + file) != null);
1080 System.err.println("Resource '" + file + "' was "
1081 + (rtn ? "" : "not") + " located by classloader.");
1084 } catch (Exception ex)
1086 System.out.println("Exception checking resources: " + file + " "
1092 String addProtocol(String file)
1094 if (file.indexOf("://") == -1)
1096 file = getCodeBase() + file;
1099 System.err.println("Prepended codebase for resource: '" + file
1109 * @return the default alignFrame acted on by the public applet methods. May
1110 * return null with an error message on System.err indicating the
1113 protected AlignFrame getDefaultTargetFrame()
1115 if (currentAlignFrame != null)
1117 return currentAlignFrame;
1119 if (initialAlignFrame != null)
1121 return initialAlignFrame;
1124 .println("Implementation error: Jalview Applet API cannot work out which AlignFrame to use.");
1129 * separator used for separatorList
1131 protected String separator = "|"; // this is a safe(ish) separator - tabs
1133 // don't work for firefox
1136 * parse the string into a list
1139 * @return elements separated by separator
1141 public String[] separatorListToArray(String list)
1143 int seplen = separator.length();
1144 if (list == null || list.equals(""))
1146 java.util.Vector jv = new Vector();
1148 while ((pos = list.indexOf(separator, cp)) > cp)
1150 jv.addElement(list.substring(cp, pos));
1153 if (cp < list.length())
1155 jv.addElement(list.substring(cp));
1159 String[] v = new String[jv.size()];
1160 for (int i = 0; i < v.length; i++)
1162 v[i] = (String) jv.elementAt(i);
1164 jv.removeAllElements();
1167 System.err.println("Array from '" + separator
1168 + "' separated List:\n" + v.length);
1169 for (int i = 0; i < v.length; i++)
1171 System.err.println("item " + i + " '" + v[i] + "'");
1178 System.err.println("Empty Array from '" + separator
1179 + "' separated List");
1185 * concatenate the list with separator
1188 * @return concatenated string
1190 public String arrayToSeparatorList(String[] list)
1192 StringBuffer v = new StringBuffer();
1195 for (int i = 0, iSize = list.length - 1; i < iSize; i++)
1197 if (list[i] != null)
1201 v.append(separator);
1203 if (list[list.length - 1] != null)
1205 v.append(list[list.length - 1]);
1209 System.err.println("Returning '" + separator
1210 + "' separated List:\n");
1211 System.err.println(v);
1213 return v.toString();
1217 System.err.println("Returning empty '" + separator
1218 + "' separated List\n");
1225 * @see jalview.appletgui.AlignFrame#getFeatureGroups()
1227 public String getFeatureGroups()
1229 String lst = arrayToSeparatorList(getDefaultTargetFrame()
1230 .getFeatureGroups());
1236 * alignframe to get feature groups on
1238 * @see jalview.appletgui.AlignFrame#getFeatureGroups()
1240 public String getFeatureGroupsOn(AlignFrame alf)
1242 String lst = arrayToSeparatorList(alf.getFeatureGroups());
1249 * @see jalview.appletgui.AlignFrame#getFeatureGroupsOfState(boolean)
1251 public String getFeatureGroupsOfState(boolean visible)
1253 return arrayToSeparatorList(getDefaultTargetFrame()
1254 .getFeatureGroupsOfState(visible));
1259 * align frame to get groups of state visible
1262 * @see jalview.appletgui.AlignFrame#getFeatureGroupsOfState(boolean)
1264 public String getFeatureGroupsOfStateOn(AlignFrame alf, boolean visible)
1266 return arrayToSeparatorList(alf.getFeatureGroupsOfState(visible));
1271 * tab separated list of group names
1274 * @see jalview.appletgui.AlignFrame#setFeatureGroupState(java.lang.String[],
1277 public void setFeatureGroupStateOn(AlignFrame alf, String groups,
1280 boolean st = state;// !(state==null || state.equals("") ||
1281 // state.toLowerCase().equals("false"));
1282 alf.setFeatureGroupState(separatorListToArray(groups), st);
1285 public void setFeatureGroupState(String groups, boolean state)
1287 setFeatureGroupStateOn(getDefaultTargetFrame(), groups, state);
1291 * List separator string
1293 * @return the separator
1295 public String getSeparator()
1301 * List separator string
1304 * the separator to set
1306 public void setSeparator(String separator)
1308 this.separator = separator;
1312 * get boolean value of applet parameter 'name' and return default if
1313 * parameter is not set
1318 * the value to return otherwise
1319 * @return true or false
1321 public boolean getDefaultParameter(String name, boolean def)
1324 if ((stn = getParameter(name)) == null)
1328 if (stn.toLowerCase().equals("true"))
1336 * bind a pdb file to a sequence in the given alignFrame.
1339 * - null or specific alignFrame. This specifies the dataset that
1340 * will be searched for a seuqence called sequenceId
1342 * - sequenceId within the dataset.
1343 * @param pdbEntryString
1344 * - the short name for the PDB file
1346 * - pdb file - either a URL or a valid PDB file.
1347 * @return true if binding was as success TODO: consider making an exception
1348 * structure for indicating when PDB parsing or seqeunceId location
1351 public boolean addPdbFile(AlignFrame alFrame, String sequenceId,
1352 String pdbEntryString, String pdbFile)
1354 return alFrame.addPdbFile(sequenceId, pdbEntryString, pdbFile);
1357 protected void setAlignPdbStructures(boolean alignPdbStructures)
1359 this.alignPdbStructures = alignPdbStructures;
1362 public boolean isAlignPdbStructures()
1364 return alignPdbStructures;
1368 * get all components associated with the applet of the given type
1372 public Vector getAppletWindow(Class class1)
1374 Vector wnds = new Vector();
1375 Component[] cmp = getComponents();
1378 for (int i=0;i<cmp.length;i++)
1380 if (class1.isAssignableFrom(cmp[i].getClass()))
1382 wnds.addElement(cmp);
1390 * bind structures in a viewer to any matching sequences in an alignFrame (use
1391 * sequenceIds to limit scope of search to specific sequences)
1395 * @param sequenceIds
1396 * @return TODO: consider making an exception structure for indicating when
1398 public SequenceStructureBinding addStructureViewInstance(
1399 AlignFrame alFrame, Object viewer, String sequenceIds)
1402 if (sequenceIds != null && sequenceIds.length() > 0)
1404 return alFrame.addStructureViewInstance(viewer,
1405 separatorListToArray(sequenceIds));
1409 return alFrame.addStructureViewInstance(viewer, null);