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.io.StructureFiletype; 029import org.biojava.nbio.structure.align.util.AtomCache; 030import org.biojava.nbio.structure.io.FileParsingParameters; 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.setFiletype(StructureFiletype.CIF); 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 // finally use BioJava's built in DSSP-like secondary structure assigner 068 SecStrucCalc secStrucCalc = new SecStrucCalc(); 069 070 // calculate and assign 071 secStrucCalc.calculate(s,true); 072 printSecStruc(s); 073 074 } 075 076 public static void printSecStruc(Structure s){ 077 List<SecStrucInfo> ssi = SecStrucTools.getSecStrucInfo(s); 078 for (SecStrucInfo ss : ssi) { 079 System.out.println(ss.getGroup().getChain().getName() + " " 080 + ss.getGroup().getResidueNumber() + " " 081 + ss.getGroup().getPDBName() + " -> " + ss.toString()); 082 } 083 } 084}