X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fstructure%2FStructureMapping.java;h=a62f1aea7413e5d7ad770d01b8aa207869ea95cf;hb=4bba61a3c701f83bdcb6707c4d9f17a1f5faaa04;hp=923633152e0821d559fcfe1c27ddcff78bda1334;hpb=e0172c233914b64dc561b0a3b0d9aad850e99efc;p=jalview.git diff --git a/src/jalview/structure/StructureMapping.java b/src/jalview/structure/StructureMapping.java index 9236331..a62f1ae 100644 --- a/src/jalview/structure/StructureMapping.java +++ b/src/jalview/structure/StructureMapping.java @@ -1,6 +1,6 @@ /* - * Jalview - A Sequence Alignment Editor and Viewer (Version 2.8.2) - * Copyright (C) 2014 The Jalview Authors + * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$) + * Copyright (C) $$Year-Rel$$ The Jalview Authors * * This file is part of Jalview. * @@ -64,6 +64,11 @@ public class StructureMapping return pdbid; } + /** + * + * @param seqpos + * @return 0 or corresponding atom number for the sequence position + */ public int getAtomNum(int seqpos) { if (mapping.length > seqpos) @@ -76,6 +81,11 @@ public class StructureMapping } } + /** + * + * @param seqpos + * @return 0 or the corresponding residue number for the sequence position + */ public int getPDBResNum(int seqpos) { if (mapping.length > seqpos) @@ -88,6 +98,11 @@ public class StructureMapping } } + /** + * + * @param pdbResNum + * @return -1 or the corresponding sequence position for a pdb residue number + */ public int getSeqPos(int pdbResNum) { for (int i = 0; i < mapping.length; i++) @@ -106,11 +121,30 @@ public class StructureMapping * * @param ana * @return the copy that was remapped to the mapped sequence + * @note this method will create a copy and add it to the dataset sequence for + * the mapped sequence as well as the mapped sequence (if it is not a + * dataset sequence). */ public AlignmentAnnotation transfer(AlignmentAnnotation ana) { AlignmentAnnotation ala_copy = new AlignmentAnnotation(ana); - ala_copy.remap(sequence, mapping, 0, -1, 1); + SequenceI ds = sequence; + while (ds.getDatasetSequence() != null) + { + ds = ds.getDatasetSequence(); + } + // need to relocate annotation from pdb coordinates to local sequence + // -1,-1 doesn't look at pdbresnum but fails to remap sequence positions... + + ala_copy.remap(ds, mapping, -1, -1, 0); + ds.addAlignmentAnnotation(ala_copy); + if (ds != sequence) + { + // mapping wasn't to an original dataset sequence, so we make a copy on + // the mapped sequence too + ala_copy = new AlignmentAnnotation(ala_copy); + sequence.addAlignmentAnnotation(ala_copy); + } return ala_copy; } }