File tree Expand file tree Collapse file tree 1 file changed +27
-5
lines changed
biojava-structure/src/main/java/org/biojava/nbio/structure/io/mmcif/chem Expand file tree Collapse file tree 1 file changed +27
-5
lines changed Original file line number Diff line number Diff line change 2222package org .biojava .nbio .structure .io .mmcif .chem ;
2323
2424import 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.
3835public 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 ))
You can’t perform that action at this time.
0 commit comments