import jalview.api.analysis.ScoreModelI;
import jalview.api.analysis.SimilarityParamsI;
import jalview.bin.Console;
-import jalview.datamodel.AlignmentView;
import jalview.datamodel.Point;
import jalview.datamodel.SequenceI;
import jalview.datamodel.SequenceGroup;
import jalview.gui.PairwiseAlignPanel;
-import jalview.gui.PaSiMapPanel;
import jalview.math.Matrix;
import jalview.math.MatrixI;
-import jalview.math.MiscMath;
import jalview.viewmodel.AlignmentViewport;
import java.io.PrintStream;
-import java.util.ArrayList;
import java.util.Hashtable;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Enumeration;
/**
* Performs Principal Component Analysis on given sequences
final private ScoreModelI scoreModel;
- final private SimilarityParamsI similarityParams;
-
final private byte dim = 3;
final private int openCost = 100;
final private int extendCost = 5;
/*
- * other
- */
- private long total; // total number of combinations
-
- private long count; // current iteration number
-
- /*
* outputs
*/
- private PairwiseAlignPanel alignment;
+ final private PairwiseAlignPanel alignment;
private MatrixI pairwiseScores;
* @param sm
* @param options
*/
- public PaSiMap(AlignmentViewport sequences, ScoreModelI sm,
- SimilarityParamsI options)
+ public PaSiMap(AlignmentViewport sequences, ScoreModelI sm, PairwiseAlignPanel pap)
{
this.seqs = sequences;
this.scoreModel = sm;
- this.similarityParams = options;
- int nseqs = seqs.getAlignment().getHeight();
- this.total = (long) MiscMath.permutations(nseqs, 2) / 2; // n!/(n-r)!
- this.count = 0l;
+ this.alignment = pap;
}
/**
{
try
{
-for (SequenceI see : seqs.getAlignment().getSequencesArray())
-{
-System.out.println(see.getName());
-}
-
-/*
- int nSeqs = seqs.getAlignment().getHeight();
- float[][] scores = new float[nSeqs][nSeqs]; // rows, cols
-
- int nSplits = 1;
- while (((float) nSeqs / nSplits) > 20f) // heap full at 341
- //while (((float) nSeqs / nSplits) > 5f) // heap full at 341
- nSplits++;
- int splitSeqs = (int) Math.ceil((float) nSeqs / nSplits);
-System.out.println(String.format("%d -> %d splits into %d seqs", nSeqs, nSplits, splitSeqs));
-
- int[] splitIndices = new int[nSplits];
- for (int i = 0; i < nSplits; i++)
- {
- splitIndices[i] = splitSeqs * (i + 1); //exclusive!!
- }
-
- HashMap<int[], Float> valuesForScores = splitCombineAndAlign(seqs.getAlignment().getSequencesArray(), splitIndices, splitSeqs);
-
- for (int[] coords : valuesForScores.keySet())
- {
- scores[coords[0]][coords[1]] = valuesForScores.get(coords);
- }
-pairwiseScores = new Matrix(scores);
-pairwiseScores.print(System.out, "%1.4f ");
-*/
-
- alignment = new PairwiseAlignPanel(seqs, true, 100, 5);
+ //alignment = new PairwiseAlignPanel(seqs, true, 100, 5);
+ alignment.calculate();
float[][] scores = alignment.getAlignmentScores(); //bigger index first -- eg scores[14][13]
- //Hashtable<SequenceI, Integer> connectivity = seqs.calculateConnectivity(scores, dim);
+ seqs.calculateConnectivity(scores, dim);
pairwiseScores = new Matrix(scores);
-pairwiseScores.print(System.out, "%1.4f ");
pairwiseScores.fillDiagonal();
eigenMatrix = pairwiseScores.copy();
}
/**
- * aligns sequences in splits
- * Splits each split into halves and aligns them agains halves of other splits
- *
- * @param seqs
- * @param i ~ indices of split
- * @param s ~ sequences per split
- *
- * @return a map of where to put in scores, value ~ scores[n][m] = v
- **/
- protected HashMap<int[], Float> splitCombineAndAlign(SequenceI[] seqArray, int[] i, int s)
- {
- HashMap<int[], Float> result = new HashMap<int[], Float>();
-
- int[][] allGroups = new int[i.length][s];
- for (int g = 0; g < i.length; g++) // group g
- {
- int e = 0; // index going through allGroups[][e]
- for (int j = g * s; j < i[g]; j++) // goes through all numbers in one group
- {
- allGroups[g][e++] = j >= seqArray.length ? -1 : j;
- }
- }
-
- int g = 0; // group count
- for (int[] group : allGroups)
- {
- ArrayList<SequenceI> sg = new ArrayList<SequenceI>();
- //SequenceGroup sg = new SequenceGroup();
- for (int index : group)
- {
- if (index == -1)
- continue;
- //sg.addSequence(seqArray[index], false);
- sg.add(seqArray[index]);
- }
- SequenceI[] sgArray = new SequenceI[sg.size()];
- int k = 0;
- for (SequenceI seq : sg)
- {
- sgArray[k++] = seq;
- }
- //seqs.setSelectionGroup(sg);
- //PairwiseAlignPanel pap = new PairwiseAlignPanel(seqs, true, 100, 5);
- //float[][] scores = pap.getAlignmentScores(); //bigger index first -- eg scores[14][13]
- float[][] scores = simulateAlignment(sgArray);
- for (int s1 = 0; s1 < scores.length; s1++) // row
- {
- result.put(new int[]{s1 + g * s, s1 + g * s}, Float.NaN); // self score = Float.NaN
- for (int s2 = 0; s2 < s1; s2++) // col
- {
-System.out.println(String.format("%s x %s -> [%d][%d] (%f)", sgArray[s1].getName(), sgArray[s2].getName(), s1+g*s, s2+g*s, scores[s1][s2]));
- result.put(new int[]{s1 + g * s, s2 + g * s}, scores[s1][s2]);
- }
- }
- g++;
- }
-
- int smallS = (int) Math.ceil((float) s/2);
- int[][] newGroups = new int[i.length * 2][smallS];
-
- g = 0;
- for (int[] group : allGroups)
- {
- int[] split1 = new int[smallS];
- int[] split2 = new int[smallS];
- for (int k = 0; k < group.length; k++)
- {
- if (k < smallS)
- split1[k] = group[k];
- else
- split2[k - smallS] = group[k];
- }
- newGroups[g++] = split1;
- newGroups[g++] = split2;
- }
-
- // align each subsplit with subsplits from other split groups
- for (int subsplitN = 0; subsplitN < newGroups.length; subsplitN++)
- {
-System.gc();
- int c = 1; // current subsplit block
- while (newGroups[subsplitN][0] > smallS * c)
- {
- c++;
- }
- for (int nextSplit = subsplitN + 1; nextSplit < newGroups.length; nextSplit++)
- {
-System.out.println(String.format("subsplitN %d, nextSplit %d, %d > %d * %d", subsplitN, nextSplit, allGroups[(int) Math.floor((float) nextSplit / 2)][0], smallS, c));
- if (allGroups[(int) Math.floor((float) nextSplit / 2)][0] > smallS * c)
- {
- ArrayList<SequenceI> sg = new ArrayList<SequenceI>();
- //SequenceGroup sg = new SequenceGroup();
- for (int index : newGroups[subsplitN])
- {
- if (index == -1)
- continue;
- //sg.addSequence(seqArray[index], false);
- sg.add(seqArray[index]);
- }
- for (int index : newGroups[nextSplit])
- {
- if (index == -1)
- continue;
- //sg.addSequence(seqArray[index], false);
- sg.add(seqArray[index]);
- }
- SequenceI[] sgArray = new SequenceI[sg.size()];
- int k = 0;
- for (SequenceI seq : sg)
- {
- sgArray[k++] = seq;
- }
- //seqs.setSelectionGroup(sg);
- //PairwiseAlignPanel pap = new PairwiseAlignPanel(seqs, true, 100, 5);
- //float[][] scores = pap.getAlignmentScores(); //bigger index first -- eg scores[14][13]
- float[][] scores = simulateAlignment(sgArray);
-System.gc();
- for (int s1 = 0; s1 < scores.length; s1++) // row
- {
- for (int s2 = 0; s2 < s1; s2++) // col
- {
- if (s1 >= smallS && s2 < smallS)
-System.out.println(String.format("%s x %s -> [%d][%d] (%f)", sgArray[s1].getName(), sgArray[s2].getName(), s1+(nextSplit-1)*smallS, s2+subsplitN*smallS, scores[s1][s2]));
- result.put(new int[]{s1 + (nextSplit-1) * smallS, s2 + subsplitN * smallS}, scores[s1][s2]);
- }
- }
- }
- }
- }
-
- return result;
- }
-
- /**
- * simulate the alignment of a PairwiseAlignPanel
- *
- * @param seqs
- * @return alignment scores
- */
- protected float[][] simulateAlignment(SequenceI[] seqs)
- {
- float[][] result = new float[seqs.length][seqs.length];
- for (int i = 1; i < seqs.length; i++)
- {
- for (int j = 0; j < i; j++)
- {
- String[] seqStrings = new String[2];
- seqStrings[0] = seqs[i].getSequenceAsString();
- seqStrings[1] = seqs[j].getSequenceAsString();
-
- AlignSeq as = new AlignSeq(seqs[i], seqStrings[0], seqs[j], seqStrings[1], AlignSeq.PEP, openCost, extendCost);
- as.seqInit(seqs[i], seqStrings[0], seqs[j], seqStrings[1], AlignSeq.PEP);
- as.calcScoreMatrix();
- as.traceAlignmentWithEndGaps();
- as.scoreAlignment();
- //as.printAlignment(System.out);
- result[i][j] = as.getAlignmentScore();
- //as.clear();
-
-System.out.println(String.format("%d / %d (%3.2f)", count, total, (float) ((count / total) * 100)));
- count++;
- }
- }
- return result;
- }
-
- /**
* Returns a PrintStream that wraps (appends its output to) the given
* StringBuilder
*
import javax.swing.JMenu;
import javax.swing.JMenuItem;
import javax.swing.JPanel;
+import javax.swing.JProgressBar;
import javax.swing.JScrollPane;
import javax.swing.SwingUtilities;
}
@Override
+ public JProgressBar getProgressBar(long id)
+ {
+ if (progressBar != null)
+ return progressBar.getProgressBar(id);
+ return null;
+ }
+
+ @Override
public void registerHandler(final long id,
final IProgressIndicatorHandler handler)
{
*/
package jalview.gui;
+import java.awt.Font;
import java.awt.Toolkit;
import java.awt.datatransfer.Clipboard;
import java.awt.datatransfer.DataFlavor;
}
/**
+ * set font size of the textarea
+ * @param size
+ */
+ public void setFont(Font font)
+ {
+ textarea.setFont(font);
+ }
+
+ /**
* DOCUMENT ME!
*/
public void setForInput(AlignmentViewPanel viewpanel)
{
}
}
+
+ /**
+ * show menu for changing the font
+ * @param e
+ */
+ @Override
+ public void fontSizeMenu_actionPerformed(ActionEvent e)
+ {
+ new FontChooser(this);
+ }
/**
* DOCUMENT ME!
import java.awt.BorderLayout;
import java.awt.Color;
+import java.awt.Component;
import java.awt.Dimension;
import java.awt.FontMetrics;
import java.awt.Graphics;
}
}
+ @Override
+ public JProgressBar getProgressBar(long id)
+ {
+ if (progressBars == null)
+ return null;
+
+ if (progressBars.get(Long.valueOf(id)) == null)
+ return null;
+
+ for (Component c : progressBars.get(Long.valueOf(id)).getComponents())
+ {
+ if (c.getClass() == JProgressBar.class)
+ return (JProgressBar) c;
+ }
+ return null;
+ }
+
/*
* (non-Javadoc)
*
TreePanel tp;
+ CutAndPasteTransfer cap;
+
/*
* The font on opening the dialog (to be restored on Cancel)
*/
init();
}
+ /**
+ * Creates a new FontChooser for a CutAndPasteTransfer
+ * @param cap
+ */
+ public FontChooser(CutAndPasteTransfer cap)
+ {
+ oldFont = new Font("Monospaced", Font.PLAIN, 12);
+ this.cap = cap;
+ init();
+ }
+
void init()
{
frame = new JInternalFrame();
frame.setFrameIcon(null);
frame.setContentPane(this);
- smoothFont.setSelected(ap.av.antiAlias);
-
- /*
- * Enable 'scale protein as cDNA' in a SplitFrame view. The selection is
- * stored in the ViewStyle of both dna and protein Viewport. Also enable
- * checkbox for copy font changes to other half of split frame.
- */
- boolean inSplitFrame = ap.av.getCodingComplement() != null;
- if (inSplitFrame)
+ if (!isCapFont())
{
- oldComplementFont = ((AlignViewport) ap.av.getCodingComplement())
- .getFont();
- oldComplementSmooth = ((AlignViewport) ap.av
- .getCodingComplement()).antiAlias;
- scaleAsCdna.setVisible(true);
- scaleAsCdna.setSelected(ap.av.isScaleProteinAsCdna());
- fontAsCdna.setVisible(true);
- fontAsCdna.setSelected(ap.av.isProteinFontAsCdna());
+ smoothFont.setSelected(ap.av.antiAlias);
+
+ /*
+ * Enable 'scale protein as cDNA' in a SplitFrame view. The selection is
+ * stored in the ViewStyle of both dna and protein Viewport. Also enable
+ * checkbox for copy font changes to other half of split frame.
+ */
+ boolean inSplitFrame = ap.av.getCodingComplement() != null;
+ if (inSplitFrame)
+ {
+ oldComplementFont = ((AlignViewport) ap.av.getCodingComplement())
+ .getFont();
+ oldComplementSmooth = ((AlignViewport) ap.av
+ .getCodingComplement()).antiAlias;
+ scaleAsCdna.setVisible(true);
+ scaleAsCdna.setSelected(ap.av.isScaleProteinAsCdna());
+ fontAsCdna.setVisible(true);
+ fontAsCdna.setSelected(ap.av.isProteinFontAsCdna());
+ }
}
if (isTreeFont())
return tp != null;
}
+ private boolean isCapFont()
+ {
+ return cap != null;
+ }
/**
* DOCUMENT ME!
*/
splitFrame.repaint();
}
}
+ else if (isCapFont())
+ {
+ cap.setFont(newFont);
+ }
monospaced.setSelected(mw == iw);
*/
package jalview.gui;
+import javax.swing.JProgressBar;
+
/**
* Visual progress indicator interface.
*
*/
boolean operationInProgress();
+ /**
+ *
+ * @param id
+ * @return progressbar mapped to id
+ */
+ public JProgressBar getProgressBar(long id);
+
}
import javax.swing.ButtonGroup;
import javax.swing.JMenuItem;
+import javax.swing.JProgressBar;
import javax.swing.JRadioButtonMenuItem;
import javax.swing.event.InternalFrameAdapter;
import javax.swing.event.InternalFrameEvent;
getRotatableCanvas().ap = panel;
PaintRefresher.Register(PCAPanel.this, panel.av.getSequenceSetId());
}
+
+ @Override
+ public JProgressBar getProgressBar(long id)
+ {
+ return progressBar.getProgressBar(id);
+ }
}
import java.awt.print.Printable;
import java.awt.print.PrinterException;
import java.awt.print.PrinterJob;
+import java.beans.PropertyChangeEvent;
+import java.beans.PropertyChangeListener;
import javax.swing.ButtonGroup;
import javax.swing.JMenuItem;
+import javax.swing.JProgressBar;
import javax.swing.JRadioButtonMenuItem;
import javax.swing.event.InternalFrameAdapter;
import javax.swing.event.InternalFrameEvent;
private static final int MIN_HEIGHT = 250;
+ private final int GAP_OPEN_COST = 100;
+
+ private final int GAP_EXTEND_COST = 5;
+
private RotatableCanvas rc;
AlignmentPanel ap;
private IProgressIndicator progressBar;
+ private long progId;
+
private boolean working;
/**
this.ap = alignPanel;
boolean nucleotide = av.getAlignment().isNucleotide();
- progressBar = new ProgressBar(statusPanel, statusBar);
+ //progressBar = new ProgressBar(statusPanel, statusBar);
addInternalFrameListener(new InternalFrameAdapter()
{
ScoreModelI scoreModel = ScoreModels.getInstance()
.getScoreModel(modelName, ap);
setPasimapModel(
- new PaSiMapModel(av, seqs, nucleotide, scoreModel, params));
+ new PaSiMapModel(av, seqs, nucleotide, scoreModel));
PaintRefresher.Register(this, av.getSequenceSetId());
setRotatableCanvas(new RotatableCanvas(alignPanel));
public void run()
{
working = true;
- long progId = System.currentTimeMillis();
- IProgressIndicator progress = this;
+ progId = System.currentTimeMillis();
+ progressBar = this;
String message = MessageManager.getString("label.pasimap_recalculating");
if (getParent() == null)
{
- progress = ap.alignFrame;
+ progressBar = ap.alignFrame;
message = MessageManager.getString("label.pasimap_calculating");
}
- progress.setProgressBar(message, progId);
+ progressBar.setProgressBar(message, progId);
try
{
- getPasimapModel().calculate();
+ //&! remove big seqs
+ for (SequenceI seq : av.getAlignment().getSequencesArray())
+ {
+ if (seq.getLength() > 20000)
+ {
+ //TODO add warning dialog
+ av.getAlignment().deleteSequence(seq);
+ }
+ }
+
+ PairwiseAlignPanel pap = new PairwiseAlignPanel(av, true, GAP_OPEN_COST, GAP_EXTEND_COST, false);
+System.out.println(pap != null);
+ setPairwiseAlignPanel(pap);
+ getPasimapModel().calculate(pap);
xCombobox.setSelectedIndex(0);
yCombobox.setSelectedIndex(1);
return;
} finally
{
- progress.setProgressBar("", progId);
+ progressBar.setProgressBar("", progId);
}
repaint();
// validate();
}
+ /*
+ * make the progressBar determinate and update its progress
+ */
+ public void updateProgressBar(int lengthOfTask, int progress)
+ {
+ JProgressBar pBar = progressBar.getProgressBar(progId);
+ if (pBar.isIndeterminate())
+ {
+ pBar.setMaximum(lengthOfTask);
+ pBar.setValue(0);
+ pBar.setIndeterminate(false);
+ }
+ updateProgressBar(progress);
+ }
+ public void updateProgressBar(int progress)
+ {
+ JProgressBar pBar = progressBar.getProgressBar(progId);
+ pBar.setValue(progress);
+ pBar.repaint();
+ }
+
+ //&!
+ public void setPairwiseAlignPanel(PairwiseAlignPanel pap)
+ {
+ pap.addPropertyChangeListener(new PropertyChangeListener()
+ {
+ @Override
+ public void propertyChange(PropertyChangeEvent pcEvent)
+ {
+ if (PairwiseAlignPanel.PROGRESS.equals(pcEvent.getPropertyName()))
+ {
+ updateProgressBar((int) pcEvent.getNewValue());
+ } else if (PairwiseAlignPanel.TOTAL.equals(pcEvent.getPropertyName())) {
+ updateProgressBar((int) pcEvent.getNewValue(), 0);
+ }
+ }
+ });
+ }
+
@Override
public void registerHandler(final long id,
final IProgressIndicatorHandler handler)
getRotatableCanvas().ap = panel;
PaintRefresher.Register(PaSiMapPanel.this, panel.av.getSequenceSetId());
}
+
+ @Override
+ public JProgressBar getProgressBar(long id)
+ {
+ return progressBar.getProgressBar(id);
+ }
}
import jalview.viewmodel.AlignmentViewport;
import jalview.math.MiscMath;
+import java.beans.PropertyChangeListener;
import java.awt.event.ActionEvent;
import java.util.Vector;
+import javax.swing.event.SwingPropertyChangeSupport;
/**
* DOCUMENT ME!
private int GAP_EXTEND_COST;
- //&!
- private long total = 0l;
- private long ccount = 0l;
-
AlignmentViewport av;
Vector<SequenceI> sequences;
private String alignmentOutput;
+ private boolean suppressTextbox;
+
+ private boolean discardAlignments;
+
+ private boolean endGaps;
+
+ // for listening
+ public static final String TOTAL = "total";
+
+ public static final String PROGRESS = "progress";
+
+ private int total;
+
+ private int progress;
+
/**
* Creates a new PairwiseAlignPanel object.
*
*/
public PairwiseAlignPanel(AlignmentViewport viewport)
{
- this(viewport, false, 120, 20); // default penalties used in AlignSeq
+ this(viewport, false, 120, 20, true); // default penalties used in AlignSeq
}
public PairwiseAlignPanel(AlignmentViewport viewport, boolean endGaps, int gapOpenCost, int gapExtendCost)
{
+ this(viewport, endGaps, gapOpenCost, gapExtendCost, true);
+ }
+ public PairwiseAlignPanel(AlignmentViewport viewport, boolean endGaps, int gapOpenCost, int gapExtendCost, boolean run)
+ {
super();
this.av = viewport;
+ this.GAP_OPEN_COST = gapOpenCost;
+ this.GAP_EXTEND_COST = gapExtendCost;
+ this.endGaps = endGaps;
+ this.total = MiscMath.combinations(av.getAlignment().getHeight(), 2);
+
+ if (run)
+ calculate();
+System.out.println("Creating pap");
+ }
+ public void calculate()
+ {
+
+ SequenceGroup selectionGroup = av.getSelectionGroup();
StringBuilder sb = new StringBuilder(1024);
sequences = new Vector<SequenceI>();
- SequenceGroup selectionGroup = viewport.getSelectionGroup();
boolean isSelection = selectionGroup != null
&& selectionGroup.getSize() > 0;
- AlignmentView view = viewport.getAlignmentView(isSelection);
- // String[] seqStrings = viewport.getViewAsString(true);
+ AlignmentView view = av.getAlignmentView(isSelection);
+ // String[] seqStrings = av.getViewAsString(true);
String[] seqStrings = view
- .getSequenceStrings(viewport.getGapCharacter());
+ .getSequenceStrings(av.getGapCharacter());
SequenceI[] seqs;
if (isSelection)
{
seqs = (SequenceI[]) view
- .getAlignmentAndHiddenColumns(viewport.getGapCharacter())[0];
+ .getAlignmentAndHiddenColumns(av.getGapCharacter())[0];
}
else
{
seqs = av.getAlignment().getSequencesArray();
}
- String type = (viewport.getAlignment().isNucleotide()) ? AlignSeq.DNA
+ String type = (av.getAlignment().isNucleotide()) ? AlignSeq.DNA
: AlignSeq.PEP;
float[][] scores = new float[seqs.length][seqs.length];
double totscore = 0D;
int count = seqs.length;
boolean first = true;
- //AlignSeq as = new AlignSeq(seqs[1], seqStrings[1], seqs[0], seqStrings[0], type, gapOpenCost, gapExtendCost);
-//&!
-this.total = (long) MiscMath.permutations(count,2) / 2;
+
+ progress = 0;
+ firePropertyChange(TOTAL, 0, total);
+
+ suppressTextbox = count<10;
+ discardAlignments = count<15;
for (int i = 1; i < count; i++)
{
// fill diagonal alignmentScores with Float.NaN
- alignmentScores[i-1][i-1] = Float.NaN;
+ alignmentScores[i - 1][i - 1] = Float.NaN;
for (int j = 0; j < i; j++)
{
AlignSeq as = new AlignSeq(seqs[i], seqStrings[i], seqs[j],
- seqStrings[j], type, gapOpenCost, gapExtendCost);
-// as.seqInit(seqs[i], seqStrings[i], seqs[j], seqStrings[j], type);
+ seqStrings[j], type, GAP_OPEN_COST, GAP_EXTEND_COST);
-System.out.println(String.format("%d / %d", ccount, total));
-this.ccount++;
if (as.s1str.length() == 0 || as.s2str.length() == 0)
{
continue;
if (!first)
{
- //System.out.println(DASHES);
+ System.out.println(DASHES);
textarea.append(DASHES);
sb.append(DASHES);
}
first = false;
- //as.printAlignment(System.out);
+ if (discardAlignments) {
+ as.printAlignment(System.out);
+ }
scores[i][j] = as.getMaxScore() / as.getASeq1().length;
-//System.out.println(String.format("%s x %s -> [%d][%d] (%f)", seqs[i].getName(), seqs[j].getName(), i, j, as.getAlignmentScore()));
alignmentScores[i][j] = as.getAlignmentScore();
totscore = totscore + scores[i][j];
- textarea.append(as.getOutput());
- sb.append(as.getOutput());
- sequences.add(as.getAlignedSeq1());
- sequences.add(as.getAlignedSeq2());
+ if (suppressTextbox)
+ {
+ textarea.append(as.getOutput());
+ sb.append(as.getOutput());
+ }
+ if (discardAlignments)
+ {
+ sequences.add(as.getAlignedSeq1());
+ sequences.add(as.getAlignedSeq2());
+ }
+
+ firePropertyChange(PROGRESS, progress, ++progress);
}
}
- alignmentScores[count-1][count-1] = Float.NaN;
+ alignmentScores[count - 1][count - 1] = Float.NaN;
this.scores = scores;
this.alignmentScores = alignmentScores;
MessageManager.getString("label.pairwise_aligned_sequences"),
AlignFrame.DEFAULT_WIDTH, AlignFrame.DEFAULT_HEIGHT);
}
+
+ public long getTotal()
+ {
+ return total;
+ }
+
+ public long getProgress()
+ {
+ return progress;
+ }
}
});
}
+ /*
+ *
+ */
+ public JProgressBar getProgressBar(long id)
+ {
+ for (Component component : progressBars.get(id).getComponents())
+ {
+ if (component.getClass().equals(JProgressBar.class))
+ return (JProgressBar) component;
+ }
+ return null;
+ }
+
}
{
SequencePoint sp = sequencePoints.get(i);
int tmp1 = (int) (((sp.coord.x - centre[0]) * getScaleFactor())
- * (getWidth() / 2.0)
+ * (getWidth() / 3.15)
+ (getWidth() / 2.0));
float pre1 = ((sp.coord.x - centre[0]) * getScaleFactor());
int tmp2 = (int) (((sp.coord.y - centre[1]) * getScaleFactor())
- * (getHeight() / 2.0)
+ * (getHeight() / 1.70)
+ (getHeight() / 2.0));
float pre2 = ((sp.coord.y - centre[1]) * getScaleFactor());
import javax.swing.JLabel;
import javax.swing.JMenuItem;
import javax.swing.JPopupMenu;
+import javax.swing.JProgressBar;
import javax.swing.JTable;
import javax.swing.SwingUtilities;
import javax.swing.table.AbstractTableModel;
}
}
+
+ @Override
+ public JProgressBar getProgressBar(long id)
+ {
+ return progressBar.getProgressBar(id);
+ }
}
import javax.swing.JEditorPane;
import javax.swing.JInternalFrame;
import javax.swing.JPanel;
+import javax.swing.JProgressBar;
import javax.swing.JScrollPane;
import javax.swing.JTabbedPane;
import javax.swing.JTextArea;
{
return progressBar.operationInProgress();
}
+
+ @Override
+ public JProgressBar getProgressBar(long id)
+ {
+ return progressBar.getProgressBar(id);
+ }
}
JMenuItem pasteMenu = new JMenuItem();
+ JMenuItem fontSizeMenu = new JMenuItem();
+
BorderLayout borderLayout2 = new BorderLayout();
protected JPanel inputButtonPanel = new JPanel();
pasteMenu_actionPerformed(e);
}
});
+ fontSizeMenu.setText(MessageManager.getString("action.change_font"));
+ fontSizeMenu.addActionListener(new ActionListener()
+ {
+ @Override
+ public void actionPerformed(ActionEvent e)
+ {
+ fontSizeMenu_actionPerformed(e);
+ }
+ });
copyItem.setText(MessageManager.getString("action.copy"));
copyItem.addActionListener(new ActionListener()
{
editMenu.add(selectAll);
editMenu.add(copyItem);
editMenu.add(pasteMenu);
+ editMenu.add(fontSizeMenu);
this.getContentPane().add(scrollPane, java.awt.BorderLayout.CENTER);
inputButtonPanel.add(ok);
inputButtonPanel.add(cancel);
}
/**
+ * shows a menu for changing the font
+ * @param e
+ */
+ public void fontSizeMenu_actionPerformed(ActionEvent e)
+ {
+ }
+
+ /**
* DOCUMENT ME!
*
* @param e
return result;
}
+ /**
+ * calculate all unique combinations of n elements into r sized groups
+ * @param n
+ * @param r
+ *
+ * @return
+ */
+ public static int combinations(int n, int r)
+ {
+ int result = 1;
+ for (int i = 0; i < r; i++)
+ {
+ result *= (n-1);
+ }
+ return (int) (result / MiscMath.factorial(r));
+ }
+
+ /**
+ * calculate the factorial of n (n >= 0)
+ * @param n
+ *
+ * @return
+ */
+ public static int factorial(int n)
+ {
+ int result = 1;
+ for (int i = 0; i < n; i++)
+ {
+ result *= (n - i);
+ }
+ return result;
+ }
+
}
import jalview.datamodel.Point;
import jalview.datamodel.SequenceI;
import jalview.datamodel.SequencePoint;
+import jalview.gui.PairwiseAlignPanel;
import jalview.viewmodel.AlignmentViewport;
import java.util.List;
private final SequenceI[] seqs;
- private final SimilarityParamsI similarityParams;
-
/*
* options - score model, nucleotide / protein
*/
* @param params
*/
public PaSiMapModel(AlignmentViewport seqData, SequenceI[] sqs, boolean nuc,
- ScoreModelI modelName, SimilarityParamsI params)
+ ScoreModelI modelName)
{
inputData = seqData;
seqs = sqs;
nucleotide = nuc;
scoreModel = modelName;
- similarityParams = params;
}
/**
* Performs the PaSiMap calculation (in the same thread) and extracts result data
* needed for visualisation by PaSiMapPanel
*/
- public void calculate()
+ public void calculate(PairwiseAlignPanel pap)
{
- pasimap = new PaSiMap(inputData, scoreModel, similarityParams);
+ pasimap = new PaSiMap(inputData, scoreModel, pap);
pasimap.run(); // executes in same thread, wait for completion
// Now find the component coordinates
this.scoreModel = sm;
}
- /**
- * Answers the parameters configured for pairwise similarity calculations
- *
- * @return
- */
- public SimilarityParamsI getSimilarityParameters()
- {
- return similarityParams;
- }
-
public List<SequencePoint> getSequencePoints()
{
return points;