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-2021.
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 static ffx.crystal.SpaceGroupInfo.isSohnckeGroup;
41  
42  import java.util.ArrayList;
43  import java.util.Arrays;
44  import java.util.List;
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    /** Space group number. */
61    public final int number;
62    /** Number of primitive symmetry equivalents. */
63    public final int numPrimitiveSymEquiv;
64    /** Space group name. */
65    public final String shortName;
66    /**
67     * Point group name. There are 32 distinct points groups, or crystal classes in three dimensions.
68     */
69    public final String pointGroupName;
70    /** Crystal system. */
71    public final CrystalSystem crystalSystem;
72    /** Laue group */
73    public final LaueSystem laueSystem;
74    /** Space group name under the PDB convention. */
75    public final String pdbName;
76    /** A List of SymOp instances. */
77    public final List<SymOp> symOps;
78    /** True for a Sohncke group (non-enantiogenic). */
79    public final boolean respectsChirality;
80    /** Real space ASU limit operators. */
81    public final ASULimit[] asuLimitOperators;
82    /** Lattice system. */
83    public final LatticeSystem latticeSystem;
84    /** Number of symmetry equivalents. */
85    private final int numSymEquiv;
86    /** Real space ASU limit values. */
87    private final double[] asuLimits;
88  
89    /**
90     * Immutable SpaceGroup instances are made available only through the factory method so this
91     * constructor is private.
92     *
93     * @param number Space group number.
94     * @param numSymEquiv Number of symmetry equivalents.
95     * @param numPrimitiveSymEquiv Number of primitive symmetry equivalents.
96     * @param shortName Short PDB name.
97     * @param pointGroupName Point group name.
98     * @param pdbName PDB space group name.
99     * @param crystalSystem Crystal system.
100    * @param laueSystem Laue System.
101    * @param symOps Symmetry operators.
102    * @param asuLimits Assymetric unit limit.
103    * @param asuLimitOperators ASULimit instance.
104    * @since 1.0
105    */
106   protected SpaceGroup(
107       int number,
108       int numSymEquiv,
109       int numPrimitiveSymEquiv,
110       String shortName,
111       String pointGroupName,
112       String pdbName,
113       CrystalSystem crystalSystem,
114       LatticeSystem latticeSystem,
115       LaueSystem laueSystem,
116       ASULimit[] asuLimitOperators,
117       double[] asuLimits,
118       SymOp... symOps) {
119     this.number = number;
120     this.numSymEquiv = numSymEquiv;
121     this.numPrimitiveSymEquiv = numPrimitiveSymEquiv;
122     this.shortName = shortName;
123     this.pointGroupName = pointGroupName;
124     this.crystalSystem = crystalSystem;
125     this.latticeSystem = latticeSystem;
126     this.laueSystem = laueSystem;
127     this.asuLimitOperators = asuLimitOperators;
128     this.asuLimits = asuLimits;
129     this.pdbName = pdbName;
130     this.respectsChirality = isSohnckeGroup(number);
131     this.symOps = new ArrayList<>(Arrays.asList(symOps));
132 
133     // ToDo: Crystal systems are subdivided into crystal classes. This info needs to be added to
134     // each space group.
135   }
136 
137   /**
138    * Return the number of symmetry operators.
139    *
140    * @return the number of symmetry operators.
141    * @since 1.0
142    */
143   public int getNumberOfSymOps() {
144     return symOps.size();
145   }
146 
147   /**
148    * Return the ith symmetry operator.
149    *
150    * @param i the symmetry operator number.
151    * @return the SymOp
152    * @since 1.0
153    */
154   public SymOp getSymOp(int i) {
155     return symOps.get(i);
156   }
157 
158   /**
159    * Check if the space group maintains chirality.
160    *
161    * @return Return true if chirality is respected.
162    */
163   public boolean respectsChirality() {
164     return respectsChirality;
165   }
166 
167 }