Logo Search packages:      
Sourcecode: cdk version File versions

AminoAcid.java

/* $Revision: 7636 $ $Author: egonw $ $Date: 2007-01-04 18:46:10 +0100 (Thu, 04 Jan 2007) $
 *
 * Copyright (C) 2005-2007  Egon Willighagen <e.willighagen@science.ru.nl>
 * 
 * Contact: cdk-devel@lists.sourceforge.net
 * 
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public License
 * as published by the Free Software Foundation; either version 2.1
 * of the License, or (at your option) any later version.
 * All we ask is that proper credit is given for our work, which includes
 * - but is not limited to - adding the above copyright notice to the beginning
 * of your source code files, and to any copyright notice that you may distribute
 * with programs based on this work.
 * 
 * This program 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 Lesser General Public License for more details.
 * 
 * You should have received a copy of the GNU Lesser General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
 */
package org.openscience.cdk;

import java.io.Serializable;

import org.openscience.cdk.interfaces.IAminoAcid;
import org.openscience.cdk.interfaces.IAtom;

/**
 * A AminoAcid is Monomer which stores additional amino acid specific 
 * informations, like the N-terminus atom.
 *
 * @cdk.module data
 *
 * @author      Egon Willighagen <e.willighagen@science.ru.nl>
 * @cdk.created 2005-08-11
 * @cdk.keyword amino acid
 */
00042 public class AminoAcid extends Monomer implements IAminoAcid, Serializable, Cloneable {

    /**
     * Determines if a de-serialized object is compatible with this class.
     *
     * This value must only be changed if and only if the new version
     * of this class is imcompatible with the old version. See Sun docs
     * for <a href=http://java.sun.com/products/jdk/1.1/docs/guide
     * /serialization/spec/version.doc.html>details</a>.
       */
00052       private static final long serialVersionUID = -5032283549467862509L;
      
      /** The atom that constitutes the N-terminus. */
00055     private IAtom nTerminus;
    /** The atom that constitutes the C-terminus. */
00057     private IAtom cTerminus;

    /**
     * Contructs a new AminoAcid.
     */
00062     public AminoAcid() {
        super();
    }
    
    /**
     * Retrieves the N-terminus atom.
     *
     * @return The Atom that is the N-terminus
     *
     * @see    #addNTerminus(IAtom)
     */
00073     public IAtom getNTerminus() {
        return nTerminus;
    }

    /**
     * Add an Atom and makes it the N-terminus atom.
     *
     * @param atom  The Atom that is the N-terminus
     *
     * @see    #getNTerminus
     */
00084     public void addNTerminus(IAtom atom) {
        super.addAtom(atom);
        nTerminus = atom;
    }
    
    /**
     * Marks an Atom as being the N-terminus atom. It assumes that the Atom
     * is already added to the AminoAcid.
     *
     * @param atom  The Atom that is the N-terminus
     *
     * @see    #addNTerminus
     */
00097     private void setNTerminus(IAtom atom) {
        nTerminus = atom;
    }

    /**
     * Retrieves the C-terminus atom.
     *
     * @return The Atom that is the C-terminus
     *
     * @see    #addCTerminus(IAtom)
     */
00108     public IAtom getCTerminus() {
        return cTerminus;
    }

    /**
     * Add an Atom and makes it the C-terminus atom.
     *
     * @param atom  The Atom that is the C-terminus
     *
     * @see    #getCTerminus
     */
00119     public void addCTerminus(IAtom atom) {
        super.addAtom(atom);
        setCTerminus(atom);
    }

    /**
     * Marks an Atom as being the C-terminus atom. It assumes that the Atom
     * is already added to the AminoAcid.
     *
     * @param atom  The Atom that is the C-terminus
     *
     * @see    #addCTerminus
     */
00132     private void setCTerminus(IAtom atom) {
        cTerminus = atom;
    }

    /**
     * Clones this AminoAcid object.
     *
     * @return    The cloned object
     */
00141     public Object clone() throws CloneNotSupportedException {
        AminoAcid clone = (AminoAcid) super.clone();
        // copying the new N-terminus and C-terminus pointers
        if (getNTerminus() != null)
            clone.setNTerminus(clone.getAtom(getAtomNumber(getNTerminus())));
        if (getCTerminus() != null)
            clone.setCTerminus(clone.getAtom(getAtomNumber(getCTerminus())));
        return clone;
    }
    
00151     public String toString() {
        StringBuffer stringContent = new StringBuffer(32);
        stringContent.append("AminoAcid(");
        stringContent.append(this.hashCode()).append(", ");
        if (nTerminus == null) {
            stringContent.append("N: null, ");
        } else {
            stringContent.append("N: ").append(nTerminus.hashCode()).append(", ");
        }
        if (cTerminus == null) {
            stringContent.append("C: null, ");
        } else {
            stringContent.append("C: ").append(cTerminus.hashCode()).append(", ");
        }
        stringContent.append(super.toString());
        stringContent.append(')');
        return stringContent.toString();
    }

}

Generated by  Doxygen 1.6.0   Back to index