import jalview.viewmodel.ViewportRanges;
import jalview.ws.DBRefFetcher;
import jalview.ws.DBRefFetcher.FetchFinishedListenerI;
+import jalview.ws.datamodel.alphafold.PAEContactMatrix;
import jalview.ws.jws1.Discoverer;
import jalview.ws.jws2.Jws2Discoverer;
import jalview.ws.jws2.jabaws2.Jws2Instance;
return showNewickTree(nf, treeTitle, null, w, h, x, y);
}
+
/**
* Add a treeviewer for the tree extracted from a Newick file object to the
* current alignment view
return tp;
}
+
+ public void showContactMapTree(AlignmentAnnotation aa,
+ PAEContactMatrix cm)
+ {
+ int x = 4, y = 5;
+ int w = 400, h = 500;
+ try
+ {
+ NewickFile fin = new NewickFile(
+ new FileParse(cm.getNewickString(), DataSourceType.PASTE));
+ fin.parse();
+ if (fin.getTree() == null)
+ {
+ return;
+ }
+ String title = "PAE Matrix Tree for "
+ + cm.getReferenceSeq().getDisplayId(false);
+ TreePanel tp = new TreePanel(alignPanel, fin, aa, title);
+
+ tp.setSize(w, h);
+
+ if (x > 0 && y > 0)
+ {
+ tp.setLocation(x, y);
+ }
+
+ Desktop.addInternalFrame(tp, title, w, h);
+ } catch (Throwable xx)
+ {
+ Console.error("Unexpected exception showing tree for contact matrix",
+ xx);
+ }
+
+ }
private boolean buildingMenu = false;
/**
{
return lastFeatureSettingsBounds;
}
+
}
class PrintThread extends Thread
import java.awt.event.MouseListener;
import java.awt.event.MouseMotionListener;
import java.awt.geom.AffineTransform;
+import java.io.IOException;
import java.util.Arrays;
import java.util.Collections;
import java.util.Iterator;
import jalview.analysis.AlignSeq;
import jalview.analysis.AlignmentUtils;
+import jalview.bin.Console;
import jalview.datamodel.Alignment;
import jalview.datamodel.AlignmentAnnotation;
import jalview.datamodel.Annotation;
+import jalview.datamodel.ContactMatrixI;
import jalview.datamodel.HiddenColumns;
import jalview.datamodel.Sequence;
import jalview.datamodel.SequenceGroup;
import jalview.datamodel.SequenceI;
+import jalview.io.DataSourceType;
import jalview.io.FileFormat;
import jalview.io.FormatAdapter;
+import jalview.io.NewickFile;
import jalview.util.Comparison;
import jalview.util.MessageManager;
import jalview.util.Platform;
+import jalview.ws.datamodel.alphafold.PAEContactMatrix;
/**
* The panel that holds the labels for alignment annotations, providing
consclipbrd.addActionListener(this);
pop.add(consclipbrd);
}
+ if (aa[selectedRow].graph == AlignmentAnnotation.CONTACT_MAP
+ && PAEContactMatrix.PAEMATRIX
+ .equals(aa[selectedRow].getCalcId()))
+ {
+ final PAEContactMatrix cm = (PAEContactMatrix) av
+ .getContactMatrix(aa[selectedRow]);
+ if (cm.getNewickString()!=null && cm.getNewickString().length()>0)
+ {
+ item = new JMenuItem("Show Matrix");
+ item.addActionListener(new ActionListener()
+ {
+
+ @Override
+ public void actionPerformed(ActionEvent e)
+ {
+
+ ap.alignFrame.showContactMapTree(aa[selectedRow],cm);
+
+ }
+ });
+ pop.addSeparator();
+ pop.add(item);
+ }
+
+ }
}
pop.show(this, evt.getX(), evt.getY());
}
import java.awt.print.Printable;
import java.awt.print.PrinterException;
import java.awt.print.PrinterJob;
+import java.util.BitSet;
import java.util.Hashtable;
import java.util.List;
import java.util.Map;
import jalview.analysis.TreeModel;
import jalview.api.AlignViewportI;
import jalview.datamodel.BinaryNode;
+import jalview.datamodel.ColumnSelection;
+import jalview.datamodel.HiddenColumns;
import jalview.datamodel.Sequence;
import jalview.datamodel.SequenceGroup;
import jalview.datamodel.SequenceI;
else
{
Vector<BinaryNode> leaves = tree.findLeaves(highlightNode);
-
+ if (tp.getColumnWise()) {
+ markColumnsFor(getAssociatedPanels(), leaves, Color.red);
+ } else {
for (int i = 0; i < leaves.size(); i++)
{
SequenceI seq = (SequenceI) leaves.elementAt(i).element();
treeSelectionChanged(seq);
}
+ }
av.sendSelection();
}
setColor(groups.get(i), col.brighter());
Vector<BinaryNode> l = tree.findLeaves(groups.get(i));
+ if (!tp.getColumnWise()) {
+ createSeqGroupFor(aps, l, col);
+ } else {
+ markColumnsFor(aps,l,col);
+ }
+ }
- Vector<SequenceI> sequences = new Vector<>();
-
- for (int j = 0; j < l.size(); j++)
+ // notify the panel(s) to redo any group specific stuff
+ // also updates structure views if necessary
+ for (int a = 0; a < aps.length; a++)
+ {
+ aps[a].updateAnnotation();
+ final AlignViewportI codingComplement = aps[a].av
+ .getCodingComplement();
+ if (codingComplement != null)
{
- SequenceI s1 = (SequenceI) l.elementAt(j).element();
+ ((AlignViewport) codingComplement).getAlignPanel()
+ .updateAnnotation();
+ }
+ }
+ }
- if (!sequences.contains(s1))
- {
- sequences.addElement(s1);
+ private void markColumnsFor(AlignmentPanel[] aps, Vector<BinaryNode> l,
+ Color col)
+ {
+ SequenceI rseq = tp.assocAnnotation.sequenceRef;
+ for (BinaryNode bn:l)
+ {
+ int colm=-1;
+ try {
+ colm = Integer.parseInt(bn.getName().substring(bn.getName().indexOf("c")+1));
+ } catch (Exception e)
+ {
+ continue;
+ }
+ ColumnSelection cs = av.getColumnSelection();
+ HiddenColumns hc = av.getAlignment().getHiddenColumns();
+ {
+ int offp = (rseq!=null) ? rseq.findIndex(rseq.getStart()-1+colm) : colm;
+
+ if (!av.hasHiddenColumns() || hc.isVisible(offp))
+ {
+ if (cs.contains(offp))
+ {
+ cs.removeElement(offp);
+ } else {
+ cs.addElement(offp);
+ }
}
}
+ }
+ }
- ColourSchemeI cs = null;
- SequenceGroup _sg = new SequenceGroup(sequences, null, cs, true, true,
- false, 0, av.getAlignment().getWidth() - 1);
+ public void createSeqGroupFor(AlignmentPanel[] aps, Vector<BinaryNode> l,
+ Color col)
+ {
- _sg.setName("JTreeGroup:" + _sg.hashCode());
- _sg.setIdColour(col);
+ Vector<SequenceI> sequences = new Vector<>();
- for (int a = 0; a < aps.length; a++)
- {
- SequenceGroup sg = new SequenceGroup(_sg);
- AlignViewport viewport = aps[a].av;
-
- // Propagate group colours in each view
- if (viewport.getGlobalColourScheme() != null)
- {
- cs = viewport.getGlobalColourScheme().getInstance(viewport, sg);
- sg.setColourScheme(cs);
- sg.getGroupColourScheme().setThreshold(
- viewport.getResidueShading().getThreshold(),
- viewport.isIgnoreGapsConsensus());
+ for (int j = 0; j < l.size(); j++)
+ {
+ SequenceI s1 = (SequenceI) l.elementAt(j).element();
- if (viewport.getResidueShading().conservationApplied())
- {
- Conservation c = new Conservation("Group",
- sg.getSequences(null), sg.getStartRes(),
- sg.getEndRes());
- c.calculate();
- c.verdict(false, viewport.getConsPercGaps());
- sg.cs.setConservation(c);
- }
- }
- // indicate that associated structure views will need an update
- viewport.setUpdateStructures(true);
- // propagate structure view update and sequence group to complement view
- viewport.addSequenceGroup(sg);
+ if (!sequences.contains(s1))
+ {
+ sequences.addElement(s1);
}
}
- // notify the panel(s) to redo any group specific stuff
- // also updates structure views if necessary
+ ColourSchemeI cs = null;
+ SequenceGroup _sg = new SequenceGroup(sequences, null, cs, true, true,
+ false, 0, av.getAlignment().getWidth() - 1);
+
+ _sg.setName("JTreeGroup:" + _sg.hashCode());
+ _sg.setIdColour(col);
+
for (int a = 0; a < aps.length; a++)
{
- aps[a].updateAnnotation();
- final AlignViewportI codingComplement = aps[a].av
- .getCodingComplement();
- if (codingComplement != null)
+ SequenceGroup sg = new SequenceGroup(_sg);
+ AlignViewport viewport = aps[a].av;
+
+ // Propagate group colours in each view
+ if (viewport.getGlobalColourScheme() != null)
{
- ((AlignViewport) codingComplement).getAlignPanel()
- .updateAnnotation();
+ cs = viewport.getGlobalColourScheme().getInstance(viewport, sg);
+ sg.setColourScheme(cs);
+ sg.getGroupColourScheme().setThreshold(
+ viewport.getResidueShading().getThreshold(),
+ viewport.isIgnoreGapsConsensus());
+
+ if (viewport.getResidueShading().conservationApplied())
+ {
+ Conservation c = new Conservation("Group", sg.getSequences(null),
+ sg.getStartRes(), sg.getEndRes());
+ c.calculate();
+ c.verdict(false, viewport.getConsPercGaps());
+ sg.cs.setConservation(c);
+ }
}
+ // indicate that associated structure views will need an update
+ viewport.setUpdateStructures(true);
+ // propagate structure view update and sequence group to complement view
+ viewport.addSequenceGroup(sg);
}
}