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 demo; 022 023import java.io.IOException; 024import java.util.List; 025 026import org.biojava.nbio.structure.Structure; 027import org.biojava.nbio.structure.StructureException; 028import org.biojava.nbio.structure.align.util.AtomCache; 029import org.biojava.nbio.structure.io.FileParsingParameters; 030import org.biojava.nbio.structure.secstruc.DSSPParser; 031import org.biojava.nbio.structure.secstruc.SecStrucCalc; 032import org.biojava.nbio.structure.secstruc.SecStrucInfo; 033import org.biojava.nbio.structure.secstruc.SecStrucTools; 034 035/** 036 * Demonstration of how to load a Structure with the SS information, either from 037 * the PDB file annotation (Author's assignment) or from the DSSP file in the 038 * PDB servers (DSSP assignment). 039 * 040 * @author Aleix Lafita 041 * 042 */ 043public class DemoLoadSecStruc { 044 045 public static void main(String[] args) throws IOException, 046 StructureException { 047 048 String pdbID = "5pti"; 049 050 // Only change needed to the DEFAULT Structure loading 051 FileParsingParameters params = new FileParsingParameters(); 052 params.setParseSecStruc(true); 053 054 AtomCache cache = new AtomCache(); 055 cache.setFileParsingParams(params); 056 057 // Use PDB format, because SS cannot be parsed from mmCIF yet 058 cache.setUseMmCif(false); 059 060 // The loaded Structure contains the SS assigned by Author (simple) 061 Structure s = cache.getStructure(pdbID); 062 063 // Print the Author's assignment (from PDB file) 064 System.out.println("Author's assignment: "); 065 printSecStruc(s); 066 067 // If the more detailed DSSP prediction is required call this 068 DSSPParser.fetch(pdbID, s, true); 069 070 // Print the assignment residue by residue 071 System.out.println("DSSP assignment: "); 072 printSecStruc(s); 073 074 // finally use BioJava's built in DSSP-like secondary structure assigner 075 SecStrucCalc secStrucCalc = new SecStrucCalc(); 076 077 // calculate and assign 078 secStrucCalc.calculate(s,true); 079 printSecStruc(s); 080 081 } 082 083 public static void printSecStruc(Structure s){ 084 List<SecStrucInfo> ssi = SecStrucTools.getSecStrucInfo(s); 085 for (SecStrucInfo ss : ssi) { 086 System.out.println(ss.getGroup().getChain().getName() + " " 087 + ss.getGroup().getResidueNumber() + " " 088 + ss.getGroup().getPDBName() + " -> " + ss.toString()); 089 } 090 } 091}