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.util.List;
024
025import org.biojava.nbio.structure.Structure;
026import org.biojava.nbio.structure.StructureIO;
027import org.biojava.nbio.structure.cluster.SubunitClustererParameters;
028import org.biojava.nbio.structure.symmetry.core.QuatSymmetryDetector;
029import org.biojava.nbio.structure.symmetry.core.QuatSymmetryParameters;
030import org.biojava.nbio.structure.symmetry.core.QuatSymmetryResults;
031
032public class DemoBioAssemblies {
033
034        public static void main(String[] args) throws Exception {
035                
036                // 1st method: get 1 bioassembly at a time, parses the file each time
037                System.out.println("Getting one bioassembly at a time");
038                Structure asymUnit = StructureIO.getStructure("2trx");
039                System.out.println("Number of bioassemblies: "+asymUnit.getPDBHeader().getNrBioAssemblies());
040
041                for (int id = 1; id<=asymUnit.getPDBHeader().getNrBioAssemblies(); id++) {
042                        Structure bioAssembly = StructureIO.getBiologicalAssembly("2trx", id);
043                        findQuatSym(bioAssembly);
044                }
045
046                
047                // 2nd method: get all bioassemblies at once, parses the file only once
048                System.out.println("Getting all bioassemblies");
049                List<Structure> bioAssemblies = StructureIO.getBiologicalAssemblies("2trx");
050                
051                for (Structure bioAssembly : bioAssemblies) {                   
052                        findQuatSym(bioAssembly);                       
053                }
054                
055
056        }
057
058        private static void findQuatSym(Structure bioAssembly) {
059                SubunitClustererParameters clusterParams = new SubunitClustererParameters();
060                QuatSymmetryParameters symmParams = new QuatSymmetryParameters();
061                QuatSymmetryResults symmetry = QuatSymmetryDetector.calcGlobalSymmetry(
062                                bioAssembly, symmParams, clusterParams);
063
064                // C2 symmetry non pseudosymmetric
065                System.out.println(symmetry.getSymmetry() +" "+ symmetry.getStoichiometry());
066
067        }
068}