/*
- * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
- * Copyright (C) $$Year-Rel$$ The Jalview Authors
+ * Jalview - A Sequence Alignment Editor and Viewer (Version 2.9.0b1)
+ * Copyright (C) 2015 The Jalview Authors
*
* This file is part of Jalview.
*
*/
package jalview.structure;
+import jalview.analysis.AlignSeq;
+import jalview.api.StructureSelectionManagerProvider;
+import jalview.commands.CommandI;
+import jalview.commands.EditCommand;
+import jalview.commands.OrderCommand;
+import jalview.datamodel.AlignedCodonFrame;
+import jalview.datamodel.AlignmentAnnotation;
+import jalview.datamodel.AlignmentI;
+import jalview.datamodel.Annotation;
+import jalview.datamodel.PDBEntry;
+import jalview.datamodel.SearchResults;
+import jalview.datamodel.SequenceI;
+import jalview.io.AppletFormatAdapter;
+import jalview.util.MappingUtils;
+import jalview.util.MessageManager;
+
import java.io.PrintStream;
import java.util.ArrayList;
import java.util.Arrays;
import MCview.PDBChain;
import MCview.PDBfile;
-import jalview.analysis.AlignSeq;
-import jalview.api.StructureSelectionManagerProvider;
-import jalview.commands.CommandI;
-import jalview.commands.EditCommand;
-import jalview.commands.OrderCommand;
-import jalview.datamodel.AlignedCodonFrame;
-import jalview.datamodel.AlignmentAnnotation;
-import jalview.datamodel.AlignmentI;
-import jalview.datamodel.Annotation;
-import jalview.datamodel.PDBEntry;
-import jalview.datamodel.SearchResults;
-import jalview.datamodel.SequenceI;
-import jalview.io.AppletFormatAdapter;
-import jalview.util.MappingUtils;
-import jalview.util.MessageManager;
-
public class StructureSelectionManager
{
public final static String NEWLINE = System.lineSeparator();
/*
* Set of any registered mappings between (dataset) sequences.
*/
- Set<AlignedCodonFrame> seqmappings = new LinkedHashSet<AlignedCodonFrame>();
-
- /*
- * Reference counters for the above mappings. Remove mappings when ref count
- * goes to zero.
- */
- Map<AlignedCodonFrame, Integer> seqMappingRefCounts = new HashMap<AlignedCodonFrame, Integer>();
+ public Set<AlignedCodonFrame> seqmappings = new LinkedHashSet<AlignedCodonFrame>();
private List<CommandListener> commandListeners = new ArrayList<CommandListener>();
if (resNum != tmp.resNumber && tmp.alignmentMapping != -1)
{
resNum = tmp.resNumber;
- mapping[tmp.alignmentMapping + 1][0] = tmp.resNumber;
- mapping[tmp.alignmentMapping + 1][1] = tmp.atomIndex;
+ if (tmp.alignmentMapping >= -1)
+ {
+ // TODO (JAL-1836) address root cause: negative residue no in PDB
+ // file
+ mapping[tmp.alignmentMapping + 1][0] = tmp.resNumber;
+ mapping[tmp.alignmentMapping + 1][1] = tmp.atomIndex;
+ }
}
index++;
results.addResult(seq, index, index);
}
- seqListener.highlightSequence(results);
+ if (!results.isEmpty())
+ {
+ seqListener.highlightSequence(results);
+ }
}
}
}
else if (listener instanceof SecondaryStructureListener)
{
((SecondaryStructureListener) listener).mouseOverSequence(seq,
- indexpos);
+ indexpos, index);
}
}
}
protected void highlightStructure(StructureListener sl, SequenceI seq,
int index)
{
+ if (!sl.isListeningFor(seq))
+ {
+ return;
+ }
int atomNo;
List<AtomSpec> atoms = new ArrayList<AtomSpec>();
for (StructureMapping sm : mappings)
}
/**
- * Decrement the reference counter for each of the given mappings, and remove
- * it entirely if its reference counter reduces to zero.
+ * Remove the given mapping
*
- * @param set
+ * @param acf
*/
- public void removeMappings(Set<AlignedCodonFrame> set)
+ public void deregisterMapping(AlignedCodonFrame acf)
{
- if (set != null)
+ if (acf != null)
{
- for (AlignedCodonFrame acf : set)
- {
- removeMapping(acf);
+ boolean removed = seqmappings.remove(acf);
+ if (removed && seqmappings.isEmpty())
+ { // debug
+ System.out.println("All mappings removed");
}
}
}
/**
- * Decrement the reference counter for the given mapping, and remove it
- * entirely if its reference counter reduces to zero.
+ * Add each of the given codonFrames to the stored set, if not aready present.
*
- * @param acf
+ * @param set
*/
- public void removeMapping(AlignedCodonFrame acf)
+ public void registerMappings(Set<AlignedCodonFrame> set)
{
- if (acf != null && seqmappings.contains(acf))
+ if (set != null)
{
- int count = seqMappingRefCounts.get(acf);
- count--;
- if (count > 0)
- {
- seqMappingRefCounts.put(acf, count);
- }
- else
+ for (AlignedCodonFrame acf : set)
{
- seqmappings.remove(acf);
- seqMappingRefCounts.remove(acf);
+ registerMapping(acf);
}
}
}
/**
- * Add each of the given codonFrames to the stored set. If not aready present,
- * increments its reference count instead.
- *
- * @param set
+ * Add the given mapping to the stored set, unless already stored.
*/
- public void addMappings(Set<AlignedCodonFrame> set)
+ public void registerMapping(AlignedCodonFrame acf)
{
- if (set != null)
+ if (acf != null)
{
- for (AlignedCodonFrame acf : set)
+ if (!seqmappings.contains(acf))
{
- addMapping(acf);
+ seqmappings.add(acf);
}
}
}
/**
- * Add the given mapping to the stored set, or if already stored, increment
- * its reference counter.
+ * Resets this object to its initial state by removing all registered
+ * listeners, codon mappings, PDB file mappings
*/
- public void addMapping(AlignedCodonFrame acf)
+ public void resetAll()
{
- if (acf != null)
+ if (mappings != null)
{
- if (seqmappings.contains(acf))
- {
- seqMappingRefCounts.put(acf, seqMappingRefCounts.get(acf) + 1);
- }
- else
- {
- seqmappings.add(acf);
- seqMappingRefCounts.put(acf, 1);
- }
+ mappings.clear();
+ }
+ if (seqmappings != null)
+ {
+ seqmappings.clear();
+ }
+ if (sel_listeners != null)
+ {
+ sel_listeners.clear();
+ }
+ if (listeners != null)
+ {
+ listeners.clear();
+ }
+ if (commandListeners != null)
+ {
+ commandListeners.clear();
+ }
+ if (view_listeners != null)
+ {
+ view_listeners.clear();
+ }
+ if (pdbFileNameId != null)
+ {
+ pdbFileNameId.clear();
+ }
+ if (pdbIdFileName != null)
+ {
+ pdbIdFileName.clear();
}
}