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 022package org.biojava.bio.seq.db; 023 024import org.biojava.bio.BioException; 025import org.biojava.bio.seq.Sequence; 026import org.biojava.utils.ChangeType; 027import org.biojava.utils.ChangeVetoException; 028import org.biojava.utils.Changeable; 029 030/** 031 * A database of sequences. This may have several implementations with 032 * rich behaviour, but basically most of the time you will just use 033 * the interface methods to do stuff. A sequence database contains a 034 * finite number of sequences stored under unique keys. 035 * 036 * @author Matthew Pocock 037 * @author <A href="mailto:Gerald.Loeffler@vienna.at">Gerald Loeffler</A> 038 * @author Thomas Down 039 */ 040public interface SequenceDBLite extends Changeable { 041 /** 042 * Signals that sequences are being added to or remove from the database. 043 * The sequences being removed should be listed in the previous field by 044 * id, either as a single String, an array or a Set. The sequences 045 * being added should be listed in the change field as either an array 046 * Object[] { id, seq}, or a Map of id->seq. 047 */ 048 public static final ChangeType SEQUENCES = new ChangeType( 049 "Sequences have been added or removed from the database", 050 "org.biojava.bio.seq.db.SequenceDB", 051 "SEQUENCES" 052 ); 053 054 /** 055 * Get the name of this sequence database. 056 * 057 * @return the name of the sequence database, which may be null. 058 */ 059 String getName(); 060 061 /** 062 * Retrieve a single sequence by its id. 063 * 064 * @param id the id to retrieve by 065 * @return the Sequence with that id 066 * @throws IllegalIDException if the database doesn't know about the id 067 * @throws BioException if there was a failure in retrieving the sequence 068 */ 069 Sequence getSequence(String id) throws IllegalIDException, BioException; 070 071 /** 072 * Adds a sequence to the database. 073 * 074 * @param seq the Sequence to add 075 * @throws IllegalIDException if a uniqe ID could not be generated for seq 076 * @throws BioException if something goes wrong with adding the sequence 077 * @throws ChangeVetoException if either the database does not allow 078 * sequences to be added or the modification was vetoed 079 */ 080 void addSequence(Sequence seq) 081 throws IllegalIDException, BioException, ChangeVetoException; 082 083 /** 084 * Remove the sequence associated with an ID from the database. 085 * 086 * @param id the ID of the sequence to remove 087 * @throws IllegalIDException if there is no sequence for the ID 088 * @throws BioException if something failed while removing the sequence for 089 * that ID 090 * @throws ChangeVetoException if either the database does not allow 091 * sequences to be removed or the modification was vetoed 092 */ 093 void removeSequence(String id) 094 throws IllegalIDException, BioException, ChangeVetoException; 095}