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 org.biojava.nbio.structure.align.gui;
022
023import java.util.List;
024
025import org.biojava.nbio.structure.Atom;
026import org.biojava.nbio.structure.Group;
027import org.biojava.nbio.structure.StructureException;
028import org.biojava.nbio.structure.StructureTools;
029import org.biojava.nbio.structure.align.gui.jmol.StructureAlignmentJmol;
030import org.biojava.nbio.structure.align.model.AFPChain;
031import org.biojava.nbio.structure.align.util.AlignmentTools;
032
033public class StructureAlignmentDisplay {
034
035        /** Display an AFPChain alignment
036         *
037         * @param afpChain
038         * @param ca1
039         * @param ca2
040         * @return a StructureAlignmentJmol instance
041         * @throws StructureException
042         */
043        public static StructureAlignmentJmol display(AFPChain afpChain, Atom[] ca1, Atom[] ca2) throws StructureException {
044
045                if ( ca1.length < 1 || ca2.length < 1){
046                        throw new StructureException("length of atoms arrays is too short! " + ca1.length + "," + ca2.length);
047                }
048
049                Group[] twistedGroups = AlignmentTools.prepareGroupsForDisplay(afpChain, ca1, ca2);
050
051                List<Group> hetatms  = StructureTools.getUnalignedGroups(ca1);
052                List<Group> hetatms2 = StructureTools.getUnalignedGroups(ca2);
053
054                return DisplayAFP.display(afpChain, twistedGroups, ca1, ca2, hetatms, hetatms2);
055
056        }
057
058}