From: gmungoc Date: Fri, 1 Jul 2016 15:54:01 +0000 (+0100) Subject: JAL-2110 bug fixing and tidying for get cross-refs X-Git-Tag: Release_2_10_0~140^2~5^2~27 X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=1488d223bc6be5b47695a8153205cc9ff8c8095d;p=jalview.git JAL-2110 bug fixing and tidying for get cross-refs --- diff --git a/src/jalview/analysis/AlignmentUtils.java b/src/jalview/analysis/AlignmentUtils.java index f94d393..9150d62 100644 --- a/src/jalview/analysis/AlignmentUtils.java +++ b/src/jalview/analysis/AlignmentUtils.java @@ -2347,13 +2347,13 @@ public class AlignmentUtils { /* * Map will hold, for each aligned column position, a map of - * {unalignedSequence, sequenceCharacter} at that position. + * {unalignedSequence, characterPerSequence} at that position. * TreeMap keeps the entries in ascending column order. */ Map> map = new TreeMap>(); /* - * r any sequences that have no mapping so can't be realigned + * record any sequences that have no mapping so can't be realigned */ unmapped.addAll(unaligned.getSequences()); @@ -2402,6 +2402,15 @@ public class AlignmentUtils return false; } + /* + * invert mapping if it is from unaligned to aligned sequence + */ + if (seqMap.getTo() == fromSeq.getDatasetSequence()) + { + seqMap = new Mapping(seq.getDatasetSequence(), seqMap.getMap() + .getInverse()); + } + char[] fromChars = fromSeq.getSequence(); int toStart = seq.getStart(); char[] toChars = seq.getSequence(); @@ -2435,7 +2444,8 @@ public class AlignmentUtils * of the next character of the mapped-to sequence; stop when all * the characters of the range have been counted */ - while (mappedCharPos <= range[1]) + while (mappedCharPos <= range[1] && fromCol <= fromChars.length + && fromCol >= 0) { if (!Comparison.isGap(fromChars[fromCol - 1])) { diff --git a/src/jalview/analysis/CrossRef.java b/src/jalview/analysis/CrossRef.java index 0011e39..e73912d 100644 --- a/src/jalview/analysis/CrossRef.java +++ b/src/jalview/analysis/CrossRef.java @@ -357,7 +357,8 @@ public class CrossRef { ASequenceFetcher sftch = SequenceFetcherFactory.getSequenceFetcher(); SequenceI[] retrieved = null; - SequenceI dss = null; + SequenceI dss = seq.getDatasetSequence() == null ? seq : seq + .getDatasetSequence(); try { retrieved = sftch.getSequences(sourceRefs, !fromDna); diff --git a/src/jalview/datamodel/AlignedCodonFrame.java b/src/jalview/datamodel/AlignedCodonFrame.java index a4b99bf..18aaecf 100644 --- a/src/jalview/datamodel/AlignedCodonFrame.java +++ b/src/jalview/datamodel/AlignedCodonFrame.java @@ -702,7 +702,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 @@ -713,12 +713,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; } diff --git a/src/jalview/gui/AlignFrame.java b/src/jalview/gui/AlignFrame.java index 64bdf44..b310ab9 100644 --- a/src/jalview/gui/AlignFrame.java +++ b/src/jalview/gui/AlignFrame.java @@ -4763,7 +4763,6 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, AlignmentI copyAlignment = null; final SequenceI[] sequenceSelection = AlignFrame.this.viewport .getSequenceSelection(); - // List cf = xrefs.getCodonFrames(); boolean copyAlignmentIsAligned = false; if (dna) { diff --git a/src/jalview/util/DBRefUtils.java b/src/jalview/util/DBRefUtils.java index ed6d860..d5d0cf5 100755 --- a/src/jalview/util/DBRefUtils.java +++ b/src/jalview/util/DBRefUtils.java @@ -546,7 +546,7 @@ public class DBRefUtils /** * Returns the (possibly empty) list of those supplied dbrefs which have the - * specified source databse + * specified source database, with a case-insensitive match of source name * * @param dbRefs * @param source @@ -560,7 +560,7 @@ public class DBRefUtils { for (DBRefEntry dbref : dbRefs) { - if (source.equals(dbref.getSource())) + if (source.equalsIgnoreCase(dbref.getSource())) { matches.add(dbref); } diff --git a/src/jalview/ws/jws2/MsaWSThread.java b/src/jalview/ws/jws2/MsaWSThread.java index bfae384..e425624 100644 --- a/src/jalview/ws/jws2/MsaWSThread.java +++ b/src/jalview/ws/jws2/MsaWSThread.java @@ -1032,6 +1032,10 @@ class MsaWSThread extends AWS2Thread implements WSClientI // becomes null if the alignment window was closed before the alignment // job finished. AlignmentI copyComplement = new Alignment(complement); + // todo should this be done by copy constructor? + copyComplement.setGapCharacter(complement.getGapCharacter()); + // share the same dataset (and the mappings it holds) + copyComplement.setDataset(complement.getDataset()); copyComplement.alignAs(al); if (copyComplement.getHeight() > 0) {