org.biojava.bio.structure
Class StructureTools

java.lang.Object
  extended by org.biojava.bio.structure.StructureTools

public class StructureTools
extends Object

A class that provides some tool methods.

Since:
1.0
Version:
%I% %G%
Author:
Andreas Prlic, Jules Jacobsen

Field Summary
static String[] backboneAtomNames
          The names of the Atoms that form the backbone.
static String caAtomName
          The Atom name of C-alpha atoms.
static String cbAtomName
           
static Logger logger
           
static String nAtomName
           
static String oAtomName
           
static Pattern pdbNumRangeRegex
          Pattern to describe subranges.
static Character UNKNOWN_GROUP_LABEL
           
 
Constructor Summary
StructureTools()
           
 
Method Summary
static Atom[] cloneCAArray(Atom[] ca)
          Provides an equivalent copy of Atoms in a new array.
static Group[] cloneGroups(Atom[] ca)
          Clone a set of CA Atoms, but returns the parent groups
static Character convert_3code_1code(String code3)
          convert three character amino acid codes into single character e.g.
static String convertAtomsToSeq(Atom[] atoms)
           
static Atom[] duplicateCA2(Atom[] ca2)
          Utility method for working with circular permutations.
static List<Bond> findBonds(Group group, List<Group> groups)
           
static Character get1LetterCode(String groupCode3)
          convert a three letter code into single character.
static Atom[] getAtomArray(Chain c, String[] atomNames)
          Returns an array of the requested Atoms from the Structure object.
static Atom[] getAtomArray(Structure s, String[] atomNames)
          Returns an array of the requested Atoms from the Structure object.
static Atom[] getAtomArrayAllModels(Structure s, String[] atomNames)
          Returns an array of the requested Atoms from the Structure object.
static Atom[] getAtomCAArray(Chain c)
          Returns an Atom array of the CA atoms.
static Atom[] getAtomCAArray(Structure s)
          Returns an Atom array of the CA atoms.
static Atom[] getBackboneAtomArray(Structure s)
          Returns an Atom array of the MainChain atoms.
static Group getGroupByPDBResidueNumber(Structure struc, ResidueNumber pdbResNum)
          Get a group represented by a ResidueNumber.
static List<Group> getGroupsWithinShell(Structure structure, Group group, double distance, boolean includeWater)
           
static int getNrAtoms(Structure s)
          Count how many number of Atoms are contained within a Structure object.
static int getNrGroups(Structure s)
          Count how many groups are contained within a structure object.
static ResidueNumber getPDBResidueNumber(Group g)
          Deprecated. replaced by Group.getResidueNumber()
static Structure getReducedStructure(Structure s, int chainNr)
          Reduce a structure to provide a smaller representation.
static Structure getReducedStructure(Structure s, String chainId)
          Reduce a structure to provide a smaller representation .
static Structure getSubRanges(Structure s, String ranges)
          In addition to the functionality provided by getReducedStructure also provides a way to specify sub-regions of a structure with the following specification: ranges can be surrounded by ( and ).
static boolean isNucleotide(String groupCode3)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

caAtomName

public static final String caAtomName
The Atom name of C-alpha atoms.

See Also:
Constant Field Values

nAtomName

public static final String nAtomName
See Also:
Constant Field Values

oAtomName

public static final String oAtomName
See Also:
Constant Field Values

cbAtomName

public static final String cbAtomName
See Also:
Constant Field Values

backboneAtomNames

public static final String[] backboneAtomNames
The names of the Atoms that form the backbone.


UNKNOWN_GROUP_LABEL

public static final Character UNKNOWN_GROUP_LABEL

logger

public static Logger logger

pdbNumRangeRegex

public static final Pattern pdbNumRangeRegex
Pattern to describe subranges. Matches "A", "A:", "A:7-53","A_7-53", etc.

See Also:
getSubRanges(Structure, String)
Constructor Detail

StructureTools

public StructureTools()
Method Detail

getNrAtoms

public static final int getNrAtoms(Structure s)
Count how many number of Atoms are contained within a Structure object.

Parameters:
s - the structure object
Returns:
the number of Atoms in this Structure

getNrGroups

public static final int getNrGroups(Structure s)
Count how many groups are contained within a structure object.

Parameters:
s - the structure object
Returns:
the number of groups in the structure

getAtomArray

public static final Atom[] getAtomArray(Structure s,
                                        String[] atomNames)
Returns an array of the requested Atoms from the Structure object. Iterates over all groups and checks if the requested atoms are in this group, no matter if this is a AminoAcid or HetatomImpl group. For structures with more than one model, only model 0 will be used.

Parameters:
s - the structure to get the atoms from
atomNames - contains the atom names to be used.
Returns:
an Atom[] array

getAtomArrayAllModels

public static final Atom[] getAtomArrayAllModels(Structure s,
                                                 String[] atomNames)
Returns an array of the requested Atoms from the Structure object. In contrast to getAtomArray(Structure, String[]) this method iterates over all chains. Iterates over all chains and groups and checks if the requested atoms are in this group, no matter if this is a AminoAcid or HetatomImpl group. For structures with more than one model, only model 0 will be used.

