X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fstructure%2FStructureMapping.java;h=c8e04a823135f00b32e7404ee4be664460210dcf;hb=c19d2a91ca05e052e3408bf5852d88eb5d0608f1;hp=c66b740cbda75588beb09bf558319f7a4fb141c8;hpb=865a855a4ca87eadb3e5ff284ed32ed307d9c34b;p=jalview.git diff --git a/src/jalview/structure/StructureMapping.java b/src/jalview/structure/StructureMapping.java index c66b740..c8e04a8 100644 --- a/src/jalview/structure/StructureMapping.java +++ b/src/jalview/structure/StructureMapping.java @@ -1,24 +1,27 @@ /* - * Jalview - A Sequence Alignment Editor and Viewer (Version 2.8.0b1) - * Copyright (C) 2014 The Jalview Authors + * Jalview - A Sequence Alignment Editor and Viewer (Version 2.9.0b2) + * Copyright (C) 2015 The Jalview Authors * * This file is part of Jalview. * * Jalview is free software: you can redistribute it and/or * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * as published by the Free Software Foundation, either version 3 + * of the License, or (at your option) any later version. * * Jalview is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty * of MERCHANTABILITY or FITNESS FOR A PARTICULAR * 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 . + * 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.structure; -import jalview.datamodel.*; +import jalview.datamodel.AlignmentAnnotation; +import jalview.datamodel.SequenceI; public class StructureMapping { @@ -61,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) @@ -73,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) @@ -85,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++) @@ -96,4 +114,37 @@ public class StructureMapping } return -1; } + + /** + * transfer a copy of an alignment annotation row in the PDB chain coordinate + * system onto the mapped sequence + * + * @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); + 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; + } }