import jalview.datamodel.Alignment;
import jalview.datamodel.AlignmentAnnotation;
import jalview.datamodel.AlignmentI;
+import jalview.datamodel.PDBEntry;
import jalview.datamodel.SequenceI;
+import jalview.jbgui.GStructureViewer;
import jalview.schemabinding.version2.AlcodMap;
import jalview.schemabinding.version2.Alcodon;
import jalview.schemabinding.version2.AlcodonFrame;
import jalview.schemes.GraduatedColor;
import jalview.schemes.ResidueColourScheme;
import jalview.schemes.ResidueProperties;
+import jalview.schemes.UserColourScheme;
import jalview.structure.StructureSelectionManager;
+import jalview.structures.models.AAStructureBindingModel;
import jalview.util.MessageManager;
import jalview.util.Platform;
import jalview.util.jarInputStreamProvider;
}
/**
- * create a JalviewModel from an algnment view and marshall it to a
+ * create a JalviewModel from an alignment view and marshall it to a
* JarOutputStream
*
* @param ap
boolean storeDS, JarOutputStream jout)
{
initSeqRefs();
- Vector jmolViewIds = new Vector(); //
- Vector userColours = new Vector();
+ List<String> chimeraViewIds = new ArrayList<String>();
+ List<UserColourScheme> userColours = new ArrayList<UserColourScheme>();
AlignViewport av = ap.av;
pdb.setId(entry.getId());
pdb.setType(entry.getType());
//
- // store any JMol views associated with this seqeunce
+ // store any JMol views associated with this sequence
// this section copes with duplicate entries in the project, so a
// dataset only view *should* be coped with sensibly
- AppJmol jmol;
+ List<String> jmolViewIds = new ArrayList<String>();
// This must have been loaded, is it still visible?
JInternalFrame[] frames = Desktop.desktop.getAllFrames();
String matchedFile = null;
for (int f = frames.length - 1; f > -1; f--)
{
- if (frames[f] instanceof AppJmol)
+ if (frames[f] instanceof GStructureViewer)
{
- jmol = (AppJmol) frames[f];
- for (int peid = 0; peid < jmol.jmb.pdbentry.length; peid++)
- {
- if (!jmol.jmb.pdbentry[peid].getId().equals(entry.getId())
- && !(entry.getId().length() > 4 && entry
- .getId()
- .toLowerCase()
- .startsWith(
- jmol.jmb.pdbentry[peid].getId()
- .toLowerCase())))
- {
- continue;
- }
- if (matchedFile == null)
- {
- matchedFile = jmol.jmb.pdbentry[peid].getFile();
- }
- else if (!matchedFile.equals(jmol.jmb.pdbentry[peid]
- .getFile()))
- {
- Cache.log
- .warn("Probably lost some PDB-Sequence mappings for this structure file (which apparently has same PDB Entry code): "
- + jmol.jmb.pdbentry[peid].getFile());
- ; // record the
- }
- // file so we
- // can get at it if the ID
- // match is ambiguous (e.g.
- // 1QIP==1qipA)
- String statestring = jmol.jmb.viewer.getStateInfo();
-
- for (int smap = 0; smap < jmol.jmb.sequence[peid].length; smap++)
- {
- // if (jal.findIndex(jmol.jmb.sequence[peid][smap]) > -1)
- if (jds == jmol.jmb.sequence[peid][smap])
- {
- StructureState state = new StructureState();
- state.setVisible(true);
- state.setXpos(jmol.getX());
- state.setYpos(jmol.getY());
- state.setWidth(jmol.getWidth());
- state.setHeight(jmol.getHeight());
- state.setViewId(jmol.getViewId());
- state.setAlignwithAlignPanel(jmol.isUsedforaligment(ap));
- state.setColourwithAlignPanel(jmol
- .isUsedforcolourby(ap));
- state.setColourByJmol(jmol.isColouredByJmol());
- if (!jmolViewIds.contains(state.getViewId()))
- {
- // Make sure we only store a Jmol state once in each XML
- // document.
- jmolViewIds.addElement(state.getViewId());
- state.setContent(statestring.replaceAll("\n", ""));
- }
- else
- {
- state.setContent("# duplicate state");
- }
- pdb.addStructureState(state);
- }
-
- }
- }
+ GStructureViewer viewFrame = (GStructureViewer) frames[f];
+ matchedFile = saveStructureState(ap, jds, pdb, entry,
+ jmolViewIds, matchedFile, viewFrame);
}
}
return object;
}
+ /**
+ * @param ap
+ * @param jds
+ * @param pdb
+ * @param entry
+ * @param jmolViewIds
+ * @param matchedFile
+ * @param viewFrame
+ * @return
+ */
+ protected String saveStructureState(AlignmentPanel ap,
+ jalview.datamodel.SequenceI jds, Pdbids pdb,
+ jalview.datamodel.PDBEntry entry, List<String> jmolViewIds,
+ String matchedFile, GStructureViewer viewFrame)
+ {
+ final AAStructureBindingModel bindingModel = viewFrame
+ .getBinding();
+ for (int peid = 0; peid < bindingModel
+ .getPdbCount(); peid++)
+ {
+ final PDBEntry pdbentry = bindingModel.getPdbEntry(peid);
+ final String pdbId = pdbentry.getId();
+ if (!pdbId.equals(entry.getId())
+ && !(entry.getId().length() > 4 && entry.getId()
+ .toLowerCase()
+ .startsWith(pdbId.toLowerCase())))
+ {
+ continue;
+ }
+ if (matchedFile == null)
+ {
+ matchedFile = pdbentry.getFile();
+ }
+ else if (!matchedFile.equals(pdbentry
+ .getFile()))
+ {
+ Cache.log
+ .warn("Probably lost some PDB-Sequence mappings for this structure file (which apparently has same PDB Entry code): "
+ + pdbentry.getFile());
+ }
+ // record the
+ // file so we
+ // can get at it if the ID
+ // match is ambiguous (e.g.
+ // 1QIP==1qipA)
+ String statestring = viewFrame.getStateInfo();
+
+ for (int smap = 0; smap < viewFrame.getBinding()
+ .getSequence()[peid].length; smap++)
+ {
+ // if (jal.findIndex(jmol.jmb.sequence[peid][smap]) > -1)
+ if (jds == viewFrame.getBinding().getSequence()[peid][smap])
+ {
+ StructureState state = new StructureState();
+ state.setVisible(true);
+ state.setXpos(viewFrame.getX());
+ state.setYpos(viewFrame.getY());
+ state.setWidth(viewFrame.getWidth());
+ state.setHeight(viewFrame.getHeight());
+ state.setViewId(viewFrame.getViewId());
+ state.setAlignwithAlignPanel(viewFrame.isUsedforaligment(ap));
+ state.setColourwithAlignPanel(viewFrame
+ .isUsedforcolourby(ap));
+ state.setColourByJmol(viewFrame.isColouredByViewer());
+ if (!jmolViewIds.contains(state.getViewId()))
+ {
+ // Make sure we only store a Jmol state once in each XML
+ // document.
+ jmolViewIds.add(state.getViewId());
+ state.setContent(statestring.replaceAll("\n", ""));
+ }
+ else
+ {
+ state.setContent("# duplicate state");
+ }
+ pdb.addStructureState(state);
+ }
+
+ }
+ }
+ return matchedFile;
+ }
+
private AnnotationColours constructAnnotationColours(
- AnnotationColourGradient acg, Vector userColours,
+ AnnotationColourGradient acg, List<UserColourScheme> userColours,
JalviewModelSequence jms)
{
AnnotationColours ac = new AnnotationColours();
}
String SetUserColourScheme(jalview.schemes.ColourSchemeI cs,
- Vector userColours, JalviewModelSequence jms)
+ List<UserColourScheme> userColours, JalviewModelSequence jms)
{
String id = null;
jalview.schemes.UserColourScheme ucs = (jalview.schemes.UserColourScheme) cs;
if (frames[f] instanceof AppJmol)
{
if (sviewid != null
- && ((AppJmol) frames[f]).getViewId().equals(sviewid))
+ && ((GStructureViewer) frames[f]).getViewId().equals(sviewid))
{
// post jalview 2.4 schema includes structure view id
comp = (AppJmol) frames[f];
String pdbFile = (String) filedat[0];
SequenceI[] seq = ((Vector<SequenceI>) filedat[2])
.toArray(new SequenceI[0]);
- comp.jmb.ssm.setMapping(seq, null, pdbFile,
+ comp.jmb.getSsm().setMapping(seq, null, pdbFile,
jalview.io.AppletFormatAdapter.FILE);
comp.jmb.addSequenceForStructFile(pdbFile, seq);
}