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.impl;
023
024import org.biojava.bio.molbio.RestrictionEnzyme;
025import org.biojava.bio.molbio.RestrictionSite;
026import org.biojava.bio.seq.FeatureHolder;
027import org.biojava.bio.seq.Sequence;
028
029/**
030 * <code>SimpleRestrictionSite</code> represents the recognition site
031 * of a restriction enzyme.
032 *
033 * @author Keith James
034 * @since 1.3
035 */
036public class SimpleRestrictionSite extends SimpleStrandedFeature
037    implements RestrictionSite
038{
039    private RestrictionEnzyme enzyme;
040    private int position;
041
042    /**
043     * Creates a new <code>SimpleRestrictionSite</code>.
044     *
045     * @param sourceSeq a <code>Sequence</code>.
046     * @param parent a <code>FeatureHolder</code>.
047     * @param template a <code>RestrictionSite.Template</code>.
048     */
049    public SimpleRestrictionSite(Sequence                 sourceSeq,
050                                 FeatureHolder            parent,
051                                 RestrictionSite.Template template)
052    {
053        super(sourceSeq, parent, template);
054
055        this.enzyme = template.enzyme;
056
057        position = template.location.getMin() +
058            template.enzyme.getDownstreamCut()[0];
059    }
060
061    public int getPosition()
062    {
063        return position;
064    }
065
066    public RestrictionEnzyme getEnzyme()
067    {
068        return enzyme;
069    }
070
071    public String toString()
072    {
073        return super.toString() + " " + enzyme;
074    }
075}