View Javadoc
1   // ******************************************************************************
2   //
3   // Title:       Force Field X.
4   // Description: Force Field X - Software for Molecular Biophysics.
5   // Copyright:   Copyright (c) Michael J. Schnieders 2001-2025.
6   //
7   // This file is part of Force Field X.
8   //
9   // Force Field X is free software; you can redistribute it and/or modify it
10  // under the terms of the GNU General Public License version 3 as published by
11  // the Free Software Foundation.
12  //
13  // Force Field X is distributed in the hope that it will be useful, but WITHOUT
14  // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
15  // FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
16  // details.
17  //
18  // You should have received a copy of the GNU General Public License along with
19  // Force Field X; if not, write to the Free Software Foundation, Inc., 59 Temple
20  // Place, Suite 330, Boston, MA 02111-1307 USA
21  //
22  // Linking this library statically or dynamically with other modules is making a
23  // combined work based on this library. Thus, the terms and conditions of the
24  // GNU General Public License cover the whole combination.
25  //
26  // As a special exception, the copyright holders of this library give you
27  // permission to link this library with independent modules to produce an
28  // executable, regardless of the license terms of these independent modules, and
29  // to copy and distribute the resulting executable under terms of your choice,
30  // provided that you also meet, for each linked independent module, the terms
31  // and conditions of the license of that module. An independent module is a
32  // module which is not derived from or based on this library. If you modify this
33  // library, you may extend this exception to your version of the library, but
34  // you are not obligated to do so. If you do not wish to do so, delete this
35  // exception statement from your version.
36  //
37  // ******************************************************************************
38  package ffx.crystal;
39  
40  import java.util.ArrayList;
41  import java.util.Arrays;
42  import java.util.List;
43  
44  import static ffx.crystal.SpaceGroupInfo.isSohnckeGroup;
45  
46  /**
47   * The Spacegroup class defines the symmetry of a crystal. There are 230 distinct space groups in
48   * three dimensions.
49   *
50   * @author Michael J. Schnieders
51   * @see <ul>
52   * <li><a href="http://it.iucr.org/Ab/" target="_blank"> International Tables for
53   * Crystallography Volume A: Space-group symmetry </a>
54   * <li><a href="http://legacy.ccp4.ac.uk/html/symmetry.html" target="_blank"> CCP4 Symlib </a>
55   * </ul>
56   * @since 1.0
57   */
58  public class SpaceGroup {
59  
60    /**
61     * Space group number.
62     */
63    public final int number;
64    /**
65     * Number of primitive symmetry equivalents.
66     */
67    public final int numPrimitiveSymEquiv;
68    /**
69     * Space group name.
70     */
71    public final String shortName;
72    /**
73     * Point group name. There are 32 distinct points groups, or crystal classes in three dimensions.
74     */
75    public final String pointGroupName;
76    /**
77     * Crystal system.
78     */
79    public final CrystalSystem crystalSystem;
80    /**
81     * Laue group
82     */
83    public final LaueSystem laueSystem;
84    /**
85     * Space group name under the PDB convention.
86     */
87    public final String pdbName;
88    /**
89     * A List of SymOp instances.
90     */
91    public final List<SymOp> symOps;
92    /**
93     * True for a Sohncke group (non-enantiogenic).
94     */
95    public final boolean respectsChirality;
96    /**
97     * Real space ASU limit operators.
98     */
99    public final ASULimit[] asuLimitOperators;
100   /**
101    * Lattice system.
102    */
103   public final LatticeSystem latticeSystem;
104   /**
105    * Number of symmetry equivalents.
106    */
107   private final int numSymEquiv;
108   /**
109    * Real space ASU limit values.
110    */
111   private final double[] asuLimits;
112 
113   /**
114    * Immutable SpaceGroup instances are made available only through the factory method so this
115    * constructor is private.
116    *
117    * @param number               Space group number.
118    * @param numSymEquiv          Number of symmetry equivalents.
119    * @param numPrimitiveSymEquiv Number of primitive symmetry equivalents.
120    * @param shortName            Short PDB name.
121    * @param pointGroupName       Point group name.
122    * @param pdbName              PDB space group name.
123    * @param crystalSystem        Crystal system.
124    * @param latticeSystem        Lattice system.
125    * @param laueSystem           Laue System.
126    * @param symOps               Symmetry operators.
127    * @param asuLimits            Asymmetric unit limit.
128    * @param asuLimitOperators    ASULimit instance.
129    * @since 1.0
130    */
131   protected SpaceGroup(
132       int number,
133       int numSymEquiv,
134       int numPrimitiveSymEquiv,
135       String shortName,
136       String pointGroupName,
137       String pdbName,
138       CrystalSystem crystalSystem,
139       LatticeSystem latticeSystem,
140       LaueSystem laueSystem,
141       ASULimit[] asuLimitOperators,
142       double[] asuLimits,
143       SymOp... symOps) {
144     this.number = number;
145     this.numSymEquiv = numSymEquiv;
146     this.numPrimitiveSymEquiv = numPrimitiveSymEquiv;
147     this.shortName = shortName;
148     this.pointGroupName = pointGroupName;
149     this.crystalSystem = crystalSystem;
150     this.latticeSystem = latticeSystem;
151     this.laueSystem = laueSystem;
152     this.asuLimitOperators = asuLimitOperators;
153     this.asuLimits = asuLimits;
154     this.pdbName = pdbName;
155     this.respectsChirality = isSohnckeGroup(number);
156     this.symOps = new ArrayList<>(Arrays.asList(symOps));
157 
158     // ToDo: Crystal systems are subdivided into crystal classes. This info needs to be added to
159     // each space group.
160   }
161 
162   /**
163    * Return the number of symmetry operators.
164    *
165    * @return the number of symmetry operators.
166    * @since 1.0
167    */
168   public int getNumberOfSymOps() {
169     return symOps.size();
170   }
171 
172   /**
173    * Return the ith symmetry operator.
174    *
175    * @param i the symmetry operator number.
176    * @return the SymOp
177    * @since 1.0
178    */
179   public SymOp getSymOp(int i) {
180     return symOps.get(i);
181   }
182 
183   /**
184    * Check if the space group maintains chirality.
185    *
186    * @return Return true if chirality is respected.
187    */
188   public boolean respectsChirality() {
189     return respectsChirality;
190   }
191 
192 }