Module EDUtilsSymmetry
[hide private]
[frames] | no frames]

Source Code for Module EDUtilsSymmetry

  1  # 
  2  #    Project: The EDNA Kernel 
  3  #             http://www.edna-site.org 
  4  # 
  5  #    File: "$Id$" 
  6  # 
  7  #    Copyright (C) 2008-2009 European Synchrotron Radiation Facility 
  8  #                            Grenoble, France 
  9  # 
 10  #    Principal authors: Marie-Francoise Incardona (incardon@esrf.fr) 
 11  #                       Olof Svensson (svensson@esrf.fr)  
 12  # 
 13  #    This program is free software: you can redistribute it and/or modify 
 14  #    it under the terms of the GNU Lesser General Public License as published 
 15  #    by the Free Software Foundation, either version 3 of the License, or 
 16  #    (at your option) any later version. 
 17  # 
 18  #    This program is distributed in the hope that it will be useful, 
 19  #    but WITHOUT ANY WARRANTY; without even the implied warranty of 
 20  #    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
 21  #    GNU Lesser General Public License for more details. 
 22  # 
 23  #    You should have received a copy of the GNU General Public License 
 24  #    and the GNU Lesser General Public License  along with this program.   
 25  #    If not, see <http://www.gnu.org/licenses/>. 
 26  # 
 27   
 28  __authors__ = [ "Marie-Francoise Incardona", "Olof Svensson" ] 
 29  __contact__ = "svensson@esrf.fr" 
 30  __license__ = "LGPLv3+" 
 31  __copyright__ = "European Synchrotron Radiation Facility, Grenoble, France" 
32 33 34 -class EDUtilsSymmetry:
35 """ 36 This utility class contains methods useful for handling symmetries. 37 """ 38 39 @staticmethod
41 """ 42 This static method returns a string containing the name of the space 43 group with minimum symmetry that corresponds to a given two-letter Bravais 44 Lattice. 45 46 Note that the "hR" Bravais Lattice is translated into the "H3" and not the 47 "R3" space group since the "H3" space group is the one used in MX in general 48 and in particular for structures deposited in the PDB. 49 50 If the Bravais Lattice is not recognised a "None" object is returned. 51 """ 52 strSpaceGroup = None 53 strBravaisLattice = _strBravaisLattice 54 if strBravaisLattice == "aP": 55 strSpaceGroup = "P1" 56 57 elif strBravaisLattice == "mP": 58 strSpaceGroup = "P2" 59 60 elif strBravaisLattice == "mC" or \ 61 strBravaisLattice == "mI": 62 strSpaceGroup = "C2" 63 64 elif strBravaisLattice == "oP": 65 strSpaceGroup = "P222" 66 67 elif strBravaisLattice == "oA" or \ 68 strBravaisLattice == "oB" or \ 69 strBravaisLattice == "oC" or \ 70 strBravaisLattice == "oS": 71 strSpaceGroup = "C222" 72 73 elif strBravaisLattice == "oF": 74 strSpaceGroup = "F222" 75 76 elif strBravaisLattice == "oI": 77 strSpaceGroup = "I222" 78 79 elif strBravaisLattice == "tP" or \ 80 strBravaisLattice == "tC": 81 strSpaceGroup = "P4" 82 83 elif strBravaisLattice == "tI" or \ 84 strBravaisLattice == "tF": 85 strSpaceGroup = "I4" 86 87 elif strBravaisLattice == "hP": 88 strSpaceGroup = "P3" 89 90 elif strBravaisLattice == "hR": 91 strSpaceGroup = "H3" 92 93 elif strBravaisLattice == "cP": 94 strSpaceGroup = "P23" 95 96 elif strBravaisLattice == "cF": 97 strSpaceGroup = "F23" 98 99 elif strBravaisLattice == "cI": 100 strSpaceGroup = "I23" 101 102 return strSpaceGroup
103 104 105 106 @staticmethod
107 - def getNumberOfSymmetryOperatorsFromSpaceGroupITNumber(_strSpaceGroupId, _strSymmetryTableFileName):
108 """ 109 """ 110 return EDUtilsSymmetry.getNumberOfSymmetryOperators(_strSpaceGroupId, 0, _strSymmetryTableFileName)
111 112 113 @staticmethod
114 - def getNumberOfSymmetryOperatorsFromSpaceGroupName(_strSpaceGroupName, _strSymmetryTableFileName):
115 """ 116 """ 117 return EDUtilsSymmetry.getNumberOfSymmetryOperators(_strSpaceGroupName, 3, _strSymmetryTableFileName)
118 119 120 121 @staticmethod
122 - def getNumberOfSymmetryOperators(_strSpaceGroupIdOrName, _iIndex, _strSymmetryTableFileName):
123 """ 124 """ 125 strNumOperators = None 126 symmetryTableFile = open(_strSymmetryTableFileName) 127 for strLine in symmetryTableFile.xreadlines(): 128 listItems = strLine.split(" ") 129 if (len(listItems) > 3 and listItems[_iIndex] == _strSpaceGroupIdOrName): 130 strNumOperators = listItems[1] 131 return strNumOperators
132 133 @staticmethod
134 - def getITNumberFromSpaceGroupName(_strSpaceGroupName, _strSymmetryTableFileName):
135 """ 136 """ 137 iITNumber = None 138 symmetryTableFile = open(_strSymmetryTableFileName) 139 for strLine in symmetryTableFile.xreadlines(): 140 listItems = strLine.split(" ") 141 if len(listItems) > 3: 142 if _strSpaceGroupName == listItems[3]: 143 iITNumber = int(listItems[0]) 144 return iITNumber
145