*/
package jalview.ext.rbvi.chimera;
+import jalview.api.AlignViewportI;
import jalview.api.AlignmentViewPanel;
import jalview.api.SequenceRenderer;
import jalview.api.structures.JalviewStructureDisplayI;
import jalview.datamodel.SearchResultsI;
import jalview.datamodel.SequenceFeature;
import jalview.datamodel.SequenceI;
+import jalview.datamodel.VisibleContigsIterator;
import jalview.httpserver.AbstractRequestHandler;
import jalview.io.DataSourceType;
import jalview.schemes.ColourSchemeI;
import jalview.schemes.ResidueProperties;
import jalview.structure.AtomSpec;
+import jalview.structure.StructureMapping;
import jalview.structure.StructureMappingcommandSet;
import jalview.structure.StructureSelectionManager;
import jalview.structures.models.AAStructureBindingModel;
private static final String ALPHACARBON = "CA";
- private List<String> chainNames = new ArrayList<String>();
+ private List<String> chainNames = new ArrayList<>();
- private Hashtable<String, String> chainFile = new Hashtable<String, String>();
+ private Hashtable<String, String> chainFile = new Hashtable<>();
/*
* Object through which we talk to Chimera
/*
* Map of ChimeraModel objects keyed by PDB full local file name
*/
- private Map<String, List<ChimeraModel>> chimeraMaps = new LinkedHashMap<String, List<ChimeraModel>>();
+ private Map<String, List<ChimeraModel>> chimeraMaps = new LinkedHashMap<>();
String lastHighlightCommand;
String file = pe.getFile();
try
{
- List<ChimeraModel> modelsToMap = new ArrayList<ChimeraModel>();
+ List<ChimeraModel> modelsToMap = new ArrayList<>();
List<ChimeraModel> oldList = viewer.getModelList();
boolean alreadyOpen = false;
System.out.println(
"Superimpose command(s):\n" + command.toString());
}
- allComs.append("~display all; chain @CA|P; ribbon ")
- .append(selectioncom.toString())
+ allComs/*.append("~display all; chain @CA|P; ribbon ")
+ .append(selectioncom.toString())*/
.append(";" + command.toString());
}
}
{
System.out.println("Select regions:\n" + selectioncom.toString());
}
- allComs.append("; ~display all; chain @CA|P; ribbon ")
- .append(selectioncom.toString()).append("; focus");
+ allComs.append("; ~display "); // all");
+ if (!isShowAlignmentOnly())
+ {
+ allComs.append("; ribbon; chain @CA|P");
+ }
+ else
+ {
+ allComs.append("; ~ribbon");
+ }
+ allComs.append("; ribbon ").append(selectioncom.toString())
+ .append("; focus");
List<String> chimeraReplies = sendChimeraCommand(allComs.toString(),
true);
for (String reply : chimeraReplies)
{
- if (reply.toLowerCase().contains("unequal numbers of atoms"))
+ String lowerCase = reply.toLowerCase();
+ if (lowerCase.contains("unequal numbers of atoms")
+ || lowerCase.contains("at least"))
{
error = reply;
}
protected List<AtomSpec> convertStructureResiduesToAlignment(
List<String> structureSelection)
{
- List<AtomSpec> atomSpecs = new ArrayList<AtomSpec>();
+ List<AtomSpec> atomSpecs = new ArrayList<>();
for (String atomSpec : structureSelection)
{
try
}
return -1;
}
+
+ @Override
+ public void showStructures(AlignViewportI av)
+ {
+ StringBuilder cmd = new StringBuilder(128);
+ cmd.append("~display; ~ribbon;");
+ if (isShowAlignmentOnly())
+ {
+ String atomSpec = getMappedResidues(av);
+ cmd.append("ribbon ").append(atomSpec);
+ }
+ else
+ {
+ cmd.append("chain @CA|P; ribbon");
+ }
+ cmd.append("; focus");
+ sendChimeraCommand(cmd.toString(), false);
+ }
+
+ /**
+ * Builds a Chimera atomSpec of residues mapped from sequences, of the format
+ * (#model:residues.chain)
+ *
+ * <pre>
+ * #0:2-94.A | #1:1-93.C | #2:1-93.A
+ * </pre>
+ *
+ * Only residues visible in the alignment are included, that is, hidden columns
+ * and sequences are excluded.
+ *
+ * @param av
+ * @return
+ */
+ private String getMappedResidues(AlignViewportI av)
+ {
+ AlignmentI alignment = av.getAlignment();
+ final int width = alignment.getWidth();
+
+ String[] files = getStructureFiles();
+
+ StringBuilder atomSpec = new StringBuilder(256);
+
+ for (int pdbfnum = 0; pdbfnum < files.length; pdbfnum++)
+ {
+ StructureMapping[] mappings = getSsm().getMapping(files[pdbfnum]);
+
+ /*
+ * Find the first mapped sequence (if any) for this PDB entry which is in
+ * the alignment
+ */
+ final int seqCountForPdbFile = getSequence()[pdbfnum].length;
+ for (int s = 0; s < seqCountForPdbFile; s++)
+ {
+ for (StructureMapping mapping : mappings)
+ {
+ final SequenceI theSequence = getSequence()[pdbfnum][s];
+ if (mapping.getSequence() == theSequence
+ && alignment.findIndex(theSequence) > -1)
+ {
+ String chainCd = mapping.getChain();
+
+ // TODO only process sequence ranges within visible columns
+ VisibleContigsIterator visible = alignment.getHiddenColumns()
+ .getVisContigsIterator(0, width, true);
+ while (visible.hasNext())
+ {
+ int[] visibleRegion = visible.next();
+ int seqStartPos = theSequence.findPosition(visibleRegion[0]);
+ int seqEndPos = theSequence.findPosition(visibleRegion[1]);
+ List<int[]> residueRanges = mapping
+ .getPDBResNumRanges(seqStartPos, seqEndPos);
+ if (!residueRanges.isEmpty())
+ {
+ if (atomSpec.length() > 0)
+ {
+ atomSpec.append("| ");
+ }
+ atomSpec.append(getModelSpec(pdbfnum)).append(":");
+ boolean first = true;
+ for (int[] range : residueRanges)
+ {
+ if (!first)
+ {
+ atomSpec.append(",");
+ }
+ first = false;
+ atomSpec.append(range[0]).append("-").append(range[1]);
+ atomSpec.append(".").append(chainCd);
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+
+ return atomSpec.toString();
+ }
}