Package org.biojava.nbio.structure
Class PdbId
- java.lang.Object
-
- org.biojava.nbio.structure.PdbId
-
- All Implemented Interfaces:
java.io.Serializable,java.lang.Comparable<PdbId>
public class PdbId extends java.lang.Object implements java.lang.Comparable<PdbId>, java.io.Serializable
A wrapper class for the PDB identifier. It handles conversion between current (short)[1-9][0-9A-Z]{3}and upcoming (extended)PDB_\d{4}[1-9][09-A-Z]PDB ID format.
Instances of this class are immutable.
Creation of PdBId instance follows strict PDB ID convention. There is only one exception to this rule which is XXXX. XXXX objects are not considered equal (unless they are the one and the same object).- Since:
- 6.0.0
- Author:
- Amr ALHOSSARY
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description static java.util.regex.PatternPATTERN_EXTENDED_PDBIDA regular expression that matches a PDB ID in the extended format.static java.util.regex.PatternPATTERN_SHORT_PDBIDA regular expression that matches a PDB ID in the short format.static java.util.regex.PatternPATTERN_SHORTABLE_EXTENDED_PDBID/ * A regular expression that matches an extended PDB ID that is compatible with the short format.
-
Constructor Summary
Constructors Constructor Description PdbId(java.lang.String id)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected java.lang.Objectclone()intcompareTo(PdbId o)booleanequals(java.lang.Object obj)java.lang.StringgetId()Get aStringrepresentation of this PdbId instance.
By default this function will try to get the PdbId in the short (4 letters) format.java.lang.StringgetId(boolean prefereShort)Get aStringrepresentation of this PdbId instance, using the passed in behavior.java.lang.StringgetShortId()Get the PDB Id in the short format.inthashCode()static booleanisShortCompatible(java.lang.String extendedId)Checks whether an Extended PDB ID is shortable, assuming it is a valid extended PDB ID.static booleanisValidExtendedPdbId(java.lang.String id)Check whetheridrepresents a valid PDB ID in the extended format.static booleanisValidShortPdbId(java.lang.String id)Check whetheridrepresents a valid PDB ID in the short format.static java.lang.StringtoExtendedId(java.lang.String shortId)ConvertsshortIdto the PDB ID extended format.static java.lang.StringtoShortId(java.lang.String extendedId)ConvertsextendedIdto the PDB ID short format.java.lang.StringtoString()
-
-
-
Field Detail
-
PATTERN_SHORT_PDBID
public static final java.util.regex.Pattern PATTERN_SHORT_PDBID
A regular expression that matches a PDB ID in the short format.
-
PATTERN_EXTENDED_PDBID
public static final java.util.regex.Pattern PATTERN_EXTENDED_PDBID
A regular expression that matches a PDB ID in the extended format.
-
PATTERN_SHORTABLE_EXTENDED_PDBID
public static final java.util.regex.Pattern PATTERN_SHORTABLE_EXTENDED_PDBID
/ * A regular expression that matches an extended PDB ID that is compatible with the short format.
-
-
Method Detail
-
isValidShortPdbId
public static boolean isValidShortPdbId(java.lang.String id)
Check whetheridrepresents a valid PDB ID in the short format.- Parameters:
id- Prospect ID- Returns:
trueifidis a valid short PDB ID,falseotherwise.- Throws:
java.lang.NullPointerException- ifidisnull.- See Also:
isValidExtendedPdbId(String)
-
isValidExtendedPdbId
public static boolean isValidExtendedPdbId(java.lang.String id)
Check whetheridrepresents a valid PDB ID in the extended format.- Parameters:
id- Prospect ID- Returns:
trueifidis a valid extended PDB ID,falseotherwise.- Throws:
java.lang.NullPointerException- ifidisnull.- See Also:
isValidShortPdbId(String)
-
isShortCompatible
public static boolean isShortCompatible(java.lang.String extendedId)
Checks whether an Extended PDB ID is shortable, assuming it is a valid extended PDB ID.- Parameters:
extendedId- the supposedly valid extended PDB ID.- Returns:
trueifextendedIdcan be shortened (ie. it matches the regular expression "(pdb|PDB)_0000[1-9][a-zA-Z0-9]{3}"),falseotherwise.- See Also:
isValidExtendedPdbId(String)
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
equals
public boolean equals(java.lang.Object obj)
- Overrides:
equalsin classjava.lang.Object
-
clone
protected java.lang.Object clone() throws java.lang.CloneNotSupportedException- Overrides:
clonein classjava.lang.Object- Throws:
java.lang.CloneNotSupportedException
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
getId
public java.lang.String getId()
Get aStringrepresentation of this PdbId instance.
By default this function will try to get the PdbId in the short (4 letters) format. If not possible, it will return the long format. N.B. This default behavior may change later;- Returns:
- the PdbId code, preferably in short format.
-
getId
public java.lang.String getId(boolean prefereShort)
Get aStringrepresentation of this PdbId instance, using the passed in behavior.- Parameters:
prefereShort- when it istrue, the class will try to produce the short ID whenever possible.- Returns:
- The PdbId in short format if possible and
prefereShortistrue, the extended PDB ID form otherwise.
-
getShortId
public java.lang.String getShortId() throws StructureExceptionGet the PDB Id in the short format. Throws an exception if the conversion is not possible.
Use this method only if you know that this PDB ID is shortable.- Returns:
- the PDB ID in the short format.
- Throws:
StructureException- if the conversion was not possible.
-
toExtendedId
public static java.lang.String toExtendedId(java.lang.String shortId) throws StructureExceptionConvertsshortIdto the PDB ID extended format. IfshortIdis a valid short PDB ID, it would be converted to an extended ID, ifshortIdis a valid extended PDB ID, it would be returned in UPPER CASE, aStructureExceptionis thrown otherwise.- Parameters:
shortId- the PDB ID to convert to extended format- Returns:
- the ID in the extended UPPER CASE format.
- Throws:
StructureException- if the conversion was not possible.
-
toShortId
public static java.lang.String toShortId(java.lang.String extendedId) throws StructureExceptionConvertsextendedIdto the PDB ID short format. IfextendedIdis a valid extended PDB ID, it would be converted to a short ID, ifextendedIdis a valid short PDB ID, it would be returned in UPPER CASE, aStructureExceptionis thrown otherwise.- Parameters:
extendedId- the PDB ID to convert to short format- Returns:
- the ID in the short UPPER CASE format.
- Throws:
StructureException- if the conversion was not possible.
-
-