*/
package jalview.appletgui;
-import jalview.datamodel.AlignmentI;
-import jalview.datamodel.PDBEntry;
-import jalview.datamodel.SequenceI;
-import jalview.io.AppletFormatAdapter;
-import jalview.io.FileParse;
-import jalview.schemes.BuriedColourScheme;
-import jalview.schemes.HelixColourScheme;
-import jalview.schemes.HydrophobicColourScheme;
-import jalview.schemes.PurinePyrimidineColourScheme;
-import jalview.schemes.StrandColourScheme;
-import jalview.schemes.TaylorColourScheme;
-import jalview.schemes.TurnColourScheme;
-import jalview.schemes.UserColourScheme;
-import jalview.schemes.ZappoColourScheme;
-import jalview.structure.StructureSelectionManager;
-import jalview.util.MessageManager;
-
import java.awt.BorderLayout;
import java.awt.CheckboxMenuItem;
import java.awt.Color;
import java.util.Hashtable;
import java.util.Vector;
+import jalview.datamodel.AlignmentI;
+import jalview.datamodel.PDBEntry;
+import jalview.datamodel.SequenceI;
+import jalview.io.AppletFormatAdapter;
+import jalview.io.FileParse;
+import jalview.schemes.BuriedColourScheme;
+import jalview.schemes.HelixColourScheme;
+import jalview.schemes.HydrophobicColourScheme;
+import jalview.schemes.PurinePyrimidineColourScheme;
+import jalview.schemes.StrandColourScheme;
+import jalview.schemes.TaylorColourScheme;
+import jalview.schemes.TurnColourScheme;
+import jalview.schemes.UserColourScheme;
+import jalview.schemes.ZappoColourScheme;
+import jalview.structure.StructureSelectionManager;
+import jalview.util.MessageManager;
+
public class AppletJmol extends EmbmenuFrame implements
// StructureListener,
KeyListener, ActionListener, ItemListener
StringBuffer sb = new StringBuffer();
try
{
- for (int s = 0; s < jmb.getPdbCount(); s++)
- {
- sb.append(jmb.printMapping(jmb.getPdbEntry(s).getFile()));
- sb.append("\n");
- }
- cap.setText(sb.toString());
+ cap.setText(jmb.printMappings());
} catch (OutOfMemoryError ex)
{
frame.dispose();
jmolHistory(true);
}
- /**
- *
- * @param pdbfile
- * @return text report of alignment between pdbfile and any associated
- * alignment sequences
- */
- public String printMapping(String pdbfile)
- {
- return getSsm().printMapping(pdbfile);
- }
-
@Override
public void resizeInnerPanel(String data)
{
}
/**
- *
- * @param pdbfile
- * @return text report of alignment between pdbfile and any associated
- * alignment sequences
- */
- public String printMapping(String pdbfile)
- {
- return getSsm().printMapping(pdbfile);
- }
-
- /**
* Ask Chimera to save its session to the given file. Returns true if
* successful, else false.
*
*/
package jalview.gui;
-import jalview.bin.Cache;
-import jalview.datamodel.Alignment;
-import jalview.datamodel.AlignmentI;
-import jalview.datamodel.ColumnSelection;
-import jalview.datamodel.PDBEntry;
-import jalview.datamodel.SequenceI;
-import jalview.io.AppletFormatAdapter;
-import jalview.io.JalviewFileChooser;
-import jalview.io.JalviewFileView;
-import jalview.schemes.BuriedColourScheme;
-import jalview.schemes.ColourSchemeI;
-import jalview.schemes.HelixColourScheme;
-import jalview.schemes.HydrophobicColourScheme;
-import jalview.schemes.PurinePyrimidineColourScheme;
-import jalview.schemes.StrandColourScheme;
-import jalview.schemes.TaylorColourScheme;
-import jalview.schemes.TurnColourScheme;
-import jalview.schemes.ZappoColourScheme;
-import jalview.structures.models.AAStructureBindingModel;
-import jalview.util.MessageManager;
-import jalview.util.Platform;
-
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Dimension;
import javax.swing.event.MenuEvent;
import javax.swing.event.MenuListener;
+import jalview.bin.Cache;
+import jalview.datamodel.Alignment;
+import jalview.datamodel.AlignmentI;
+import jalview.datamodel.ColumnSelection;
+import jalview.datamodel.PDBEntry;
+import jalview.datamodel.SequenceI;
+import jalview.io.AppletFormatAdapter;
+import jalview.io.JalviewFileChooser;
+import jalview.io.JalviewFileView;
+import jalview.schemes.BuriedColourScheme;
+import jalview.schemes.ColourSchemeI;
+import jalview.schemes.HelixColourScheme;
+import jalview.schemes.HydrophobicColourScheme;
+import jalview.schemes.PurinePyrimidineColourScheme;
+import jalview.schemes.StrandColourScheme;
+import jalview.schemes.TaylorColourScheme;
+import jalview.schemes.TurnColourScheme;
+import jalview.schemes.ZappoColourScheme;
+import jalview.structures.models.AAStructureBindingModel;
+import jalview.util.MessageManager;
+import jalview.util.Platform;
+
public class AppJmol extends StructureViewerBase
{
AppJmolBinding jmb;
jalview.gui.CutAndPasteTransfer cap = new jalview.gui.CutAndPasteTransfer();
try
{
- for (int pdbe = 0; pdbe < jmb.getPdbCount(); pdbe++)
- {
- cap.appendText(jmb.printMapping(jmb.getPdbEntry(pdbe).getFile()));
- cap.appendText("\n");
- }
+ cap.appendText(jmb.printMappings());
} catch (OutOfMemoryError e)
{
new OOMWarning(
jalview.gui.CutAndPasteTransfer cap = new jalview.gui.CutAndPasteTransfer();
try
{
- for (int pdbe = 0; pdbe < jmb.getPdbCount(); pdbe++)
- {
- cap.appendText(jmb.printMapping(jmb.getPdbEntry(pdbe).getFile()));
- cap.appendText("\n");
- }
+ cap.appendText(jmb.printMappings());
} catch (OutOfMemoryError e)
{
new OOMWarning(
public class StructureSelectionManager
{
+ public final static String NEWLINE = System.lineSeparator();
+
static IdentityHashMap<StructureSelectionManagerProvider, StructureSelectionManager> instances;
private List<StructureMapping> mappings = new ArrayList<StructureMapping>();
do
{
- Atom tmp = (Atom) maxChain.atoms.elementAt(index);
+ Atom tmp = maxChain.atoms.elementAt(index);
if (resNum != tmp.resNumber && tmp.alignmentMapping != -1)
{
resNum = tmp.resNumber;
return tmp.toArray(new StructureMapping[tmp.size()]);
}
- public String printMapping(String pdbfile)
+ /**
+ * Returns a readable description of all mappings for the given pdbfile to any
+ * of the given sequences
+ *
+ * @param pdbfile
+ * @param seqs
+ * @return
+ */
+ public String printMappings(String pdbfile, List<SequenceI> seqs)
{
+ if (pdbfile == null || seqs == null || seqs.isEmpty())
+ {
+ return "";
+ }
+
StringBuilder sb = new StringBuilder(64);
for (StructureMapping sm : mappings)
{
- if (sm.pdbfile.equals(pdbfile))
+ if (sm.pdbfile.equals(pdbfile) && seqs.contains(sm.sequence))
{
sb.append(sm.mappingDetails);
+ sb.append(NEWLINE);
+ // separator makes it easier to read multiple mappings
+ sb.append("=====================");
+ sb.append(NEWLINE);
}
}
+ sb.append(NEWLINE);
return sb.toString();
}
package jalview.structures.models;
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.List;
import jalview.api.StructureSelectionManagerProvider;
}
}
+ /**
+ * Returns a readable description of all mappings for the wrapped pdbfile to
+ * any mapped sequences
+ *
+ * @param pdbfile
+ * @param seqs
+ * @return
+ */
+ public String printMappings()
+ {
+ if (pdbEntry == null)
+ {
+ return "";
+ }
+ StringBuilder sb = new StringBuilder(128);
+ for (int pdbe = 0; pdbe < getPdbCount(); pdbe++)
+ {
+ String pdbfile = getPdbEntry(pdbe).getFile();
+ List<SequenceI> seqs = Arrays.asList(getSequence()[pdbe]);
+ sb.append(getSsm().printMappings(pdbfile, seqs));
+ }
+ return sb.toString();
+ }
+
@Override
public void highlightAtoms(List<AtomSpec> atoms)
{