From: Jim Procter Date: Wed, 16 Sep 2020 16:39:22 +0000 (+0100) Subject: JAL-3748 pass a list to findAlignedSequence to return mapping that relates CDS and... X-Git-Tag: Release_2_11_1_3~5^2~30 X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=ce93212014c116c4c516c6dc85c5032449d311eb;p=jalview.git JAL-3748 pass a list to findAlignedSequence to return mapping that relates CDS and the returned Peptide sequence to avoid searching twice --- diff --git a/src/jalview/analysis/AlignmentUtils.java b/src/jalview/analysis/AlignmentUtils.java index 2b88cb0..cd142ca 100644 --- a/src/jalview/analysis/AlignmentUtils.java +++ b/src/jalview/analysis/AlignmentUtils.java @@ -960,11 +960,12 @@ public class AlignmentUtils .findMappingsForSequence(cdsSeq, mappings); for (AlignedCodonFrame mapping : dnaMappings) { - SequenceI peptide = mapping.findAlignedSequence(cdsSeq, protein); + List foundMap=new ArrayList<>(); + SequenceI peptide = mapping.findAlignedSequence(cdsSeq, protein,foundMap); if (peptide != null) { final int peptideLength = peptide.getLength(); - Mapping map = mapping.getMappingBetween(cdsSeq, peptide); + Mapping map = foundMap.get(0).getMapping(); if (map != null) { MapList mapList = map.getMap(); diff --git a/src/jalview/datamodel/AlignedCodonFrame.java b/src/jalview/datamodel/AlignedCodonFrame.java index fbc8a61..d1b12d3 100644 --- a/src/jalview/datamodel/AlignedCodonFrame.java +++ b/src/jalview/datamodel/AlignedCodonFrame.java @@ -455,6 +455,20 @@ public class AlignedCodonFrame */ public SequenceI findAlignedSequence(SequenceI seq, AlignmentI al) { + return findAlignedSequence(seq, al, null); + } + /** + * Convenience method to return the first aligned sequence in the given + * alignment whose dataset has a mapping with the given (aligned or dataset) + * sequence, and optionally the mapping that relates them + * + * @param seq + * @param al + * @param map - list to add the mapping to + * @return sequence from al that maps to seq + */ + public SequenceI findAlignedSequence(SequenceI seq, AlignmentI al,List map) + { /* * Search mapped protein ('to') sequences first. */ @@ -466,6 +480,10 @@ public class AlignedCodonFrame { if (ssm.covers(sourceAligned,true)) { + if (map != null) + { + map.add(ssm); + } return sourceAligned; } } @@ -484,6 +502,10 @@ public class AlignedCodonFrame { if (ssm.covers(sourceAligned,true)) { + if (map != null) + { + map.add(ssm); + } return sourceAligned; } }