From f4d531c14c933d33377556506adb70980fffda9e Mon Sep 17 00:00:00 2001 From: Jim Procter Date: Sun, 27 Aug 2017 14:23:06 +0100 Subject: [PATCH] JAL-2691 discover any existing chain mappings for a structure view --- .../structures/models/AAStructureBindingModel.java | 50 +++++++++++++++++++- 1 file changed, 49 insertions(+), 1 deletion(-) diff --git a/src/jalview/structures/models/AAStructureBindingModel.java b/src/jalview/structures/models/AAStructureBindingModel.java index 9f4cea0..a3c4beb 100644 --- a/src/jalview/structures/models/AAStructureBindingModel.java +++ b/src/jalview/structures/models/AAStructureBindingModel.java @@ -142,7 +142,6 @@ public abstract class AAStructureBindingModel * @param ssm * @param pdbentry * @param sequenceIs - * @param chains * @param protocol */ public AAStructureBindingModel(StructureSelectionManager ssm, @@ -154,8 +153,57 @@ public abstract class AAStructureBindingModel this.nucleotide = Comparison.isNucleotide(sequenceIs); this.pdbEntry = pdbentry; this.protocol = protocol; + resolveChains(); } + private boolean resolveChains() + { + /** + * final count of chain mappings discovered + */ + int chainmaps = 0; + String[][] newchains = new String[pdbEntry.length][]; + int pe = 0; + for (PDBEntry pdb : pdbEntry) + { + SequenceI[] seqsForPdb = sequence[pe]; + if (seqsForPdb != null) + { + newchains[pe] = new String[seqsForPdb.length]; + int se = 0; + for (SequenceI asq : seqsForPdb) + { + String chain = (chains != null && chains[pe] != null) + ? chains[pe][se] + : null; + SequenceI sq = asq.getDatasetSequence(); + if (sq.getAllPDBEntries() != null) + { + for (PDBEntry pdbentry : sq.getAllPDBEntries()) + { + if (pdb.getFile() != null && pdbentry.getFile() != null + && pdb.getFile().equals(pdbentry.getFile())) + { + String chaincode = pdbentry.getChainCode(); + if (chaincode != null && chaincode.length() > 0) + { + chain = chaincode; + chainmaps++; + break; + } + } + } + } + newchains[pe][se] = chain; + se++; + } + pe++; + } + } + + chains = newchains; + return chainmaps > 0; + } public StructureSelectionManager getSsm() { return ssm; -- 1.7.10.2