import ext.edu.ucsf.rbvi.strucviz2.ChimeraModel;
import ext.edu.ucsf.rbvi.strucviz2.StructureManager;
import ext.edu.ucsf.rbvi.strucviz2.StructureManager.ModelType;
+import jalview.api.AlignViewportI;
import jalview.api.AlignmentViewPanel;
import jalview.api.structures.JalviewStructureDisplayI;
import jalview.bin.Cache;
* @param pdbfnum
* @return
*/
- protected String getModelSpec(int pdbfnum)
+ @Override
+ public String getModelSpec(int pdbfnum)
{
if (pdbfnum < 0 || pdbfnum >= getPdbCount())
{
* to the Chimera command 'list models type molecule', see
* ChimeraManager.getModelList().
*/
- List<ChimeraModel> maps = chimeraMaps.get(getStructureFiles()[pdbfnum]);
+ String[] structureFiles = getStructureFiles();
+ if (pdbfnum < 0 || pdbfnum >= structureFiles.length)
+ {
+ return "";
+ }
+
+ List<ChimeraModel> maps = chimeraMaps.get(structureFiles[pdbfnum]);
boolean hasSubModels = maps != null && maps.size() > 1;
- return "#" + String.valueOf(pdbfnum) + (hasSubModels ? ".1" : "");
+ String spec = "#" + String.valueOf(pdbfnum);
+ return hasSubModels ? spec + ".1" : spec;
}
/**
public int sendFeaturesToViewer(AlignmentViewPanel avp)
{
// TODO refactor as required to pull up to an interface
-
Map<String, Map<Object, AtomSpecModel>> featureValues = buildFeaturesMap(
avp);
List<StructureCommandI> commands = getCommandGenerator()
{
return "https://www.cgl.ucsf.edu/chimera/docs/UsersGuide";
}
+
+ @Override
+ public void showStructures(AlignViewportI av, boolean refocus)
+ {
+ StructureCommandI cmd = buildShowStructuresCommand(av, refocus);
+ executeCommand(cmd, false);
+ }
+
+ /**
+ * Builds a command to show parts of the structure, depending on whether
+ * <ul>
+ * <li>all structures or regions mapped to alignment only are shown</li>
+ * <li>all chains or only selected chains are shown</li>
+ * </ul>
+ *
+ * @param av
+ * @param refocus
+ * @return
+ */
+ protected StructureCommandI buildShowStructuresCommand(
+ AlignViewportI av,
+ boolean refocus)
+ {
+ // TODO refactor using command generator
+ // pull up this method and Jmol variant to base class
+ StringBuilder cmd = new StringBuilder(128);
+ cmd.append("~display");
+
+ if (isShowAlignmentOnly())
+ {
+ AtomSpecModel model = getShownResidues(av);
+ String atomSpec = getCommandGenerator().getAtomSpec(model, false);
+ if (!atomSpec.isEmpty())
+ {
+ cmd.append("; ~ribbon; ribbon ").append(atomSpec);
+ }
+ }
+ else
+ {
+ cmd.append("; ribbon");
+ }
+
+ /*
+ * hide any chains selected not to be shown (whether mapped to
+ * sequence in the alignment or not)
+ */
+ for (String pdbChain : chainsToHide)
+ {
+ String chainId = pdbChain.split(":")[1];
+ String modelNo = getModelIdForFile(getFileForChain(pdbChain));
+ if (!"".equals(modelNo))
+ {
+ cmd.append("; ~ribbon #").append(modelNo).append(":.")
+ .append(chainId);
+ }
+ }
+ if (refocus)
+ {
+ cmd.append("; focus");
+ }
+ return new StructureCommand(cmd.toString());
+ }
+
+ @Override
+ public int getModelForPdbFile(String fileName, int fileIndex)
+ {
+ if (chimeraMaps.containsKey(fileName))
+ {
+ List<ChimeraModel> models = chimeraMaps.get(fileName);
+ if (!models.isEmpty())
+ {
+ return models.get(0).getModelNumber();
+ }
+ }
+ return -1;
+ }
}