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.StructureException;
027import org.biojava.nbio.structure.StructureIO;
028import org.biojava.nbio.structure.align.multiple.MultipleAlignment;
029import org.biojava.nbio.structure.cluster.SubunitCluster;
030import org.biojava.nbio.structure.cluster.SubunitClustererMethod;
031import org.biojava.nbio.structure.cluster.SubunitClustererParameters;
032import org.biojava.nbio.structure.symmetry.core.QuatSymmetryDetector;
033import org.biojava.nbio.structure.symmetry.core.QuatSymmetryParameters;
034import org.biojava.nbio.structure.symmetry.core.QuatSymmetryResults;
035
036/**
037 * A demo on how to use the quaternary symmetry detection algorithms.
038 * 
039 * @author Jose Duarte
040 *
041 */
042public class DemoSymmetry {
043
044        public static void main(String[] args) throws Exception {
045                
046                System.out.println("Getting all bioassemblies");
047                List<Structure> bioAssemblies = StructureIO.getBiologicalAssemblies("4hhb");
048                
049                for (Structure bioAssembly : bioAssemblies) {                   
050                        findQuatSym(bioAssembly);                       
051                }
052                
053
054        }
055
056        private static void findQuatSym(Structure bioAssembly) throws StructureException {
057
058                QuatSymmetryParameters symmParams = new QuatSymmetryParameters();               
059                
060                System.out.println("GLOBAL SYMMETRY, NO CLUSTERING");
061                SubunitClustererParameters clusterParams = new SubunitClustererParameters();
062                clusterParams.setSequenceIdentityThreshold(0.95);
063                clusterParams.setRMSDThreshold(0.0);
064                clusterParams.setClustererMethod(SubunitClustererMethod.SEQUENCE);
065
066                QuatSymmetryResults globalResults = QuatSymmetryDetector.calcGlobalSymmetry(bioAssembly, symmParams, clusterParams);    
067                
068                
069                
070                System.out.println(globalResults.getSymmetry() + (globalResults.isPseudoStoichiometric()?"(pseudo)":""));
071                
072                System.out.println("There are "+globalResults.getSubunitClusters().size()+" subunit clusters");
073                int i = 1;
074                for (SubunitCluster suc : globalResults.getSubunitClusters()) {
075                        //System.out.println(suc.getClustererMethod());
076                        MultipleAlignment ma = suc.getMultipleAlignment();
077                                                
078                        System.out.printf("Cluster %d (clustered by %s), RMSD = %4.2f\n", i, suc.getClustererMethod(), ma.getScore("RMSD"));
079                        
080                        i++;
081                }
082
083                System.out.println("\nGLOBAL SYMMETRY, WITH CLUSTERING (PSEUDO-SYMMETRY)");
084                clusterParams = new SubunitClustererParameters();
085                // we can either set sequence identity to 40% or rmsd to 2, both would have the same effect of clustering the alpha/beta subunits together
086                clusterParams.setSequenceIdentityThreshold(0.4);
087                clusterParams.setClustererMethod(SubunitClustererMethod.STRUCTURE);
088                clusterParams.setRMSDThreshold(3.0);
089
090                globalResults = QuatSymmetryDetector.calcGlobalSymmetry(bioAssembly, symmParams, clusterParams);
091
092
093
094                System.out.println(globalResults.getSymmetry() + (globalResults.isPseudoStoichiometric()?"(pseudo)":""));
095
096                System.out.println("There are "+globalResults.getSubunitClusters().size()+" subunit clusters");
097                i = 1;
098                for (SubunitCluster suc : globalResults.getSubunitClusters()) {
099                        //System.out.println(suc.getClustererMethod());
100                        MultipleAlignment ma = suc.getMultipleAlignment();
101
102                        System.out.printf("Cluster %d (clustered by %s), RMSD = %4.2f\n", i, suc.getClustererMethod(), ma.getScore("RMSD"));
103
104                        i++;
105                }
106
107
108                System.out.println("\n\nLOCAL SYMMETRIES");
109                List<QuatSymmetryResults> localResults = QuatSymmetryDetector.calcLocalSymmetries(bioAssembly, symmParams, clusterParams);
110
111                System.out.println("Number of local symmetries: "+localResults.size());
112
113                for (QuatSymmetryResults results : localResults) {
114                        System.out.println(results.getSymmetry()+" "+results.getStoichiometry());
115                }
116
117
118        }
119}