action.text = Text
action.by_pairwise_id = By Pairwise Identity
action.by_id = By Id
+action.by_evalue = By E-Value
+action.by_bit_score = By Bit Score
action.by_length = By Length
action.by_group = By Group
action.unmark_as_reference = Unmark as Reference
private static boolean sortLengthAscending;
+ private static boolean sortEValueAscending;
+
+ private static boolean sortBitScoreAscending;
+
/**
* Sorts sequences in the alignment by Percentage Identity with the given
* reference sequence, sorting the highest identity to the top
List<SequenceI> algn;
synchronized (algn = align.getSequences())
{
- List<SequenceI> tmp = new ArrayList<SequenceI>();
+ List<SequenceI> tmp = new ArrayList<>();
for (int i = 0; i < seqs.length; i++)
{
}
/**
+ * Sorts by sequence evalue. Currently moves all sequences without an evalue to
+ * the top of the alignment.
+ *
+ * @param align
+ * The alignment object to sort
+ */
+ public static void sortByEValue(AlignmentI align)
+ {
+ int nSeq = align.getHeight();
+
+ double[] evalue = new double[nSeq];
+ SequenceI[] seqs = new SequenceI[nSeq];
+
+ for (int i = 0; i < nSeq; i++)
+ {
+ seqs[i] = align.getSequenceAt(i);
+ AlignmentAnnotation[] ann = seqs[i].getAnnotation("Search Scores");
+ if (ann != null)
+ {
+ evalue[i] = ann[0].getEValue();
+ }
+ else
+ {
+ evalue[i] = -1;
+ }
+ }
+
+ QuickSort.sort(evalue, seqs);
+
+ if (sortEValueAscending)
+ {
+ setReverseOrder(align, seqs);
+ }
+ else
+ {
+ setOrder(align, seqs);
+ }
+
+ sortEValueAscending = !sortEValueAscending;
+ }
+
+ /**
+ * Sorts by sequence bit score. Currently moves all sequences without a bit
+ * score to the top of the alignment
+ *
+ * @param align
+ * The alignment object to sort
+ */
+ public static void sortByBitScore(AlignmentI align)
+ {
+ int nSeq = align.getHeight();
+
+ double[] score = new double[nSeq];
+ SequenceI[] seqs = new SequenceI[nSeq];
+
+ for (int i = 0; i < nSeq; i++)
+ {
+ seqs[i] = align.getSequenceAt(i);
+ AlignmentAnnotation[] ann = seqs[i].getAnnotation("Search Scores");
+ if (ann != null)
+ {
+ score[i] = ann[0].getEValue();
+ }
+ else
+ {
+ score[i] = -1;
+ }
+ }
+
+ QuickSort.sort(score, seqs);
+
+ if (sortBitScoreAscending)
+ {
+ setReverseOrder(align, seqs);
+ }
+ else
+ {
+ setOrder(align, seqs);
+ }
+
+ sortBitScoreAscending = !sortBitScoreAscending;
+ }
+
+ /**
* Sorts the alignment by size of group. <br>
* Maintains the order of sequences in each group by order in given alignment
* object.
{
// MAINTAINS ORIGNAL SEQUENCE ORDER,
// ORDERS BY GROUP SIZE
- List<SequenceGroup> groups = new ArrayList<SequenceGroup>();
+ List<SequenceGroup> groups = new ArrayList<>();
if (groups.hashCode() != lastGroupHash)
{
// NOW ADD SEQUENCES MAINTAINING ALIGNMENT ORDER
// /////////////////////////////////////////////
- List<SequenceI> seqs = new ArrayList<SequenceI>();
+ List<SequenceI> seqs = new ArrayList<>();
for (int i = 0; i < groups.size(); i++)
{
// tmp2 = tmp.retainAll(mask);
// return tmp2.addAll(mask.removeAll(tmp2))
- ArrayList<SequenceI> seqs = new ArrayList<SequenceI>();
+ ArrayList<SequenceI> seqs = new ArrayList<>();
int i, idx;
boolean[] tmask = new boolean[mask.size()];
{
int nSeq = align.getHeight();
- List<SequenceI> tmp = new ArrayList<SequenceI>();
+ List<SequenceI> tmp = new ArrayList<>();
tmp = _sortByTree(tree.getTopNode(), tmp, align.getSequences());
{
sortGroupMenuItem_actionPerformed();
}
+ else if (source == sortEValueMenuItem)
+ {
+ sortEValueMenuItem_actionPerformed();
+ }
+ else if (source == sortBitScoreMenuItem)
+ {
+ sortBitScoreMenuItem_actionPerformed();
+ }
else if (source == removeRedundancyMenuItem)
{
removeRedundancyMenuItem_actionPerformed();
}
+ public void sortEValueMenuItem_actionPerformed()
+ {
+ SequenceI[] oldOrder = viewport.getAlignment().getSequencesArray();
+ AlignmentSorter.sortByEValue(viewport.getAlignment());
+ addHistoryItem(new OrderCommand("Group Sort", oldOrder,
+ viewport.getAlignment()));
+ alignPanel.paintAlignment(true, false);
+
+ }
+
+ public void sortBitScoreMenuItem_actionPerformed()
+ {
+ SequenceI[] oldOrder = viewport.getAlignment().getSequencesArray();
+ AlignmentSorter.sortByBitScore(viewport.getAlignment());
+ addHistoryItem(new OrderCommand("Group Sort", oldOrder,
+ viewport.getAlignment()));
+ alignPanel.paintAlignment(true, false);
+
+ }
+
public void removeRedundancyMenuItem_actionPerformed()
{
new RedundancyPanel(alignPanel);
MenuItem sortGroupMenuItem = new MenuItem();
+ MenuItem sortEValueMenuItem = new MenuItem();
+
+ MenuItem sortBitScoreMenuItem = new MenuItem();
+
MenuItem removeRedundancyMenuItem = new MenuItem();
MenuItem pairwiseAlignmentMenuItem = new MenuItem();
alignPanel.paintAlignment(true, false);
}
+ @Override
+ public void sortEValueMenuItem_actionPerformed(ActionEvent e)
+ {
+ SequenceI[] oldOrder = viewport.getAlignment().getSequencesArray();
+ AlignmentSorter.sortByEValue(viewport.getAlignment());
+ addHistoryItem(new OrderCommand("Group Sort", oldOrder,
+ viewport.getAlignment()));
+ alignPanel.paintAlignment(true, false);
+
+ }
+
+ @Override
+ public void sortBitScoreMenuItem_actionPerformed(ActionEvent e)
+ {
+ SequenceI[] oldOrder = viewport.getAlignment().getSequencesArray();
+ AlignmentSorter.sortByBitScore(viewport.getAlignment());
+ addHistoryItem(new OrderCommand("Group Sort", oldOrder,
+ viewport.getAlignment()));
+ alignPanel.paintAlignment(true, false);
+
+ }
+
/**
* DOCUMENT ME!
*
sortGroupMenuItem_actionPerformed(e);
}
});
+ JMenuItem sortEValueMenuItem = new JMenuItem(
+ MessageManager.getString("action.by_evalue"));
+ sortEValueMenuItem.addActionListener(new ActionListener()
+ {
+ @Override
+ public void actionPerformed(ActionEvent e)
+ {
+ sortEValueMenuItem_actionPerformed(e);
+ }
+ });
+ JMenuItem sortBitScoreMenuItem = new JMenuItem(
+ MessageManager.getString("action.by_bit_score"));
+ sortBitScoreMenuItem.addActionListener(new ActionListener()
+ {
+ @Override
+ public void actionPerformed(ActionEvent e)
+ {
+ sortBitScoreMenuItem_actionPerformed(e);
+ }
+ });
JMenuItem removeRedundancyMenuItem = new JMenuItem(
MessageManager.getString("action.remove_redundancy"));
sort.add(sortLengthMenuItem);
sort.add(sortGroupMenuItem);
sort.add(sortPairwiseMenuItem);
+ sort.add(sortEValueMenuItem);
+ sort.add(sortBitScoreMenuItem);
sort.add(sortByTreeMenu);
calculateMenu.add(sort);
calculateMenu.add(calculateTree);
{
}
+ protected void sortEValueMenuItem_actionPerformed(ActionEvent e)
+ {
+ }
+
+ protected void sortBitScoreMenuItem_actionPerformed(ActionEvent e)
+ {
+ }
+
protected void removeRedundancyMenuItem_actionPerformed(ActionEvent e)
{
}