}
- private static final int MIN_PASIMAP_SELECTION = 8;
+ /**
+ * minimum number of sequences needed for PASIMAP is 9 (so each has 8 connections)
+ */
+ private static final int MIN_PASIMAP_SELECTION = 9;
AlignFrame af;
import jalview.datamodel.AlignmentI;
import jalview.datamodel.AlignmentView;
import jalview.datamodel.HiddenColumns;
+import jalview.datamodel.SequenceGroup;
import jalview.datamodel.SequenceI;
import jalview.gui.ImageExporter.ImageWriterI;
import jalview.gui.JalviewColourChooser.ColourChooserListener;
private static final int MIN_HEIGHT = 250;
+ private static final int MAX_PASIMAP_SEQ = 20000;
+
private final int GAP_OPEN_COST = 100;
private final int GAP_EXTEND_COST = 5;
working = true;
progId = System.currentTimeMillis();
progressBar = this;
- String message = MessageManager.getString("label.pasimap_recalculating");
+ String message = MessageManager
+ .getString("label.pasimap_recalculating");
if (getParent() == null)
{
progressBar = ap.alignFrame;
progressBar.setProgressBar(message, progId);
try
{
- //&! remove big seqs
- for (SequenceI seq : av.getAlignment().getSequencesArray())
+ SequenceGroup selGroup=av.getSelectionGroup();
+
+ if (selGroup==null)
{
- if (seq.getLength() > 20000)
- {
- //TODO add warning dialog
- av.getAlignment().deleteSequence(seq);
- }
+ selGroup = new SequenceGroup(av.getAlignment().getSequences());
+ selGroup.setStartRes(0);
+ selGroup.setEndRes(av.getAlignment().getWidth()-1);
}
-
- PairwiseAlignPanel pap = new PairwiseAlignPanel(av, true, GAP_OPEN_COST, GAP_EXTEND_COST, false);
-System.out.println(pap != null);
+
+ if (selGroup.getSize()>MAX_PASIMAP_SEQ)
+ {
+ int start = selGroup.getStartRes(),end=selGroup.getEndRes();
+ selGroup = new SequenceGroup(selGroup.getSequences().subList(0, MAX_PASIMAP_SEQ));
+ selGroup.setStartRes(start);
+ selGroup.setEndRes(end);
+ Console.warn("Truncated input sequences for PASIMAP analysis to "+MAX_PASIMAP_SEQ);
+ }
+
+ PairwiseAlignPanel pap = new PairwiseAlignPanel(av, selGroup, true,
+ GAP_OPEN_COST, GAP_EXTEND_COST, false);
+ System.out.println(pap != null);
setPairwiseAlignPanel(pap);
getPasimapModel().calculate(pap);
repaint();
if (getParent() == null)
{
- Desktop.addInternalFrame(this,
- MessageManager.formatMessage("label.calc_title", "PaSiMap",
- getPasimapModel().getScoreModelName()),
+ Desktop.addInternalFrame(
+ this, MessageManager.formatMessage("label.calc_title",
+ "PaSiMap", getPasimapModel().getScoreModelName()),
475, 450);
this.setMinimumSize(new Dimension(MIN_WIDTH, MIN_HEIGHT));
}
public void updateProgressBar(int lengthOfTask, int progress)
{
JProgressBar pBar = progressBar.getProgressBar(progId);
+ if (pBar==null)
+ {
+ return;
+ }
if (pBar.isIndeterminate())
{
pBar.setMaximum(lengthOfTask);
public void updateProgressBar(int progress)
{
JProgressBar pBar = progressBar.getProgressBar(progId);
+
+ if (pBar==null)
+ {
+ return;
+ }
+
pBar.setValue(progress);
pBar.repaint();
}
private int progress;
+ private SequenceGroup selection;
+ /**
+ * input sequences
+ */
+ private SequenceI[] seqs=null;
+
/**
* Creates a new PairwiseAlignPanel object.
*
*/
public PairwiseAlignPanel(AlignmentViewport viewport)
{
- this(viewport, false, 120, 20, true); // default penalties used in AlignSeq
+ this(viewport, null, 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);
+ this(viewport, null, endGaps, gapOpenCost, gapExtendCost, true);
}
- public PairwiseAlignPanel(AlignmentViewport viewport, boolean endGaps, int gapOpenCost, int gapExtendCost, boolean run)
+
+ public PairwiseAlignPanel(AlignmentViewport viewport, SequenceGroup selection, 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.selection = selection;
this.total = MiscMath.combinations(av.getAlignment().getHeight(), 2);
-
+
if (run)
calculate();
-System.out.println("Creating pap");
+ System.out.println("Creating pap");
}
-
+
public void calculate()
{
- SequenceGroup selectionGroup = av.getSelectionGroup();
StringBuilder sb = new StringBuilder(1024);
sequences = new Vector<SequenceI>();
+ String[] seqStrings;
+ seqs=null;
- boolean isSelection = selectionGroup != null
- && selectionGroup.getSize() > 0;
- AlignmentView view = av.getAlignmentView(isSelection);
- // String[] seqStrings = av.getViewAsString(true);
- String[] seqStrings = view
- .getSequenceStrings(av.getGapCharacter());
-
- SequenceI[] seqs;
- if (isSelection)
+ if (selection != null)
{
- seqs = (SequenceI[]) view
- .getAlignmentAndHiddenColumns(av.getGapCharacter())[0];
+ // given a set of sequences to compare
+ seqs = selection.getSelectionAsNewSequences(av.getAlignment());
+ seqStrings = new String[seqs.length];
+ int s = 0;
+ for (SequenceI seq : seqs)
+ {
+ seqStrings[s++] = seq.getSequenceAsString();
+ }
}
else
{
- seqs = av.getAlignment().getSequencesArray();
+ SequenceGroup selectionGroup = av.getSelectionGroup();
+ boolean isSelection = selectionGroup != null
+ && selectionGroup.getSize() > 0;
+ AlignmentView view = av.getAlignmentView(isSelection);
+ seqStrings = view.getSequenceStrings(av.getGapCharacter());
+ if (isSelection)
+ {
+ seqs = (SequenceI[]) view
+ .getAlignmentAndHiddenColumns(av.getGapCharacter())[0];
+ }
+ else
+ {
+ seqs = av.getAlignment().getSequencesArray();
+ }
}
-
+
String type = (av.getAlignment().isNucleotide()) ? AlignSeq.DNA
: AlignSeq.PEP;
{
return progress;
}
+ public SequenceI[] getInputSequences()
+ {
+ return seqs;
+ }
}