X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fanalysis%2FAlignSeq.java;h=3eae385a0473f4e266d627a85539abfd55f6fb0e;hb=a8f483d04205bb8273ee311c12968b7e86d205fa;hp=3ede7a8c521fda407ecd9d73940d690aea5fe052;hpb=87b5fe5acb60c8474e6a3c5dc5eaf48f23f8c2ec;p=jalview.git diff --git a/src/jalview/analysis/AlignSeq.java b/src/jalview/analysis/AlignSeq.java index 3ede7a8..3eae385 100755 --- a/src/jalview/analysis/AlignSeq.java +++ b/src/jalview/analysis/AlignSeq.java @@ -1,6 +1,6 @@ /* - * Jalview - A Sequence Alignment Editor and Viewer (Version 2.8) - * Copyright (C) 2012 J Procter, AM Waterhouse, LM Lui, J Engelhardt, G Barton, M Clamp, S Searle + * Jalview - A Sequence Alignment Editor and Viewer (Version 2.8.2) + * Copyright (C) 2014 The Jalview Authors * * This file is part of Jalview. * @@ -14,6 +14,7 @@ * PURPOSE. See the GNU General Public License for more details. * * You should have received a copy of the GNU General Public License along with Jalview. If not, see . + * The Jalview Authors are detailed in the 'AUTHORS' file. */ package jalview.analysis; import java.util.*; @@ -940,7 +941,76 @@ public class AlignSeq return as; } + /** + * + * @return mapping from positions in S1 to corresponding positions in S2 + */ + public jalview.datamodel.Mapping getMappingFromS1(boolean allowmismatch) + { + ArrayList as1 = new ArrayList(), as2 = new ArrayList(); + int pdbpos = s2.getStart() + getSeq2Start() - 2; + int alignpos = s1.getStart() + getSeq1Start() - 2; + int lp2 = pdbpos - 3, lp1 = alignpos - 3; + boolean lastmatch = false; + // and now trace the alignment onto the atom set. + for (int i = 0; i < astr1.length(); i++) + { + char c1 = astr1.charAt(i), c2 = astr2.charAt(i); + if (c1 != '-') + { + alignpos++; + } + if (c2 != '-') + { + pdbpos++; + } + + if (allowmismatch || c1 == c2) + { + lastmatch = true; + // extend mapping interval. + if (lp1 + 1 != alignpos || lp2+1 !=pdbpos) + { + as1.add(Integer.valueOf(alignpos)); + as2.add(Integer.valueOf(pdbpos)); + } + lp1 = alignpos; + lp2 = pdbpos; + } + else + { + lastmatch = false; + } + } + // construct range pairs + int[] mapseq1 = new int[as1.size() + (lastmatch ? 1 : 0)], mapseq2 = new int[as2 + .size() + (lastmatch ? 1 : 0)]; + int i = 0; + for (Integer ip : as1) + { + mapseq1[i++] = ip; + } + ; + i = 0; + for (Integer ip : as2) + { + mapseq2[i++] = ip; + } + ; + if (lastmatch) + { + mapseq1[mapseq1.length - 1] = alignpos; + mapseq2[mapseq2.length - 1] = pdbpos; + } + MapList map = new MapList(mapseq1, mapseq2, 1, 1); + + jalview.datamodel.Mapping mapping = new Mapping(map); + mapping.setTo(s2); + return mapping; + } + + /** * compute the PID vector used by the redundancy filter. * * @param originalSequences