import jalview.datamodel.Annotation;
import jalview.datamodel.HiddenColumns;
import jalview.datamodel.PDBEntry;
+import jalview.datamodel.SearchResultMatchI;
import jalview.datamodel.SearchResults;
import jalview.datamodel.SearchResultsI;
import jalview.datamodel.SequenceI;
{
seqPos = seq.findPosition(indexpos);
}
+
+ // precompute so we can also relay structure highlights
+ if (results == null)
+ {
+ results = MappingUtils.buildSearchResults(seq, seqPos,
+ seqmappings);
+ }
+ if (handlingVamsasMo)
+ {
+ results.addResult(seq, seqPos, seqPos);
+
+ }
+
for (int i = 0; i < listeners.size(); i++)
{
Object listener = listeners.elementAt(i);
}
if (listener instanceof StructureListener)
{
- highlightStructure((StructureListener) listener, seq, seqPos);
+ StructureListener sl = (StructureListener) listener;
+ // TODO: consider merging highlightStructure variants second call
+ // functionally same as first if seq/seqPos is part of the searchResults
+ if (highlightStructure(sl, seq, seqPos)==0 && relaySeqMappings)
+ {
+ // structure highlights for mapped sequences
+ highlightStructure(sl,results);
+ }
}
else
{
{
if (relaySeqMappings)
{
- if (results == null)
- {
- results = MappingUtils.buildSearchResults(seq, seqPos,
- seqmappings);
- }
- if (handlingVamsasMo)
- {
- results.addResult(seq, seqPos, seqPos);
-
- }
if (!results.isEmpty())
{
seqListener.highlightSequence(results);
}
/**
+ * highlights positions in a structure viewer corresponding to one or more positions on sequences
+ * @param sl
+ * @param searchResults
+ * @return 0 or number of structure regions highlighted
+ */
+ public int highlightStructure(StructureListener sl, SearchResultsI searchResults)
+ {
+ int atomNo;
+ List<AtomSpec> atoms = new ArrayList<>();
+
+ for (SearchResultMatchI sr: searchResults.getResults())
+ {
+ SequenceI seq = sr.getSequence();
+ for (StructureMapping sm : mappings)
+ {
+ if (sm.sequence == seq || sm.sequence == seq.getDatasetSequence()
+ || (sm.sequence.getDatasetSequence() != null
+ && (sm.sequence.getDatasetSequence() == seq
+ || sm.sequence.getDatasetSequence() == seq
+ .getDatasetSequence())))
+ {
+ for (int index=sr.getStart();index<=sr.getEnd();index++)
+ {
+ atomNo = sm.getAtomNum(index);
+
+ if (atomNo > 0)
+ {
+ atoms.add(new AtomSpec(sm.pdbfile, sm.pdbchain,
+ sm.getPDBResNum(index), atomNo));
+ }
+ }
+ }
+ }
+ }
+ sl.highlightAtoms(atoms);
+ return atoms.size();
+ }
+ /**
* Send suitable messages to a StructureListener to highlight atoms
* corresponding to the given sequence position(s)
*
* @param sl
* @param seq
* @param positions
+ * @return 0 if no atoms identified for position(s)
*/
- public void highlightStructure(StructureListener sl, SequenceI seq,
+ public int highlightStructure(StructureListener sl, SequenceI seq,
int... positions)
{
if (!sl.isListeningFor(seq))
{
- return;
+ return 0;
}
int atomNo;
List<AtomSpec> atoms = new ArrayList<>();
}
}
sl.highlightAtoms(atoms);
+ return atoms.size();
}
/**