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.scop; 022 023import java.io.IOException; 024import java.io.Serializable; 025import java.util.HashSet; 026import java.util.List; 027import java.util.Set; 028 029import javax.xml.bind.annotation.XmlAccessType; 030import javax.xml.bind.annotation.XmlAccessorType; 031import javax.xml.bind.annotation.XmlRootElement; 032 033import org.biojava.nbio.structure.PdbId; 034import org.biojava.nbio.structure.ResidueRange; 035import org.biojava.nbio.structure.Structure; 036import org.biojava.nbio.structure.StructureException; 037import org.biojava.nbio.structure.StructureIdentifier; 038import org.biojava.nbio.structure.SubstructureIdentifier; 039import org.biojava.nbio.structure.align.util.AtomCache; 040 041 042/** Container for the information for a domain. Contains a line in the file 043 * dir.cla.scop.txt_1.75 044 * 045 * e.g d1dlwa_ 1dlw A: a.1.1.1 14982 cl=46456,cf=46457,sf=46458,fa=46459,dm=46460,sp=46461,px=14982 046 * 047 * Instantiated using {@link ScopDatabase#getDomainByScopID(String)} 048 * @author Andreas Prlic 049 * 050 */ 051@XmlRootElement(name = "ScopDomain", namespace ="http://source.rcsb.org") 052@XmlAccessorType(XmlAccessType.PUBLIC_MEMBER) 053public class ScopDomain implements Serializable, Cloneable, StructureIdentifier { 054 055 private static final long serialVersionUID = 5890476209571654301L; 056 057 String scopId; 058 PdbId pdbId; 059 List<String> ranges; 060 String classificationId; 061 Integer sunid; 062 063 int classId; 064 int foldId; 065 int superfamilyId; 066 int familyId; 067 int domainId; 068 int speciesId; 069 int px; 070 071 072 073 074 @Override 075 public String toString() { 076 StringBuilder buf = new StringBuilder(); 077 buf.append(scopId); 078 buf.append("\t") ; 079 buf.append(pdbId.getId().toLowerCase()); 080 buf.append( "\t"); 081 082 int rangePos = 0; 083 for (String range: ranges){ 084 rangePos++; 085 086 buf.append(range); 087 088 if ( ( ranges.size()> 1 ) && (rangePos < ranges.size())) 089 buf.append(","); 090 } 091 buf.append("\t") ; 092 buf.append(classificationId); 093 buf.append("\t") ; 094 buf.append(String.valueOf(sunid)); 095 buf.append("\t") ; 096 097 buf.append("cl="); 098 buf.append(String.valueOf(classId)); 099 buf.append(",cf="); 100 buf.append(String.valueOf(foldId)); 101 buf.append(",sf="); 102 buf.append(String.valueOf(superfamilyId)); 103 buf.append(",fa="); 104 buf.append(String.valueOf(familyId)); 105 buf.append(",dm="); 106 buf.append(String.valueOf(domainId)); 107 buf.append(",sp="); 108 buf.append(String.valueOf(speciesId)); 109 buf.append(",px="); 110 buf.append(String.valueOf(px)); 111 112 113 return buf.toString(); 114 } 115 116 public String getScopId() { 117 return scopId; 118 } 119 public void setScopId(String scopId) { 120 this.scopId = scopId; 121 } 122 123 /** 124 * Gets the PDB identifier for this protein structure. 125 * Before BioJava 6.0.0, this method used to return a {@link String}. 126 * 127 * @return the {@link PdbId} PDB identifier 128 * @see #setPdbId(PdbId) 129 * @since 6.0.0 130 */ 131 public PdbId getPdbId() { 132 return pdbId; 133 } 134 135 /** 136 * @param pdbId 137 * @deprecated use {@link #setPdbId(PdbId)} 138 */ 139 @Deprecated 140 public void setPdbId(String pdbId) { 141 if (pdbId == null) 142 this.pdbId = null; 143 else 144 this.pdbId = new PdbId(pdbId); 145 } 146 147 148 /** 149 * @param pdbId 150 * @since 6.0.0 151 */ 152 public void setPdbId(PdbId pdbId) { 153 this.pdbId = pdbId; 154 } 155 156 public List<String> getRanges() { 157 return ranges; 158 } 159 public void setRanges(List<String> ranges) { 160 this.ranges = ranges; 161 } 162 public String getClassificationId() { 163 return classificationId; 164 } 165 public void setClassificationId(String classificationId) { 166 this.classificationId = classificationId; 167 } 168 public Integer getSunid() { 169 return sunid; 170 } 171 public void setSunid(Integer sunid) { 172 this.sunid = sunid; 173 } 174 public int getClassId() { 175 return classId; 176 } 177 public void setClassId(int classId) { 178 this.classId = classId; 179 } 180 public int getFoldId() { 181 return foldId; 182 } 183 public void setFoldId(int foldId) { 184 this.foldId = foldId; 185 } 186 public int getSuperfamilyId() { 187 return superfamilyId; 188 } 189 public void setSuperfamilyId(int superfamilyId) { 190 this.superfamilyId = superfamilyId; 191 } 192 public int getFamilyId() { 193 return familyId; 194 } 195 public void setFamilyId(int familyId) { 196 this.familyId = familyId; 197 } 198 public int getDomainId() { 199 return domainId; 200 } 201 public void setDomainId(int domainId) { 202 this.domainId = domainId; 203 } 204 public int getSpeciesId() { 205 return speciesId; 206 } 207 public void setSpeciesId(int speciesId) { 208 this.speciesId = speciesId; 209 } 210 public int getPx() { 211 return px; 212 } 213 public void setPx(int px) { 214 this.px = px; 215 } 216 217 @Override 218 protected Object clone() throws CloneNotSupportedException { 219 220 super.clone(); 221 222 ScopDomain n = new ScopDomain(); 223 n.setClassId(getClassId()); 224 n.setClassificationId(getClassificationId()); 225 n.setDomainId(getDomainId()); 226 n.setFamilyId(getFamilyId()); 227 n.setFoldId(getFoldId()); 228 n.setPdbId(getPdbId()); 229 n.setPx(getPx()); 230 n.setRanges(getRanges()); 231 n.setScopId(getScopId()); 232 n.setSpeciesId(getSpeciesId()); 233 n.setSunid(getSunid()); 234 n.setSuperfamilyId(getSuperfamilyId()); 235 236 237 return n; 238 239 240 } 241 242 /** 243 * Returns the chains this domain is defined over; contains more than 1 element only if this domains is a multi-chain domain. 244 */ 245 public Set<String> getChains() { 246 Set<String> chains = new HashSet<String>(); 247 List<ResidueRange> rrs = ResidueRange.parseMultiple(getRanges()); 248 for (ResidueRange rr : rrs) chains.add(rr.getChainName()); 249 return chains; 250 } 251 252 @Override 253 public String getIdentifier() { 254 return getScopId(); 255 } 256 257 public List<ResidueRange> getResidueRanges() { 258 return ResidueRange.parseMultiple(ranges); 259 } 260 261 @Override 262 public SubstructureIdentifier toCanonical() { 263 return new SubstructureIdentifier(getPdbId(), ResidueRange.parseMultiple(getRanges())); 264 } 265 266 @Override 267 public Structure reduce(Structure input) throws StructureException { 268 return toCanonical().reduce(input); 269 } 270 271 @Override 272 public Structure loadStructure(AtomCache cache) throws StructureException, 273 IOException { 274 return cache.getStructureForPdbId(pdbId); 275 } 276 277}