Parameters:
s - the structure to get the atoms from
atomNames - contains the atom names to be used.
Returns:
an Atom[] array

getAtomArray

public static final Atom[] getAtomArray(Chain c,
                                        String[] atomNames)
Returns an array of the requested Atoms from the Structure object. Iterates over all groups and checks if the requested atoms are in this group, no matter if this is a AminoAcid or Hetatom group.

Parameters:
c - the Chain to get the atoms from
atomNames - contains the atom names to be used.
Returns:
an Atom[] array

getAtomCAArray

public static final Atom[] getAtomCAArray(Chain c)
Returns an Atom array of the CA atoms.

Parameters:
c - the structure object
Returns:
an Atom[] array

cloneCAArray

public static final Atom[] cloneCAArray(Atom[] ca)
                                 throws StructureException
Provides an equivalent copy of Atoms in a new array. Clones everything, starting with parent groups and chains. The chain will only contain groups that are part of the CA array.

Parameters:
ca - array of CA atoms
Returns:
Atom array
Throws:
StructureException

cloneGroups

public static Group[] cloneGroups(Atom[] ca)
Clone a set of CA Atoms, but returns the parent groups

Parameters:
ca - Atom array
Returns:
Group array

duplicateCA2

public static Atom[] duplicateCA2(Atom[] ca2)
                           throws StructureException
Utility method for working with circular permutations. Creates a duplicated and cloned set of Calpha atoms from the input array.

Parameters:
ca2 - atom array
Returns:
cloned and duplicated set of input array
Throws:
StructureException

getAtomCAArray

public static Atom[] getAtomCAArray(Structure s)
Returns an Atom array of the CA atoms.

Parameters:
s - the structure object
Returns:
an Atom[] array

getBackboneAtomArray

public static Atom[] getBackboneAtomArray(Structure s)
Returns an Atom array of the MainChain atoms.

Parameters:
s - the structure object
Returns:
an Atom[] array

convert_3code_1code

public static final Character convert_3code_1code(String code3)
                                           throws UnknownPdbAminoAcidException
convert three character amino acid codes into single character e.g. convert CYS to C

Parameters:
code3 - a three character amino acid representation String
Returns:
a character
Throws:
IllegalSymbolException
UnknownPdbAminoAcidException

get1LetterCode

public static final Character get1LetterCode(String groupCode3)
convert a three letter code into single character. catches for unusual characters

Parameters:
groupCode3 - three letter representation
Returns:
null if group is a nucleotide code

isNucleotide

public static final boolean isNucleotide(String groupCode3)

getReducedStructure

public static final Structure getReducedStructure(Structure s,
                                                  String chainId)
                                           throws StructureException
Reduce a structure to provide a smaller representation . Only takes the first model of the structure. If chainId is provided only return a structure containing that Chain ID. Converts lower case chain IDs to upper case if structure does not contain a chain with that ID.

Parameters:
s -
chainId -
Returns:
Structure
Throws:
StructureException
Since:
3.0

getReducedStructure

public static final Structure getReducedStructure(Structure s,
                                                  int chainNr)
                                           throws StructureException
Reduce a structure to provide a smaller representation. Only takes the first model of the structure. If chainNr >=0 only takes the chain at that position into account.

Parameters:
s -
chainNr - can be -1 to request all chains of model 0, otherwise will only add chain at this position
Returns:
Structure object
Throws:
StructureException
Since:
3.0

getSubRanges

public static final Structure getSubRanges(Structure s,
                                           String ranges)
                                    throws StructureException
In addition to the functionality provided by getReducedStructure also provides a way to specify sub-regions of a structure with the following specification: ranges can be surrounded by ( and ). (but will be removed). ranges are specified as PDBresnum1 : PDBresnum2 a list of ranges is separated by , Example 4GCR (A:1-83) 1CDG (A:407-495,A:582-686) 1CDG (A_407-495,A_582-686)

Parameters:
s - The full structure
ranges - A comma-seperated list of ranges, optionally surrounded by parentheses
Returns:
Substructure of s specified by ranges
Throws:
StructureException

convertAtomsToSeq

public static final String convertAtomsToSeq(Atom[] atoms)

getPDBResidueNumber

public static final ResidueNumber getPDBResidueNumber(Group g)
Deprecated. replaced by Group.getResidueNumber()

get a PDB residue number object for this group

Parameters:
g - Group object
Returns:
a ResidueNumber object

getGroupByPDBResidueNumber

public static final Group getGroupByPDBResidueNumber(Structure struc,
                                                     ResidueNumber pdbResNum)
                                              throws StructureException
Get a group represented by a ResidueNumber.

Parameters:
struc - a Structure
pdbResNum - a ResidueNumber
Returns:
a group in the structure that is represented by the pdbResNum.
Throws:
StructureException - if the group cannot be found.

getGroupsWithinShell

public static List<Group> getGroupsWithinShell(Structure structure,
                                               Group group,
                                               double distance,
                                               boolean includeWater)

findBonds

public static List<Bond> findBonds(Group group,
                                   List<Group> groups)