-jalview.release=releases/Release_2_10_2b1_Branch
-jalview.version=2.10.2b2
+jalview.release=releases/Release_2_10_3_Branch
+jalview.version=2.10.3
<p>
Gap open : 12 <br> Gap extend : 2
</p>
- <p>When you select the pairwise alignment option a new window will
- come up which will display the alignments in a text format as they
- are calculated. Also displayed is information about the alignment
- such as alignment score, length and percentage identity between the
+ <p>When you select the pairwise alignment option, a new window
+ will come up which displays the alignments in a text format, for
+ example:</p>
+ <p>
+ <pre>
+ FER1_SPIOL/5-13 TTMMGMAT<br />
+ |. .. ||<br />
+ FER1_MESCR/5-15 TAALSGAT
+ </pre>
+ shows the aligned sequences, where '|' links identical residues, and
+ (for peptide) '.' links residues that have a positive PAM250 score.
+ <p>The window also shows information about the alignment such as
+ alignment score, length and percentage identity between the
sequences.</p>
- <p> </p>
+ <p>A button is also provided to allow you to view the sequences as
+ an alignment.</p>
</body>
</html>
</li>
<li><!-- JAL-2617 -->Stop codons are excluded in CDS/Protein view from Ensembl locus cross-references</li>
+ <li><!-- JAL-2685 -->Start/End limits are shown in Pairwise Alignment report</li>
</ul>
<ul><li>Example groovy script for generating a matrix of percent identity scores for current alignment.</li></ul>
<em>Testing and Deployment</em>
<ul>
<li><!-- JAL-2643 -->Pressing tab after updating the colour threshold text field doesn't trigger an update to the alignment view</li>
<li><!-- JAL-2682 -->Race condition when parsing sequence ID strings in parallel</li>
- <li><!-- JAL-2608 -->Overview windows are also closed when alignment window is closed</li>
+ <li><!-- JAL-2608 -->Overview windows are also closed when alignment window is closed</li>
+ <li><!-- JAL-2548 -->Export of features doesn't always respect group visibility</li>
</ul>
<em>Desktop</em>
<ul>
<li><!-- JAL-2757 -->Can't edit the query after the server error warning icon is shown in Uniprot and PDB Free Text Search Dialogs
</li>
<li><!-- JAL-2253 -->Slow EnsemblGenome ID lookup</li>
+ <li><!-- JAL-2529 -->Revised Ensembl REST API CDNA query</li>
<li><!-- JAL-2739 -->Hidden column marker in last column not rendered when switching back from Wrapped to normal view</li>
<li><!-- JAL-2768 -->Annotation display corrupted when scrolling right in unwapped alignment view</li>
<li><!-- JAL-2542 -->Existing features on subsequence incorrectly relocated when full sequence retrieved from database</li>
<li><!-- JAL-1900,JAL-1625 -->Unable to minimise windows within the Jalview desktop on OSX</li>
<li><!-- JAL-2667 -->Mouse wheel doesn't scroll vertically when in wrapped alignment mode</li>
<li><!-- JAL-2636 -->Scale mark not shown when close to right hand end of alignment</li>
+ <li><!-- JAL-2684 -->Pairwise alignment only aligns selected regions of each selected sequence</li>
+ <li><!-- JAL-2973 -->Alignment ruler height set incorrectly after canceling the Alignment Window's Font dialog</li>
+ <li><!-- JAL-2036 -->Show cross-references not enabled after restoring project until a new view is created</li>
</ul>
<strong><em>Applet</em></strong><br/>
<ul>
<li><!-- JAL-2687 -->Concurrent modification exception when closing alignment panel</li>
</ul>
+ <strong><em>BioJSON</em></strong><br/>
+ <ul>
+ <li>
+ <!-- JAL-2546 -->BioJSON export does not preserve non-positional features
+ </li>
+ </ul>
</div>
</td>
</tr>
import java.awt.Color;
import java.awt.Graphics;
+import java.io.PrintStream;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
*/
public class AlignSeq
{
+ private static final int MAX_NAME_LENGTH = 30;
+
+ private static final int GAP_OPEN_COST = 120;
+
+ private static final int GAP_EXTEND_COST = 20;
+
+ private static final int GAP_INDEX = -1;
+
public static final String PEP = "pep";
public static final String DNA = "dna";
float[][] F;
- int[][] traceback;
+ int[][] traceback; // todo is this actually used?
int[] seq1;
/** DOCUMENT ME!! */
public int seq2start;
- /** DOCUMENT ME!! */
public int seq2end;
int count;
- /** DOCUMENT ME!! */
public float maxscore;
- float pid;
-
int prev = 0;
- int gapOpen = 120;
-
- int gapExtend = 20;
-
StringBuffer output = new StringBuffer();
String type; // AlignSeq.PEP or AlignSeq.DNA
private ScoreMatrix scoreMatrix;
- private static final int GAP_INDEX = -1;
-
/**
* Creates a new AlignSeq object.
*
}
}
- // System.out.println(maxi + " " + maxj + " " + score[maxi][maxj]);
int i = maxi;
int j = maxj;
int trace;
- maxscore = score[i][j] / 10;
+ maxscore = score[i][j] / 10f;
seq1end = maxi + 1;
seq2end = maxj + 1;
/**
* DOCUMENT ME!
*/
- public void printAlignment(java.io.PrintStream os)
+ public void printAlignment(PrintStream os)
{
// TODO: Use original sequence characters rather than re-translated
// characters in output
// Find the biggest id length for formatting purposes
- String s1id = s1.getName(), s2id = s2.getName();
- int maxid = s1.getName().length();
- if (s2.getName().length() > maxid)
- {
- maxid = s2.getName().length();
- }
- if (maxid > 30)
+ String s1id = getAlignedSeq1().getDisplayId(true);
+ String s2id = getAlignedSeq2().getDisplayId(true);
+ int nameLength = Math.max(s1id.length(), s2id.length());
+ if (nameLength > MAX_NAME_LENGTH)
{
- maxid = 30;
+ int truncateBy = nameLength - MAX_NAME_LENGTH;
+ nameLength = MAX_NAME_LENGTH;
// JAL-527 - truncate the sequence ids
- if (s1.getName().length() > maxid)
+ if (s1id.length() > nameLength)
{
- s1id = s1.getName().substring(0, 30);
+ int slashPos = s1id.lastIndexOf('/');
+ s1id = s1id.substring(0, slashPos - truncateBy)
+ + s1id.substring(slashPos);
}
- if (s2.getName().length() > maxid)
+ if (s2id.length() > nameLength)
{
- s2id = s2.getName().substring(0, 30);
+ int slashPos = s2id.lastIndexOf('/');
+ s2id = s2id.substring(0, slashPos - truncateBy)
+ + s2id.substring(slashPos);
}
}
- int len = 72 - maxid - 1;
+ int len = 72 - nameLength - 1;
int nochunks = ((aseq1.length - count) / len)
+ ((aseq1.length - count) % len > 0 ? 1 : 0);
- pid = 0;
+ float pid = 0f;
output.append("Score = ").append(score[maxi][maxj]).append(NEWLINE);
output.append("Length of alignment = ")
.append(String.valueOf(aseq1.length - count)).append(NEWLINE);
output.append("Sequence ");
- output.append(new Format("%" + maxid + "s").form(s1.getName()));
- output.append(" : ").append(String.valueOf(s1.getStart()))
- .append(" - ").append(String.valueOf(s1.getEnd()));
+ Format nameFormat = new Format("%" + nameLength + "s");
+ output.append(nameFormat.form(s1id));
output.append(" (Sequence length = ")
.append(String.valueOf(s1str.length())).append(")")
.append(NEWLINE);
output.append("Sequence ");
- output.append(new Format("%" + maxid + "s").form(s2.getName()));
- output.append(" : ").append(String.valueOf(s2.getStart()))
- .append(" - ").append(String.valueOf(s2.getEnd()));
+ output.append(nameFormat.form(s2id));
output.append(" (Sequence length = ")
.append(String.valueOf(s2str.length())).append(")")
.append(NEWLINE).append(NEWLINE);
for (int j = 0; j < nochunks; j++)
{
// Print the first aligned sequence
- output.append(new Format("%" + (maxid) + "s").form(s1id)).append(" ");
+ output.append(nameFormat.form(s1id)).append(" ");
for (int i = 0; i < len; i++)
{
}
output.append(NEWLINE);
- output.append(new Format("%" + (maxid) + "s").form(" ")).append(" ");
+ output.append(nameFormat.form(" ")).append(" ");
/*
* Print out the match symbols:
pid++;
output.append("|");
}
- else if (type.equals("pep"))
+ else if (PEP.equals(type))
{
if (pam250.getPairwiseScore(c1, c2) > 0)
{
// Now print the second aligned sequence
output = output.append(NEWLINE);
- output = output.append(new Format("%" + (maxid) + "s").form(s2id))
- .append(" ");
+ output = output.append(nameFormat.form(s2id)).append(" ");
for (int i = 0; i < len; i++)
{
}
pid = pid / (aseq1.length - count) * 100;
- output = output.append(new Format("Percentage ID = %2.2f\n").form(pid));
+ output.append(new Format("Percentage ID = %3.2f\n").form(pid));
+ output.append(NEWLINE);
try
{
os.print(output.toString());
public int findTrace(int i, int j)
{
int t = 0;
- // float pairwiseScore = lookup[seq1[i]][seq2[j]];
float pairwiseScore = scoreMatrix.getPairwiseScore(s1str.charAt(i),
s2str.charAt(j));
float max = score[i - 1][j - 1] + (pairwiseScore * 10);
// top left hand element
score[0][0] = scoreMatrix.getPairwiseScore(s1str.charAt(0),
s2str.charAt(0)) * 10;
- E[0][0] = -gapExtend;
+ E[0][0] = -GAP_EXTEND_COST;
F[0][0] = 0;
// Calculate the top row first
for (int j = 1; j < m; j++)
{
// What should these values be? 0 maybe
- E[0][j] = max(score[0][j - 1] - gapOpen, E[0][j - 1] - gapExtend);
- F[0][j] = -gapExtend;
+ E[0][j] = max(score[0][j - 1] - GAP_OPEN_COST, E[0][j - 1] - GAP_EXTEND_COST);
+ F[0][j] = -GAP_EXTEND_COST;
float pairwiseScore = scoreMatrix.getPairwiseScore(s1str.charAt(0),
s2str.charAt(j));
- score[0][j] = max(pairwiseScore * 10, -gapOpen, -gapExtend);
+ score[0][j] = max(pairwiseScore * 10, -GAP_OPEN_COST, -GAP_EXTEND_COST);
traceback[0][j] = 1;
}
// Now do the left hand column
for (int i = 1; i < n; i++)
{
- E[i][0] = -gapOpen;
- F[i][0] = max(score[i - 1][0] - gapOpen, F[i - 1][0] - gapExtend);
+ E[i][0] = -GAP_OPEN_COST;
+ F[i][0] = max(score[i - 1][0] - GAP_OPEN_COST, F[i - 1][0] - GAP_EXTEND_COST);
float pairwiseScore = scoreMatrix.getPairwiseScore(s1str.charAt(i),
s2str.charAt(0));
{
for (int j = 1; j < m; j++)
{
- E[i][j] = max(score[i][j - 1] - gapOpen, E[i][j - 1] - gapExtend);
- F[i][j] = max(score[i - 1][j] - gapOpen, F[i - 1][j] - gapExtend);
+ E[i][j] = max(score[i][j - 1] - GAP_OPEN_COST, E[i][j - 1] - GAP_EXTEND_COST);
+ F[i][j] = max(score[i - 1][j] - GAP_OPEN_COST, F[i - 1][j] - GAP_EXTEND_COST);
float pairwiseScore = scoreMatrix.getPairwiseScore(s1str.charAt(i),
s2str.charAt(j));
private AnnotationColumnChooser annotationColumnSelectionState;
- @Override
- public void finalize()
- {
- applet = null;
- quality = null;
- alignment = null;
- colSel = null;
- }
-
public AlignViewport(AlignmentI al, JalviewLite applet)
{
super(al);
// this value is set false when selection area being dragged
boolean fastPaint = true;
- @Override
- public void finalize() throws Throwable
- {
- alignFrame = null;
- av = null;
- vpRanges = null;
- seqPanel = null;
- seqPanelHolder = null;
- sequenceHolderPanel = null;
- scalePanel = null;
- scalePanelHolder = null;
- annotationPanel = null;
- annotationPanelHolder = null;
- annotationSpaceFillerHolder = null;
- super.finalize();
- }
-
public AlignmentPanel(AlignFrame af, final AlignViewport av)
{
try
*/
private AlignViewControllerGuiI avcg;
- @Override
- protected void finalize() throws Throwable
- {
- viewport = null;
- alignPanel = null;
- avcg = null;
- };
-
public AlignViewController(AlignViewControllerGuiI alignFrame,
AlignViewportI viewport, AlignmentViewPanel alignPanel)
{
private boolean isrna;
- /*
- * (non-Javadoc)
- *
- * @see java.lang.Object#finalize()
- */
- @Override
- protected void finalize() throws Throwable
- {
- sequenceRef = null;
- groupRef = null;
- super.finalize();
- }
-
public static int getGraphValueFromString(String string)
{
if (string.equalsIgnoreCase("BAR_GRAPH"))
to = tto;
}
- /*
- * (non-Javadoc)
- *
- * @see java.lang.Object#finalize()
- */
- @Override
- protected void finalize() throws Throwable
- {
- map = null;
- to = null;
- super.finalize();
- }
-
/**
* Returns an iterator which can serve up the aligned codon column positions
* and their corresponding peptide products
/*
* Create a new AlignmentPanel (with its own, new Viewport)
*/
- AlignmentPanel newap = new Jalview2XML().copyAlignPanel(alignPanel,
- true);
+ AlignmentPanel newap = new Jalview2XML().copyAlignPanel(alignPanel);
if (!copyAnnotation)
{
/*
public void itemStateChanged(ItemEvent evt)
{
fr.setGroupVisibility(check.getText(), check.isSelected());
- af.alignPanel.getSeqPanel().seqCanvas.repaint();
- if (af.alignPanel.overviewPanel != null)
- {
- af.alignPanel.overviewPanel.updateOverviewImage();
- }
-
resetTable(new String[] { grp });
+ af.alignPanel.paintAlignment(true, true);
}
});
groupPanel.add(check);
ap.av.setScaleProteinAsCdna(oldProteinScale);
ap.av.setProteinFontAsCdna(oldMirrorFont);
ap.av.antiAlias = oldSmoothFont;
- ap.paintAlignment(true, false);
+ ap.fontChanged();
if (scaleAsCdna.isVisible() && scaleAsCdna.isEnabled())
{
}
}
- void clearSeqRefs()
- {
- if (_cleartables)
- {
- if (seqRefIds != null)
- {
- seqRefIds.clear();
- }
- if (seqsToIds != null)
- {
- seqsToIds.clear();
- }
- if (incompleteSeqs != null)
- {
- incompleteSeqs.clear();
- }
- // seqRefIds = null;
- // seqsToIds = null;
- }
- else
- {
- // do nothing
- warn("clearSeqRefs called when _cleartables was not set. Doing nothing.");
- // seqRefIds = new Hashtable();
- // seqsToIds = new IdentityHashMap();
- }
- }
-
void initSeqRefs()
{
if (seqsToIds == null)
}
- public jalview.gui.AlignmentPanel copyAlignPanel(AlignmentPanel ap,
- boolean keepSeqRefs)
+ /**
+ * Provides a 'copy' of an alignment view (on action New View) by 'saving' the
+ * view as XML (but not to file), and then reloading it
+ *
+ * @param ap
+ * @return
+ */
+ public AlignmentPanel copyAlignPanel(AlignmentPanel ap)
{
initSeqRefs();
JalviewModel jm = saveState(ap, null, null, null);
- if (!keepSeqRefs)
- {
- clearSeqRefs();
- jm.getJalviewModelSequence().getViewport(0).setSequenceSetId(null);
- }
- else
- {
- uniqueSetSuffix = "";
- jm.getJalviewModelSequence().getViewport(0).setId(null); // we don't
- // overwrite the
- // view we just
- // copied
- }
+ uniqueSetSuffix = "";
+ jm.getJalviewModelSequence().getViewport(0).setId(null);
+ // we don't overwrite the view we just copied
+
if (this.frefedSequence == null)
{
- frefedSequence = new Vector();
+ frefedSequence = new Vector<SeqFref>();
}
viewportsAdded.clear();
return af.alignPanel;
}
- /**
- * flag indicating if hashtables should be cleared on finalization TODO this
- * flag may not be necessary
- */
- private final boolean _cleartables = true;
-
private Hashtable jvids2vobj;
- /*
- * (non-Javadoc)
- *
- * @see java.lang.Object#finalize()
- */
- @Override
- protected void finalize() throws Throwable
- {
- // really make sure we have no buried refs left.
- if (_cleartables)
- {
- clearSeqRefs();
- }
- this.seqRefIds = null;
- this.seqsToIds = null;
- super.finalize();
- }
-
private void warn(String msg)
{
warn(msg, null);
import jalview.analysis.AlignSeq;
import jalview.datamodel.Alignment;
-import jalview.datamodel.Sequence;
+import jalview.datamodel.AlignmentView;
+import jalview.datamodel.SequenceGroup;
import jalview.datamodel.SequenceI;
import jalview.jbgui.GPairwiseAlignPanel;
import jalview.util.MessageManager;
public class PairwiseAlignPanel extends GPairwiseAlignPanel
{
+ private static final String DASHES = "---------------------\n";
+
AlignmentViewport av;
- Vector sequences;
+ Vector<SequenceI> sequences;
/**
* Creates a new PairwiseAlignPanel object.
*
- * @param av
+ * @param viewport
* DOCUMENT ME!
*/
- public PairwiseAlignPanel(AlignmentViewport av)
+ public PairwiseAlignPanel(AlignmentViewport viewport)
{
super();
- this.av = av;
+ this.av = viewport;
- sequences = new Vector();
+ sequences = new Vector<SequenceI>();
- SequenceI[] seqs;
- String[] seqStrings = av.getViewAsString(true);
+ SequenceGroup selectionGroup = viewport.getSelectionGroup();
+ boolean isSelection = selectionGroup != null
+ && selectionGroup.getSize() > 0;
+ AlignmentView view = viewport.getAlignmentView(isSelection);
+ // String[] seqStrings = viewport.getViewAsString(true);
+ String[] seqStrings = view.getSequenceStrings(viewport
+ .getGapCharacter());
- if (av.getSelectionGroup() == null)
+ SequenceI[] seqs;
+ if (isSelection)
{
- seqs = av.getAlignment().getSequencesArray();
+ seqs = (SequenceI[]) view.getAlignmentAndHiddenColumns(viewport
+ .getGapCharacter())[0];
}
else
{
- seqs = av.getSelectionGroup().getSequencesInOrder(av.getAlignment());
+ seqs = av.getAlignment().getSequencesArray();
}
- String type = (av.getAlignment().isNucleotide()) ? AlignSeq.DNA
+ String type = (viewport.getAlignment().isNucleotide()) ? AlignSeq.DNA
: AlignSeq.PEP;
float[][] scores = new float[seqs.length][seqs.length];
- double totscore = 0;
+ double totscore = 0D;
int count = seqs.length;
-
- Sequence seq;
+ boolean first = true;
for (int i = 1; i < count; i++)
{
for (int j = 0; j < i; j++)
{
-
AlignSeq as = new AlignSeq(seqs[i], seqStrings[i], seqs[j],
seqStrings[j], type);
as.calcScoreMatrix();
as.traceAlignment();
+ if (!first)
+ {
+ System.out.println(DASHES);
+ textarea.append(DASHES);
+ }
+ first = false;
as.printAlignment(System.out);
- scores[i][j] = (float) as.getMaxScore()
- / (float) as.getASeq1().length;
+ scores[i][j] = as.getMaxScore()
+ / as.getASeq1().length;
totscore = totscore + scores[i][j];
textarea.append(as.getOutput());
if (count > 2)
{
- System.out.println(
- "Pairwise alignment scaled similarity score matrix\n");
+ printScoreMatrix(seqs, scores, totscore);
+ }
+ }
- for (int i = 0; i < count; i++)
- {
- jalview.util.Format.print(System.out, "%s \n",
- ("" + i) + " " + seqs[i].getName());
- }
+ /**
+ * Prints a matrix of seqi-seqj pairwise alignment scores to sysout
+ *
+ * @param seqs
+ * @param scores
+ * @param totscore
+ */
+ protected void printScoreMatrix(SequenceI[] seqs, float[][] scores,
+ double totscore)
+ {
+ System.out
+ .println("Pairwise alignment scaled similarity score matrix\n");
- System.out.println("\n");
+ for (int i = 0; i < seqs.length; i++)
+ {
+ System.out.println(String.format("%3d %s", i + 1,
+ seqs[i].getDisplayId(true)));
+ }
+
+ /*
+ * table heading columns for sequences 1, 2, 3...
+ */
+ System.out.print("\n ");
+ for (int i = 0; i < seqs.length; i++)
+ {
+ System.out.print(String.format("%7d", i + 1));
+ }
+ System.out.println();
- for (int i = 0; i < count; i++)
+ for (int i = 0; i < seqs.length; i++)
+ {
+ System.out.print(String.format("%3d", i + 1));
+ for (int j = 0; j < i; j++)
{
- for (int j = 0; j < i; j++)
- {
- jalview.util.Format.print(System.out, "%7.3f",
- scores[i][j] / totscore);
- }
+ /*
+ * as a fraction of tot score, outputs are 0 <= score <= 1
+ */
+ System.out.print(String.format("%7.3f", scores[i][j] / totscore));
}
-
- System.out.println("\n");
+ System.out.println();
}
+
+ System.out.println("\n");
}
/**
* @param e
* DOCUMENT ME!
*/
+ @Override
protected void viewInEditorButton_actionPerformed(ActionEvent e)
{
- Sequence[] seq = new Sequence[sequences.size()];
+ SequenceI[] seq = new SequenceI[sequences.size()];
for (int i = 0; i < sequences.size(); i++)
{
- seq[i] = (Sequence) sequences.elementAt(i);
+ seq[i] = sequences.elementAt(i);
}
AlignFrame af = new AlignFrame(new Alignment(seq),
import java.awt.event.ActionListener;
import java.awt.image.BufferedImage;
import java.beans.PropertyChangeEvent;
+import java.beans.PropertyChangeListener;
import java.io.FileOutputStream;
import java.util.ArrayList;
import java.util.List;
import javax.swing.ButtonGroup;
import javax.swing.JMenuItem;
import javax.swing.JRadioButtonMenuItem;
+import javax.swing.event.InternalFrameAdapter;
+import javax.swing.event.InternalFrameEvent;
import org.jibble.epsgraphics.EpsGraphics2D;
buildAssociatedViewMenu();
- av.addPropertyChangeListener(new java.beans.PropertyChangeListener()
+ final PropertyChangeListener listener = addAlignmentListener();
+
+ /*
+ * remove listener when window is closed, so that this
+ * panel can be garbage collected
+ */
+ addInternalFrameListener(new InternalFrameAdapter()
+ {
+ @Override
+ public void internalFrameClosed(InternalFrameEvent evt)
+ {
+ if (av != null)
+ {
+ av.removePropertyChangeListener(listener);
+ }
+ }
+ });
+
+ TreeLoader tl = new TreeLoader(newTree, inputData);
+ tl.start();
+
+ }
+
+ /**
+ * @return
+ */
+ protected PropertyChangeListener addAlignmentListener()
+ {
+ final PropertyChangeListener listener = new PropertyChangeListener()
{
@Override
public void propertyChange(PropertyChangeEvent evt)
repaint();
}
}
- });
-
- TreeLoader tl = new TreeLoader(newTree, inputData);
- tl.start();
-
+ };
+ av.addPropertyChangeListener(listener);
+ return listener;
}
@Override
private ItemListener _handler;
- @Override
- protected void finalize() throws Throwable
- {
- _selectedviews = null;
- _handler = null;
- _allviews = null;
- super.finalize();
- }
-
/**
* create a new view selection menu. This menu has some standard entries
* (select all, invert selection), and a checkbox for every view. Mousing over
return tempStructFile.toString();
}
- /*
- * (non-Javadoc)
- *
- * @see java.lang.Object#finalize()
- */
- @Override
- protected void finalize() throws Throwable
- {
- source = null;
- alignFrame = null;
- viewport = null;
- super.finalize();
- }
-
}
error = false;
}
- @Override
- protected void finalize() throws Throwable
- {
- dataIn = null;
- super.finalize();
- }
-
}
jvlite.setExecutor(this);
}
- @Override
- protected void finalize() throws Throwable
- {
- jvlite = null;
- executor = null;
- if (jsExecQueue != null)
- {
- jsExecQueue.clear();
- }
- jsExecQueue = null;
- super.finalize();
- }
-
private Vector jsExecQueue;
private Thread executor = null;
}
@Override
- public void finalize() throws Throwable
- {
- jvlite = null;
- super.finalize();
- }
-
- @Override
public void releaseReferences(Object svl)
{
public void removePropertyChangeListener(
java.beans.PropertyChangeListener listener)
{
- changeSupport.removePropertyChangeListener(listener);
+ if (changeSupport != null)
+ {
+ changeSupport.removePropertyChangeListener(listener);
+ }
}
/**
{
try
{
- Closeable svc = (Closeable) service;
- service = null;
- svc.close();
- } catch (Exception e)
+ ((Closeable) service).close();
+ } catch (Throwable t)
{
+ // ignore
}
- ;
}
super.finalize();
}
s2 = new Sequence("Seq2", "ASDFA");
s2.setStart(5);
s2.setEnd(9);
- s3 = new Sequence("Seq1", "SDFAQQQSSS");
+ s3 = new Sequence("Seq3", "SDFAQQQSSS");
}
};
as.printAlignment(ps);
- String expected = "Score = 320.0\nLength of alignment = 10\nSequence Seq1 : 3 - 18 (Sequence length = 14)\nSequence Seq1 : 1 - 10 (Sequence length = 10)\n\n"
- + "Seq1 SDFAQQQRRR\n"
- + " ||||||| \n"
- + "Seq1 SDFAQQQSSS\n\n" + "Percentage ID = 70.00\n";
+ String expected = "Score = 320.0\nLength of alignment = 10\nSequence Seq1/4-13 (Sequence length = 14)\nSequence Seq3/1-10 (Sequence length = 10)\n\n"
+ + "Seq1/4-13 SDFAQQQRRR\n"
+ + " ||||||| \n"
+ + "Seq3/1-10 SDFAQQQSSS\n\n" + "Percentage ID = 70.00\n\n";
assertEquals(expected, baos.toString());
}
}
--- /dev/null
+package jalview.gui;
+
+import static org.testng.Assert.assertEquals;
+
+import jalview.datamodel.AlignmentI;
+import jalview.datamodel.SequenceGroup;
+import jalview.io.DataSourceType;
+import jalview.io.FileLoader;
+
+import javax.swing.JTextArea;
+
+import junit.extensions.PA;
+
+import org.testng.annotations.Test;
+
+public class PairwiseAlignmentPanelTest
+{
+ @Test(groups = "Functional")
+ public void testConstructor_withSelectionGroup()
+ {
+ AlignFrame af = new FileLoader().LoadFileWaitTillLoaded(
+ "examples/uniref50.fa", DataSourceType.FILE);
+ AlignViewport viewport = af.getViewport();
+ AlignmentI al = viewport.getAlignment();
+
+ /*
+ * select columns 29-36 of sequences 4 and 5 for alignment
+ * Q93XJ9_SOLTU/23-29 L-KAISNV
+ * FER1_PEA/26-32 V-TTTKAF
+ */
+ SequenceGroup sg = new SequenceGroup();
+ sg.addSequence(al.getSequenceAt(3), false);
+ sg.addSequence(al.getSequenceAt(4), false);
+ sg.setStartRes(28);
+ sg.setEndRes(35);
+ viewport.setSelectionGroup(sg);
+
+ PairwiseAlignPanel testee = new PairwiseAlignPanel(viewport);
+
+ String text = ((JTextArea) PA.getValue(testee, "textarea")).getText();
+ String expected = "Score = 80.0\n" + "Length of alignment = 4\n"
+ + "Sequence FER1_PEA/29-32 (Sequence length = 7)\n"
+ + "Sequence Q93XJ9_SOLTU/23-26 (Sequence length = 7)\n\n"
+ + " FER1_PEA/29-32 TKAF\n" + " ||.\n"
+ + "Q93XJ9_SOLTU/23-26 LKAI\n\n" + "Percentage ID = 50.00\n\n";
+ assertEquals(text, expected);
+ }
+
+ /**
+ * This test aligns the same sequences as testConstructor_withSelectionGroup
+ * but as a complete alignment (no selection). Note that in fact the user is
+ * currently required to make a selection in order to calculate pairwise
+ * alignments, so this case does not arise.
+ */
+ @Test(groups = "Functional")
+ public void testConstructor_noSelectionGroup()
+ {
+ String seqs = ">Q93XJ9_SOLTU/23-29\nL-KAISNV\n>FER1_PEA/26-32\nV-TTTKAF\n";
+ AlignFrame af = new FileLoader().LoadFileWaitTillLoaded(seqs,
+ DataSourceType.PASTE);
+ AlignViewport viewport = af.getViewport();
+
+ PairwiseAlignPanel testee = new PairwiseAlignPanel(viewport);
+
+ String text = ((JTextArea) PA.getValue(testee, "textarea")).getText();
+ String expected = "Score = 80.0\n" + "Length of alignment = 4\n"
+ + "Sequence FER1_PEA/29-32 (Sequence length = 7)\n"
+ + "Sequence Q93XJ9_SOLTU/23-26 (Sequence length = 7)\n\n"
+ + " FER1_PEA/29-32 TKAF\n" + " ||.\n"
+ + "Q93XJ9_SOLTU/23-26 LKAI\n\n" + "Percentage ID = 50.00\n\n";
+ assertEquals(text, expected);
+ }
+}