Class MMCIFFileTools
- java.lang.Object
-
- org.biojava.nbio.structure.io.mmcif.MMCIFFileTools
-
public class MMCIFFileTools extends Object
Some tools for mmCIF file writing. See http://www.iucr.org/__data/assets/pdf_file/0019/22618/cifguide.pdf CIF categories are represented as a simple bean, typically extendingAbstractBean
. By default, all fields from the bean are taken as the CIF labels. Fields may be omitted by annotating them as@IgnoreField
. The CIF label for a field may be changed (for instance, for fields that are not valid Java identifiers) by defining a function static MapgetCIFLabelMap() mapping from the field's name to the correct label.- Author:
- Jose Duarte, Spencer Bliven
-
-
Field Summary
Fields Modifier and Type Field Description static String
MMCIF_DEFAULT_VALUE
The character to be printed out as a default value in mmCIF files, e.g. for the default alt_locsstatic String
MMCIF_MISSING_VALUE
The character to be printed out in cases where a value is not assigned in mmCIF files
-
Constructor Summary
Constructors Constructor Description MMCIFFileTools()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static AtomSite
convertAtomToAtomSite(Atom a, int model, String chainName, String chainId)
Converts an Atom object to anAtomSite
object.static AtomSite
convertAtomToAtomSite(Atom a, int model, String chainName, String chainId, int atomId)
Converts an Atom object to anAtomSite
object.static List<AtomSite>
convertChainToAtomSites(Chain c, int model, String chainName, String chainId)
Converts a Chain into a List ofAtomSite
objectsstatic Cell
convertCrystalCellToCell(CrystalCell c)
Converts a CrystalCell object to aCell
object.static List<AtomSite>
convertGroupToAtomSites(Group g, int model, String chainName, String chainId)
Converts a Group into a List ofAtomSite
objects.static Symmetry
convertSpaceGroupToSymmetry(SpaceGroup sg)
Converts a SpaceGroup object to aSymmetry
object.static List<AtomSite>
convertStructureToAtomSites(Structure s)
Converts a Structure into a List ofAtomSite
objectsstatic String[]
getFieldNames(Field[] fields)
Gets the mmCIF record name for each field.static Field[]
getFields(Class<?> c)
Gets all fields for a particular class, filtering fields annotated with@IgnoreField
.static String
toLoopMmCifHeaderString(String categoryName, String className)
Produces a mmCIF loop header string for the given categoryName and className.static String
toMMCIF(String categoryName, Object o)
Converts a mmCIF bean (seeorg.biojava.nbio.structure.io.mmcif.model
to a String representing it in mmCIF (single-record) format.static <T> String
toMMCIF(List<T> list, Class<T> klass)
Converts a list of mmCIF beans (seeorg.biojava.nbio.structure.io.mmcif.model
to a String representing them in mmCIF loop format with one record per line.
-
-
-
Field Detail
-
MMCIF_MISSING_VALUE
public static final String MMCIF_MISSING_VALUE
The character to be printed out in cases where a value is not assigned in mmCIF files- See Also:
- Constant Field Values
-
MMCIF_DEFAULT_VALUE
public static final String MMCIF_DEFAULT_VALUE
The character to be printed out as a default value in mmCIF files, e.g. for the default alt_locs- See Also:
- Constant Field Values
-
-
Constructor Detail
-
MMCIFFileTools
public MMCIFFileTools()
-
-
Method Detail
-
toLoopMmCifHeaderString
public static String toLoopMmCifHeaderString(String categoryName, String className) throws ClassNotFoundException
Produces a mmCIF loop header string for the given categoryName and className. className must be one of the beans in theorg.biojava.nbio.structure.io.mmcif.model
package- Parameters:
categoryName
-className
-- Returns:
- Throws:
ClassNotFoundException
- if the given className can not be found
-
toMMCIF
public static String toMMCIF(String categoryName, Object o)
Converts a mmCIF bean (seeorg.biojava.nbio.structure.io.mmcif.model
to a String representing it in mmCIF (single-record) format.- Parameters:
categoryName
-o
-- Returns:
-
getFields
public static Field[] getFields(Class<?> c)
Gets all fields for a particular class, filtering fields annotated with@IgnoreField
. As a side effect, callssetAccessible(true)
on all fields.- Parameters:
c
-- Returns:
-
getFieldNames
public static String[] getFieldNames(Field[] fields)
Gets the mmCIF record name for each field. This is generally just the name of the field or the value specified by the@CIFLabel
annotation. As a side effect, callssetAccessible(true)
on all fields.- Parameters:
fields
-- Returns:
-
toMMCIF
public static <T> String toMMCIF(List<T> list, Class<T> klass)
Converts a list of mmCIF beans (seeorg.biojava.nbio.structure.io.mmcif.model
to a String representing them in mmCIF loop format with one record per line.- Parameters:
list
-- Returns:
-
convertSpaceGroupToSymmetry
public static Symmetry convertSpaceGroupToSymmetry(SpaceGroup sg)
Converts a SpaceGroup object to aSymmetry
object.- Parameters:
sg
-- Returns:
-
convertCrystalCellToCell
public static Cell convertCrystalCellToCell(CrystalCell c)
Converts a CrystalCell object to aCell
object.- Parameters:
c
-- Returns:
-
convertAtomToAtomSite
public static AtomSite convertAtomToAtomSite(Atom a, int model, String chainName, String chainId)
Converts an Atom object to anAtomSite
object.- Parameters:
a
-model
- the model number for the output AtomSiteschainName
- the chain identifier (author id) for the output AtomSiteschainId
- the internal chain identifier (asym id) for the output AtomSites- Returns:
-
convertAtomToAtomSite
public static AtomSite convertAtomToAtomSite(Atom a, int model, String chainName, String chainId, int atomId)
Converts an Atom object to anAtomSite
object.- Parameters:
a
- the atommodel
- the model number for the output AtomSiteschainName
- the chain identifier (author id) for the output AtomSiteschainId
- the internal chain identifier (asym id) for the output AtomSitesatomId
- the atom id to be written to AtomSite- Returns:
-
convertGroupToAtomSites
public static List<AtomSite> convertGroupToAtomSites(Group g, int model, String chainName, String chainId)
Converts a Group into a List ofAtomSite
objects. Atoms in other altloc groups (different from the main group) are also included, removing possible duplicates via using the atom identifier to assess uniqueness.- Parameters:
g
- the groupmodel
- the model number for the output AtomSiteschainName
- the chain identifier (author id) for the output AtomSiteschainId
- the internal chain identifier (asym id) for the output AtomSites- Returns:
-
convertChainToAtomSites
public static List<AtomSite> convertChainToAtomSites(Chain c, int model, String chainName, String chainId)
Converts a Chain into a List ofAtomSite
objects- Parameters:
c
- the chainmodel
- the model number for the output AtomSiteschainName
- the chain identifier (author id) for the output AtomSiteschainId
- the internal chain identifier (asym id) for the output AtomSites- Returns:
-
convertStructureToAtomSites
public static List<AtomSite> convertStructureToAtomSites(Structure s)
Converts a Structure into a List ofAtomSite
objects- Parameters:
s
-- Returns:
-
-