X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fstructure%2FStructureSelectionManager.java;h=688762fa38c44e9c7e8aecc9b4c4a246af709c9a;hb=c19d2a91ca05e052e3408bf5852d88eb5d0608f1;hp=cf604901294225357148143b1bca115e6325426b;hpb=43d326c3a7616aedecfce6f7980b3831ec25243a;p=jalview.git diff --git a/src/jalview/structure/StructureSelectionManager.java b/src/jalview/structure/StructureSelectionManager.java index cf60490..688762f 100644 --- a/src/jalview/structure/StructureSelectionManager.java +++ b/src/jalview/structure/StructureSelectionManager.java @@ -1,6 +1,6 @@ /* - * 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.0b2) + * Copyright (C) 2015 The Jalview Authors * * This file is part of Jalview. * @@ -70,13 +70,7 @@ public class StructureSelectionManager /* * Set of any registered mappings between (dataset) sequences. */ - Set seqmappings = new LinkedHashSet(); - - /* - * Reference counters for the above mappings. Remove mappings when ref count - * goes to zero. - */ - private Map seqMappingRefCounts = new HashMap(); + public Set seqmappings = new LinkedHashSet(); private List commandListeners = new ArrayList(); @@ -518,8 +512,13 @@ public class StructureSelectionManager 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++; @@ -721,7 +720,7 @@ public class StructureSelectionManager { results = MappingUtils.buildSearchResults(seq, index, seqmappings); - } + } if (handlingVamsasMo) { results.addResult(seq, index, index); @@ -911,83 +910,48 @@ public class StructureSelectionManager } /** - * Decrement the reference counter for each of the given mappings, and remove - * it entirely if its reference counter reduces to zero. - * - * @param set - */ - public void removeMappings(Set set) - { - if (set != null) - { - for (AlignedCodonFrame acf : set) - { - removeMapping(acf); - } - } - } - - /** - * Decrement the reference counter for the given mapping, and remove it - * entirely if its reference counter reduces to zero. + * Remove the given mapping * * @param acf */ - public void removeMapping(AlignedCodonFrame acf) + public void deregisterMapping(AlignedCodonFrame acf) { - if (acf != null && seqmappings.contains(acf)) + if (acf != null) { - int count = seqMappingRefCounts.get(acf); - count--; - if (count > 0) - { - seqMappingRefCounts.put(acf, count); - } - else - { - seqmappings.remove(acf); - seqMappingRefCounts.remove(acf); - if (seqmappings.isEmpty()) - { // debug - System.out.println("All mappings removed"); - } + boolean removed = seqmappings.remove(acf); + if (removed && seqmappings.isEmpty()) + { // debug + System.out.println("All mappings removed"); } } } /** - * Add each of the given codonFrames to the stored set. If not aready present, - * increments its reference count instead. + * Add each of the given codonFrames to the stored set, if not aready present. * * @param set */ - public void addMappings(Set set) + public void registerMappings(Set set) { if (set != null) { for (AlignedCodonFrame acf : set) { - addMapping(acf); + registerMapping(acf); } } } /** - * Add the given mapping to the stored set, or if already stored, increment - * its reference counter. + * Add the given mapping to the stored set, unless already stored. */ - public void addMapping(AlignedCodonFrame acf) + public void registerMapping(AlignedCodonFrame acf) { if (acf != null) { - if (seqmappings.contains(acf)) - { - seqMappingRefCounts.put(acf, seqMappingRefCounts.get(acf) + 1); - } - else + if (!seqmappings.contains(acf)) { seqmappings.add(acf); - seqMappingRefCounts.put(acf, 1); } } } @@ -1006,10 +970,6 @@ public class StructureSelectionManager { seqmappings.clear(); } - if (seqMappingRefCounts != null) - { - seqMappingRefCounts.clear(); - } if (sel_listeners != null) { sel_listeners.clear(); @@ -1187,20 +1147,4 @@ public class StructureSelectionManager } return null; } - - /** - * Returns the reference count for a mapping - * - * @param acf - * @return - */ - protected int getMappingReferenceCount(AlignedCodonFrame acf) - { - if (seqMappingRefCounts == null) - { - return 0; - } - Integer count = seqMappingRefCounts.get(acf); - return (count == null ? 0 : count.intValue()); - } }