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 */ 021package org.biojava.nbio.structure.asa; 022 023import org.biojava.nbio.structure.*; 024 025import java.io.Serializable; 026import java.util.ArrayList; 027import java.util.HashMap; 028import java.util.List; 029 030/** 031 * A class to store the results of ASA calculations, it can 032 * hold ASA values per atom present in {@link org.biojava.nbio.structure.Group} 033 * 034 * @author duarte_j 035 * 036 */ 037public class GroupAsa implements Serializable { 038 039 040 private static final long serialVersionUID = 1L; 041 042 // ASA in extended tripeptide conformation (GLY-X-GLY) 043 private static final HashMap<Character,Double> tripeptAsa = initTriPeptAsas(); 044 045 private static HashMap<Character,Double> initTriPeptAsas() { 046 // ASA in extended tripeptide conformation (GLY-X-GLY) from Miller et al JMB 1987 (for calculation of relative ASAs) 047 HashMap<Character,Double> map = new HashMap<Character,Double>(); 048 map.put('A', 113.0); 049 map.put('R', 241.0); 050 map.put('N', 158.0); 051 map.put('D', 151.0); 052 map.put('C', 140.0); 053 map.put('Q', 189.0); 054 map.put('E', 183.0); 055 map.put('G', 85.0); 056 map.put('H', 194.0); 057 map.put('I', 182.0); 058 map.put('L', 180.0); 059 map.put('K', 211.0); 060 map.put('M', 204.0); 061 map.put('F', 218.0); 062 map.put('P', 143.0); 063 map.put('S', 122.0); 064 map.put('T', 146.0); 065 map.put('W', 259.0); 066 map.put('Y', 229.0); 067 map.put('V', 160.0); 068 return map; 069 } 070 071 072 073 074 private Group g; 075 076 /** 077 * ASA of uncomplexed residue 078 */ 079 private double asaU; 080 081 /** 082 * ASA of complexed residue 083 */ 084 private double asaC; 085 086 /** 087 * The individual atoms uncomplexed ASAs 088 */ 089 private List<Double> atomAsaUs; 090 091 /** 092 * The individual atoms complexed ASAs 093 */ 094 private List<Double> atomAsaCs; 095 096 public GroupAsa(Group g) { 097 this.g = g; 098 099 int groupNoHSize = getGroupNoHSize(); 100 atomAsaUs = new ArrayList<>(groupNoHSize); 101 atomAsaCs = new ArrayList<>(groupNoHSize); 102 } 103 104 private int getGroupNoHSize() { 105 int count = 0; 106 for (Atom atom:g.getAtoms()) { 107 if (atom.getElement()!=Element.H) count++; 108 } 109 return count; 110 } 111 112 public Group getGroup() { 113 return g; 114 } 115 116 /** 117 * Returns the ASA of the residue in the uncomplexed state 118 * @return 119 */ 120 public double getAsaU() { 121 return asaU; 122 } 123 124 public void setAsaU(double asaU) { 125 this.asaU = asaU; 126 } 127 128 /** 129 * Returns the ASA of the residue in the complexed state 130 * @return 131 */ 132 public double getAsaC() { 133 return asaC; 134 } 135 136 public void setAsaC(double asaC) { 137 this.asaC = asaC; 138 } 139 140 public void addAtomAsaU(double asa) { 141 this.asaU += asa; 142 this.atomAsaUs.add(asa); 143 } 144 145 public void addAtomAsaC(double asa) { 146 this.asaC += asa; 147 this.atomAsaCs.add(asa); 148 } 149 150 public List<Double> getAtomAsaUs() { 151 return atomAsaUs; 152 } 153 154 public void setAtomAsaUs(List<Double> atomAsaUs) { 155 this.atomAsaUs = atomAsaUs; 156 this.asaU = 0; 157 for (Double atomAsaU : atomAsaUs) { 158 this.asaU += atomAsaU; 159 } 160 } 161 162 public List<Double> getAtomAsaCs() { 163 return atomAsaCs; 164 } 165 166 public void setAtomAsaCs(List<Double> atomAsaCs) { 167 this.atomAsaCs = atomAsaCs; 168 this.asaC = 0; 169 for (Double atomAsaC : atomAsaCs) { 170 this.asaC += atomAsaC; 171 } 172 } 173 174 175 /** 176 * Returns the BSA value for this group, i.e. the difference between ASA uncomplexed and ASA complexed 177 * @return 178 */ 179 public double getBsa() { 180 return (asaU-asaC); 181 } 182 183 /** 184 * Returns the bsa/asa(uncomplexed) ratio, i.e. the ratio of burial of a residue upon complexation 185 * @return 186 */ 187 public double getBsaToAsaRatio() { 188 return getBsa()/asaU; 189 } 190 191 /** 192 * Returns the relative (uncomplexed) ASA, i.e. the ASA of the residue 193 * with respect to its ASA in an extended tri-peptide conformation (GLY-x-GLY) 194 * @return 195 */ 196 public double getRelativeAsaU() { 197 if (!g.getType().equals(GroupType.AMINOACID)) 198 throw new IllegalArgumentException("Can not calculate relative ASA for non amino-acid"); 199 200 char aa = ((AminoAcid)g).getAminoType(); 201 202 return (asaU/tripeptAsa.get(aa)); 203 204 } 205 206 /** 207 * Returns the relative (complexed) ASA, i.e. the ASA of the residue 208 * with respect to its ASA in an extended tri-peptide conformation (GLY-x-GLY) 209 * @return 210 */ 211 public double getRelativeAsaC() { 212 if (!g.getType().equals(GroupType.AMINOACID)) 213 throw new IllegalArgumentException("Can not calculate relative ASA for non amino-acid"); 214 215 char aa = ((AminoAcid)g).getAminoType(); 216 217 return (asaC/tripeptAsa.get(aa)); 218 219 } 220 221 @Override 222 public Object clone() { 223 GroupAsa n = new GroupAsa(this.g); 224 n.setAsaC(this.getAsaC()); 225 n.setAsaU(this.getAsaU()); 226 n.atomAsaUs = new ArrayList<Double>(this.atomAsaUs.size()); 227 n.atomAsaCs = new ArrayList<Double>(this.atomAsaCs.size()); 228 for (int i=0;i<this.atomAsaUs.size();i++) { 229 n.atomAsaUs.add(this.atomAsaUs.get(i)); 230 } 231 for (int i=0;i<this.atomAsaCs.size();i++) { 232 n.atomAsaCs.add(this.atomAsaCs.get(i)); 233 } 234 235 return n; 236 } 237}