X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fstructure%2FStructureSelectionManager.java;h=ae5431bc8d1b224ad807d08a50f3dfc3889114cc;hb=d043ce47fc710d3eb2629ba926a8a7417bd67d8c;hp=bd3d7b32c3848a3799e5eba7eaf8a76a124e04d9;hpb=49db0dff1da16c3355b43a41498c1fc93ef47e91;p=jalview.git diff --git a/src/jalview/structure/StructureSelectionManager.java b/src/jalview/structure/StructureSelectionManager.java index bd3d7b32..ae5431b 100644 --- a/src/jalview/structure/StructureSelectionManager.java +++ b/src/jalview/structure/StructureSelectionManager.java @@ -20,11 +20,12 @@ */ package jalview.structure; + import jalview.analysis.AlignSeq; import jalview.api.StructureSelectionManagerProvider; import jalview.bin.ApplicationSingletonProvider; import jalview.bin.ApplicationSingletonProvider.ApplicationSingletonI; -import jalview.bin.Cache; +import jalview.bin.Console; import jalview.commands.CommandI; import jalview.commands.EditCommand; import jalview.commands.OrderCommand; @@ -57,6 +58,7 @@ import java.util.Enumeration; import java.util.HashMap; import java.util.IdentityHashMap; import java.util.List; +import java.util.Locale; import java.util.Map; import java.util.Vector; @@ -68,6 +70,7 @@ public class StructureSelectionManager implements ApplicationSingletonI { public final static String NEWLINE = System.lineSeparator(); + private List mappings = new ArrayList<>(); private boolean processSecondaryStructure = false; @@ -84,7 +87,6 @@ public class StructureSelectionManager implements ApplicationSingletonI private List commandListeners = new ArrayList<>(); private List sel_listeners = new ArrayList<>(); - /* * instances of this class scoped by some context class */ @@ -144,7 +146,52 @@ public class StructureSelectionManager implements ApplicationSingletonI } return instance; } +/** Null provider in 2.11.2 + + + private static StructureSelectionManager nullProvider = null; + public static StructureSelectionManager getStructureSelectionManager( + StructureSelectionManagerProvider context) + { + if (context == null) + { + if (nullProvider == null) + { + if (instances != null) + { + throw new Error(MessageManager.getString( + "error.implementation_error_structure_selection_manager_null"), + new NullPointerException(MessageManager + .getString("exception.ssm_context_is_null"))); + } + else + { + nullProvider = new StructureSelectionManager(); + } + return nullProvider; + } + } + if (instances == null) + { + instances = new java.util.IdentityHashMap<>(); + } + StructureSelectionManager instance = instances.get(context); + if (instance == null) + { + if (nullProvider != null) + { + instance = nullProvider; + } + else + { + instance = new StructureSelectionManager(); + } + instances.put(context, instance); + } + return instance; + } +*/ /** * @return true if will try to use external services for processing secondary @@ -464,8 +511,8 @@ public class StructureSelectionManager implements ApplicationSingletonI } catch (SiftsException e) { isMapUsingSIFTs = false; - Cache.log.error("SIFTS mapping failed", e); - Cache.log.error("Falling back on Needleman & Wunsch alignment"); + Console.error("SIFTS mapping failed", e); + Console.error("Falling back on Needleman & Wunsch alignment"); siftsClient = null; } @@ -572,21 +619,23 @@ public class StructureSelectionManager implements ApplicationSingletonI pdb, maxChain, sqmpping, maxAlignseq, siftsClient); seqToStrucMapping.add(siftsMapping); maxChain.makeExactMapping(siftsMapping, seq); - maxChain.transferRESNUMFeatures(seq, "IEA: SIFTS"); + maxChain.transferRESNUMFeatures(seq, "IEA: SIFTS", + pdb.getId().toLowerCase(Locale.ROOT)); maxChain.transferResidueAnnotation(siftsMapping, null); ds.addPDBId(maxChain.sequence.getAllPDBEntries().get(0)); } catch (SiftsException e) { // fall back to NW alignment - Cache.log.error(e.getMessage()); + Console.error(e.getMessage()); StructureMapping nwMapping = getNWMappings(seq, pdbFile, targetChainId, maxChain, pdb, maxAlignseq); seqToStrucMapping.add(nwMapping); maxChain.makeExactMapping(maxAlignseq, seq); - maxChain.transferRESNUMFeatures(seq, "IEA:Jalview"); // FIXME: is - // this - // "IEA:Jalview" ? + maxChain.transferRESNUMFeatures(seq, "IEA:Jalview", + pdb.getId().toLowerCase(Locale.ROOT)); // FIXME: is + // this + // "IEA:Jalview" ? maxChain.transferResidueAnnotation(nwMapping, sqmpping); ds.addPDBId(maxChain.sequence.getAllPDBEntries().get(0)); } @@ -604,7 +653,8 @@ public class StructureSelectionManager implements ApplicationSingletonI siftsClient); foundSiftsMappings.add(siftsMapping); chain.makeExactMapping(siftsMapping, seq); - chain.transferRESNUMFeatures(seq, "IEA: SIFTS");// FIXME: is this + chain.transferRESNUMFeatures(seq, "IEA: SIFTS", + pdb.getId().toLowerCase(Locale.ROOT));// FIXME: is this // "IEA:SIFTS" ? chain.transferResidueAnnotation(siftsMapping, null); } catch (SiftsException e) @@ -629,8 +679,9 @@ public class StructureSelectionManager implements ApplicationSingletonI StructureMapping nwMapping = getNWMappings(seq, pdbFile, maxChainId, maxChain, pdb, maxAlignseq); seqToStrucMapping.add(nwMapping); - maxChain.transferRESNUMFeatures(seq, null); // FIXME: is this - // "IEA:Jalview" ? + maxChain.transferRESNUMFeatures(seq, null, + pdb.getId().toLowerCase(Locale.ROOT)); // FIXME: is this + // "IEA:Jalview" ? maxChain.transferResidueAnnotation(nwMapping, sqmpping); ds.addPDBId(maxChain.sequence.getAllPDBEntries().get(0)); } @@ -685,6 +736,7 @@ public class StructureSelectionManager implements ApplicationSingletonI { ds = ds.getDatasetSequence(); } + ; if (ds.getAnnotation() != null) { for (AlignmentAnnotation ala : ds.getAnnotation()) @@ -796,7 +848,8 @@ public class StructureSelectionManager implements ApplicationSingletonI maxChain.makeExactMapping(maxAlignseq, seq); jalview.datamodel.Mapping sqmpping = maxAlignseq .getMappingFromS1(false); - maxChain.transferRESNUMFeatures(seq, null); + maxChain.transferRESNUMFeatures(seq, null, + pdb.getId().toLowerCase(Locale.ROOT)); HashMap mapping = new HashMap<>(); int resNum = -10000; @@ -938,9 +991,9 @@ public class StructureSelectionManager implements ApplicationSingletonI if (s != null) { result = s; + } } } - } return result; } @@ -1368,7 +1421,7 @@ public class StructureSelectionManager implements ApplicationSingletonI { slis.viewPosition(startRes, endRes, startSeq, endSeq, source); } - + ; } } } @@ -1379,12 +1432,11 @@ public class StructureSelectionManager implements ApplicationSingletonI * * @param provider */ - public static void release(StructureSelectionManagerProvider provider) { getInstance().selectionManagers.remove(provider); } - + public void registerPDBEntry(PDBEntry pdbentry) { if (pdbentry.getFile() != null