From 22abbe2e23f5e82e27fa7fa5dbbb4d7885a6fc3a Mon Sep 17 00:00:00 2001 From: Jim Procter Date: Tue, 16 Aug 2016 15:15:15 +0100 Subject: [PATCH] JAL-2154 always resolve dataset sequences when creating a mapping for a DBRefEntry --- src/jalview/analysis/CrossRef.java | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/src/jalview/analysis/CrossRef.java b/src/jalview/analysis/CrossRef.java index 1edc9e5..355f46a 100644 --- a/src/jalview/analysis/CrossRef.java +++ b/src/jalview/analysis/CrossRef.java @@ -675,24 +675,28 @@ public class CrossRef DBRefEntry xref, AlignedCodonFrame mappings, boolean fromDna) { MapList mapping = null; - + SequenceI dsmapFrom = mapFrom.getDatasetSequence() == null ? mapFrom + : mapFrom.getDatasetSequence(); + SequenceI dsmapTo = mapFrom.getDatasetSequence() == null ? mapTo + : mapTo.getDatasetSequence(); /* - * look for a reverse mapping, if found make its inverse + * look for a reverse mapping, if found make its inverse. + * Note - we do this on dataset sequences only. */ - if (mapTo.getDBRefs() != null) + if (dsmapTo.getDBRefs() != null) { - for (DBRefEntry dbref : mapTo.getDBRefs()) + for (DBRefEntry dbref : dsmapTo.getDBRefs()) { String name = dbref.getSource() + "|" + dbref.getAccessionId(); - if (dbref.hasMap() && mapFrom.getName().startsWith(name)) + if (dbref.hasMap() && dsmapFrom.getName().startsWith(name)) { /* * looks like we've found a map from 'mapTo' to 'mapFrom' * - invert it to make the mapping the other way */ MapList reverse = dbref.getMap().getMap().getInverse(); - xref.setMap(new Mapping(mapTo, reverse)); - mappings.addMap(mapFrom, mapTo, reverse); + xref.setMap(new Mapping(dsmapTo, reverse)); + mappings.addMap(mapFrom, dsmapTo, reverse); return true; } } -- 1.7.10.2