X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;ds=sidebyside;f=src%2Fjalview%2Fext%2Frbvi%2Fchimera%2FJalviewChimeraBinding.java;h=47ada530f53315a6af6c54fd75caa102595ba742;hb=4194c2c98f734d6d43f64a66e506995b5a0f64da;hp=00446f2ab334d297adb824bfed7a4370a55dee21;hpb=74f21ca6ca8fa17d53708e457d191e15904f8310;p=jalview.git diff --git a/src/jalview/ext/rbvi/chimera/JalviewChimeraBinding.java b/src/jalview/ext/rbvi/chimera/JalviewChimeraBinding.java index 00446f2..47ada53 100644 --- a/src/jalview/ext/rbvi/chimera/JalviewChimeraBinding.java +++ b/src/jalview/ext/rbvi/chimera/JalviewChimeraBinding.java @@ -76,9 +76,9 @@ public abstract class JalviewChimeraBinding extends AAStructureBindingModel private static final String ALPHACARBON = "CA"; - private List chainNames = new ArrayList(); + private List chainNames = new ArrayList<>(); - private Hashtable chainFile = new Hashtable(); + private Hashtable chainFile = new Hashtable<>(); /* * Object through which we talk to Chimera @@ -106,7 +106,7 @@ public abstract class JalviewChimeraBinding extends AAStructureBindingModel /* * Map of ChimeraModel objects keyed by PDB full local file name */ - private Map> chimeraMaps = new LinkedHashMap>(); + private Map> chimeraMaps = new LinkedHashMap<>(); String lastHighlightCommand; @@ -122,8 +122,8 @@ public abstract class JalviewChimeraBinding extends AAStructureBindingModel /** * Open a PDB structure file in Chimera and set up mappings from Jalview. * - * We check if the PDB model id is already loaded in Chimera, if so don't - * reopen it. This is the case if Chimera has opened a saved session file. + * We check if the PDB model id is already loaded in Chimera, if so don't reopen + * it. This is the case if Chimera has opened a saved session file. * * @param pe * @return @@ -133,8 +133,9 @@ public abstract class JalviewChimeraBinding extends AAStructureBindingModel String file = pe.getFile(); try { - List modelsToMap = new ArrayList(); - List oldList = viewer.getModelList(); + List modelsToMap = new ArrayList<>(); + List oldList = viewer.isChimeraX() ? new ArrayList<>() + : viewer.getModelList(); boolean alreadyOpen = false; /* @@ -156,13 +157,32 @@ public abstract class JalviewChimeraBinding extends AAStructureBindingModel if (!alreadyOpen) { viewer.openModel(file, pe.getId(), ModelType.PDB_MODEL); - List newList = viewer.getModelList(); - // JAL-1728 newList.removeAll(oldList) does not work - for (ChimeraModel cm : newList) + if (viewer.isChimeraX()) { - if (cm.getModelName().equals(pe.getId())) + /* + * ChimeraX hack: force chimera model name to pdbId + */ + int modelNumber = chimeraMaps.size() + 1; + String command = "setattr #" + modelNumber + " models name " + + pe.getId(); + sendChimeraCommand(command, false); + modelsToMap.add(new ChimeraModel(pe.getId(), ModelType.PDB_MODEL, + modelNumber, 0)); + } + else + { + /* + * Chimera: query for actual models and find the one with + * matching model name - set in viewer.openModel() + */ + List newList = viewer.getModelList(); + // JAL-1728 newList.removeAll(oldList) does not work + for (ChimeraModel cm : newList) { - modelsToMap.add(cm); + if (cm.getModelName().equals(pe.getId())) + { + modelsToMap.add(cm); + } } } } @@ -200,9 +220,9 @@ public abstract class JalviewChimeraBinding extends AAStructureBindingModel } /** - * Starts a thread that waits for the Chimera process to finish, so that we - * can then close the associated resources. This avoids leaving orphaned - * Chimera viewer panels in Jalview if the user closes Chimera. + * Starts a thread that waits for the Chimera process to finish, so that we can + * then close the associated resources. This avoids leaving orphaned Chimera + * viewer panels in Jalview if the user closes Chimera. */ protected void startChimeraProcessMonitor() { @@ -231,8 +251,8 @@ public abstract class JalviewChimeraBinding extends AAStructureBindingModel } /** - * Start a dedicated HttpServer to listen for Chimera notifications, and tell - * it to start listening + * Start a dedicated HttpServer to listen for Chimera notifications, and tell it + * to start listening */ public void startChimeraListener() { @@ -699,7 +719,7 @@ public abstract class JalviewChimeraBinding extends AAStructureBindingModel String[] files, SequenceRenderer sr, AlignmentViewPanel viewPanel) { return ChimeraCommands.getColourBySequenceCommand(getSsm(), files, - getSequence(), sr, viewPanel); + getSequence(), sr, viewPanel, viewer.isChimeraX()); } /** @@ -757,9 +777,8 @@ public abstract class JalviewChimeraBinding extends AAStructureBindingModel } /** - * Construct and send a command to highlight zero, one or more atoms. We do - * this by sending an "rlabel" command to show the residue label at that - * position. + * Construct and send a command to highlight zero, one or more atoms. We do this + * by sending an "rlabel" command to show the residue label at that position. */ @Override public void highlightAtoms(List atoms) @@ -857,7 +876,7 @@ public abstract class JalviewChimeraBinding extends AAStructureBindingModel protected List convertStructureResiduesToAlignment( List structureSelection) { - List atomSpecs = new ArrayList(); + List atomSpecs = new ArrayList<>(); for (String atomSpec : structureSelection) { try @@ -1110,7 +1129,7 @@ public abstract class JalviewChimeraBinding extends AAStructureBindingModel StructureMappingcommandSet commandSet = ChimeraCommands .getSetAttributeCommandsForFeatures(getSsm(), files, - getSequence(), avp); + getSequence(), avp, viewer.isChimeraX()); String[] commands = commandSet.commands; if (commands.length > 10) { @@ -1127,9 +1146,9 @@ public abstract class JalviewChimeraBinding extends AAStructureBindingModel } /** - * Write commands to a temporary file, and send a command to Chimera to open - * the file as a commands script. For use when sending a large number of - * separate commands would overload the REST interface mechanism. + * Write commands to a temporary file, and send a command to Chimera to open the + * file as a commands script. For use when sending a large number of separate + * commands would overload the REST interface mechanism. * * @param commands */