X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fstructure%2FStructureSelectionManager.java;h=7eb910746e18f8025039b110bafe7c0e68bef6df;hb=75db7abd6c89a9465861dc7604faca4893c52101;hp=b973f45f869a381d6e052ea355a51482c77977a4;hpb=461fa736a460f28d57cb0fe1f3a1cd05c32f0f7c;p=jalview.git diff --git a/src/jalview/structure/StructureSelectionManager.java b/src/jalview/structure/StructureSelectionManager.java index b973f45..7eb9107 100644 --- a/src/jalview/structure/StructureSelectionManager.java +++ b/src/jalview/structure/StructureSelectionManager.java @@ -66,7 +66,7 @@ public class StructureSelectionManager static IdentityHashMap instances; - private List mappings = new ArrayList(); + private List mappings = new ArrayList<>(); private boolean processSecondaryStructure = false; @@ -74,20 +74,16 @@ public class StructureSelectionManager private boolean addTempFacAnnot = false; - private IProgressIndicator progressIndicator; - private SiftsClient siftsClient = null; - private long progressSessionId; - /* * Set of any registered mappings between (dataset) sequences. */ - private List seqmappings = new ArrayList(); + private List seqmappings = new ArrayList<>(); - private List commandListeners = new ArrayList(); + private List commandListeners = new ArrayList<>(); - private List sel_listeners = new ArrayList(); + private List sel_listeners = new ArrayList<>(); /** * @return true if will try to use external services for processing secondary @@ -175,9 +171,9 @@ public class StructureSelectionManager * map between the PDB IDs (or structure identifiers) used by Jalview and the * absolute filenames for PDB data that corresponds to it */ - Map pdbIdFileName = new HashMap(); + Map pdbIdFileName = new HashMap<>(); - Map pdbFileNameId = new HashMap(); + Map pdbFileNameId = new HashMap<>(); public void registerPDBFile(String idForFile, String absoluteFile) { @@ -228,7 +224,7 @@ public class StructureSelectionManager } if (instances == null) { - instances = new java.util.IdentityHashMap(); + instances = new java.util.IdentityHashMap<>(); } StructureSelectionManager instance = instances.get(context); if (instance == null) @@ -324,9 +320,11 @@ public class StructureSelectionManager * @return null or the structure data parsed as a pdb file */ synchronized public StructureFile setMapping(SequenceI[] sequence, - String[] targetChains, String pdbFile, DataSourceType protocol) + String[] targetChains, String pdbFile, DataSourceType protocol, + IProgressIndicator progress) { - return setMapping(true, sequence, targetChains, pdbFile, protocol); + return computeMapping(true, sequence, targetChains, pdbFile, protocol, + progress); } /** @@ -353,6 +351,16 @@ public class StructureSelectionManager SequenceI[] sequenceArray, String[] targetChainIds, String pdbFile, DataSourceType sourceType) { + return computeMapping(forStructureView, sequenceArray, targetChainIds, + pdbFile, sourceType, null); + } + + synchronized public StructureFile computeMapping( + boolean forStructureView, SequenceI[] sequenceArray, + String[] targetChainIds, String pdbFile, DataSourceType sourceType, + IProgressIndicator progress) + { + long progressSessionId = System.currentTimeMillis() * 3; /* * There will be better ways of doing this in the future, for now we'll use * the tried and tested MCview pdb mapping @@ -500,12 +508,14 @@ public class StructureSelectionManager pdbFile = "INLINE" + pdb.getId(); } - List seqToStrucMapping = new ArrayList(); + List seqToStrucMapping = new ArrayList<>(); if (isMapUsingSIFTs && seq.isProtein()) { - setProgressBar(null); - setProgressBar(MessageManager - .getString("status.obtaining_mapping_with_sifts")); + if (progress!=null) { + progress.setProgressBar(MessageManager + .getString("status.obtaining_mapping_with_sifts"), + progressSessionId); + } jalview.datamodel.Mapping sqmpping = maxAlignseq .getMappingFromS1(false); if (targetChainId != null && !targetChainId.trim().isEmpty()) @@ -538,7 +548,7 @@ public class StructureSelectionManager } else { - List foundSiftsMappings = new ArrayList(); + List foundSiftsMappings = new ArrayList<>(); for (PDBChain chain : pdb.getChains()) { try @@ -575,20 +585,25 @@ public class StructureSelectionManager } else { - setProgressBar(null); - setProgressBar(MessageManager - .getString("status.obtaining_mapping_with_nw_alignment")); + if (progress != null) + { + progress.setProgressBar(MessageManager + .getString("status.obtaining_mapping_with_nw_alignment"), + progressSessionId); + } StructureMapping nwMapping = getNWMappings(seq, pdbFile, maxChainId, maxChain, pdb, maxAlignseq); seqToStrucMapping.add(nwMapping); ds.addPDBId(maxChain.sequence.getAllPDBEntries().get(0)); - } - if (forStructureView) { mappings.addAll(seqToStrucMapping); } + if (progress != null) + { + progress.setProgressBar(null, progressSessionId); + } } return pdb; } @@ -683,7 +698,7 @@ public class StructureSelectionManager .getMappingFromS1(false); maxChain.transferRESNUMFeatures(seq, null); - HashMap mapping = new HashMap(); + HashMap mapping = new HashMap<>(); int resNum = -10000; int index = 0; char insCode = ' '; @@ -737,7 +752,7 @@ public class StructureSelectionManager * Remove mappings to the closed listener's PDB files, but first check if * another listener is still interested */ - List pdbs = new ArrayList(Arrays.asList(pdbfiles)); + List pdbs = new ArrayList<>(Arrays.asList(pdbfiles)); StructureListener sl; for (int i = 0; i < listeners.size(); i++) @@ -758,7 +773,7 @@ public class StructureSelectionManager */ if (pdbs.size() > 0) { - List tmp = new ArrayList(); + List tmp = new ArrayList<>(); for (StructureMapping sm : mappings) { if (!pdbs.contains(sm.pdbfile)) @@ -952,7 +967,7 @@ public class StructureSelectionManager return; } int atomNo; - List atoms = new ArrayList(); + List atoms = new ArrayList<>(); for (StructureMapping sm : mappings) { if (sm.sequence == seq || sm.sequence == seq.getDatasetSequence() @@ -1060,7 +1075,7 @@ public class StructureSelectionManager public StructureMapping[] getMapping(String pdbfile) { - List tmp = new ArrayList(); + List tmp = new ArrayList<>(); for (StructureMapping sm : mappings) { if (sm.pdbfile.equals(pdbfile)) @@ -1220,7 +1235,7 @@ public class StructureSelectionManager } } - Vector view_listeners = new Vector(); + Vector view_listeners = new Vector<>(); public synchronized void sendViewPosition( jalview.api.AlignmentViewPanel source, int startRes, int endRes, @@ -1343,35 +1358,6 @@ public class StructureSelectionManager return null; } - public IProgressIndicator getProgressIndicator() - { - return progressIndicator; - } - - public void setProgressIndicator(IProgressIndicator progressIndicator) - { - this.progressIndicator = progressIndicator; - } - - public long getProgressSessionId() - { - return progressSessionId; - } - - public void setProgressSessionId(long progressSessionId) - { - this.progressSessionId = progressSessionId; - } - - public void setProgressBar(String message) - { - if (progressIndicator == null) - { - return; - } - progressIndicator.setProgressBar(message, progressSessionId); - } - public List getSequenceMappings() { return seqmappings;