+ // Sometimes SIFTS mappings are wrongly swapped between different chains of
+ // a PDB entry. This results to wrong mappings being generated. The boolean
+ // flag 'isGetEntityIdDirectly, determines whether an entity to process is
+ // determined by a greedy heuristic search or by just matching the Chain Id
+ // directly against the entity Id tag. Setting the default value to 'false'
+ // utilise the heuristic search which always produces correct mappings but
+ // less optimised processing, where as changing the value to 'true'
+ // optimises performance but might result to incorrect mapping in some cases
+ // where SIFTS mappings are wrongly swapped between different chains.
+ boolean isGetEntityIdDirectly = false;
+ if (isGetEntityIdDirectly)
+ {
+ List<Entity> entities = siftsEntry.getEntity();
+ for (Entity entity : entities)
+ {
+ if (!entity.getEntityId().equalsIgnoreCase(id))
+ {
+ continue;
+ }
+ return entity;
+ }
+ }
+ Entity entity = getEntityByMostOptimalMatchedId(id);
+ if (entity != null)
+ {
+ return entity;
+ }
+ throw new SiftsException("Entity " + id + " not found");
+ }
+
+ /**
+ * This method was added because EntityId is NOT always equal to ChainId.
+ * Hence, it provides the logic to greedily detect the "true" Entity for a
+ * given chainId where discrepancies exist.
+ *
+ * @param chainId
+ * @return
+ */
+ public Entity getEntityByMostOptimalMatchedId(String chainId)
+ {
+ // System.out.println("---> advanced greedy entityId matching block entered..");