X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fdatamodel%2FAlignedCodonFrame.java;h=bb705b682e16c8788db89ab44ee093ad51693b9f;hb=90ad4273c7105b7763247192e1c6739eed30ba4c;hp=473a534954a4ed1ddcb545d7ed21156fa7342f39;hpb=98ed247d8b6d868cb25550d816a1c165373ffb0f;p=jalview.git diff --git a/src/jalview/datamodel/AlignedCodonFrame.java b/src/jalview/datamodel/AlignedCodonFrame.java index 473a534..bb705b6 100644 --- a/src/jalview/datamodel/AlignedCodonFrame.java +++ b/src/jalview/datamodel/AlignedCodonFrame.java @@ -60,14 +60,15 @@ public class AlignedCodonFrame } /** - * Returns a hashCode derived from the hashcodes of the mappings + * Returns a hashCode derived from the hashcodes of the mappings and fromSeq * * @see SequenceToSequenceMapping#hashCode() */ @Override public int hashCode() { - return mapping.hashCode(); + return (fromSeq == null ? 0 : fromSeq.hashCode() * 31) + + mapping.hashCode(); } /** @@ -88,7 +89,12 @@ public class AlignedCodonFrame { return that.mapping == null; } - return this.mapping.equals(that.mapping); + // TODO: can simplify by asserting fromSeq is a dataset sequence + return (this.fromSeq == that.fromSeq || (this.fromSeq != null + && that.fromSeq != null + && this.fromSeq.getDatasetSequence() != null && this.fromSeq + .getDatasetSequence() == that.fromSeq + .getDatasetSequence())) && this.mapping.equals(that.mapping); } public SequenceI getFromSeq() @@ -466,7 +472,8 @@ public class AlignedCodonFrame for (SequenceToSequenceMapping ssm : mappings) { - if (ssm.mapping.to == protein) + if (ssm.mapping.to == protein + && ssm.mapping.getMap().getFromRatio() == 3) { ml = ssm.mapping.map; dnaSeq = ssm.fromSeq; @@ -696,7 +703,7 @@ public class AlignedCodonFrame } /** - * Returns the first mapping found that is from 'fromSeq' to 'toSeq', or null + * Returns the first mapping found that is between 'fromSeq' and 'toSeq', or null * if none found * * @param fromSeq @@ -707,12 +714,17 @@ public class AlignedCodonFrame */ public Mapping getMappingBetween(SequenceI fromSeq, SequenceI toSeq) { + SequenceI dssFrom = fromSeq.getDatasetSequence() == null ? fromSeq + : fromSeq.getDatasetSequence(); + SequenceI dssTo = toSeq.getDatasetSequence() == null ? toSeq : toSeq + .getDatasetSequence(); + for (SequenceToSequenceMapping mapping : mappings) { SequenceI from = mapping.fromSeq; SequenceI to = mapping.mapping.to; - if ((from == fromSeq || from == fromSeq.getDatasetSequence()) - && (to == toSeq || to == toSeq.getDatasetSequence())) + if ((from == dssFrom && to == dssTo) + || (from == dssTo && to == dssFrom)) { return mapping.mapping; }