001/* 002 * BioJava development code 003 * 004 * This code may be freely distributed and modified under the 005 * terms of the GNU Lesser General Public Licence. This should 006 * be distributed with the code. If you do not have a copy, 007 * see: 008 * 009 * http://www.gnu.org/copyleft/lesser.html 010 * 011 * Copyright for this code is held jointly by the individual 012 * authors. These should be listed in @author doc comments. 013 * 014 * For more information on the BioJava project and its aims, 015 * or to join the biojava-l mailing list, visit the home page 016 * at: 017 * 018 * http://www.biojava.org/ 019 * 020 */ 021 022 023package org.biojava.bio.alignment; 024 025import org.biojava.bio.symbol.Edit; 026import org.biojava.bio.symbol.Location; 027import org.biojava.utils.ChangeType; 028import org.biojava.utils.ChangeVetoException; 029 030/** 031 * <p>EditableAlignment is an interface that defines methods for 032 * shifting bases within an Alignment.</p> 033 * 034 * <p>Shift should work as follows. Bases within a sequence can be 035 * shifted to the right with offset > 1 to the left with offset < 036 * 1. Shifting bases will be allowed if:</p> 037 * 038 * <li>1: Shift would remove only gaps on one side, they will be 039 * replace with gaps on the other. 040 * 041 * <li>2: Shift is at the end of a sequence. It will add gaps if the 042 * range location is less than the whole sequence. 043 * 044 * <li>Shifts that would delete bases will throw a 045 * IllegalEditException 046 * 047 * <p>If the Alignment is an UnequalLengthAlignment it should be 048 * acceptable to shift bases in such a way as to increase (or 049 * decrease) the size of the overall length of the alignment, 050 * i.e. shift them over the edge.</p> 051 * 052 * @author David Waring 053 */ 054public interface EditableAlignment{ 055 056 /** 057 * <P> edit() allows edits on an individual sequence, they should be reflected back 058 * to the underlying SymbolList. 059 */ 060 061 public void edit (Object label,Edit edit)throws ChangeVetoException; 062 063 064 /** 065 * loc in this case is the Alignment Location 066 */ 067 public void shiftAtAlignmentLoc(Object label, Location loc, int offset) throws ChangeVetoException,IllegalAlignmentEditException,IndexOutOfBoundsException; 068 069 070 /** 071 * loc in this case is the SymbolList Location 072 */ 073 public void shiftAtSequenceLoc(Object label, Location loc, int offset) throws ChangeVetoException,IllegalAlignmentEditException,IndexOutOfBoundsException; 074 075 public static final ChangeType LOCATION = new ChangeType( 076 "The location of a sequence is being changed", 077 "org.biojava.bio.alignment.EditableAlignment", 078 "LOCATION" 079 ); 080 081 public static final ChangeType GAPS = new ChangeType( 082 "The gap within a sequence are changing", 083 "org.biojava.bio.alignment.EditableAlignment", 084 "GAPS" 085 ); 086 087 088}