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 * Created on 05.03.2004
021 * @author Andreas Prlic
022 *
023 */
024package org.biojava.nbio.structure;
025
026/**
027 * A nucleotide group is almost the same as a Hetatm group.
028 * @see HetatomImpl
029 * @see AminoAcidImpl
030 * @author Andreas Prlic
031 * @since 1.4
032 * @version %I% %G%
033 */
034public class NucleotideImpl extends HetatomImpl {
035
036        private static final long serialVersionUID = -7467726932980288712L;
037        /** this is a "nucleotide", a special occurance of a Hetatom. */
038        public static final GroupType type = GroupType.NUCLEOTIDE;
039
040        /*
041         * inherits most from Hetero and has just a few extensions.
042         */
043        public NucleotideImpl() {
044                super();
045
046        }
047
048        @Override
049        public GroupType getType(){ return type;}
050
051
052        @Override
053        public String toString(){
054
055                String str = "PDB: "+ pdb_name + " " + residueNumber +  " "+ pdb_flag;
056                if (pdb_flag) {
057                        str = str + "atoms: "+atoms.size();
058                }
059                return str ;
060
061        }
062
063        /**
064         * Returns the O3' atom if present, otherwise null
065         * @return O3' atom or null
066         */
067        public Atom getO3Prime() {
068
069                return getAtom("O3'");
070
071        }
072
073        /**
074         * Returns the O5' atom if present, otherwise null
075         * @return O5' atom or null
076         */
077        public Atom getO5Prime() {
078
079                return getAtom("O5'");
080
081        }
082
083        /**
084         * Returns the P atom if present, otherwise null
085         * @return P atom or null
086         */
087        public Atom getP() {
088
089                return getAtom("P");
090
091        }
092
093        // note we need to implement a clone here, despite there's one in super class already,
094        // that's due to issue https://github.com/biojava/biojava/issues/631 - JD 2017-01-21
095        @Override
096        public Object clone() {
097
098                NucleotideImpl n = new NucleotideImpl();
099                n.setPDBFlag(has3D());
100                n.setResidueNumber(getResidueNumber());
101
102                n.setPDBName(getPDBName());
103
104                //clone atoms and bonds.
105                cloneAtomsAndBonds(n);
106
107                // copying the alt loc groups if present, otherwise they stay null
108                if (getAltLocs()!=null && !getAltLocs().isEmpty()) {
109                        for (Group altLocGroup:this.getAltLocs()) {
110                                Group nAltLocGroup = (Group)altLocGroup.clone();
111                                n.addAltLoc(nAltLocGroup);
112                        }
113                }
114
115                if (chemComp!=null)
116                        n.setChemComp(chemComp);
117
118
119                return n;
120        }
121}