+
+ /**
+ * construct a 1:1 mapping using given residue and sequence numbering
+ * @param seq
+ * @param pdbFile
+ * @param identityChainId
+ * @param identityChain
+ * @param pdb
+ * @return
+ */
+
+ private StructureMapping getIdMappings(SequenceI seq, String pdbFile,
+ String identityChainId, PDBChain identityChain, StructureFile pdb)
+ {
+ final StringBuilder mappingDetails = new StringBuilder(128);
+ mappingDetails.append(NEWLINE)
+ .append("Sequence \u27f7 Structure mapping details");
+ mappingDetails.append(NEWLINE);
+ mappingDetails.append("Method: Matching length 1:1");
+ mappingDetails.append(NEWLINE).append("PDB Sequence is :")
+ .append(NEWLINE).append("Sequence = ")
+ .append(identityChain.sequence.getSequenceAsString());
+ mappingDetails.append(NEWLINE).append("No of residues = ")
+ .append(identityChain.residues.size()).append(NEWLINE)
+ .append(NEWLINE);
+
+ mappingDetails.append(NEWLINE)
+ .append("Aligned Sequence is: " + seq.getDisplayId(true));
+ mappingDetails.append(NEWLINE)
+ .append("Sequence = " + seq.getSequenceAsString());
+
+ int from = Math.max(seq.getStart(),identityChain.sequence.getStart());
+ int to = Math.min(seq.getEnd(), identityChain.sequence.getEnd());
+ jalview.datamodel.Mapping sqmpping = new jalview.datamodel.Mapping(seq,
+ new MapList(new int[]
+ { from,to },
+ new int[]
+ { from,to },
+ 1, 1));
+ identityChain.mapChainWith(sqmpping, seq);
+
+ identityChain.transferRESNUMFeatures(seq, null,
+ pdb.getId().toLowerCase(Locale.ROOT));
+
+ // Construct mapping
+ // TODO REFACTOR TO PDBChain as a builder
+ HashMap<Integer, int[]> mapping = new HashMap<>();
+ int resNum = -10000;
+ int index = 0;
+ char insCode = ' ';
+
+ do
+ {
+ Atom tmp = identityChain.atoms.elementAt(index);
+ if ((resNum != tmp.resNumber || insCode != tmp.insCode)
+ && tmp.alignmentMapping != -1)
+ {
+ resNum = tmp.resNumber;
+ insCode = tmp.insCode;
+ if (tmp.alignmentMapping >= -1)
+ {
+ mapping.put(tmp.alignmentMapping + 1,
+ new int[]
+ { tmp.resNumber, tmp.atomIndex });
+ }
+ }
+
+ index++;
+ } while (index < identityChain.atoms.size());
+
+ StructureMapping idMapping = new StructureMapping(seq, pdbFile,
+ pdb.getId(), identityChainId, mapping,
+ mappingDetails.toString());
+ identityChain.transferResidueAnnotation(idMapping, sqmpping);
+ return idMapping;
+ }