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 java.util.Set; 025 026import org.biojava.bio.BioException; 027import org.biojava.bio.seq.Sequence; 028import org.biojava.bio.seq.impl.ViewSequence; 029 030/** 031 * SequenceDB implementation that returns new SequenceView instances 032 * wrapping the sequences in an underlying database. One appropriate 033 * use of this would be to wrap a DB in one of these and then wrap 034 * this in an annotating db so that the annotation is added to views, 035 * not the underlying sequences. 036 * 037 * @author Matthew Pocock 038 * @since 1.2 039 */ 040 041public class ViewingSequenceDB extends SequenceDBWrapper { 042 /** 043 * Create a new ViewingSequenceDB that views the sequences in parent. 044 * 045 * @param parent the SequenceDB to view 046 */ 047 public ViewingSequenceDB(SequenceDB parent) { 048 super(parent); 049 } 050 051 public String getName() { 052 return getParent().getName(); 053 } 054 055 public Sequence getSequence(String id) throws BioException { 056 Sequence seq = getParent().getSequence(id); 057 return new ViewSequence(seq); 058 } 059 060 public Set ids() { 061 return getParent().ids(); 062 } 063}