package demo;

import java.io.IOException;
import org.biojava.nbio.structure.Atom;
import org.biojava.nbio.structure.Structure;
import org.biojava.nbio.structure.StructureException;
import org.biojava.nbio.structure.StructureTools;
import org.biojava.nbio.structure.align.multiple.MultipleAlignment;
import org.biojava.nbio.structure.align.multiple.util.MultipleAlignmentWriter;
import org.biojava.nbio.structure.align.util.AtomCache;
import org.biojava.nbio.structure.symmetry.internal.CESymmParameters;
import org.biojava.nbio.structure.symmetry.internal.CESymmParameters.RefineMethod;
import org.biojava.nbio.structure.symmetry.internal.CESymmParameters.SymmetryType;
import org.biojava.nbio.structure.symmetry.internal.CeSymm;

/**
 * Quick demo of how to call CE-Symm programmatically.
 * Some examples of different symmetry types are proposed.
 *
 * @author Spencer Bliven
 * @author Aleix Lafita
 *
 */
public class DemoCeSymm {

	public static void main(String[] args) 
			throws IOException, StructureException {

		/* 
		 * Some examples:
		 * 
		 * CLOSED
		 * 2-fold: 1hiv.A, 
		 * 3-fold: 4i4q, 4dou
		 * 5-fold: 2jaj.A
		 * 6-fold: 1u6d
		 * 7-fold: 1jof.A
		 * 8-fold: 1vzw, d1i4na_
		 * 
		 * OPEN
		 * ankyrin: 1n0r.A, 3ehq.A
		 * leucine repeats: 2bnh.A, 3o6n
		 * helical: 1d0b.A
		 * 
		 * MULTIPLE AXES
		 * dihedral: 4hhb, 1vym
		 * hierarchical: 4gcr, 1ppr.O, 1hiv
		 * monoclonal Ab: 4NZU
		 * 
		 * - For more examples see the symmetry benchmark
		 */

		//Set the name of the protein structure to analyze
		String name = "1u6d";

		//Download the atoms
		AtomCache cache = new AtomCache();
		Structure s = cache.getStructure(name);
		Atom[] atoms = StructureTools.getRepresentativeAtomArray(s);

		CeSymm ceSymm = new CeSymm();

		//Choose some parameters
		CESymmParameters params = (CESymmParameters) ceSymm.getParameters();
		params.setRefineMethod(RefineMethod.SINGLE);
		params.setSymmetryType(SymmetryType.AUTO);
		params.setOptimization(true);
		params.setMultipleAxes(true);

		//Run the alignment
		MultipleAlignment symmetry = ceSymm.analyze(atoms, params);

		//Display the results in FatCat format
		System.out.println(MultipleAlignmentWriter.toFatCat(symmetry));
	}
	
}

@@ -28,32 +28,33 @@
 io.IOException;%0A
+%0A
 import org.bioja
@@ -429,16 +429,85 @@
 mCache;%0A
+import org.biojava.nbio.structure.symmetry.core.QuatSymmetryResults;%0A
 import o
@@ -793,16 +793,80 @@
 .CeSymm;
+%0Aimport org.biojava.nbio.structure.symmetry.utils.SymmetryTools;
 %0A%0A/**%0A *
@@ -2221,16 +2221,18 @@
 arams);%0A
+%09%09
 %0A%09%09//Dis
@@ -2331,15 +2331,202 @@
 etry));%0A
+%09%09%0A%09%09//Obtain the point group symmetry%0A%09%09QuatSymmetryResults pg = SymmetryTools.getQuaternarySymmetry(symmetry);%0A%09%09System.out.println(%22Point group internal symmetry: %22+pg.getSymmetry());%0A
 %09%7D%0A%09%0A%7D%0A

Add demo for point group internal symmetry calculation