From: gmungoc Date: Wed, 5 Aug 2020 08:13:33 +0000 (+0100) Subject: JAL-3700 fix for propagation of sort commands X-Git-Tag: Release_2_11_1_3~5^2~34 X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=43e966997685777da741087d56c2067a46757806;p=jalview.git JAL-3700 fix for propagation of sort commands --- diff --git a/src/jalview/datamodel/AlignedCodonFrame.java b/src/jalview/datamodel/AlignedCodonFrame.java index 7fa8b29..6103df5 100644 --- a/src/jalview/datamodel/AlignedCodonFrame.java +++ b/src/jalview/datamodel/AlignedCodonFrame.java @@ -311,8 +311,8 @@ public class AlignedCodonFrame /** * Return the corresponding aligned or dataset dna sequence for given amino - * acid sequence, or null if not found. returns the sequence from - * the first mapping found that involves the protein sequence. + * acid sequence, or null if not found. returns the sequence from the first + * mapping found that involves the protein sequence. * * @param aaSeqRef * @return @@ -819,7 +819,7 @@ public class AlignedCodonFrame * Two AlignedCodonFrame objects are equal if they hold the same ordered list * of mappings * - * @see SequenceToSequenceMapping# + * @see SequenceToSequenceMapping#equals */ @Override public boolean equals(Object obj) @@ -836,12 +836,20 @@ public class AlignedCodonFrame return mappings; } - public SequenceToSequenceMapping getCoveringMapping(SequenceI cds, - SequenceI peptide) + /** + * Returns the first mapping found which is between the two given sequences, + * and covers the full extent of both. + * + * @param seq1 + * @param seq2 + * @return + */ + public SequenceToSequenceMapping getCoveringMapping(SequenceI seq1, + SequenceI seq2) { for (SequenceToSequenceMapping mapping : mappings) { - if (mapping.covers(peptide) && mapping.covers(cds)) + if (mapping.covers(seq2) && mapping.covers(seq1)) { return mapping; } diff --git a/src/jalview/util/MappingUtils.java b/src/jalview/util/MappingUtils.java index cf90bf9..499fc6b 100644 --- a/src/jalview/util/MappingUtils.java +++ b/src/jalview/util/MappingUtils.java @@ -22,6 +22,7 @@ package jalview.util; import jalview.analysis.AlignmentSorter; import jalview.api.AlignViewportI; +import jalview.bin.Cache; import jalview.commands.CommandI; import jalview.commands.EditCommand; import jalview.commands.EditCommand.Action; @@ -79,7 +80,7 @@ public final class MappingUtils action = action.getUndoAction(); } // TODO write this - System.err.println("MappingUtils.mapCutOrPaste not yet implemented"); + Cache.log.error("MappingUtils.mapCutOrPaste not yet implemented"); } /** @@ -443,20 +444,23 @@ public final class MappingUtils { for (AlignedCodonFrame acf : mappings) { - SequenceI mappedSeq = mappingToNucleotide ? acf.getDnaForAaSeq(seq) - : acf.getAaForDnaSeq(seq); - if (mappedSeq != null) - { for (SequenceI seq2 : mapTo.getSequences()) { - if (seq2.getDatasetSequence() == mappedSeq) + /* + * the corresponding peptide / CDS is the one for which there is + * a complete ('covering') mapping to 'seq' + */ + SequenceI peptide = mappingToNucleotide ? seq2 : seq; + SequenceI cds = mappingToNucleotide ? seq : seq2; + SequenceToSequenceMapping s2s = acf.getCoveringMapping(cds, + peptide); + if (s2s != null) { mappedOrder.add(seq2); j++; break; } } - } } }