Skip to content

Commit 309f17a

Browse files
committed
adding similar lookup table to ResidueType
1 parent 3f2c4ac commit 309f17a

File tree

1 file changed

+27
-5
lines changed
  • biojava-structure/src/main/java/org/biojava/nbio/structure/io/mmcif/chem

1 file changed

+27
-5
lines changed

biojava-structure/src/main/java/org/biojava/nbio/structure/io/mmcif/chem/PolymerType.java

Lines changed: 27 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,7 @@
2222
package org.biojava.nbio.structure.io.mmcif.chem;
2323

2424
import java.io.Serializable;
25-
import java.util.Arrays;
26-
import java.util.Collections;
27-
import java.util.HashSet;
28-
import java.util.Set;
25+
import java.util.*;
2926

3027
/**
3128
* Enumerates the classification of polymers.
@@ -38,7 +35,6 @@
3835
public enum PolymerType implements Serializable
3936
{
4037

41-
4238
/**
4339
* polypeptide(L)
4440
*/
@@ -94,6 +90,19 @@ public enum PolymerType implements Serializable
9490
*/
9591
unknown(null);
9692

93+
static Map<String,PolymerType> lookupTable = new HashMap<>();
94+
95+
static {
96+
97+
for (PolymerType rt : PolymerType.values() ) {
98+
if ( rt == unknown)
99+
continue;
100+
lookupTable.put(rt.entity_poly_type,rt);
101+
lookupTable.put(rt.entity_poly_type.toLowerCase(),rt);
102+
}
103+
}
104+
105+
97106
PolymerType(String entity_poly_type)
98107
{
99108
this.entity_poly_type = entity_poly_type;
@@ -102,6 +111,19 @@ public enum PolymerType implements Serializable
102111

103112
public static PolymerType polymerTypeFromString(String polymerType)
104113
{
114+
115+
if ( polymerType.equalsIgnoreCase(peptide.entity_poly_type))
116+
return peptide;
117+
118+
PolymerType ptype = lookupTable.get(polymerType);
119+
if ( ptype != null)
120+
return ptype;
121+
122+
ptype = lookupTable.get(polymerType.toLowerCase());
123+
if ( ptype != null)
124+
return ptype;
125+
126+
105127
for(PolymerType pt : PolymerType.values())
106128
{
107129
if(polymerType.equals(pt.entity_poly_type))

0 commit comments

Comments
 (0)