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 026import java.io.Serializable; 027 028/** 029 * AminoAcid inherits most from Hetatom. Adds a few AminoAcid 030 * specific methods. 031 * @author Andreas Prlic 032 * @author Jules Jacobsen 033 * @since 1.4 034 * @version %I% %G% 035 * 036 */ 037public class AminoAcidImpl extends HetatomImpl implements AminoAcid, Serializable { 038 039 private static final long serialVersionUID = -6018854413829044230L; 040 041 /** this is an Amino acid. type is "amino". */ 042 public static final GroupType type = GroupType.AMINOACID; 043 044 /** IUPAC amino acid residue names 045 */ 046 private Character amino_char ; 047 048 private String recordType; // allows to distinguish between AAs that have been created from SEQRES records and ATOM records 049 050 /** 051 * inherits most from Hetero and has just a few extensions. 052 */ 053 public AminoAcidImpl() { 054 super(); 055 056 amino_char = null; 057 recordType = ATOMRECORD; 058 } 059 060 @Override 061 public GroupType getType(){ return type;} 062 063 /** 064 * {@inheritDoc} 065 */ 066 @Override 067 public Atom getN() {return getAtom("N"); } 068 069 /** 070 * {@inheritDoc} 071 */ 072 @Override 073 public Atom getCA() { 074 // note CA can also be Calcium, but that can't happen in a standard aminoacid, so this should be safe 075 return getAtom("CA"); 076 } 077 078 /** 079 * {@inheritDoc} 080 */ 081 @Override 082 public Atom getC() {return getAtom("C"); } 083 084 /** 085 * {@inheritDoc} 086 */ 087 @Override 088 public Atom getO() {return getAtom("O"); } 089 090 /** 091 * {@inheritDoc} 092 */ 093 @Override 094 public Atom getCB() {return getAtom("CB"); } 095 096 097 /** 098 * {@inheritDoc} 099 */ 100 @Override 101 public Character getAminoType() { 102 return amino_char; 103 } 104 105 /** 106 * {@inheritDoc} 107 */ 108 @Override 109 public void setAminoType(Character aa){ 110 amino_char = aa ; 111 } 112 113 /** 114 * {@inheritDoc} 115 */ 116 @Override 117 public void setRecordType(String recordName) { 118 recordType = recordName; 119 } 120 121 /** 122 * {@inheritDoc} 123 */ 124 @Override 125 public String getRecordType() { 126 return recordType; 127 } 128 129 /** string representation. */ 130 @Override 131 public String toString(){ 132 133 String str = "AminoAcid "+ recordType + ":"+ pdb_name + " " + amino_char + 134 " " + residueNumber + " "+ pdb_flag + " " + recordType ; 135 if (pdb_flag) { 136 str = str + " atoms: "+atoms.size(); 137 } 138 if (!getAltLocs().isEmpty()) 139 str += " has altLocs :" + getAltLocs().size(); 140 141 return str ; 142 143 } 144 /** set three character name of AminoAcid. 145 * 146 * @param s a String specifying the PDBName value 147 * @see #getPDBName() 148 */ 149 @Override 150 public void setPDBName(String s) { 151 152 pdb_name =s ; 153 154 } 155 156 157 /** returns and identical copy of this Group object . 158 * @return and identical copy of this Group object 159 */ 160 @Override 161 public Object clone() { 162 163 AminoAcidImpl n = new AminoAcidImpl(); 164 n.setPDBFlag(has3D()); 165 n.setResidueNumber(getResidueNumber()); 166 167 n.setPDBName(getPDBName()); 168 169 n.setAminoType(getAminoType()); 170 n.setRecordType(recordType); 171 172 // copy the atoms 173 for (Atom atom1 : atoms) { 174 Atom atom = (Atom) atom1.clone(); 175 n.addAtom(atom); 176 atom.setGroup(n); 177 } 178 179 // copying the alt loc groups if present, otherwise they stay null 180 if (getAltLocs()!=null && !getAltLocs().isEmpty()) { 181 for (Group altLocGroup:this.getAltLocs()) { 182 Group nAltLocGroup = (Group)altLocGroup.clone(); 183 n.addAltLoc(nAltLocGroup); 184 } 185 } 186 187 if (chemComp!=null) 188 n.setChemComp(chemComp); 189 190 191 return n; 192 } 193 194 195}