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