--- /dev/null
+// Requested by Hari Jayaram
+// script to output residue positions and values for selected region
+
+// thanks to this thread for cut'n'paste code
+// http://comments.gmane.org/gmane.comp.lang.groovy.user/53010
+
+// Jalview issue at http://issues.jalview.org/browse/JAL-1542
+
+import java.awt.datatransfer.StringSelection
+import static java.awt.Toolkit.*
+
+def curviewport = Jalview.getAlignframes()[Jalview.getAlignframes().length-1].getViewport()
+
+def debug = false
+
+// TSV output by default.
+// change "\t" to "," to output CSV file
+def sep = "\t"
+def gapChar = "-"
+
+if (curviewport.getSelectionGroup()) {
+ // gets selection for topmost alignment
+ def selreg = curviewport.getSelectionGroup()
+ def groupStartCol = selreg.getStartRes()
+ def groupEndCol = selreg.getEndRes()
+
+ if (debug) {println "groupStartCol: " + groupStartCol + ", groupEndCol: " + groupEndCol}
+
+ def csv=new StringBuilder(512)
+
+ // for each sequence in the current selection
+ selreg.getSequences().eachWithIndex{ seq, seqNo ->
+ csv.append(seq.getDisplayId(false).padRight(20,' '))
+ // get map of sequence sites to alignment positions
+ def gaps = seq.gapMap()
+ if (debug) {println "gaps: " + gaps}
+
+ // initialise loop variable to 'not quite shown first column'
+ def lastColShown = groupStartCol-1
+
+ for (mapPos=0 ; ; mapPos++) {
+ def nextResiduePos = gaps[mapPos]
+ // skip over sites that precede selected columns
+ if (nextResiduePos < groupStartCol) {
+ continue;
+ }
+
+ if (debug) {println "mapPos: " + mapPos + ", lastColShown: " + lastColShown + ", nextResiduePos: " + nextResiduePos + ", csv: " + csv}
+
+ // fill in any gaps
+ while (lastColShown < groupEndCol && lastColShown+1 < nextResiduePos) {
+ csv.append(sep+gapChar)
+ lastColShown++
+ }
+ if (lastColShown >= groupEndCol) {
+ break
+ }
+ lastColShown = nextResiduePos
+ def residue = seq.getDatasetSequence().getCharAt(mapPos)
+ csv.append(sep+(mapPos+1) + " (" + residue + ")") // user output is base 1
+ }
+ csv.append("\n")
+ }
+ def result = csv.toString()
+ defaultToolkit.systemClipboard.setContents(new StringSelection(result), null)
+ print result
+ println "Sites for selected region copied to the clipboard"
+} else {
+ "Select a region in the alignment window."
+}
<p><strong>Sequence logo</strong></p>
By clicking on the label you can also activate the sequence logo. It
indicates the relative amount of residues per column which can be
- estimated by it's size in the logo. The tooltip of a column gives the
+ estimated by its size in the logo. The tooltip of a column gives the
exact numbers for all occuring residues.
<br />If columns of the alignment are very diverse, then it can
sometimes be difficult to see the sequence logo - in this case, right
are two residues per column, the actual column and the interacting
base. The opening bracket is always the one on the left side.<br>
Like sequence logos the relative amount of a specific base pair can be
-estimated by it's size in the logo. The tool tip of a column gives the
+estimated by its size in the logo. The tool tip of a column gives the
exact numbers for all occurring valid base pairs.
</p>
</body>
</head>
<body>
-<p> <em>Colouring above a percentage identity threshold</em></p>
+<p> <strong>Colouring above a percentage identity threshold</strong></p>
<p> Selecting this option causes the colour scheme to be applied to only those
residues that occur in that column more than a certain percentage of the time.
For instance selecting the threshold to be 100 will only colour those columns
<body>
-<p><em>Blosum62</a></em> </p>
+<p><strong>Blosum62</a></strong> </p>
<p>Gaps are coloured white. If a residue matches the consensus sequence residue
at that position it is coloured dark blue. If it does not match the consensus
residue but the 2 residues have a positive Blosum62 score, it is coloured light
</head>
<body>
-<p><em>Buried index</em></p>
+<p><strong>Buried index</strong></p>
<div align="center">
<table width="400" border="1">
<tr>
</head>
<body>
-<p><em>Clustal X Colour Scheme</em></p>
+<p><strong>Clustal X Colour Scheme</strong></p>
<p>This is an emulation of the default colourscheme used for alignments in
Clustal X, a graphical interface for the ClustalW multiple sequence alignment
program. Each residue in the alignment is assigned a colour if the
-->
<head><title>Colouring by Conservation</title></head>
<body>
-<p><em>Colouring by Conservation</em></p>
+<p><strong>Colouring by Conservation</strong></p>
<p>This is an approach to alignment colouring which highlights
regions of an alignment where physicochemical properties are
conserved. It is based on the one used in
</head>
<body>
-<p><em>Helix Propensity</em> </p>
+<p><strong>Helix Propensity</strong> </p>
<div align="center">
<table width="400" border="1">
<tr>
</head>
<body>
-<p><em>Hydrophobicity</em></p>
+<p><strong>Hydrophobicity</strong></p>
<p>According to the hydrophobicity table of Kyte, J., and Doolittle, R.F., J.
Mol. Biol. 1157, 105-132, 1982. The most hydrophobic residues according to this
table are coloured red and the most hydrophilic ones are coloured blue.</p>
</head>
<body>
-<p><em>Nucleotide Colours</em></p>
+<p><strong>Nucleotide Colours</strong></p>
<div align="center">
<table width="200" border="1">
<tr>
</head>
<body>
-<p><em>PID Colours</em><br>
+<p><strong>PID Colours</strong><br>
<br>
The PID option colours the residues (boxes and/or text) according to the percentage
of the residues in each column that agree with the consensus sequence. Only
</head>
<body>
-<p><em>Purine/Pyrimidine Colours</em></p>
+<p><strong>Purine/Pyrimidine Colours</strong></p>
<div align="center">
<table width="200" border="1">
<tr>
</head>
<body>
-<p><em>Strand propensity</em></p>
+<p><strong>Strand propensity</strong></p>
<div align="center">
<table width="400" border="1">
<tr>
</head>
<body>
-<p><em><a name="taylor">Taylor</a></em></p>
+<p><strong><a name="taylor">Taylor</a></strong></p>
<p>These colours were invented by Willie Taylor and an entertaining description
of their birth can be found in Protein Engineering, Vol 10 , 743-746 (1997)</p>
<div align="center">
</head>
<body>
-<p><em>Turn propensity</em></p>
+<p><strong>Turn propensity</strong></p>
<div align="center">
<table width="400" border="1">
<tr>
-->
<head><title>User Defined Colours</title></head>
<body>
-<p><em>User Defined Colours</em></p>
-<p><img src="userDefined.gif" width="719" height="368"> </p>
+<p><strong>User Defined Colours</strong></p>
+<p><img src="userDefined_java6.gif" width="815" height="402"> </p>
<p>You may define any number of new colour schemes, each with a unique name. <br>
<br>
- Each of the residues in a new colour scheme may be assigned a new user defined
- colour. <br>
- <br>
- Click "Apply" or "OK" to set your new colours on the active
- alignment window. </p>
-<p>Click "Cancel" to undo your changes if you pressed the "Apply"
- button. <br>
- <br>
- If you save your colour scheme with a unique name the colour scheme name will
- be added to the "Colour" menu on each new alignment window.<br>
+ Each of the residues in a colour scheme may be assigned any chosen colour. <br>
+ Select one or more residues, then select the desired colour.<br/>
+ Use Ctrl-click to select multiple residues, or click then Shift-click to select a block.<br/>
+ Note that the currently selected buttons are highlighted by a lighter text colour.
+ <p>
+ The <strong>Case Sensitive</strong> option allows you to choose distinct colours for upper and
+ lower case residue codes.
+ <p>
+ Click <strong>Apply</strong> or <strong>OK</strong> to set your new colours on the active
+ alignment window.<br/>
+ Click <strong>Cancel</strong> to undo your changes if you pressed the <strong>Apply</strong>
+ button.
+ </p>
+ If you save your colour scheme with a unique name, the colour scheme name will
+ be added to the <strong>Colour</strong> menu on each new alignment window.<br>
<br>
Any saved colour schemes will be automatically loaded the next time you use
- Jalview.</p>
+ Jalview.
+ <br><br>
+ <em>Note: the screenshot shows the appearance when running Java version 6. For Java 7 (from Jalview 2.8.2) only the Swatches colour chooser is
+ currently supported (for reasons of available screen space).</em>
+ <p/>
</body>
</html>
</head>
<body>
-<p><em>Zappo Colours</em><br>
+<p><strong>Zappo Colours</strong><br>
<br>
The residues are coloured according to their physicochemical properties as
follows: </p>
The jars are obtained from the <em>embedded</em> directory within the
<a href="http://dist.codehaus.org/groovy/distributions">groovy
distribution</a>. The easiest way of adding them to the Jalview classpath
- is to download and build jalview from it's source distribution, and
+ is to download and build jalview from its source distribution, and
then add the groovy-all-*.jar to the lib directory whose path is given
in the java.ext.dirs property.
</p>
then tries to query a subset of all the databases it can access in order to match
the alignment sequence to any records retrieved from the database. If a
match is found, then the sequence is annotated with that database's
-reference, and any cross-references that it's records contain.</p>
+reference, and any cross-references that its records contain.</p>
<p><strong>The Sequence Identification Process</strong><br>
The method of accession id discovery is derived from the method which
earlier Jalview versions used for Uniprot sequence feature retrieval,
import jalview.schemes.ColourSchemeI;
import jalview.schemes.ResidueProperties;
import jalview.schemes.UserColourScheme;
+import jalview.util.ColorUtils;
import jalview.util.MessageManager;
import java.awt.Color;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
+import java.util.ArrayList;
import java.util.Hashtable;
import java.util.StringTokenizer;
-import java.util.Vector;
import javax.swing.JButton;
import javax.swing.JInternalFrame;
import javax.swing.event.ChangeListener;
/**
- * DOCUMENT ME!
+ * This panel allows the user to assign colours to Amino Acid residue codes, and
+ * save the colour scheme.
*
- * @author $author$
- * @version $Revision$
+ * @author Andrew Waterhouse
+ * @author Mungo Carstairs
*/
public class UserDefinedColours extends GUserDefinedColours implements
ChangeListener
{
+ private static final int MY_FRAME_HEIGHT = 420;
+
+ private static final int MY_FRAME_WIDTH = 810;
+
+ private static final int MY_FRAME_WIDTH_CASE_SENSITIVE = 970;
+
AlignmentPanel ap;
SequenceGroup seqGroup;
- Vector selectedButtons;
+ ArrayList<JButton> selectedButtons;
ColourSchemeI oldColourScheme;
JalviewStructureDisplayI jmol;
- Vector upperCaseButtons;
+ ArrayList<JButton> upperCaseButtons;
- Vector lowerCaseButtons;
+ ArrayList<JButton> lowerCaseButtons;
/**
* Creates a new UserDefinedColours object.
showFrame();
}
- public UserDefinedColours(JalviewStructureDisplayI jmol, ColourSchemeI oldcs)
+ public UserDefinedColours(JalviewStructureDisplayI jmol,
+ ColourSchemeI oldcs)
{
super();
this.jmol = jmol;
frame = new JInternalFrame();
frame.setContentPane(this);
Desktop.addInternalFrame(frame,
- MessageManager.getString("label.user_defined_colours"), 720,
- 370, true);
+ MessageManager.getString("label.user_defined_colours"),
+ MY_FRAME_WIDTH, MY_FRAME_HEIGHT, true);
if (seqGroup != null)
{
frame.setTitle(frame.getTitle() + " (" + seqGroup.getName() + ")");
}
-
- if (new jalview.util.Platform().isAMac())
- {
- frame.setSize(760, 370);
- }
}
void resetButtonPanel(boolean caseSensitive)
if (upperCaseButtons == null)
{
- upperCaseButtons = new Vector();
+ upperCaseButtons = new ArrayList<JButton>();
}
JButton button;
if (lowerCaseButtons == null)
{
- lowerCaseButtons = new Vector();
+ lowerCaseButtons = new ArrayList<JButton>();
}
for (int i = 0; i < 20; i++)
buttonPanel.add(makeButton("x", "x", lowerCaseButtons, 22));
}
+ // JAL-1360 widen the frame dynamically to accommodate case-sensitive AA
+ // codes
+ if (this.frame != null)
+ {
+ int newWidth = caseSensitive ? MY_FRAME_WIDTH_CASE_SENSITIVE
+ : MY_FRAME_WIDTH;
+ this.frame.setSize(newWidth, this.frame.getHeight());
+ }
+
buttonPanel.validate();
validate();
}
* @param evt
* DOCUMENT ME!
*/
+ @Override
public void stateChanged(ChangeEvent evt)
{
if (selectedButtons != null)
{
JButton button = null;
+ final Color newColour = colorChooser.getColor();
for (int i = 0; i < selectedButtons.size(); i++)
{
- button = (JButton) selectedButtons.elementAt(i);
- button.setBackground(colorChooser.getColor());
- button.setForeground(button.getBackground().brighter().brighter()
- .brighter());
+ button = selectedButtons.get(i);
+ button.setBackground(newColour);
+ button.setForeground(ColorUtils.brighterThan(newColour));
}
if (button == lcaseColour)
{
for (int i = 0; i < lowerCaseButtons.size(); i++)
{
- button = (JButton) lowerCaseButtons.elementAt(i);
- button.setBackground(colorChooser.getColor());
- button.setForeground(button.getBackground().brighter().brighter()
- .brighter());
+ button = lowerCaseButtons.get(i);
+ button.setBackground(newColour);
+ button.setForeground(ColorUtils.brighterThan(button
+ .getBackground()));
}
}
}
}
/**
- * DOCUMENT ME!
+ * Performs actions when a residue button is clicked. This manages the button
+ * selection set (highlighted by brighter foreground text).
+ * <p>
+ * On select button(s) with Ctrl/click or Shift/click: set button foreground
+ * text to brighter than background.
+ * <p>
+ * On unselect button(s) with Ctrl/click on selected, or click to release
+ * current selection: reset foreground text to darker than background.
+ * <p>
+ * Simple click: clear selection (resetting foreground to darker); set clicked
+ * button foreground to brighter
+ * <p>
+ * Finally, synchronize the colour chooser to the colour of the first button
+ * in the selected set.
*
* @param e
- * DOCUMENT ME!
*/
public void colourButtonPressed(MouseEvent e)
{
if (selectedButtons == null)
{
- selectedButtons = new Vector();
+ selectedButtons = new ArrayList<JButton>();
}
JButton pressed = (JButton) e.getSource();
JButton start, end = (JButton) e.getSource();
if (selectedButtons.size() > 0)
{
- start = (JButton) selectedButtons
- .elementAt(selectedButtons.size() - 1);
+ start = selectedButtons.get(selectedButtons.size() - 1);
}
else
{
JButton button = (JButton) buttonPanel.getComponent(b);
if (!selectedButtons.contains(button))
{
- button.setForeground(button.getBackground().brighter().brighter());
+ button.setForeground(ColorUtils.brighterThan(button
+ .getBackground()));
selectedButtons.add(button);
}
}
{
for (int b = 0; b < selectedButtons.size(); b++)
{
- JButton button = (JButton) selectedButtons.elementAt(b);
- button.setForeground(button.getBackground().darker().darker());
+ JButton button = selectedButtons.get(b);
+ button.setForeground(ColorUtils.darkerThan(button.getBackground()));
}
selectedButtons.clear();
- pressed.setForeground(pressed.getBackground().brighter().brighter());
- selectedButtons.addElement(pressed);
+ pressed.setForeground(ColorUtils.brighterThan(pressed.getBackground()));
+ selectedButtons.add(pressed);
}
else if (e.isControlDown())
{
if (selectedButtons.contains(pressed))
{
- pressed.setForeground(pressed.getBackground().darker().darker());
+ pressed.setForeground(ColorUtils.darkerThan(pressed.getBackground()));
selectedButtons.remove(pressed);
}
else
{
- pressed.setForeground(pressed.getBackground().brighter().brighter());
- selectedButtons.addElement(pressed);
+ pressed.setForeground(ColorUtils.brighterThan(pressed
+ .getBackground()));
+ selectedButtons.add(pressed);
}
}
if (selectedButtons.size() > 0)
{
- colorChooser.setColor(((JButton) selectedButtons.elementAt(0))
- .getBackground());
+ colorChooser.setColor((selectedButtons.get(0)).getBackground());
}
}
* @param aa
* DOCUMENT ME!
*/
- JButton makeButton(String label, String aa, Vector caseSensitiveButtons,
- int buttonIndex)
+ JButton makeButton(String label, String aa,
+ ArrayList<JButton> caseSensitiveButtons, int buttonIndex)
{
final JButton button;
Color col;
if (buttonIndex < caseSensitiveButtons.size())
{
- button = (JButton) caseSensitiveButtons.elementAt(buttonIndex);
+ button = caseSensitiveButtons.get(buttonIndex);
col = button.getBackground();
}
else
button = new JButton();
button.addMouseListener(new java.awt.event.MouseAdapter()
{
+ @Override
public void mouseClicked(MouseEvent e)
{
colourButtonPressed(e);
}
});
- caseSensitiveButtons.addElement(button);
+ caseSensitiveButtons.add(button);
col = Color.white;
if (oldColourScheme != null)
button.setMargin(new java.awt.Insets(2, 14, 2, 14));
}
+ button.setOpaque(true); // required for the next line to have effect
button.setBackground(col);
button.setText(label);
- button.setForeground(col.darker().darker().darker());
+ button.setForeground(ColorUtils.darkerThan(col));
button.setFont(new java.awt.Font("Verdana", Font.BOLD, 10));
return button;
* @param e
* DOCUMENT ME!
*/
+ @Override
protected void okButton_actionPerformed(ActionEvent e)
{
applyButton_actionPerformed(null);
* @param e
* DOCUMENT ME!
*/
+ @Override
protected void applyButton_actionPerformed(ActionEvent e)
{
UserColourScheme ucs = getSchemeFromButtons();
for (int i = 0; i < 24; i++)
{
- JButton button = (JButton) upperCaseButtons.elementAt(i);
+ JButton button = upperCaseButtons.get(i);
newColours[i] = button.getBackground();
}
newColours = new Color[23];
for (int i = 0; i < 23; i++)
{
- JButton button = (JButton) lowerCaseButtons.elementAt(i);
+ JButton button = lowerCaseButtons.get(i);
newColours[i] = button.getBackground();
}
ucs.setLowerCaseColours(newColours);
* @param e
* DOCUMENT ME!
*/
+ @Override
protected void loadbutton_actionPerformed(ActionEvent e)
{
- upperCaseButtons = new Vector();
- lowerCaseButtons = new Vector();
+ upperCaseButtons = new ArrayList<JButton>();
+ lowerCaseButtons = new ArrayList<JButton>();
JalviewFileChooser chooser = new JalviewFileChooser(
jalview.bin.Cache.getProperty("LAST_DIRECTORY"), new String[]
resetButtonPanel(true);
for (int i = 0; i < lowerCaseButtons.size(); i++)
{
- JButton button = (JButton) lowerCaseButtons.elementAt(i);
+ JButton button = lowerCaseButtons.get(i);
button.setBackground(ucs.getLowerCaseColours()[i]);
}
for (int i = 0; i < upperCaseButtons.size(); i++)
{
- JButton button = (JButton) upperCaseButtons.elementAt(i);
+ JButton button = upperCaseButtons.get(i);
button.setBackground(colors[i]);
}
jalview.binding.JalviewUserColours jucs = new jalview.binding.JalviewUserColours();
- jucs = (jalview.binding.JalviewUserColours) jucs.unmarshal(in);
+ jucs = jucs.unmarshal(in);
newColours = new Color[jucs.getColourCount()];
* @param e
* DOCUMENT ME!
*/
+ @Override
protected void savebutton_actionPerformed(ActionEvent e)
{
if (schemeName.getText().trim().length() < 1)
{
int reply = JOptionPane.showInternalConfirmDialog(Desktop.desktop,
MessageManager.formatMessage(
- "label.colour_scheme_exists_overwrite", new String[]
+ "label.colour_scheme_exists_overwrite", new Object[]
{ schemeName.getText(), schemeName.getText() }),
MessageManager.getString("label.duplicate_scheme_name"),
JOptionPane.YES_NO_OPTION);
* @param e
* DOCUMENT ME!
*/
+ @Override
protected void cancelButton_actionPerformed(ActionEvent e)
{
if (ap != null)
}
+ @Override
public void caseSensitive_actionPerformed(ActionEvent e)
{
resetButtonPanel(caseSensitive.isSelected());
lcaseColour.setEnabled(caseSensitive.isSelected());
}
+ @Override
public void lcaseColour_actionPerformed(ActionEvent e)
{
if (selectedButtons == null)
{
- selectedButtons = new Vector();
+ selectedButtons = new ArrayList<JButton>();
}
else
{
}
selectedButtons.add(lcaseColour);
}
-
}
import java.awt.*;
import java.awt.event.*;
+
import javax.swing.*;
+import javax.swing.colorchooser.AbstractColorChooserPanel;
/**
* DOCUMENT ME!
jPanel4.add(panel1, java.awt.BorderLayout.CENTER);
this.add(jPanel4, java.awt.BorderLayout.CENTER);
this.add(colorChooser, java.awt.BorderLayout.EAST);
+
+ AbstractColorChooserPanel[] choosers = colorChooser.getChooserPanels();
+ // JAL-1360 larger JColorChooser in Java 7 overwrites AA panel; restrict to swatch picker only
+ if (choosers.length > 3) {
+ // Java 7 default has 5 options rather than 3 for choosing colours; keep the first only
+ colorChooser.setChooserPanels(new AbstractColorChooserPanel[]{choosers[0]});
+ }
}
/**
}
+ /**
+ * Returns a colour three shades darker. Note you can't guarantee that
+ * brighterThan reverses this, as darkerThan may result in black.
+ *
+ * @param col
+ * @return
+ */
+ public static Color darkerThan(Color col)
+ {
+ return col == null ? null : col.darker().darker().darker();
+ }
+
+ /**
+ * Returns a colour three shades brighter. Note you can't guarantee that
+ * darkerThan reverses this, as brighterThan may result in white.
+ *
+ * @param col
+ * @return
+ */
+ public static Color brighterThan(Color col)
+ {
+ return col == null ? null : col.brighter().brighter().brighter();
+ }
+
}
--- /dev/null
+package jalview.util;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNull;
+
+import java.awt.Color;
+
+import org.junit.Test;
+
+public class ColorUtilsTest
+{
+
+ Color paleColour = new Color(97, 203, 111); // pale green
+
+ Color midColour = new Color(135, 57, 41); // mid red
+
+ Color darkColour = new Color(11, 30, 50); // dark blue
+
+ @Test
+ public void testDarkerThan()
+ {
+ assertEquals("Wrong darker shade", new Color(32, 69, 37),
+ ColorUtils.darkerThan(paleColour));
+ assertEquals("Wrong darker shade", new Color(45, 18, 13),
+ ColorUtils.darkerThan(midColour));
+ assertEquals("Wrong darker shade", new Color(2, 9, 16),
+ ColorUtils.darkerThan(darkColour));
+ assertNull(ColorUtils.darkerThan(null));
+ }
+
+ @Test
+ public void testBrighterThan()
+ {
+ assertEquals("Wrong brighter shade", new Color(255, 255, 255), // white
+ ColorUtils.brighterThan(paleColour));
+ assertEquals("Wrong brighter shade", new Color(255, 164, 117),
+ ColorUtils.brighterThan(midColour));
+ assertEquals("Wrong brighter shade", new Color(30, 85, 144),
+ ColorUtils.brighterThan(darkColour));
+ assertNull(ColorUtils.brighterThan(null));
+ }
+}
--- /dev/null
+package jalview.ws.jabaws;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.fail;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.function.Consumer;
+
+import org.junit.Test;
+
+import compbio.data.msa.MsaWS;
+import compbio.data.msa.RegistryWS;
+import compbio.data.sequence.FastaSequence;
+import compbio.metadata.JobStatus;
+import compbio.ws.client.Jws2Client;
+import compbio.ws.client.Services;
+
+public class MinJabawsClientTests {
+
+ /**
+ * simple test for the benefit of JAL-1338
+ * @throws Exception
+ */
+ @SuppressWarnings("rawtypes")
+ @Test
+ public void msaTest() throws Exception {
+ String url;
+ RegistryWS registry = Jws2Client
+ .connectToRegistry(url = "http://www.compbio.dundee.ac.uk/jabaws");
+ if (registry != null) {
+
+ MsaWS msaservice = null;
+ for (Services service : registry.getSupportedServices()) {
+ if (service.equals(Services.ClustalOWS)) {
+ msaservice = (MsaWS) Jws2Client.connect(url, service);
+ if (msaservice != null) {
+ break;
+ }
+ }
+ }
+ if (msaservice == null) {
+ fail("couldn't find a clustalO service on the public registry");
+ }
+ FastaSequence fsq = new FastaSequence("seqA",
+ "SESESESESESESESSESESSESESESESESESESESESEEEEEESSESESESESSSSESESESESESESE");
+ List<FastaSequence> iseqs = new ArrayList<FastaSequence>();
+ for (int i = 0; i < 9; i++) {
+ iseqs.add(new FastaSequence(fsq.getId() + i, fsq.getSequence()
+ + fsq.getSequence().substring(i + 3, i + 3 + i)));
+ }
+
+ String jobid = msaservice.align(iseqs);
+ if (jobid != null) {
+ JobStatus js = null;
+ do {
+ try {
+ Thread.sleep(500);
+ } catch (InterruptedException q) {
+ }
+ ;
+ js = msaservice.getJobStatus(jobid);
+ } while (!js.equals(JobStatus.FAILED)
+ && !js.equals(JobStatus.CANCELLED)
+ && !js.equals(JobStatus.FINISHED));
+ assertEquals("Trial alignment failed. State was " + js.name(),
+ js, JobStatus.FINISHED);
+ assertEquals(
+ "Mismatch in number of input and result sequences - assume alignment service wasn't interacted with correctly",
+ msaservice.getResult(jobid).getSequences().size(),
+ iseqs.size());
+ msaservice.getResult(jobid).getSequences()
+ .forEach(new Consumer<FastaSequence>() {
+ @Override
+ public void accept(FastaSequence t) {
+ System.out.println(">"+t.getId());
+ System.out.println(t.getFormattedFasta());
+ }
+ });
+ }
+
+ }
+ }
+}