<commit_before>package org.biojava.bio.structure.align.gui;

import java.util.List;

import org.biojava.bio.structure.Atom;
import org.biojava.bio.structure.Calc;
import org.biojava.bio.structure.Group;
import org.biojava.bio.structure.StructureException;
import org.biojava.bio.structure.align.AFPTwister;
import org.biojava.bio.structure.align.gui.jmol.StructureAlignmentJmol;
import org.biojava.bio.structure.align.model.AFPChain;
import org.biojava.bio.structure.jama.Matrix;

public class StructureAlignmentDisplay {

   public static StructureAlignmentJmol display(AFPChain afpChain, Atom[] ca1,
         Atom[] ca2, List<Group> hetatms, List<Group> nucs1,
         List<Group> hetatms2, List<Group> nucs2) throws StructureException {

      Group[] twistedGroups = new Group[ ca2.length];


      if ( afpChain.getBlockRotationMatrix().length == 0 ) {
         throw new StructureException("No rotation matrix found to rotate 2nd structure!");
      }

      int blockNum = afpChain.getBlockNum();
      int i = -1;
     
      if  ( blockNum == 1 ) {
         
         Matrix m   =  afpChain.getBlockRotationMatrix()[ 0];
         Atom shift =  afpChain.getBlockShiftVector()   [ 0 ];

         shiftAll(afpChain, ca2,hetatms2, nucs2, m,shift, twistedGroups);
         
      } else {
         
         for (Atom a: ca2){
            i++;
            twistedGroups[i]=a.getParent();
            
         }<commit_msg>new convenience method for easier display of structure alignments<commit_after>package org.biojava.bio.structure.align.gui;

import java.util.ArrayList;
import java.util.List;

import org.biojava.bio.structure.Atom;
import org.biojava.bio.structure.Calc;
import org.biojava.bio.structure.Chain;
import org.biojava.bio.structure.Group;
import org.biojava.bio.structure.StructureException;
import org.biojava.bio.structure.align.AFPTwister;
import org.biojava.bio.structure.align.gui.jmol.StructureAlignmentJmol;
import org.biojava.bio.structure.align.model.AFPChain;
import org.biojava.bio.structure.jama.Matrix;

public class StructureAlignmentDisplay {

   public static StructureAlignmentJmol display(AFPChain afpChain, Atom[] ca1, Atom[] ca2) throws StructureException {
      
      if ( ca1.length < 1 || ca2.length < 1){
         throw new StructureException("length of atoms arrays is too short! " + ca1.length + "," + ca2.length);
      }
      
      List<Group> hetatms  = new ArrayList<Group>();
      List<Group> nucs1    = new ArrayList<Group>();
      List<Group> hetatms2 = new ArrayList<Group>();
      List<Group> nucs2    = new ArrayList<Group>();
      
      Group g1 = ca1[0].getParent();
      Chain c1 = null;
      if ( g1 != null) {
         c1 = g1.getParent();
         if ( c1 != null){
            hetatms = c1.getAtomGroups("hetatm");;
            nucs1  = c1.getAtomGroups("nucleotide");
         }
      }
      
      Group g2 = ca2[0].getParent();
      Chain c2 = null;
      if ( g2 != null){
         c2 = g2.getParent();
         if ( c2 != null){
            hetatms2 = c2.getAtomGroups("hetatm");
            nucs2 = c2.getAtomGroups("nucleotide");
         }
      }
            
      
      return display(afpChain, ca1, ca2, hetatms, nucs1, hetatms2, nucs2);
   }
   
   public static StructureAlignmentJmol display(AFPChain afpChain, Atom[] ca1,
         Atom[] ca2, List<Group> hetatms, List<Group> nucs1,
         List<Group> hetatms2, List<Group> nucs2) throws StructureException {

      Group[] twistedGroups = new Group[ ca2.length];


      if ( afpChain.getBlockRotationMatrix().length == 0 ) {
         throw new StructureException("No rotation matrix found to rotate 2nd structure!");
      }

      int blockNum = afpChain.getBlockNum();
      int i = -1;
     
      if  ( blockNum == 1 ) {
         
         Matrix m   =  afpChain.getBlockRotationMatrix()[ 0];
         Atom shift =  afpChain.getBlockShiftVector()   [ 0 ];

         shiftAll(afpChain, ca2,hetatms2, nucs2, m,shift, twistedGroups);
         
      } else {
         
         for (Atom a: ca2){
            i++;
            twistedGroups[i]=a.getParent();
            
         }
{'fraction_non_alphanumeric': 0.11565448826518268, 'fraction_numerical': 0.017178804742317928, 'mean_word_length': 2.557659208261618, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 19, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5532746', 'n_tokens_mistral': 1341, 'n_tokens_neox': 1297, 'n_words': 277}